File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
src/dotty/tools/dotc/core Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -205,7 +205,9 @@ object TypeErasure {
205205 }
206206
207207 /** The erased least upper bound is computed as follows
208- * - if both argument are arrays, an array of the lub of the element types
208+ * - if both argument are arrays of objects, an array of the lub of the element types
209+ * - if both arguments are arrays of same primitives, an array of this primitive
210+ * - if one argument is array of primitives and the other is array of objects, Object
209211 * - if one argument is an array, Object
210212 * - otherwise a common superclass or trait S of the argument classes, with the
211213 * following two properties:
@@ -217,8 +219,14 @@ object TypeErasure {
217219 */
218220 def erasedLub (tp1 : Type , tp2 : Type )(implicit ctx : Context ): Type = tp1 match {
219221 case JavaArrayType (elem1) =>
222+ import dotty .tools .dotc .transform .TypeUtils ._
220223 tp2 match {
221- case JavaArrayType (elem2) => JavaArrayType (erasedLub(elem1, elem2))
224+ case JavaArrayType (elem2) =>
225+ if (elem1.isPrimitiveValueType || elem2.isPrimitiveValueType) {
226+ if (elem1.classSymbol eq elem2.classSymbol) // same primitive
227+ JavaArrayType (elem1)
228+ else defn.ObjectType
229+ } else JavaArrayType (erasedLub(elem1, elem2))
222230 case _ => defn.ObjectType
223231 }
224232 case _ =>
You can’t perform that action at this time.
0 commit comments