Skip to content

Commit 4cd9697

Browse files
committed
WIP widen 1
1 parent 7859527 commit 4cd9697

25 files changed

+50
-50
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
326326
if (t.exists) t
327327
else {
328328
val arity = app.meth.tpe.widenDealias.firstParamTypes.size - env.size
329-
val returnsUnit = app.meth.tpe.widenDealias.resultType.classSymbol == defn.UnitClass
329+
val returnsUnit = app.meth.tpe.widenDealias.resultType.widen.classSymbol == defn.UnitClass
330330
if (returnsUnit) requiredClass(("dotty.runtime.function.JProcedure" + arity))
331331
else if (arity <= 2) requiredClass(("dotty.runtime.function.JFunction" + arity))
332332
else requiredClass(("scala.Function" + arity))

compiler/src/dotty/tools/backend/jvm/BCodeHelpers.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
425425
} // for the lazy val in ScalaSigBytes to be GC'ed, the invoker of emitAnnotations() should hold the ScalaSigBytes in a method-local var that doesn't escape.
426426
*/
427427
case t @ Apply(constr, args) if t.tpe.derivesFrom(JavaAnnotationClass) =>
428-
val typ = t.tpe.classSymbol.denot.info
428+
val typ = t.tpe.widen.classSymbol.denot.info
429429
val assocs = assocsFromApply(t)
430430
val desc = innerClasesStore.typeDescriptor(typ) // the class descriptor of the nested annotation class
431431
val nestedVisitor = av.visitAnnotation(name, desc)
@@ -621,7 +621,7 @@ trait BCodeHelpers extends BCodeIdiomatic with BytecodeWriters {
621621
*/
622622
def getExceptions(excs: List[Annotation]): List[String] = {
623623
for (case ThrownException(exc) <- excs.distinct)
624-
yield internalName(TypeErasure.erasure(exc).classSymbol)
624+
yield internalName(TypeErasure.erasure(exc).widen.classSymbol)
625625
}
626626
} // end of trait BCForwardersGen
627627

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ object desugar {
12261226
if (arity == 0)
12271227
if (ctx.mode is Mode.Type) TypeTree(defn.UnitType) else unitLiteral
12281228
else if (ctx.mode is Mode.Type) AppliedTypeTree(ref(tupleTypeRef), ts)
1229-
else Apply(ref(tupleTypeRef.classSymbol.companionModule.termRef), ts)
1229+
else Apply(ref(tupleTypeRef.widen.classSymbol.companionModule.termRef), ts)
12301230
}
12311231

