Skip to content
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

Fix MT separate compilation bug (bis) #18461

Closed
Closed
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
8 changes: 7 additions & 1 deletion compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,13 @@ class TreeUnpickler(reader: TastyReader,
val args = until(end)(readTpt())
val tree = untpd.AppliedTypeTree(tycon, args)
val ownType = ctx.typeAssigner.processAppliedType(tree, tycon.tpe.safeAppliedTo(args.tpes))
tree.withType(postProcessFunction(ownType))
val tp = postProcessFunction(ownType)
// Much like in the MATCHtpt case,
// normalize the type to avoid differences in the type of trees,
// (between joint compilation and separate compilation)
// which affects how types are compared in subtyping.
val tpn = tp.normalized
tree.withType(tpn)
case ANNOTATEDtpt =>
Annotated(readTpt(), readTree())
case LAMBDAtpt =>
Expand Down
7 changes: 7 additions & 0 deletions tests/pos/i18261.bis.min/Main_0.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
trait VAL

type Foo[T, M] = M match { case VAL => T }

class Cand[A]
object Cand:
given inst[X, Y <: Foo[X, VAL]]: Cand[Y] = new Cand[Y]
4 changes: 4 additions & 0 deletions tests/pos/i18261.bis.min/Test_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Test:
def test: Unit =
summon[Cand[Int]]
summon[Cand[Long]]
7 changes: 7 additions & 0 deletions tests/pos/i18261.bis/DFBits_0.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
trait DFBits[W <: Int]

trait Candidate[R]:
type OutW <: Int
object Candidate:
given [W <: Int, R <: Foo[DFBits[W], VAL]]: Candidate[R] with
type OutW = W
4 changes: 4 additions & 0 deletions tests/pos/i18261.bis/Foo_0.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
trait VAL

type Foo[T, M] = M match
case VAL => T
5 changes: 5 additions & 0 deletions tests/pos/i18261.bis/Test_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def baz[L](lhs: L)(using icL: Candidate[L]): DFBits[Int] = ???
object Test:
val x: DFBits[8] = ???
val z: DFBits[Int] = baz(x)
summon[Candidate[z.type]]
Loading