Skip to content

Commit 4b90cf3

Browse files
committed
Fix incorrect caching with path-dependent types
The added test case used to fail Ycheck:typer with the seemingly identicals: Found: (a: (aa : A{type B = Int}), b: a.B): CCPoly[(aa : A{type B = Int})] Required: (a: (aa : A{type B = Int}), b: a.B): CCPoly[(aa : A{type B = Int})] In fact one of the `aa` is a a TypeVar instantiated to `A {type B = Int }`. The MethodType comparison failed the signature check because the `a.B` where `a` is backed by a type variable had a stale signature cached. Fixed by changing `isProvisional` to traverse ParamRefs. [Cherry-picked c32e535][modified]
1 parent 1523e5f commit 4b90cf3

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

+3
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ object Types extends TypeUtils {
140140
!t.isPermanentlyInstantiated || test(t.permanentInst, theAcc)
141141
case t: LazyRef =>
142142
!t.completed || test(t.ref, theAcc)
143+
case t: ParamRef =>
144+
(t: Type).mightBeProvisional = false // break cycles
145+
test(t.underlying, theAcc)
143146
case _ =>
144147
(if theAcc != null then theAcc else ProAcc()).foldOver(false, t)
145148
end if

tests/pos/dep-poly-class.scala

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
trait A:
2+
type B
3+
4+
class CCPoly[T <: A](a: T, b: a.B)
5+
6+
object Test:
7+
def test(): Unit =
8+
val aa: A { type B = Int } = new A { type B = Int }
9+
val x: CCPoly[aa.type] = CCPoly(aa, 1)

0 commit comments

Comments
 (0)