Skip to content

Commit b8a249c

Browse files
committed
Create the symbol at the next phase
Create the symbol at the next phase, so that it is a valid member of the corresponding function for all valid periods of its SymDenotations. Otherwise, the valid period will offset by 1, which causes a stale symbol in compiling stdlib.
1 parent f7c00e6 commit b8a249c

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package dotty.tools.dotc
22
package transform
33

44
import ast.Trees._, ast.tpd, core._
5-
import Contexts.Context, Types._, Decorators._, Symbols._, DenotTransformers._
5+
import Contexts._, Types._, Decorators._, Symbols._, DenotTransformers._
66
import SymDenotations._, Scopes._, StdNames._, NameOps._, Names._
77
import MegaPhase.MiniPhase
88

@@ -24,7 +24,11 @@ class SpecializedApplyMethods extends MiniPhase with InfoTransformer {
2424

2525
private def specApplySymbol(sym: Symbol, args: List[Type], ret: Type)(using Context): Symbol = {
2626
val name = nme.apply.specializedFunction(ret, args)
27-
newSymbol(sym, name, Flags.Method, MethodType(args, ret))
27+
// Create the symbol at the next phase, so that it is a valid member of the
28+
// corresponding function for all valid periods of its SymDenotations.
29+
// Otherwise, the valid period will offset by 1, which causes a stale symbol
30+
// in compiling stdlib.
31+
atNextPhase(newSymbol(sym, name, Flags.Method, MethodType(args, ret)))
2832
}
2933

3034
private def specFun0(op: Type => Unit)(using Context): Unit = {
@@ -84,7 +88,7 @@ class SpecializedApplyMethods extends MiniPhase with InfoTransformer {
8488
def synthesizeApply(names: collection.Set[TermName]): Tree = {
8589
val applyBuf = new mutable.ListBuffer[DefDef]
8690
names.foreach { name =>
87-
val applySym = cls.info.decls.lookup(name)
91+
val applySym = atNextPhase(cls.info.decls.lookup(name))
8892
val ddef = DefDef(
8993
applySym.asTerm,
9094
{ vparamss =>

0 commit comments

Comments
 (0)