File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -170,9 +170,9 @@ object TypeErasure {
170170 }
171171 }
172172
173- /** Is `tp` an abstract type or polymorphic type parameter that has `Any`
174- * as upper bound and that is not Java defined? Arrays of such types are
175- * erased to `Object` instead of `ObjectArray `.
173+ /** Is `tp` an abstract type or polymorphic type parameter that has `Any`, `AnyVal`,
174+ * or a universal trait as upper bound and that is not Java defined? Arrays of such types are
175+ * erased to `Object` instead of `Object[] `.
176176 */
177177 def isUnboundedGeneric (tp : Type )(implicit ctx : Context ): Boolean = tp.dealias match {
178178 case tp : TypeRef =>
@@ -182,13 +182,14 @@ object TypeErasure {
182182 case tp : PolyParam =>
183183 ! tp.derivesFrom(defn.ObjectClass ) &&
184184 ! tp.binder.resultType.isInstanceOf [JavaMethodType ]
185+ case tp : TypeAlias => isUnboundedGeneric(tp.alias)
186+ case tp : TypeBounds => ! tp.hi.derivesFrom(defn.ObjectClass )
185187 case tp : TypeProxy => isUnboundedGeneric(tp.underlying)
186188 case tp : AndType => isUnboundedGeneric(tp.tp1) || isUnboundedGeneric(tp.tp2)
187189 case tp : OrType => isUnboundedGeneric(tp.tp1) && isUnboundedGeneric(tp.tp2)
188190 case _ => false
189191 }
190192
191-
192193 /** The erased least upper bound is computed as follows
193194 * - if both argument are arrays, an array of the lub of the element types
194195 * - if one argument is an array, Object
Original file line number Diff line number Diff line change 1+ trait Foo extends Any
2+
3+ object Univ {
4+ def univ [T <: Foo ](x : Array [T ]) = {}
5+ def univ2 (x : Array [_ <: Foo ]) = {}
6+ }
You can’t perform that action at this time.
0 commit comments