diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index 79088214519b..e4a5c0ae8c6d 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -1073,12 +1073,10 @@ class TreeUnpickler(reader: TastyReader, def makeSelect(qual: Tree, name: Name, denot: Denotation): Select = var qualType = qual.tpe.widenIfUnstable val owner = denot.symbol.maybeOwner - if (owner.isPackageObject && qualType.termSymbol.is(Package)) - qualType = qualType.select(owner.sourceModule) - val tpe = name match { + val tpe0 = name match case name: TypeName => TypeRef(qualType, name, denot) case name: TermName => TermRef(qualType, name, denot) - } + val tpe = TypeOps.makePackageObjPrefixExplicit(tpe0) ConstFold.Select(untpd.Select(qual, name).withType(tpe)) def completeSelect(name: Name, sig: Signature, target: Name): Select = diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index e19337965bcc..7604158e0511 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -3591,6 +3591,7 @@ class Typer extends Namer gadts.println(i"insert GADT cast from $tree to $target") tree.cast(target) case _ => + //typr.println(i"OK ${tree.tpe}\n${TypeComparer.explained(_.isSubType(tree.tpe, pt))}") // uncomment for unexpected successes tree } diff --git a/tests/neg/i13377/LeakFoo_1.scala b/tests/neg/i13377/LeakFoo_1.scala new file mode 100644 index 000000000000..e8d679f627a3 --- /dev/null +++ b/tests/neg/i13377/LeakFoo_1.scala @@ -0,0 +1,3 @@ +import scala.util.NotGiven +type LeakFoo[T] = core.LeakingFoo[T] +val ok = summon[NotGiven[LeakFoo[1] =:= LeakFoo[2]]] diff --git a/tests/neg/i13377/Test_2.scala b/tests/neg/i13377/Test_2.scala new file mode 100644 index 000000000000..02971c189679 --- /dev/null +++ b/tests/neg/i13377/Test_2.scala @@ -0,0 +1,3 @@ +import scala.util.NotGiven +val x: LeakFoo[1] = ??? : LeakFoo[2] // error +val notok = summon[NotGiven[LeakFoo[1] =:= LeakFoo[2]]] // ok diff --git a/tests/neg/i13377/coreFoo_1.scala b/tests/neg/i13377/coreFoo_1.scala new file mode 100644 index 000000000000..cb80a6efb776 --- /dev/null +++ b/tests/neg/i13377/coreFoo_1.scala @@ -0,0 +1,4 @@ +package core + +opaque type Foo[T] <: Int = Int +type LeakingFoo[T] = Foo[T]