Skip to content

Commit 1a11195

Browse files
committed
Fixing issue when synchronizing defTrees
1 parent 26a2887 commit 1a11195

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ class Compiler {
6464
new CheckStatic, // Check restrictions that apply to @static members
6565
new BetaReduce, // Reduce closure applications
6666
new InlineVals, // Check right hand-sides of an `inline val`s
67-
new ExpandSAMs, // Expand single abstract method closures to anonymous classes
68-
new init.Checker) :: // Check initialization of objects
67+
new ExpandSAMs) :: // Expand single abstract method closures to anonymous classes
68+
List(new init.Checker) :: // Check initialization of objects
6969
List(new ElimRepeated, // Rewrite vararg parameters and arguments
7070
new ProtectedAccessors, // Add accessors for protected members
7171
new ExtensionMethods, // Expand methods of value classes with extension methods

compiler/src/dotty/tools/dotc/core/Symbols.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ object Symbols {
8484
*/
8585
def retainsDefTree(using Context): Boolean =
8686
ctx.settings.YretainTrees.value ||
87+
ctx.settings.YcheckInit.value || // initialization check
8788
denot.owner.isTerm || // no risk of leaking memory after a run for these
88-
denot.isOneOf(InlineOrProxy) || // need to keep inline info
89-
ctx.settings.YcheckInit.value // initialization check
89+
denot.isOneOf(InlineOrProxy) // need to keep inline info
9090

9191
/** The last denotation of this symbol */
9292
private var lastDenot: SymDenotation = _

compiler/src/dotty/tools/dotc/transform/SyncDefTree.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ package transform
44

55
import dotty.tools.dotc._
66
import ast.tpd
7-
import tpd._
7+
import tpd._
88

99
import dotty.tools.dotc.core._
1010
import Contexts._
1111
import Types._
1212
import Symbols._
13+
import StdNames._
1314

1415
import dotty.tools.dotc.transform._
1516
import MegaPhase._
@@ -31,7 +32,7 @@ class SyncDefTree extends MiniPhase {
3132
}
3233

3334
override def transformValDef(tree: ValDef)(using Context): Tree = {
34-
tree.symbol.defTree = tree
35+
if tree.name != nme.WILDCARD then tree.symbol.defTree = tree
3536
tree
3637
}
3738

compiler/src/dotty/tools/dotc/transform/init/Semantic.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,6 @@ class Semantic {
406406
given Trace = trace1
407407
val cls = target.owner.enclosingClass.asClass
408408
val ddef = target.defTree.asInstanceOf[DefDef]
409-
// try early promotion here; if returns error, returns cold
410409
val env2 = Env(ddef, args.map(_.value).widenArgs)
411410
if target.isPrimaryConstructor then
412411
given Env = env2
@@ -857,8 +856,7 @@ class Semantic {
857856
case vdef : ValDef =>
858857
// local val definition
859858
// TODO: support explicit @cold annotation for local definitions
860-
eval(vdef.rhs, thisV, klass, true)
861-
// .ensureHot("Local definitions may only hold initialized values", vdef)
859+
eval(vdef.rhs, thisV, klass, cacheResult = true)
862860

863861
case ddef : DefDef =>
864862
// local method

0 commit comments

Comments
 (0)