Skip to content

Commit

Permalink
Fix MT separate compilation bug (bis)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Aug 26, 2023
1 parent 2616c8b commit 09efbe2
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
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]]

0 comments on commit 09efbe2

Please sign in to comment.