Skip to content

Commit 80f578b

Browse files
committed
WIP widen2
1 parent 4cd9697 commit 80f578b

File tree

10 files changed

+19
-19
lines changed

10 files changed

+19
-19
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ class ClassfileParser(
558558

559559
class ClassfileAnnotation(annotType: Type, args: List[untpd.Tree]) extends LazyAnnotation {
560560
protected var mySym: Symbol | (Context ?=> Symbol) =
561-
(using ctx: Context) => annotType.classSymbol
561+
(using ctx: Context) => annotType.widen.classSymbol
562562

563563
protected var myTree: Tree | (Context ?=> Tree) =
564564
(using ctx: Context) => untpd.resolveConstructor(annotType, args)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ object PatternMatcher {
723723

724724
def outerTest: Tree = thisPhase.transformFollowingDeep {
725725
val expectedOuter = singleton(expectedTp.normalizedPrefix)
726-
val expectedClass = expectedTp.dealias.classSymbol.asClass
726+
val expectedClass = expectedTp.dealias.widen.classSymbol.asClass
727727
ExplicitOuter.ensureOuterAccessors(expectedClass)
728728
scrutinee.ensureConforms(expectedTp)
729729
.outerSelect(1, expectedClass.owner.typeRef)

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ object Splicer {
465465
}
466466
def javaArraySig(tpe: Type): String = {
467467
val (elemType, depth) = arrayDepth(tpe, 0)
468-
val sym = elemType.classSymbol
468+
val sym = elemType.widen.classSymbol
469469
val suffix =
470470
if (sym == defn.BooleanClass) "Z"
471471
else if (sym == defn.ByteClass) "B"
@@ -482,12 +482,12 @@ object Splicer {
482482
case tpe: JavaArrayType => javaArraySig(tpe)
483483
case _ =>
484484
// Take the flatten name of the class and the full package name
485-
val pack = tpe.classSymbol.topLevelClass.owner
485+
val pack = tpe.widen.classSymbol.topLevelClass.owner
486486
val packageName = if (pack == defn.EmptyPackageClass) "" else s"${pack.fullName}."
487-
packageName + tpe.classSymbol.fullNameSeparated(FlatName).toString
487+
packageName + tpe.widen.classSymbol.fullNameSeparated(FlatName).toString
488488
}
489489

490-
val sym = param.classSymbol
490+
val sym = param.widen.classSymbol
491491
if (sym == defn.BooleanClass) classOf[Boolean]
492492
else if (sym == defn.ByteClass) classOf[Byte]
493493
else if (sym == defn.CharClass) classOf[Char]

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class SyntheticMembers(thisPhase: DenotTransformer) {
9595
if (isDerivedValueClass(clazz)) clazz.paramAccessors.take(1) // Tail parameters can only be `erased`
9696
else clazz.caseAccessors
9797
val isEnumCase = clazz.derivesFrom(defn.EnumClass) && clazz != defn.EnumClass
98-
val isEnumValue = isEnumCase && clazz.isAnonymousClass && clazz.classParents.head.classSymbol.is(Enum)
98+
val isEnumValue = isEnumCase && clazz.isAnonymousClass && clazz.classParents.head.widen.classSymbol.is(Enum)
9999
val isNonJavaEnumValue = isEnumValue && !clazz.derivesFrom(defn.JavaEnumClass)
100100

101101
val symbolsToSynthesize: List[Symbol] =
@@ -302,7 +302,7 @@ class SyntheticMembers(thisPhase: DenotTransformer) {
302302
def chooseHashcode(using Context) =
303303
if (clazz.is(ModuleClass))
304304
Literal(Constant(clazz.name.stripModuleClassSuffix.toString.hashCode))
305-
else if (accessors.exists(_.info.finalResultType.classSymbol.isPrimitiveValueClass))
305+
else if (accessors.exists(_.info.finalResultType.widen.classSymbol.isPrimitiveValueClass))
306306
caseHashCodeBody
307307
else
308308
ref(defn.ScalaRuntime__hashCode).appliedTo(This(clazz))
@@ -576,9 +576,9 @@ class SyntheticMembers(thisPhase: DenotTransformer) {
576576
else if (impl.removeAttachment(ExtendsSingletonMirror).isDefined)
577577
makeSingletonMirror()
578578
else if (impl.removeAttachment(ExtendsProductMirror).isDefined)
579-
makeProductMirror(monoType.typeRef.dealias.classSymbol)
579+
makeProductMirror(monoType.typeRef.dealias.widen.classSymbol)
580580
else if (impl.removeAttachment(ExtendsSumMirror).isDefined)
581-
makeSumMirror(monoType.typeRef.dealias.classSymbol)
581+
makeSumMirror(monoType.typeRef.dealias.widen.classSymbol)
582582

583583
cpy.Template(impl)(parents = newParents, body = newBody)
584584
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ object Checking {
142142
checkConstructor(ctor.symbol, parent.tpe, parent)
143143

144144
case ref =>
145-
val cls = ref.tpe.classSymbol.asClass
145+
val cls = ref.tpe.widen.classSymbol.asClass
146146
if (!state.parentsInited.contains(cls) && cls.primaryConstructor.exists)
147147
checkConstructor(cls.primaryConstructor, ref.tpe, ref)
148148
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ object Summarization {
8383
}
8484

8585
val tref = typeRefOf(tpt.tpe)
86-
val cls = tref.classSymbol.asClass
86+
val cls = tref.widen.classSymbol.asClass
8787
// local class may capture, thus we need to track it
8888
if (tref.prefix == NoPrefix) {
8989
val cur = theCtx.owner.lexicallyEnclosingClass.asClass
@@ -305,7 +305,7 @@ object Summarization {
305305

306306
case ref =>
307307
val tref: TypeRef = ref.tpe.typeConstructor.asInstanceOf
308-
val cls = tref.classSymbol.asClass
308+
val cls = tref.widen.classSymbol.asClass
309309
if (cls == defn.AnyClass || cls == defn.AnyValClass) Effects.empty
310310
else {
311311
val ctor = cls.primaryConstructor
@@ -326,7 +326,7 @@ object Summarization {
326326
def classSummary(cls: ClassSymbol)(implicit env: Env): ClassSummary = trace("summarizing " + cls.show, init) {
327327
def extractParentOuters(parent: Type, source: Tree): (ClassSymbol, Potentials) = {
328328
val tref = parent.typeConstructor.stripAnnots.asInstanceOf[TypeRef]
329-
val parentCls = tref.classSymbol.asClass
329+
val parentCls = tref.widen.classSymbol.asClass
330330
val env2: Env = env.withOwner(cls.owner.lexicallyEnclosingClass)
331331
if (tref.prefix != NoPrefix)
332332
parentCls -> analyze(tref.prefix, source)(env2)._1

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ trait Checking {
910910

911911
def checkParentCall(call: Tree, caller: ClassSymbol)(using Context): Unit =
912912
if (!ctx.isAfterTyper) {
913-
val called = call.tpe.classSymbol
913+
val called = call.tpe.widen.classSymbol
914914
if (caller.is(Trait))
915915
report.error(i"$caller may not call constructor of $called", call.srcPos)
916916
else if (called.is(Trait) && !caller.mixins.contains(called))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ trait Deriving {
8383
private def processDerivedInstance(derived: untpd.Tree): Unit = {
8484
val originalTypeClassType = typedAheadType(derived, AnyTypeConstructorProto).tpe
8585
val typeClassType = checkClassType(underlyingClassRef(originalTypeClassType), derived.srcPos, traitReq = false, stablePrefixReq = true)
86-
val typeClass = typeClassType.classSymbol
86+
val typeClass = typeClassType.widen.classSymbol
8787
val typeClassParams = typeClass.typeParams
8888
val typeClassArity = typeClassParams.length
8989

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ trait Implicits:
11011101
else ViewProto(wildApprox(argument.tpe.widen), wildApprox(pt))
11021102
// Not clear whether we need to drop the `.widen` here. All tests pass with it in place, though.
11031103

1104-
val isNot: Boolean = wildProto.classSymbol == defn.NotClass
1104+
val isNot: Boolean = wildProto.widen.classSymbol == defn.NotClass
11051105

11061106
/** Try to type-check implicit reference, after checking that this is not
11071107
* a diverging search

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ object Inferencing {
336336
def companionRef(tp: Type)(using Context): Type =
337337
tp.underlyingClassRef(refinementOK = true) match {
338338
case tp: TypeRef =>
339-
val companion = tp.classSymbol.companionModule
339+
val companion = tp.widen.classSymbol.companionModule
340340
if (companion.exists)
341341
companion.termRef.asSeenFrom(tp.prefix, companion.owner)
342342
else NoType
@@ -356,7 +356,7 @@ object Inferencing {
356356
else if (v == -1) tvar.instantiate(fromBelow = true)
357357
else {
358358
val bounds = TypeComparer.fullBounds(tvar.origin)
359-
if (bounds.hi <:< bounds.lo || bounds.hi.classSymbol.is(Final) || fromScala2x)
359+
if (bounds.hi <:< bounds.lo || bounds.hi.widen.classSymbol.is(Final) || fromScala2x)
360360
tvar.instantiate(fromBelow = false)
361361
else {
362362
// We do not add the created symbols to GADT constraint immediately, since they may have inter-dependencies.

0 commit comments

Comments
 (0)