diff options
-rw-r--r-- | src/dotty/tools/dotc/core/TypeErasure.scala | 7 | ||||
-rw-r--r-- | tests/pos/valueclasses/t9298/JUse.java | 7 | ||||
-rw-r--r-- | tests/pos/valueclasses/t9298/Meter.scala | 3 | ||||
-rw-r--r-- | tests/pos/valueclasses/t9298/Use.scala | 9 |
4 files changed, 24 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/TypeErasure.scala b/src/dotty/tools/dotc/core/TypeErasure.scala index 9d5436d9f..71146bd4e 100644 --- a/src/dotty/tools/dotc/core/TypeErasure.scala +++ b/src/dotty/tools/dotc/core/TypeErasure.scala @@ -145,12 +145,15 @@ object TypeErasure { * - For companion methods : the erasure of their type with semiEraseVCs = false. * The signature of these methods are used to keep a * link between companions and should not be semi-erased. + * - For Java-defined symbols: : the erasure of their type with isJava = true, + * semiEraseVCs = false. Semi-erasure never happens in Java. * - For all other symbols : the semi-erasure of their types, with * isJava, isConstructor set according to symbol. */ def transformInfo(sym: Symbol, tp: Type)(implicit ctx: Context): Type = { - val semiEraseVCs = !sym.isCompanionMethod - val erase = erasureFn(sym is JavaDefined, semiEraseVCs, sym.isConstructor, wildcardOK = false) + val isJava = sym is JavaDefined + val semiEraseVCs = !isJava && !sym.isCompanionMethod + val erase = erasureFn(isJava, semiEraseVCs, sym.isConstructor, wildcardOK = false) def eraseParamBounds(tp: PolyType): Type = tp.derivedPolyType( diff --git a/tests/pos/valueclasses/t9298/JUse.java b/tests/pos/valueclasses/t9298/JUse.java new file mode 100644 index 000000000..a872c895a --- /dev/null +++ b/tests/pos/valueclasses/t9298/JUse.java @@ -0,0 +1,7 @@ +package t9298; + +class JUse { + public static Meter jm() { + return new Meter(2); + } +} diff --git a/tests/pos/valueclasses/t9298/Meter.scala b/tests/pos/valueclasses/t9298/Meter.scala new file mode 100644 index 000000000..290b28509 --- /dev/null +++ b/tests/pos/valueclasses/t9298/Meter.scala @@ -0,0 +1,3 @@ +package t9298 + +class Meter(val x: Int) extends AnyVal diff --git a/tests/pos/valueclasses/t9298/Use.scala b/tests/pos/valueclasses/t9298/Use.scala new file mode 100644 index 000000000..41f1fb035 --- /dev/null +++ b/tests/pos/valueclasses/t9298/Use.scala @@ -0,0 +1,9 @@ +// TODO: this should be a run test once we have run tests + +package t9298 + +object Use { + def main(args: Array[String]): Unit = { + val x: Meter = JUse.jm + } +} |