diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 8a0b0f12c167..aacaf33b574d 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -1038,17 +1038,15 @@ object Types { TypeComparer.isSameTypeWhenFrozen(this, that) /** Is this type a primitive value type which can be widened to the primitive value type `that`? */ - def isValueSubType(that: Type)(using Context): Boolean = widen match { + def isValueSubType(that: Type)(using Context): Boolean = widenDealias match case self: TypeRef if self.symbol.isPrimitiveValueClass => - that.widenExpr match { + that.widenExpr.dealias match case that: TypeRef if that.symbol.isPrimitiveValueClass => defn.isValueSubClass(self.symbol, that.symbol) case _ => false - } case _ => false - } def relaxed_<:<(that: Type)(using Context): Boolean = (this <:< that) || (this isValueSubType that) diff --git a/tasty/test/dotty/tools/tasty/TastyHeaderUnpicklerTest.scala b/tasty/test/dotty/tools/tasty/TastyHeaderUnpicklerTest.scala index b9f2aff3f564..9f54c4b3061b 100644 --- a/tasty/test/dotty/tools/tasty/TastyHeaderUnpicklerTest.scala +++ b/tasty/test/dotty/tools/tasty/TastyHeaderUnpicklerTest.scala @@ -57,8 +57,8 @@ object TastyHeaderUnpicklerTest { buf.writeNat(exp) buf.writeNat(compilerBytes.length) buf.writeBytes(compilerBytes, compilerBytes.length) - buf.writeUncompressedLong(237478l) - buf.writeUncompressedLong(324789l) + buf.writeUncompressedLong(237478L) + buf.writeUncompressedLong(324789L) buf } diff --git a/tests/pos/i12265.scala b/tests/pos/i12265.scala new file mode 100644 index 000000000000..420d382a342b --- /dev/null +++ b/tests/pos/i12265.scala @@ -0,0 +1,14 @@ +object OK { + def apply(n: Int ): Unit = () + def apply(n: Long): Unit = () + apply(3) // ok + apply(3L) // ok +} + +object KO { + type Key = Int + def apply(n: Key ): Unit = () + def apply(n: Long): Unit = () + apply(3) // error + apply(3L) // ok +}