Skip to content

Commit 0a8c17e

Browse files
committed
Avoid eager forcing in enterArgBinding
Caused a cyclic reference error when compiling the three files in test "testNonCyclic".
1 parent ecac7b3 commit 0a8c17e

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

src/dotty/tools/dotc/config/Printers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ object Printers {
1515
val typr: Printer = new Printer
1616
val constr: Printer = noPrinter
1717
val overload: Printer = noPrinter
18-
val implicits: Printer = new Printer
18+
val implicits: Printer = noPrinter
1919
val unapp: Printer = noPrinter
2020
val completions = noPrinter
2121
val gadts = noPrinter

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,9 @@ object SymDenotations {
128128
if (myFlags is Touched) throw new CyclicReference(this)
129129
myFlags |= Touched
130130

131-
Context.theBase.initialCtx.traceIndented(s"completing ${this.debugString}", completions) {
132-
// println("completing " + debugString)
133-
completer.complete(this)
134-
}
131+
completions.println(s"completing ${this.debugString}")
132+
completer.complete(this)
133+
completions.println(s"completed ${this.debugString}")
135134
}
136135

137136
protected[dotc] final def info_=(tp: Type) = {

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package dotty.tools.dotc
22
package core
33

44
import Contexts._, Types._, Symbols._, Names._, Flags._, Scopes._
5+
import SymDenotations._
56
import util.SimpleMap
67

78
trait TypeOps { this: Context =>
@@ -86,8 +87,14 @@ trait TypeOps { this: Context =>
8687
}
8788

8889
private def enterArgBinding(formal: Symbol, info: Type, cls: ClassSymbol, decls: Scope) = {
90+
val lazyInfo = new LazyType { // needed so we do not force `formal`.
91+
def complete(denot: SymDenotation): Unit = {
92+
denot setFlag formal.flags & RetainedTypeArgFlags
93+
denot.info = info
94+
}
95+
}
8996
val typeArgFlag = if (formal is Local) TypeArgument else EmptyFlags
90-
val sym = ctx.newSymbol(cls, formal.name, formal.flags & RetainedTypeArgFlags | typeArgFlag, info)
97+
val sym = ctx.newSymbol(cls, formal.name, formal.flagsUNSAFE & RetainedTypeArgFlags | typeArgFlag, lazyInfo)
9198
cls.enter(sym, decls)
9299
}
93100

test/dotc/tests.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ class tests extends CompilerTest {
5757
@Test def tools_io = compileDir(dotcDir + "tools/io")
5858
@Test def tools = compileDir(dotcDir + "tools")
5959

60-
@Test def dotc_compilercommand = compileFile(dotcDir + "tools/dotc/config/", "CompilerCommand")
60+
@Test def testNonCyclic = compileArgs(Array(
61+
dotcDir + "tools/dotc/CompilationUnit.scala",
62+
dotcDir + "tools/dotc/core/Types.scala",
63+
dotcDir + "tools/dotc/ast/Trees.scala",
64+
"-Ylog:frontend",
65+
"-Xprompt"))
6166

67+
//@Test def dotc_compilercommand = compileFile(dotcDir + "tools/dotc/config/", "CompilerCommand")
6268
}

0 commit comments

Comments
 (0)