Skip to content

Commit 6f6f1ef

Browse files
authored
Merge pull request #13413 from dotty-staging/fix-13377
Fix problem when making package objects explicit during unpickling
2 parents 22e9224 + a057ece commit 6f6f1ef

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,12 +1073,10 @@ class TreeUnpickler(reader: TastyReader,
10731073
def makeSelect(qual: Tree, name: Name, denot: Denotation): Select =
10741074
var qualType = qual.tpe.widenIfUnstable
10751075
val owner = denot.symbol.maybeOwner
1076-
if (owner.isPackageObject && qualType.termSymbol.is(Package))
1077-
qualType = qualType.select(owner.sourceModule)
1078-
val tpe = name match {
1076+
val tpe0 = name match
10791077
case name: TypeName => TypeRef(qualType, name, denot)
10801078
case name: TermName => TermRef(qualType, name, denot)
1081-
}
1079+
val tpe = TypeOps.makePackageObjPrefixExplicit(tpe0)
10821080
ConstFold.Select(untpd.Select(qual, name).withType(tpe))
10831081

10841082
def completeSelect(name: Name, sig: Signature, target: Name): Select =

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3591,6 +3591,7 @@ class Typer extends Namer
35913591
gadts.println(i"insert GADT cast from $tree to $target")
35923592
tree.cast(target)
35933593
case _ =>
3594+
//typr.println(i"OK ${tree.tpe}\n${TypeComparer.explained(_.isSubType(tree.tpe, pt))}") // uncomment for unexpected successes
35943595
tree
35953596
}
35963597

tests/neg/i13377/LeakFoo_1.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import scala.util.NotGiven
2+
type LeakFoo[T] = core.LeakingFoo[T]
3+
val ok = summon[NotGiven[LeakFoo[1] =:= LeakFoo[2]]]

tests/neg/i13377/Test_2.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import scala.util.NotGiven
2+
val x: LeakFoo[1] = ??? : LeakFoo[2] // error
3+
val notok = summon[NotGiven[LeakFoo[1] =:= LeakFoo[2]]] // ok

tests/neg/i13377/coreFoo_1.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package core
2+
3+
opaque type Foo[T] <: Int = Int
4+
type LeakingFoo[T] = Foo[T]

0 commit comments

Comments
 (0)