Skip to content

Don't force NamedType denotations in containsRefinedThis #1026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
2 changes: 1 addition & 1 deletion scripts/common
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ update() {

export LC_ALL=en_US.UTF-8

sbtArgs="-Ddotty.jenkins.build=yes -Dfile.encoding=UTF-8 -ivy $baseDir/ivy2 -Dsbt.global.base=$HOME/.sbt/0.13 -sbt-dir $HOME/.sbt/0.13"
sbtArgs="-Ddotty.jenkins.build=yes -J-Xmx1500m -Dfile.encoding=UTF-8 -ivy $baseDir/ivy2 -Dsbt.global.base=$HOME/.sbt/0.13 -sbt-dir $HOME/.sbt/0.13"
12 changes: 7 additions & 5 deletions src/dotty/tools/dotc/core/TypeApplications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -695,11 +695,13 @@ class TypeApplications(val self: Type) extends AnyVal {
case RefinedThis(tp) =>
tp eq target
case tp: NamedType =>
if (tp.symbol.isClass) !tp.symbol.isStatic && recur(tp.prefix)
else tp.info match {
case TypeAlias(alias) => recur(alias)
case _ => recur(tp.prefix)
}
if (tp.denotationIsCurrent)
if (tp.symbol.isClass) !tp.symbol.isStatic && recur(tp.prefix)
else tp.info match {
case TypeAlias(alias) => recur(alias)
case _ => recur(tp.prefix)
}
else recur(tp.prefix)
case tp: RefinedType =>
recur(tp.refinedInfo) || recur(tp.parent)
case tp: TypeBounds =>
Expand Down
3 changes: 3 additions & 0 deletions src/dotty/tools/dotc/transform/TreeChecker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ class TreeChecker extends Phase with SymTransformer {
ctx.println(ex.getStackTrace.take(30).deep.mkString("\n"))
ctx.println("<<<")
throw ex
case ex: Throwable =>
println("!!!!!!" + ex)
throw ex
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,20 @@ 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
// with NoCompleter. This provokes a CyclicReference when the symbol
// 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 {
Expand Down
2 changes: 1 addition & 1 deletion test/dotc/scala-collections.whitelist
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion test/dotc/tests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -232,7 +233,8 @@ class tests extends CompilerTest {

@Test def tasty_new_all = compileFiles(newDir, testPickling)
@Test def tasty_dotc_config = compileDir(dotcDir, "config", testPickling)
@Test def tasty_dotc_printing = compileDir(dotcDir, "printing", testPickling)
// disabled because it seems to cause repeated test failures (problem with output?)
// @Test def tasty_dotc_printing = compileDir(dotcDir, "printing", testPickling)
//@Test def tasty_dotc_reporting = compileDir(dotcDir, "reporting", testPickling)
@Test def tasty_dotc_util = compileDir(dotcDir, "util", testPickling)
@Test def tasty_core = compileList("tasty_core", List(
Expand Down
2 changes: 1 addition & 1 deletion test/test/CompilerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ abstract class CompilerTest extends DottyTest {
case ExistsSame => // nothing else to do
case ExistsDifferent =>
val nextDest = dest.parent / (dest match {
case f: SFile => SFile(replaceVersion(f.stripExtension, nr)).addExtension(f.extension)
case d: Directory => Directory(replaceVersion(d.name, nr))
case f => SFile(replaceVersion(f.stripExtension, nr)).addExtension(f.extension)
})
computeDestAndCopyFiles(source, nextDest, kind, flags, nerr, nr + 1, partestOutput)
}
Expand Down
8 changes: 8 additions & 0 deletions tests/neg/i974.scala
Original file line number Diff line number Diff line change
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you intend to have the same test twice, with just the names changed? (Foo -> Foo2, Bar -> Bar2)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because 1 expected error also succeeds if the file is not found.

trait Bar2[T] {
type Elem = T
}
2 changes: 2 additions & 0 deletions tests/pos/i974.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Foo[A]
class Bar[CC[X] <: Foo[CC[X]]]