Skip to content

Commit beb6fce

Browse files
committed
Don't force NamedType denotations in containsRefinedThis
containsRefinedThis inspects symbols and infos of named types in order to avoid needless traversals. As i974 shows, this can lead to infinite recursions. The fix is not to force a NamedType denotation, assume the worst and traverse the prefix if a NamedType is not yet populated with a denotation. Fixes scala#974 and makes MutableSortedSetFactory in stdlib compile.
1 parent da661c8 commit beb6fce

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/dotty/tools/dotc/core/TypeApplications.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -695,11 +695,13 @@ class TypeApplications(val self: Type) extends AnyVal {
695695
case RefinedThis(tp) =>
696696
tp eq target
697697
case tp: NamedType =>
698-
if (tp.symbol.isClass) !tp.symbol.isStatic && recur(tp.prefix)
699-
else tp.info match {
700-
case TypeAlias(alias) => recur(alias)
701-
case _ => recur(tp.prefix)
702-
}
698+
if (tp.denotationIsCurrent)
699+
if (tp.symbol.isClass) !tp.symbol.isStatic && recur(tp.prefix)
700+
else tp.info match {
701+
case TypeAlias(alias) => recur(alias)
702+
case _ => recur(tp.prefix)
703+
}
704+
else recur(tp.prefix)
703705
case tp: RefinedType =>
704706
recur(tp.refinedInfo) || recur(tp.parent)
705707
case tp: TypeBounds =>

test/dotc/scala-collections.whitelist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@
266266
./scala-scala/src/library/scala/collection/generic/ParFactory.scala
267267

268268
# https://github.com/lampepfl/dotty/issues/974 -> @smarter
269-
#./scala-scala/src/library/scala/collection/generic/MutableSortedSetFactory.scala
269+
./scala-scala/src/library/scala/collection/generic/MutableSortedSetFactory.scala
270270

271271
# cyclic reference, maybe related to #974 -> @smarter
272272
#./scala-scala/src/library/scala/collection/generic/ParSetFactory.scala

tests/pos/i974.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Foo[A]
2+
class Bar[CC[X] <: Foo[CC[X]]]

0 commit comments

Comments
 (0)