12321232
private def isTopLevelDef(stat: Tree)(using Context): Boolean = stat match

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
340340
def AnonClass(parents: List[Type], fns: List[TermSymbol], methNames: List[TermName])(using Context): Block = {
341341
val owner = fns.head.owner
342342
val parents1 =
343-
if (parents.head.classSymbol.is(Trait)) {
343+
if (parents.head.widen.classSymbol.is(Trait)) {
344344
val head = parents.head.parents.head
345345
if (head.isRef(defn.AnyClass)) defn.AnyRefType :: parents else head :: parents
346346
}
@@ -454,7 +454,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
454454
* `length` arguments are given.
455455
*/
456456
def newArray(elemTpe: Type, returnTpe: Type, span: Span, dims: JavaSeqLiteral)(using Context): Tree = {
457-
val elemClass = elemTpe.classSymbol
457+
val elemClass = elemTpe.widen.classSymbol
458458
def newArr =
459459
ref(defn.DottyArraysModule).select(defn.newArrayMethod).withSpan(span)
460460

@@ -468,7 +468,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
468468

469469
/** The wrapped array method name for an array of type elemtp */
470470
def wrapArrayMethodName(elemtp: Type)(using Context): TermName = {
471-
val elemCls = elemtp.classSymbol
471+
val elemCls = elemtp.widen.classSymbol
472472
if (elemCls.isPrimitiveValueClass) nme.wrapXArray(elemCls.name)
473473
else if (elemCls.derivesFrom(defn.ObjectClass) && !elemCls.isNotRuntimeClass) nme.wrapRefArray
474474
else nme.genericWrapArray

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ object Constants {
157157
case param: TypeParamRef =>
158158
ctx.typerState.constraint.entry(param) match {
159159
case TypeBounds(lo, hi) =>
160-
if (hi.classSymbol.isPrimitiveValueClass) hi //constrain further with high bound
160+
if (hi.widen.classSymbol.isPrimitiveValueClass) hi //constrain further with high bound
161161
else classBound(lo)
162162
case NoType => classBound(param.binder.paramInfos(param.paramNum).lo)
163163
case inst => classBound(inst)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ class Definitions {
11611161
EmptyTypeName
11621162

11631163
/** If type `ref` refers to a class in the scala package, its name, otherwise EmptyTypeName */
1164-
def scalaClassName(ref: Type)(using Context): TypeName = scalaClassName(ref.classSymbol)
1164+
def scalaClassName(ref: Type)(using Context): TypeName = scalaClassName(ref.widen.classSymbol)
11651165

11661166
private def isVarArityClass(cls: Symbol, prefix: String) =
11671167
cls.isClass
@@ -1365,8 +1365,8 @@ class Definitions {
13651365
def tupleTypes(tp: Type, bound: Int = Int.MaxValue)(using Context): Option[List[Type]] = {
13661366
@tailrec def rec(tp: Type, acc: List[Type], bound: Int): Option[List[Type]] = tp.normalized.dealias match {
13671367
case _ if bound < 0 => Some(acc.reverse)
1368-
case tp: AppliedType if defn.PairClass == tp.classSymbol => rec(tp.args(1), tp.args.head :: acc, bound - 1)
1369-
case tp: AppliedType if defn.isTupleClass(tp.tycon.classSymbol) => Some(acc.reverse ::: tp.args)
1368+
case tp: AppliedType if defn.PairClass == tp.widen.classSymbol => rec(tp.args(1), tp.args.head :: acc, bound - 1)
1369+
case tp: AppliedType if defn.isTupleClass(tp.tycon.widen.classSymbol) => Some(acc.reverse ::: tp.args)
13701370
case tp: TermRef if tp.symbol == defn.EmptyTupleModule => Some(acc.reverse)
13711371
case _ => None
13721372
}
@@ -1573,7 +1573,7 @@ class Definitions {
15731573

15741574
/** The type of the boxed class corresponding to primitive value type `tp`. */
15751575
def boxedType(tp: Type)(using Context): TypeRef = {
1576-
val cls = tp.classSymbol
1576+
val cls = tp.widen.classSymbol
15771577
if (cls eq ByteClass) BoxedByteClass
15781578
else if (cls eq ShortClass) BoxedShortClass
15791579
else if (cls eq CharClass) BoxedCharClass

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ object JavaNullInterop {
121121
// We don't make the outmost levels of type arguments nullable if tycon is Java-defined.
122122
// This is because Java classes are _all_ nullified, so both `java.util.List[String]` and
123123
// `java.util.List[String|Null]` contain nullable elements.
124-
outermostLevelAlreadyNullable = tp.classSymbol.is(JavaDefined)
124+
outermostLevelAlreadyNullable = tp.widen.classSymbol.is(JavaDefined)
125125
val targs2 = targs map this
126126
outermostLevelAlreadyNullable = oldOutermostNullable
127127
val appTp2 = derivedAppliedType(appTp, tycon, targs2)

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ trait PatternTypeConstrainer { self: TypeComparer =>
7777

7878
def classesMayBeCompatible: Boolean = {
7979
import Flags._
80-
val patClassSym = pat.widenSingleton.classSymbol
81-
val scrutClassSym = scrut.widenSingleton.classSymbol
80+
val patClassSym = pat.widen.classSymbol
81+
val scrutClassSym = scrut.widen.classSymbol
8282
!patClassSym.exists || !scrutClassSym.exists || {
8383
if (patClassSym.is(Final)) patClassSym.derivesFrom(scrutClassSym)
8484
else if (scrutClassSym.is(Final)) scrutClassSym.derivesFrom(patClassSym)
@@ -100,18 +100,18 @@ trait PatternTypeConstrainer { self: TypeComparer =>
100100
// in principle however, if `A extends B, C`, then `A` can be treated as `B & C`
101101
scrut.firstParent
102102
case scrut @ AppliedType(tycon: TypeRef, _) if tycon.symbol.isClass =>
103-
val patClassSym = pat.classSymbol
103+
val patClassSym = pat.widen.classSymbol
104104
// as above, we do not consider all parents for performance reasons
105105
def firstParentSharedWithPat(tp: Type, tpClassSym: ClassSymbol): Symbol = {
106106
var parents = tpClassSym.info.parents
107107
parents match {
108108
case first :: rest =>
109-
if (first.classSymbol == defn.ObjectClass) parents = rest
109+
if (first.widen.classSymbol == defn.ObjectClass) parents = rest
110110
case _ => ;
111111
}
112112
parents match {
113113
case first :: _ =>
114-
val firstClassSym = first.classSymbol.asClass
114+
val firstClassSym = first.widen.classSymbol.asClass
115115
val res = if (patClassSym.derivesFrom(firstClassSym)) firstClassSym
116116
else firstParentSharedWithPat(first, firstClassSym)
117117
res

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,7 @@ object SymDenotations {
16921692
/** The symbol of the superclass, NoSymbol if no superclass exists */
16931693
def superClass(using Context): Symbol = classParents match {
16941694
case parent :: _ =>
1695-
val cls = parent.classSymbol
1695+
val cls = parent.widen.classSymbol
16961696
if (cls.is(Trait)) NoSymbol else cls
16971697
case _ =>
16981698
NoSymbol
@@ -1758,7 +1758,7 @@ object SymDenotations {
17581758
val builder = new BaseDataBuilder
17591759
def traverse(parents: List[Type]): Unit = parents match {
17601760
case p :: parents1 =>
1761-
p.classSymbol match {
1761+
p.widen.classSymbol match {
17621762
case pcls: ClassSymbol => builder.addAll(pcls.baseClasses)
17631763
case _ => assert(isRefinementClass || p.isError || ctx.mode.is(Mode.Interactive), s"$this has non-class parent: $p")
17641764
}
@@ -1896,7 +1896,7 @@ object SymDenotations {
18961896
def collect(denots: PreDenotation, parents: List[Type]): PreDenotation = parents match
18971897
case p :: ps =>
18981898
val denots1 = collect(denots, ps)
1899-
p.classSymbol.denot match
1899+
p.widen.classSymbol.denot match
19001900
case parentd: ClassDenotation =>
19011901
val inherited = parentd.nonPrivateMembersNamed(name)
19021902
denots1.union(inherited.mapInherited(ownDenots, denots1, thisType))
@@ -2075,8 +2075,8 @@ object SymDenotations {
20752075
var names = Set[Name]()
20762076
def maybeAdd(name: Name) = if (keepOnly(thisType, name)) names += name
20772077
try {
2078-
for (p <- classParents if p.classSymbol.isClass)
2079-
for (name <- p.classSymbol.asClass.memberNames(keepOnly))
2078+
for (p <- classParents if p.widen.classSymbol.isClass)
2079+
for (name <- p.widen.classSymbol.asClass.memberNames(keepOnly))
20802080
maybeAdd(name)
20812081
val ownSyms =
20822082
if (keepOnly eq implicitFilter)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ class TypeApplications(val self: Type) extends AnyVal {
436436
*/
437437
def translateJavaArrayElementType(using Context): Type =
438438
// A type parameter upper-bounded solely by `FromJavaObject` has `ObjectClass` as its classSymbol
439-
if self.typeSymbol.isAbstractOrParamType && (self.classSymbol eq defn.ObjectClass) then
439+
if self.typeSymbol.isAbstractOrParamType && (self.widen.classSymbol eq defn.ObjectClass) then
440440
AndType(self, defn.ObjectType)
441441
else
442442
self

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2374,8 +2374,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
23742374
case (tp1: ConstantType, tp2: ConstantType) =>
23752375
tp1 != tp2
23762376
case (tp1: TypeRef, tp2: TypeRef) if tp1.symbol.isClass && tp2.symbol.isClass =>
2377-
val cls1 = tp1.classSymbol
2378-
val cls2 = tp2.classSymbol
2377+
val cls1 = tp1.widen.classSymbol
2378+
val cls2 = tp2.widen.classSymbol
23792379
if (cls1.derivesFrom(cls2) || cls2.derivesFrom(cls1))
23802380
false
23812381
else

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ object TypeErasure {
299299
tp2 match {
300300
case JavaArrayType(elem2) =>
301301
if (elem1.isPrimitiveValueType || elem2.isPrimitiveValueType)
302-
if (elem1.classSymbol eq elem2.classSymbol) // same primitive
302+
if (elem1.widen.classSymbol eq elem2.widen.classSymbol) // same primitive
303303
JavaArrayType(elem1)
304304
else defn.ObjectType
305305
else JavaArrayType(erasedLub(elem1, elem2))
@@ -309,7 +309,7 @@ object TypeErasure {
309309
tp2 match {
310310
case JavaArrayType(_) => defn.ObjectType
311311
case _ =>
312-
val cls2 = tp2.classSymbol
312+
val cls2 = tp2.widen.classSymbol
313313

314314
/** takeWhile+1 */
315315
def takeUntil[T](l: List[T])(f: T => Boolean): List[T] = {
@@ -495,7 +495,7 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
495495
if ((cls eq defn.ObjectClass) || cls.isPrimitiveValueClass) Nil
496496
else parents.mapConserve(eraseParent) match {
497497
case tr :: trs1 =>
498-
assert(!tr.classSymbol.is(Trait), i"$cls has bad parents $parents%, %")
498+
assert(!tr.widen.classSymbol.is(Trait), i"$cls has bad parents $parents%, %")
499499
val tr1 = if (cls.is(Trait)) defn.ObjectType else tr
500500
tr1 :: trs1.filterNot(_.isAnyRef)
501501
case nil => nil

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ object Types {
619619
case tp: JavaArrayType =>
620620
defn.ObjectType.findMember(name, pre, required, excluded)
621621
case err: ErrorType =>
622-
newErrorSymbol(pre.classSymbol orElse defn.RootClass, name, err.msg)
622+
newErrorSymbol(pre.widen.classSymbol orElse defn.RootClass, name, err.msg)
623623
case _ =>
624624
NoDenotation
625625
}
@@ -4894,7 +4894,7 @@ object Types {
48944894
absMems.head.info match {
48954895
case mt: MethodType if !mt.isParamDependent &&
48964896
!defn.isContextFunctionType(mt.resultType) =>
4897-
val cls = tp.classSymbol
4897+
val cls = tp.widen.classSymbol
48984898

48994899
// Given a SAM type such as:
49004900
//

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
131131
*/
132132
private lazy val printWithoutPrefix: Set[Symbol] =
133133
(defn.ScalaPredefModule.termRef.typeAliasMembers
134-
++ defn.ScalaPackageObject.termRef.typeAliasMembers).map(_.info.classSymbol).toSet
134+
++ defn.ScalaPackageObject.termRef.typeAliasMembers).map(_.info.widen.classSymbol).toSet
135135
+ defn.ObjectClass
136136
+ defn.FromJavaObjectSymbol
137137

compiler/src/dotty/tools/dotc/reporting/messages.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2196,7 +2196,7 @@ import ast.tpd
21962196
.find(_.nonPrivateMember(memberName).matchingDenotation(accMixin.thisType, acc.info).exists)
21972197
val staticSuperName = staticSuper match {
21982198
case Some(parent) =>
2199-
parent.classSymbol.name.show
2199+
parent.widen.classSymbol.name.show
22002200
case None => // Might be reachable under separate compilation
22012201
"SomeParent"
22022202
}

compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ private class ExtractDependenciesCollector extends tpd.TreeTraverser { thisTreeT
320320
else DependencyByInheritance
321321
val from = resolveDependencySource
322322
tree.parents.foreach { parent =>
323-
_dependencies += ClassDependency(from, parent.tpe.classSymbol, depContext)
323+
_dependencies += ClassDependency(from, parent.tpe.widen.classSymbol, depContext)
324324
}
325325
}
326326

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class CapturedVars extends MiniPhase with IdentityDenotTransformer { thisPhase =
9595
val sym = atPhase(thisPhase)(vdef.symbol)
9696
if (captured contains sym) {
9797
val newd = atPhase(thisPhase)(sym.denot).copySymDenotation(
98-
info = refClass(sym.info.classSymbol, sym.hasAnnotation(defn.VolatileAnnot)).typeRef,
98+
info = refClass(sym.info.widen.classSymbol, sym.hasAnnotation(defn.VolatileAnnot)).typeRef,
9999
initFlags = sym.flags &~ Mutable)
100100
newd.removeAnnotation(defn.VolatileAnnot)
101101
newd.installAfter(thisPhase)
@@ -107,7 +107,7 @@ class CapturedVars extends MiniPhase with IdentityDenotTransformer { thisPhase =
107107
val vble = vdef.symbol
108108
if (captured.contains(vble)) {
109109
def boxMethod(name: TermName): Tree =
110-
ref(vble.info.classSymbol.companionModule.info.member(name).symbol)
110+
ref(vble.info.widen.classSymbol.companionModule.info.member(name).symbol)
111111
cpy.ValDef(vdef)(
112112
rhs = boxMethod(nme.create).appliedTo(vdef.rhs),
113113
tpt = TypeTree(vble.info).withSpan(vdef.tpt.span))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class CheckReentrant extends MiniPhase {
7474
sym.info.widenExpr.classSymbols.foreach(addVars)
7575
}
7676
for (parent <- cls.classInfo.classParents)
77-
addVars(parent.classSymbol.asClass)
77+
addVars(parent.widen.classSymbol.asClass)
7878
}
7979
}
8080

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class Constructors extends MiniPhase with IdentityDenotTransformer { thisPhase =
176176
if (fn.symbol.is(OuterAccessor)
177177
|| fn.symbol.isGetter && fn.symbol.name == nme.OUTER
178178
) &&
179-
fn.symbol.info.resultType.classSymbol == outerParam.info.classSymbol =>
179+
fn.symbol.info.resultType.widen.classSymbol == outerParam.info.widen.classSymbol =>
180180
ref(outerParam)
181181
case tree: RefTree if tree.symbol.is(ParamAccessor) && tree.symbol.name == nme.OUTER =>
182182
ref(outerParam)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class ElimRepeated extends MiniPhase with InfoTransformer { thisPhase =>
154154
JavaSeqLiteral(elems, elemtpt)
155155
case _ =>
156156
val elemType = tree.tpe.elemType
157-
var elemClass = erasure(elemType).classSymbol
157+
var elemClass = erasure(elemType).widen.classSymbol
158158
if defn.NotRuntimeClasses.contains(elemClass) then
159159
elemClass = defn.ObjectClass
160160
end if

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ object Erasure {
243243
case ErasedValueType(tycon, _) =>
244244
New(tycon, cast(tree, underlyingOfValueClass(tycon.symbol.asClass)) :: Nil) // todo: use adaptToType?
245245
case tp =>
246-
val cls = tp.classSymbol
246+
val cls = tp.widen.classSymbol
247247
if (cls eq defn.UnitClass) constant(tree, ref(defn.BoxedUnit_UNIT))
248248
else if (cls eq defn.NothingClass) tree // a non-terminating expression doesn't need boxing
249249
else {
@@ -331,7 +331,7 @@ object Erasure {
331331

332332
case _ =>
333333
if (pt.isPrimitiveValueType)
334-
primitiveConversion(tree, pt.classSymbol)
334+
primitiveConversion(tree, pt.widen.classSymbol)
335335
else
336336
tree.asInstance(pt)
337337
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ExpandSAMs extends MiniPhase {
4141
case tpe @ SAMType(_) if tpe.isRef(defn.PartialFunctionClass) =>
4242
val tpe1 = checkRefinements(tpe, fn)
4343
toPartialFunction(tree, tpe1)
44-
case tpe @ SAMType(_) if isPlatformSam(tpe.classSymbol.asClass) =>
44+
case tpe @ SAMType(_) if isPlatformSam(tpe.widen.classSymbol.asClass) =>
4545
checkRefinements(tpe, fn)
4646
tree
4747
case tpe =>

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class ExplicitOuter extends MiniPhase with InfoTransformer { thisPhase =>
115115

116116
override def transformClosure(tree: Closure)(using Context): tpd.Tree = {
117117
if (tree.tpt ne EmptyTree) {
118-
val cls = tree.tpt.asInstanceOf[TypeTree].tpe.classSymbol
118+
val cls = tree.tpt.asInstanceOf[TypeTree].tpe.widen.classSymbol
119119
if (cls.exists && hasOuter(cls.asClass))
120120
report.error("Not a single abstract method type, requires an outer pointer", tree.srcPos)
121121
}
@@ -146,7 +146,7 @@ object ExplicitOuter {
146146
val encl = cls.owner.enclosingClass
147147
if (cls.is(Scala2x))
148148
encl.asClass.classInfo.selfInfo match {
149-
case tp: TypeRef => tp.classSymbol
149+
case tp: TypeRef => tp.widen.classSymbol
150150
case self: Symbol => self
151151
case _ => encl
152152
}
@@ -213,7 +213,7 @@ object ExplicitOuter {
213213
(!hasLocalInstantiation(cls) || // needs outer because we might not know whether outer is referenced or not
214214
cls.mixins.exists(needsOuterIfReferenced) || // needs outer for parent traits
215215
cls.info.parents.exists(parent => // needs outer to potentially pass along to parent
216-
needsOuterIfReferenced(parent.classSymbol.asClass)))
216+
needsOuterIfReferenced(parent.widen.classSymbol.asClass)))
217217

218218
/** Class is always instantiated in the compilation unit where it is defined */
219219
private def hasLocalInstantiation(cls: ClassSymbol)(using Context): Boolean =
@@ -279,7 +279,7 @@ object ExplicitOuter {
279279
tree match {
280280
case _: This | _: Ident => isOuterRef(tree.tpe)
281281
case nw: New =>
282-
val newCls = nw.tpe.classSymbol
282+
val newCls = nw.tpe.widen.classSymbol
283283
isOuterSym(newCls.owner.enclosingClass) ||
284284
hasOuterPrefix(nw.tpe) ||
285285
newCls.owner.isTerm && cls.isProperlyContainedIn(newCls)

0 commit comments

Comments
 (0)