Skip to content

Commit eb69870

Browse files
committed
Fix nesting level to account for block scopes
Previously, the nesting level of a symbol was always equal to the nesting level of its owner incremented by one, but in a situation like i8900a.scala where we have: ... val a = unwrap[?Outer]({ class Local ... the owner of both `?Outer` and `Local` is `a`, and so they ended up with the same level even though `Local` should not leak outside of the block that defines it (i8900a.scala compiled regardless due to the disabled check for forward references in TreePickler re-enabled later in this PR). We rectify this by associating each scope with a level which is always greated than the level of the enclosing scope (repurposing the existing Scope#nestingLevel method which wasn't used for anything), newly created symbols then simply take the level of the current scope (this required tweaking typedCase so that the pattern symbols were typed in the scope were they end up being entered). Also add a `-Yprint-level` option for debugging level-related issues.
1 parent 8aa6889 commit eb69870

21 files changed

+97
-70
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
7070
protected def rootContext(using Context): Context = {
7171
ctx.initialize()
7272
ctx.base.setPhasePlan(comp.phases)
73-
val rootScope = new MutableScope
73+
val rootScope = new MutableScope(0)
7474
val bootstrap = ctx.fresh
7575
.setPeriod(Period(comp.nextRunId, FirstPhaseId))
7676
.setScope(rootScope)

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import typer.ProtoTypes
77
import transform.SymUtils._
88
import transform.TypeUtils._
99
import core._
10+
import Scopes.newScope
1011
import util.Spans._, Types._, Contexts._, Constants._, Names._, Flags._, NameOps._
1112
import Symbols._, StdNames._, Annotations._, Trees._, Symbols._
1213
import Decorators._, DenotTransformers._
@@ -344,7 +345,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
344345
}
345346
else parents
346347
val cls = newNormalizedClassSymbol(owner, tpnme.ANON_CLASS, Synthetic | Final, parents1,
347-
coord = fns.map(_.span).reduceLeft(_ union _))
348+
newScope, coord = fns.map(_.span).reduceLeft(_ union _))
348349
val constr = newConstructor(cls, Synthetic, Nil, Nil).entered
349350
def forwarder(fn: TermSymbol, name: TermName) = {
350351
val fwdMeth = fn.copy(cls, name, Synthetic | Method | Final).entered.asTerm

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ private sealed trait YSettings:
274274
val YprintSyms: Setting[Boolean] = BooleanSetting("-Yprint-syms", "When printing trees print info in symbols instead of corresponding info in trees.")
275275
val YprintDebug: Setting[Boolean] = BooleanSetting("-Yprint-debug", "When printing trees, print some extra information useful for debugging.")
276276
val YprintDebugOwners: Setting[Boolean] = BooleanSetting("-Yprint-debug-owners", "When printing trees, print owners of definitions.")
277+
val YprintLevel: Setting[Boolean] = BooleanSetting("-Yprint-level", "print nesting levels of symbols and type variables.")
277278
val YshowPrintErrors: Setting[Boolean] = BooleanSetting("-Yshow-print-errors", "Don't suppress exceptions thrown during tree printing.")
278279
val YtestPickler: Setting[Boolean] = BooleanSetting("-Ytest-pickler", "Self-test for pickling functionality; should be used with -Ystop-after:pickler.")
279280
val YcheckReentrant: Setting[Boolean] = BooleanSetting("-Ycheck-reentrant", "Check that compiled program does not contain vars that can be accessed from a global root.")

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ object Contexts {
270270
if owner != null && owner.isClass then owner.asClass.unforcedDecls
271271
else scope
272272

273+
def nestingLevel: Int =
274+
val sc = effectiveScope
275+
if sc != null then sc.nestingLevel else 0
276+
273277
/** Sourcefile corresponding to given abstract file, memoized */
274278
def getSource(file: AbstractFile, codec: => Codec = Codec(settings.encoding.value)) = {
275279
util.Stats.record("Context.getSource")

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ class Definitions {
4949
private def newPermanentClassSymbol(owner: Symbol, name: TypeName, flags: FlagSet, infoFn: ClassSymbol => Type) =
5050
newClassSymbol(owner, name, flags | Permanent | NoInits | Open, infoFn)
5151

52-
private def enterCompleteClassSymbol(owner: Symbol, name: TypeName, flags: FlagSet, parents: List[TypeRef], decls: Scope = newScope) =
52+
private def enterCompleteClassSymbol(owner: Symbol, name: TypeName, flags: FlagSet, parents: List[TypeRef]): ClassSymbol =
53+
enterCompleteClassSymbol(owner, name, flags, parents, newScope(owner.nestingLevel + 1))
54+
55+
private def enterCompleteClassSymbol(owner: Symbol, name: TypeName, flags: FlagSet, parents: List[TypeRef], decls: Scope) =
5356
newCompleteClassSymbol(owner, name, flags | Permanent | NoInits | Open, parents, decls).entered
5457

5558
private def enterTypeField(cls: ClassSymbol, name: TypeName, flags: FlagSet, scope: MutableScope) =
@@ -433,7 +436,7 @@ class Definitions {
433436
Any_toString, Any_##, Any_getClass, Any_isInstanceOf, Any_typeTest, Object_eq, Object_ne)
434437

435438
@tu lazy val AnyKindClass: ClassSymbol = {
436-
val cls = newCompleteClassSymbol(ScalaPackageClass, tpnme.AnyKind, AbstractFinal | Permanent, Nil)
439+
val cls = newCompleteClassSymbol(ScalaPackageClass, tpnme.AnyKind, AbstractFinal | Permanent, Nil, newScope(0))
437440
if (!ctx.settings.YnoKindPolymorphism.value)
438441
// Enable kind-polymorphism by exposing scala.AnyKind
439442
cls.entered

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ object Scopes {
7575
*/
7676
def size: Int
7777

78-
/** The number of outer scopes from which symbols are inherited */
78+
/** The number of scopes enclosing this scope. */
7979
def nestingLevel: Int
8080

8181
/** The symbols in this scope in the order they were entered;
@@ -193,15 +193,15 @@ object Scopes {
193193
* This is necessary because when run from reflection every scope needs to have a
194194
* SynchronizedScope as mixin.
195195
*/
196-
class MutableScope protected[Scopes](initElems: ScopeEntry, initSize: Int, val nestingLevel: Int = 0)
196+
class MutableScope protected[Scopes](initElems: ScopeEntry, initSize: Int, val nestingLevel: Int)
197197
extends Scope {
198198

199199
/** Scope shares elements with `base` */
200200
protected[Scopes] def this(base: Scope)(using Context) =
201201
this(base.lastEntry, base.size, base.nestingLevel + 1)
202202
ensureCapacity(MinHashedScopeSize)
203203

204-
def this() = this(null, 0, 0)
204+
def this(nestingLevel: Int) = this(null, 0, nestingLevel)
205205

206206
private[dotc] var lastEntry: ScopeEntry = initElems
207207

@@ -225,7 +225,7 @@ object Scopes {
225225
/** Use specified synthesize for this scope */
226226
def useSynthesizer(s: SymbolSynthesizer): Unit = synthesize = s
227227

228-
protected def newScopeLikeThis(): MutableScope = new MutableScope()
228+
protected def newScopeLikeThis(): MutableScope = new MutableScope(nestingLevel)
229229

230230
/** Clone scope, taking care not to force the denotations of any symbols in the scope.
231231
*/
@@ -440,7 +440,10 @@ object Scopes {
440440
}
441441

442442
/** Create a new scope */
443-
def newScope: MutableScope = new MutableScope()
443+
def newScope(using Context): MutableScope =
444+
new MutableScope(ctx.nestingLevel + 1)
445+
446+
def newScope(nestingLevel: Int): MutableScope = new MutableScope(nestingLevel)
444447

445448
/** Create a new scope nested in another one with which it shares its elements */
446449
def newNestedScope(outer: Scope)(using Context): MutableScope = new MutableScope(outer)
@@ -468,8 +471,4 @@ object Scopes {
468471
override def lookupEntry(name: Name)(using Context): ScopeEntry = null
469472
override def lookupNextEntry(entry: ScopeEntry)(using Context): ScopeEntry = null
470473
}
471-
472-
/** A class for error scopes (mutable)
473-
*/
474-
class ErrorScope(owner: Symbol) extends MutableScope
475474
}

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,14 +1477,6 @@ object SymDenotations {
14771477
else if is(Contravariant) then Contravariant
14781478
else EmptyFlags
14791479

1480-
/** The length of the owner chain of this symbol. 1 for _root_, 0 for NoSymbol */
1481-
def nestingLevel(using Context): Int =
1482-
@tailrec def recur(d: SymDenotation, n: Int): Int = d match
1483-
case NoDenotation => n
1484-
case d: ClassDenotation => d.nestingLevel + n // profit from the cache in ClassDenotation
1485-
case _ => recur(d.owner, n + 1)
1486-
recur(this, 0)
1487-
14881480
/** The flags to be used for a type parameter owned by this symbol.
14891481
* Overridden by ClassDenotation.
14901482
*/
@@ -2323,12 +2315,6 @@ object SymDenotations {
23232315

23242316
override def registeredCompanion_=(c: Symbol) =
23252317
myCompanion = c
2326-
2327-
private var myNestingLevel = -1
2328-
2329-
override def nestingLevel(using Context) =
2330-
if myNestingLevel == -1 then myNestingLevel = owner.nestingLevel + 1
2331-
myNestingLevel
23322318
}
23332319

23342320
/** The denotation of a package class.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ object SymbolLoaders {
221221
/** The scope of a package. This is different from a normal scope
222222
* in that names of scope entries are kept in mangled form.
223223
*/
224-
final class PackageScope extends MutableScope {
224+
final class PackageScope extends MutableScope(0) {
225225
override def newScopeEntry(name: Name, sym: Symbol)(using Context): ScopeEntry =
226226
super.newScopeEntry(name.mangled, sym)
227227

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ object Symbols {
4646
* @param coord The coordinates of the symbol (a position or an index)
4747
* @param id A unique identifier of the symbol (unique per ContextBase)
4848
*/
49-
class Symbol private[Symbols] (private var myCoord: Coord, val id: Int)
49+
class Symbol private[Symbols] (private var myCoord: Coord, val id: Int, val nestingLevel: Int)
5050
extends Designator, ParamInfo, SrcPos, printing.Showable {
5151

5252
type ThisName <: Name
@@ -368,8 +368,8 @@ object Symbols {
368368
type TermSymbol = Symbol { type ThisName = TermName }
369369
type TypeSymbol = Symbol { type ThisName = TypeName }
370370

371-
class ClassSymbol private[Symbols] (coord: Coord, val assocFile: AbstractFile, id: Int)
372-
extends Symbol(coord, id) {
371+
class ClassSymbol private[Symbols] (coord: Coord, val assocFile: AbstractFile, id: Int, nestingLevel: Int)
372+
extends Symbol(coord, id, nestingLevel) {
373373

374374
type ThisName = TypeName
375375

@@ -459,7 +459,7 @@ object Symbols {
459459
override protected def prefixString: String = "ClassSymbol"
460460
}
461461

462-
@sharable object NoSymbol extends Symbol(NoCoord, 0) {
462+
@sharable object NoSymbol extends Symbol(NoCoord, 0, 0) {
463463
override def associatedFile(using Context): AbstractFile = NoSource.file
464464
override def recomputeDenot(lastd: SymDenotation)(using Context): SymDenotation = NoDenotation
465465
}
@@ -516,7 +516,7 @@ object Symbols {
516516
info: Type,
517517
privateWithin: Symbol = NoSymbol,
518518
coord: Coord = NoCoord)(using Context): Symbol { type ThisName = N } = {
519-
val sym = new Symbol(coord, ctx.base.nextSymId).asInstanceOf[Symbol { type ThisName = N }]
519+
val sym = new Symbol(coord, ctx.base.nextSymId, ctx.nestingLevel).asInstanceOf[Symbol { type ThisName = N }]
520520
val denot = SymDenotation(sym, owner, name, flags, info, privateWithin)
521521
sym.denot = denot
522522
sym
@@ -534,7 +534,7 @@ object Symbols {
534534
coord: Coord = NoCoord,
535535
assocFile: AbstractFile = null)(using Context): ClassSymbol
536536
= {
537-
val cls = new ClassSymbol(coord, assocFile, ctx.base.nextSymId)
537+
val cls = new ClassSymbol(coord, assocFile, ctx.base.nextSymId, ctx.nestingLevel)
538538
val denot = SymDenotation(cls, owner, name, flags, infoFn(cls), privateWithin)
539539
cls.denot = denot
540540
cls
@@ -546,7 +546,7 @@ object Symbols {
546546
name: TypeName,
547547
flags: FlagSet,
548548
parents: List[TypeRef],
549-
decls: Scope = newScope,
549+
decls: Scope,
550550
selfInfo: Type = NoType,
551551
privateWithin: Symbol = NoSymbol,
552552
coord: Coord = NoCoord,
@@ -564,7 +564,7 @@ object Symbols {
564564
name: TypeName,
565565
flags: FlagSet,
566566
parentTypes: List[Type],
567-
decls: Scope = newScope,
567+
decls: Scope,
568568
selfInfo: Type = NoType,
569569
privateWithin: Symbol = NoSymbol,
570570
coord: Coord = NoCoord,
@@ -580,7 +580,7 @@ object Symbols {
580580
}
581581

582582
def newRefinedClassSymbol(coord: Coord = NoCoord)(using Context): ClassSymbol =
583-
newCompleteClassSymbol(ctx.owner, tpnme.REFINE_CLASS, NonMember, parents = Nil, coord = coord)
583+
newCompleteClassSymbol(ctx.owner, tpnme.REFINE_CLASS, NonMember, parents = Nil, newScope, coord = coord)
584584

585585
/** Create a module symbol with associated module class
586586
* from its non-info fields and a function producing the info
@@ -646,7 +646,7 @@ object Symbols {
646646
name: TermName,
647647
modFlags: FlagSet = EmptyFlags,
648648
clsFlags: FlagSet = EmptyFlags,
649-
decls: Scope = newScope)(using Context): TermSymbol =
649+
decls: Scope = newScope(0))(using Context): TermSymbol =
650650
newCompleteModuleSymbol(
651651
owner, name,
652652
modFlags | PackageCreationFlags, clsFlags | PackageCreationFlags,

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4667,7 +4667,7 @@ object Types {
46674667
* @param origin The parameter that's tracked by the type variable.
46684668
* @param creatorState The typer state in which the variable was created.
46694669
*/
4670-
final class TypeVar private(initOrigin: TypeParamRef, creatorState: TyperState, nestingLevel: Int) extends CachedProxyType with ValueType {
4670+
final class TypeVar private(initOrigin: TypeParamRef, creatorState: TyperState, val nestingLevel: Int) extends CachedProxyType with ValueType {
46714671

46724672
private var currentOrigin = initOrigin
46734673

@@ -4713,6 +4713,8 @@ object Types {
47134713
* are nested more deeply than the type variable itself.
47144714
*/
47154715
private def avoidCaptures(tp: Type)(using Context): Type =
4716+
if ctx.isAfterTyper then
4717+
return tp
47164718
val problemSyms = new TypeAccumulator[Set[Symbol]]:
47174719
def apply(syms: Set[Symbol], t: Type): Set[Symbol] = t match
47184720
case ref: NamedType
@@ -4806,7 +4808,7 @@ object Types {
48064808
}
48074809
object TypeVar:
48084810
def apply(initOrigin: TypeParamRef, creatorState: TyperState)(using Context) =
4809-
new TypeVar(initOrigin, creatorState, ctx.owner.nestingLevel)
4811+
new TypeVar(initOrigin, creatorState, ctx.nestingLevel)
48104812

48114813
type TypeVars = SimpleIdentitySet[TypeVar]
48124814

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ class ClassfileParser(
6262

6363
protected val staticModule: Symbol = moduleRoot.sourceModule(using ictx)
6464

65-
protected val instanceScope: MutableScope = newScope // the scope of all instance definitions
66-
protected val staticScope: MutableScope = newScope // the scope of all static definitions
65+
protected val instanceScope: MutableScope = newScope(0) // the scope of all instance definitions
66+
protected val staticScope: MutableScope = newScope(0) // the scope of all static definitions
6767
protected var pool: ConstantPool = _ // the classfile's constant pool
6868

6969
protected var currentClassName: SimpleName = _ // JVM name of the current class

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
233233
}
234234

235235
/** The `decls` scope associated with given symbol */
236-
protected def symScope(sym: Symbol): Scope = symScopes.getOrElseUpdate(sym, newScope)
236+
protected def symScope(sym: Symbol): Scope = symScopes.getOrElseUpdate(sym, newScope(0))
237237

238238
/** Does entry represent an (internal) symbol */
239239
protected def isSymbolEntry(i: Int)(using Context): Boolean = {

compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
2929
protected def maxToTextRecursions: Int = 100
3030

3131
protected def showUniqueIds = ctx.settings.uniqid.value || Printer.debugPrintUnique
32+
protected def showNestingLevel = ctx.settings.YprintLevel.value
3233

3334
protected final def limiter: MessageLimiter = ctx.property(MessageLimiter).get
3435

@@ -155,7 +156,12 @@ class PlainPrinter(_ctx: Context) extends Printer {
155156
case tp: TermParamRef =>
156157
ParamRefNameString(tp) ~ lambdaHash(tp.binder) ~ ".type"
157158
case tp: TypeParamRef =>
158-
ParamRefNameString(tp) ~ lambdaHash(tp.binder)
159+
val suffix =
160+
if showNestingLevel then
161+
val tvar = ctx.typerState.constraint.typeVarOfParam(tp)
162+
if tvar.exists then s"#${tvar.asInstanceOf[TypeVar].nestingLevel.toString}" else ""
163+
else ""
164+
ParamRefNameString(tp) ~ lambdaHash(tp.binder) ~ suffix
159165
case tp: SingletonType =>
160166
toTextSingleton(tp)
161167
case AppliedType(tycon, args) =>
@@ -271,9 +277,13 @@ class PlainPrinter(_ctx: Context) extends Printer {
271277
catch { case ex: NullPointerException => "" }
272278
else ""
273279

274-
/** If -uniqid is set, the unique id of symbol, after a # */
280+
/** A string to append to a symbol composed of:
281+
* - if -uniqid is set, its unique id after a #.
282+
* - if -Yprint-level, its nesting level after a %.
283+
*/
275284
protected def idString(sym: Symbol): String =
276-
if (showUniqueIds || Printer.debugPrintUnique) "#" + sym.id else ""
285+
(if (showUniqueIds || Printer.debugPrintUnique) "#" + sym.id else "") +
286+
(if (showNestingLevel) "%" + sym.nestingLevel else "")
277287

278288
def nameString(sym: Symbol): String =
279289
simpleNameString(sym) + idString(sym) // + "<" + (if (sym.exists) sym.owner else "") + ">"

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,15 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
798798
protected def optAscription[T >: Untyped](tpt: Tree[T]): Text = optText(tpt)(": " ~ _)
799799

800800
private def idText(tree: untpd.Tree): Text =
801-
if showUniqueIds && tree.hasType && tree.symbol.exists then s"#${tree.symbol.id}" else ""
801+
(if showUniqueIds && tree.hasType && tree.symbol.exists then s"#${tree.symbol.id}" else "") ~
802+
(if showNestingLevel then tree.typeOpt match
803+
case tp: NamedType if !tp.symbol.isStatic => s"%${tp.symbol.nestingLevel}"
804+
case tp: TypeVar => s"%${tp.nestingLevel}"
805+
case tp: TypeParamRef => ctx.typerState.constraint.typeVarOfParam(tp) match
806+
case tvar: TypeVar => s"%${tvar.nestingLevel}"
807+
case _ => ""
808+
case _ => ""
809+
else "")
802810

803811
private def useSymbol(tree: untpd.Tree) =
804812
tree.hasType && tree.symbol.exists && ctx.settings.YprintSyms.value

compiler/src/dotty/tools/dotc/quoted/MacroExpansion.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ object MacroExpansion {
1414
ctx.property(MacroExpansionPosition)
1515

1616
def context(inlinedFrom: tpd.Tree)(using Context): Context =
17-
QuotesCache.init(ctx.fresh).setProperty(MacroExpansionPosition, SourcePosition(inlinedFrom.source, inlinedFrom.span)).setTypeAssigner(new Typer).withSource(inlinedFrom.source)
17+
QuotesCache.init(ctx.fresh).setProperty(MacroExpansionPosition, SourcePosition(inlinedFrom.source, inlinedFrom.span)).setTypeAssigner(new Typer(ctx.nestingLevel + 1)).withSource(inlinedFrom.source)
1818
}
1919

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package dotc
33
package transform
44

55
import core._
6+
import Scopes.newScope
67
import Contexts._, Symbols._, Types._, Flags._, Decorators._, StdNames._, Constants._
78
import MegaPhase._
89
import SymUtils._
@@ -123,7 +124,7 @@ class ExpandSAMs extends MiniPhase:
123124
val parents = List(
124125
defn.AbstractPartialFunctionClass.typeRef.appliedTo(anonTpe.firstParamTypes.head, anonTpe.resultType),
125126
defn.SerializableType)
126-
val pfSym = newNormalizedClassSymbol(anonSym.owner, tpnme.ANON_CLASS, Synthetic | Final, parents, coord = tree.span)
127+
val pfSym = newNormalizedClassSymbol(anonSym.owner, tpnme.ANON_CLASS, Synthetic | Final, parents, newScope, coord = tree.span)
127128

128129
def overrideSym(sym: Symbol) = sym.copy(
129130
owner = pfSym,

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import Constants._
2525
import ProtoTypes._
2626
import ErrorReporting._
2727
import Inferencing.{fullyDefinedType, isFullyDefined}
28+
import Scopes.newScope
2829
import Trees._
2930
import transform.SymUtils._
3031
import transform.TypeUtils._
@@ -1774,7 +1775,7 @@ final class SearchRoot extends SearchHistory:
17741775
// }
17751776

17761777
val parents = List(defn.ObjectType, defn.SerializableType)
1777-
val classSym = newNormalizedClassSymbol(ctx.owner, LazyImplicitName.fresh().toTypeName, Synthetic | Final, parents, coord = span)
1778+
val classSym = newNormalizedClassSymbol(ctx.owner, LazyImplicitName.fresh().toTypeName, Synthetic | Final, parents, newScope, coord = span)
17781779
val vsyms = pruned.map(_._1.symbol)
17791780
val nsyms = vsyms.map(vsym => newSymbol(classSym, vsym.name, EmptyFlags, vsym.info, coord = span).entered)
17801781
val vsymMap = (vsyms zip nsyms).toMap

0 commit comments

Comments
 (0)