Skip to content

Commit

Permalink
Fix caching issue caused by incorrect isProvisional check
Browse files Browse the repository at this point in the history
A static TypeRef can still be provisional if it's currently being completed (see
the logic in `Namer#TypeDefCompleter#typeSig`).

Fixes scala#16950.
  • Loading branch information
smarter authored and Kordyjan committed Apr 13, 2023
1 parent aecbfa7 commit f0f6baf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 2 additions & 3 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,9 @@ object Types {
if t.mightBeProvisional then
t.mightBeProvisional = t match
case t: TypeRef =>
!t.currentSymbol.isStatic && {
t.currentSymbol.isProvisional || !t.currentSymbol.isStatic && {
(t: Type).mightBeProvisional = false // break cycles
t.symbol.isProvisional
|| test(t.prefix, theAcc)
test(t.prefix, theAcc)
|| t.denot.infoOrCompleter.match
case info: LazyType => true
case info: AliasingBounds => test(info.alias, theAcc)
Expand Down
11 changes: 11 additions & 0 deletions tests/pos/i16950.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
object Foo:
def bar(x : Bar.YOf[Any]): Unit = ???

trait K:
type CType <: Bar.YOf[Any]
def foo : K =
val x : CType = ???
x // was: error: Found: CType, Expected: K

object Bar:
type YOf[T] = K { type M }

0 comments on commit f0f6baf

Please sign in to comment.