Skip to content

Fix problem when making package objects explicit during unpickling #13413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 3 additions & 0 deletions tests/neg/i13377/LeakFoo_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import scala.util.NotGiven
type LeakFoo[T] = core.LeakingFoo[T]
val ok = summon[NotGiven[LeakFoo[1] =:= LeakFoo[2]]]
3 changes: 3 additions & 0 deletions tests/neg/i13377/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import scala.util.NotGiven
val x: LeakFoo[1] = ??? : LeakFoo[2] // error
val notok = summon[NotGiven[LeakFoo[1] =:= LeakFoo[2]]] // ok
4 changes: 4 additions & 0 deletions tests/neg/i13377/coreFoo_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package core

opaque type Foo[T] <: Int = Int
type LeakingFoo[T] = Foo[T]