diff options
-rw-r--r-- | src/dotty/tools/dotc/typer/Checking.scala | 12 | ||||
-rw-r--r-- | test/dotc/scala-collections.whitelist | 2 | ||||
-rw-r--r-- | test/dotc/tests.scala | 1 | ||||
-rw-r--r-- | tests/neg/i974.scala | 8 | ||||
-rw-r--r-- | tests/pos/i974.scala | 2 |
5 files changed, 18 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/typer/Checking.scala b/src/dotty/tools/dotc/typer/Checking.scala index 57032c4d9..6ded7c109 100644 --- a/src/dotty/tools/dotc/typer/Checking.scala +++ b/src/dotty/tools/dotc/typer/Checking.scala @@ -138,9 +138,7 @@ object Checking { case SuperType(thistp, _) => isInteresting(thistp) case AndType(tp1, tp2) => isInteresting(tp1) || isInteresting(tp2) case OrType(tp1, tp2) => isInteresting(tp1) && isInteresting(tp2) - case _: RefinedType => false - // Note: it's important not to visit parents of RefinedTypes, - // since otherwise spurious #Apply projections might be inserted. + case _: RefinedType => true case _ => false } // If prefix is interesting, check info of typeref recursively, marking the referred symbol @@ -148,10 +146,12 @@ object Checking { // is hit again. Without this precaution we could stackoverflow here. if (isInteresting(pre)) { val info = tp.info - val symInfo = tp.symbol.info - if (tp.symbol.exists) tp.symbol.info = SymDenotations.NoCompleter + val sym = tp.symbol + if (sym.infoOrCompleter == SymDenotations.NoCompleter) throw CyclicReference(sym) + val symInfo = sym.info + if (sym.exists) sym.info = SymDenotations.NoCompleter try checkInfo(info) - finally if (tp.symbol.exists) tp.symbol.info = symInfo + finally if (sym.exists) sym.info = symInfo } tp } catch { diff --git a/test/dotc/scala-collections.whitelist b/test/dotc/scala-collections.whitelist index 2abb16c1e..f6a13cc72 100644 --- a/test/dotc/scala-collections.whitelist +++ b/test/dotc/scala-collections.whitelist @@ -266,7 +266,7 @@ ./scala-scala/src/library/scala/collection/generic/ParFactory.scala # https://github.com/lampepfl/dotty/issues/974 -> @smarter -#./scala-scala/src/library/scala/collection/generic/MutableSortedSetFactory.scala +./scala-scala/src/library/scala/collection/generic/MutableSortedSetFactory.scala # cyclic reference, maybe related to #974 -> @smarter #./scala-scala/src/library/scala/collection/generic/ParSetFactory.scala diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala index 2810a8b55..b61783b0b 100644 --- a/test/dotc/tests.scala +++ b/test/dotc/tests.scala @@ -158,6 +158,7 @@ class tests extends CompilerTest { @Test def neg_finalSealed = compileFile(negDir, "final-sealed", xerrors = 2) @Test def neg_i705 = compileFile(negDir, "i705-inner-value-class", xerrors = 7) @Test def neg_i866 = compileFile(negDir, "i866", xerrors = 2) + @Test def neg_i974 = compileFile(negDir, "i974", xerrors = 2) @Test def neg_moduleSubtyping = compileFile(negDir, "moduleSubtyping", xerrors = 4) @Test def neg_escapingRefs = compileFile(negDir, "escapingRefs", xerrors = 2) @Test def neg_instantiateAbstract = compileFile(negDir, "instantiateAbstract", xerrors = 8) diff --git a/tests/neg/i974.scala b/tests/neg/i974.scala new file mode 100644 index 000000000..89db4b2d9 --- /dev/null +++ b/tests/neg/i974.scala @@ -0,0 +1,8 @@ +trait Foo[T <: Bar[T]#Elem] // error: illegal cyclic reference +trait Bar[T] { + type Elem = T +} +trait Foo2[T <: Bar2[T]#Elem] // error: illegal cyclic reference +trait Bar2[T] { + type Elem = T +} diff --git a/tests/pos/i974.scala b/tests/pos/i974.scala new file mode 100644 index 000000000..4c7c15e8d --- /dev/null +++ b/tests/pos/i974.scala @@ -0,0 +1,2 @@ +class Foo[A] +class Bar[CC[X] <: Foo[CC[X]]] |