Skip to content

Commit f0f6baf

Browse files
smarterKordyjan
authored andcommitted
Fix caching issue caused by incorrect isProvisional check
A static TypeRef can still be provisional if it's currently being completed (see the logic in `Namer#TypeDefCompleter#typeSig`). Fixes #16950.
1 parent aecbfa7 commit f0f6baf

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,9 @@ object Types {
118118
if t.mightBeProvisional then
119119
t.mightBeProvisional = t match
120120
case t: TypeRef =>
121-
!t.currentSymbol.isStatic && {
121+
t.currentSymbol.isProvisional || !t.currentSymbol.isStatic && {
122122
(t: Type).mightBeProvisional = false // break cycles
123-
t.symbol.isProvisional
124-
|| test(t.prefix, theAcc)
123+
test(t.prefix, theAcc)
125124
|| t.denot.infoOrCompleter.match
126125
case info: LazyType => true
127126
case info: AliasingBounds => test(info.alias, theAcc)

tests/pos/i16950.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
object Foo:
2+
def bar(x : Bar.YOf[Any]): Unit = ???
3+
4+
trait K:
5+
type CType <: Bar.YOf[Any]
6+
def foo : K =
7+
val x : CType = ???
8+
x // was: error: Found: CType, Expected: K
9+
10+
object Bar:
11+
type YOf[T] = K { type M }

0 commit comments

Comments
 (0)