Skip to content

Commit 946c7be

Browse files
committed
WIP widen 3
1 parent 0293b06 commit 946c7be

14 files changed

+30
-30
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ case class Env(ctx: Context) {
4141
* It's true for primitive values
4242
*/
4343
def isAlwaysInitialized(tp: Type)(implicit env: Env): Boolean = {
44-
val sym = tp.widen.finalResultType.typeSymbol
44+
val sym = tp.widen.finalResultType.widen.typeSymbol
4545
sym.isPrimitiveValueClass || sym == defn.StringClass
4646
}
4747

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ class SpaceEngine(using Context) extends SpaceLogic {
486486
case tp @ RefinedType(parent, _, _) =>
487487
erase(parent)
488488

489-
case tref: TypeRef if tref.typeSymbol.isPatternBound =>
489+
case tref: TypeRef if tref.symbol.isPatternBound =>
490490
if (inArray) tref.underlying else WildcardType
491491

492492
case _ => tp

compiler/src/dotty/tools/dotc/transform/sjs/PrepJSInterop.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ class PrepJSInterop extends MacroTransform with IdentityDenotTransformer { thisP
315315

316316
// Check the parents
317317
for (parent <- sym.info.parents) {
318-
parent.typeSymbol match {
318+
parent.widen.typeSymbol match {
319319
case parentSym if parentSym == defn.ObjectClass =>
320320
// AnyRef is valid, except for non-native JS classes and objects
321321
if (!isJSNative && !sym.is(Trait)) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ object Applications {
116116
if (sel.exists) sel :: tupleSelectors(n + 1, tp) else Nil
117117
}
118118
def genTupleSelectors(n: Int, tp: Type): List[Type] = tp match {
119-
case tp: AppliedType if !defn.isTupleClass(tp.typeSymbol) && tp.derivesFrom(defn.PairClass) =>
119+
case tp: AppliedType if !defn.isTupleClass(tp.tycon.typeSymbol) && tp.derivesFrom(defn.PairClass) =>
120120
val List(head, tail) = tp.args
121121
head :: genTupleSelectors(n, tail)
122122
case _ => tupleSelectors(n, tp)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ trait Deriving {
9999
if (evidenceParamInfos.isEmpty) ExprType(resultType)
100100
else ImplicitMethodType(evidenceParamInfos.map(typeClassType.appliedTo), resultType)
101101
val derivedInfo = if (derivedParams.isEmpty) methodOrExpr else PolyType.fromParams(derivedParams, methodOrExpr)
102-
addDerivedInstance(originalTypeClassType.typeSymbol.name, derivedInfo, derived.srcPos)
102+
addDerivedInstance(originalTypeClassType.widen.typeSymbol.name, derivedInfo, derived.srcPos)
103103
}
104104

105105
def deriveSingleParameter: Unit = {
@@ -270,7 +270,7 @@ trait Deriving {
270270
/** The type class instance definition with symbol `sym` */
271271
def typeclassInstance(sym: Symbol)(using Context): List[Type] => (List[List[tpd.Tree]] => tpd.Tree) = {
272272
(tparamRefs: List[Type]) => (paramRefss: List[List[tpd.Tree]]) =>
273-
val tparams = tparamRefs.map(_.typeSymbol.asType)
273+
val tparams = tparamRefs.map(_.widen.typeSymbol.asType)
274274
val params = if (paramRefss.isEmpty) Nil else paramRefss.head.map(_.symbol.asTerm)
275275
tparams.foreach(ctx.enter(_))
276276
params.foreach(ctx.enter(_))

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -876,10 +876,10 @@ trait Implicits:
876876
}
877877

878878
case _ =>
879-
val userDefined = userDefinedMsg(pt.typeSymbol, defn.ImplicitNotFoundAnnot).map(raw =>
879+
val userDefined = userDefinedMsg(pt.widen.typeSymbol, defn.ImplicitNotFoundAnnot).map(raw =>
880880
err.userDefinedErrorString(
881881
raw,
882-
pt.typeSymbol.typeParams.map(_.name.unexpandedName.toString),
882+
pt.widen.typeSymbol.typeParams.map(_.name.unexpandedName.toString),
883883
pt.widenExpr.dropDependentRefinement.argInfos))
884884

885885
def hiddenImplicitsAddendum: String =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ trait ImportSuggestions:
7575

7676
def rootsStrictlyIn(ref: Type)(using Context): List[TermRef] =
7777
val site = ref.widen
78-
val refSym = site.typeSymbol
78+
val refSym = site.widen.typeSymbol
7979
val nested =
8080
if refSym.is(Package) then
8181
if refSym == defn.EmptyPackageClass // Don't search the empty package

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,7 @@ class Namer { typer: Typer =>
11501150
defn.ObjectType
11511151
}
11521152
else {
1153-
val pclazz = pt.typeSymbol
1153+
val pclazz = pt.widen.typeSymbol
11541154
if pclazz.is(Final) then
11551155
report.error(ExtendFinalClass(cls, pclazz), cls.srcPos)
11561156
else if pclazz.isEffectivelySealed && pclazz.associatedFile != cls.associatedFile then

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ trait QuotesAndSplices {
257257
patBuf += pat1
258258
}
259259
case Select(pat, _) if tree.symbol.isTypeSplice =>
260-
val sym = tree.tpe.dealias.typeSymbol
260+
val sym = tree.tpe.dealias.widen.typeSymbol
261261
if sym.exists then
262262
val tdef = TypeDef(sym.asType).withSpan(sym.span)
263263
freshTypeBindingsBuff += transformTypeBindingTypeDef(tdef, freshTypePatBuf)
@@ -327,9 +327,9 @@ trait QuotesAndSplices {
327327
val isFreshTypeBindings = freshTypeBindings.map(_.symbol).toSet
328328
val typeMap = new TypeMap() {
329329
def apply(tp: Type): Type = tp match {
330-
case tp: TypeRef if tp.typeSymbol.isTypeSplice =>
330+
case tp: TypeRef if tp.symbol.isTypeSplice =>
331331
val tp1 = tp.dealias
332-
if (isFreshTypeBindings(tp1.typeSymbol)) tp1
332+
if (isFreshTypeBindings(tp1.widen.typeSymbol)) tp1
333333
else tp
334334
case tp => mapOver(tp)
335335
}
@@ -408,8 +408,8 @@ trait QuotesAndSplices {
408408
class ReplaceBindings extends TypeMap() {
409409
override def apply(tp: Type): Type = tp match {
410410
case tp: TypeRef =>
411-
val tp1 = if (tp.typeSymbol.isTypeSplice) tp.dealias else tp
412-
mapOver(typeBindings.get(tp1.typeSymbol).fold(tp)(_.symbol.typeRef))
411+
val tp1 = if (tp.symbol.isTypeSplice) tp.dealias else tp
412+
mapOver(typeBindings.get(tp1.widen.typeSymbol).fold(tp)(_.symbol.typeRef))
413413
case tp => mapOver(tp)
414414
}
415415
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ object RefChecks {
311311
if (subOther(member.owner) && deferredCheck)
312312
//Console.println(infoString(member) + " shadows1 " + infoString(other) " in " + clazz);//DEBUG
313313
return
314-
val parentSymbols = clazz.info.parents.map(_.typeSymbol)
314+
val parentSymbols = clazz.info.parents.map(_.widen.typeSymbol)
315315
if (parentSymbols exists (p => subOther(p) && subMember(p) && deferredCheck))
316316
//Console.println(infoString(member) + " shadows2 " + infoString(other) + " in " + clazz);//DEBUG
317317
return
@@ -574,8 +574,8 @@ object RefChecks {
574574
mismatches match {
575575
// Only one mismatched parameter: say something useful.
576576
case (pa, pc) :: Nil =>
577-
val abstractSym = pa.typeSymbol
578-
val concreteSym = pc.typeSymbol
577+
val abstractSym = pa.widen.typeSymbol
578+
val concreteSym = pc.widen.typeSymbol
579579
def subclassMsg(c1: Symbol, c2: Symbol) =
580580
s": ${c1.showLocated} is a subclass of ${c2.showLocated}, but method parameter types must match exactly."
581581
val addendum =
@@ -1129,7 +1129,7 @@ class RefChecks extends MiniPhase { thisPhase =>
11291129

11301130
override def transformNew(tree: New)(using Context): New = {
11311131
val tpe = tree.tpe
1132-
val sym = tpe.typeSymbol
1132+
val sym = tpe.widen.typeSymbol
11331133
checkUndesiredProperties(sym, tree.srcPos)
11341134
currentLevel.enterReference(sym, tree.span)
11351135
tpe.dealias.foreachPart {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
3232
case defn.ArrayOf(elemTp) =>
3333
val etag = typer.inferImplicitArg(defn.ClassTagClass.typeRef.appliedTo(elemTp), span)
3434
if etag.tpe.isError then EmptyTree else etag.select(nme.wrap)
35-
case tp if hasStableErasure(tp) && !defn.isBottomClass(tp.typeSymbol) =>
36-
val sym = tp.typeSymbol
35+
case tp if hasStableErasure(tp) && !defn.isBottomClass(tp.widen.typeSymbol) =>
36+
val sym = tp.widen.typeSymbol
3737
val classTag = ref(defn.ClassTagModule)
3838
val tag =
3939
if defn.SpecialClassTagClasses.contains(sym) then

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ trait TypeAssigner {
100100
case Nil =>
101101
em"$name cannot"
102102
case sym :: Nil =>
103-
em"${if (sym.owner == pre.typeSymbol) sym.show else sym.showLocated} cannot"
103+
em"${if (sym.owner == pre.widen.typeSymbol) sym.show else sym.showLocated} cannot"
104104
case _ =>
105105
em"none of the overloaded alternatives named $name can"
106106
}
@@ -248,7 +248,7 @@ trait TypeAssigner {
248248
case err: ErrorType => untpd.cpy.Super(tree)(qual, mix).withType(err)
249249
case qtype @ ThisType(_) =>
250250
val cls = qtype.cls
251-
def findMixinSuper(site: Type): Type = site.parents filter (_.typeSymbol.name == mix.name) match {
251+
def findMixinSuper(site: Type): Type = site.parents filter (_.widen.typeSymbol.name == mix.name) match {
252252
case p :: Nil =>
253253
p.typeConstructor
254254
case Nil =>

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ class Typer extends Namer
680680
case templ: untpd.Template =>
681681
import untpd._
682682
var templ1 = templ
683-
def isEligible(tp: Type) = tp.exists && !tp.typeSymbol.is(Final) && !tp.isRef(defn.AnyClass)
683+
def isEligible(tp: Type) = tp.exists && !tp.widen.typeSymbol.is(Final) && !tp.isRef(defn.AnyClass)
684684
if (templ1.parents.isEmpty &&
685685
isFullyDefined(pt, ForceDegree.flipBottom) &&
686686
isSkolemFree(pt) &&
@@ -1226,7 +1226,7 @@ class Typer extends Namer
12261226
if (protoFormals.length == 1 && params.length != 1 && ptIsCorrectProduct(protoFormals.head)) {
12271227
val isGenericTuple =
12281228
protoFormals.head.derivesFrom(defn.TupleClass)
1229-
&& !defn.isTupleClass(protoFormals.head.typeSymbol)
1229+
&& !defn.isTupleClass(protoFormals.head.widen.typeSymbol)
12301230
desugar.makeTupledFunction(params, fnBody, isGenericTuple)
12311231
}
12321232
else {
@@ -1671,7 +1671,7 @@ class Typer extends Namer
16711671
checkRefinementNonCyclic(refinement, refineCls, seen)
16721672
val rsym = refinement.symbol
16731673
val polymorphicRefinementAllowed =
1674-
tpt1.tpe.typeSymbol == defn.PolyFunctionClass && rsym.name == nme.apply
1674+
tpt1.tpe.widen.typeSymbol == defn.PolyFunctionClass && rsym.name == nme.apply
16751675
if (!polymorphicRefinementAllowed && rsym.info.isInstanceOf[PolyType] && rsym.allOverriddenSymbols.isEmpty)
16761676
report.error(PolymorphicMethodMissingTypeInParent(rsym, tpt1.symbol), refinement.srcPos)
16771677

@@ -2062,7 +2062,7 @@ class Typer extends Namer
20622062
var result =
20632063
if isTreeType(tree) then typedType(tree)(using superCtx)
20642064
else typedExpr(tree)(using superCtx)
2065-
val psym = result.tpe.dealias.typeSymbol
2065+
val psym = result.tpe.dealias.widen.typeSymbol
20662066
if (seenParents.contains(psym) && !cls.isRefinementClass) {
20672067
// Desugaring can adds parents to classes, but we don't want to emit an
20682068
// error if the same parent was explicitly added in user code.
@@ -2105,7 +2105,7 @@ class Typer extends Namer
21052105
val constr1 = typed(constr).asInstanceOf[DefDef]
21062106
val parentsWithClass = ensureFirstTreeIsClass(parents.mapconserve(typedParent).filterConserve(!_.isEmpty), cdef.nameSpan)
21072107
val parents1 = ensureConstrCall(cls, parentsWithClass)(using superCtx)
2108-
val firstParent = parents1.head.tpe.dealias.typeSymbol
2108+
val firstParent = parents1.head.tpe.dealias.widen.typeSymbol
21092109

21102110
checkEnumParent(cls, firstParent)
21112111

@@ -2185,7 +2185,7 @@ class Typer extends Namer
21852185
if (!cls.isClass) defn.ObjectClass
21862186
else if (!cls.is(Trait)) cls.asClass
21872187
else cls.asClass.classParents match {
2188-
case parentRef :: _ => realClassParent(parentRef.typeSymbol)
2188+
case parentRef :: _ => realClassParent(parentRef.widen.typeSymbol)
21892189
case nil => defn.ObjectClass
21902190
}
21912191
def improve(candidate: ClassSymbol, parent: Type): ClassSymbol = {

compiler/test/dotty/tools/dotc/typer/DivergenceChecker.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class DivergenceCheckerTests extends DottyTest {
4545
Set(l, s),
4646
Set(l, t2, a, b),
4747
Set(l, t2, a, b, i)
48-
).map(_.map(_.dealias.typeSymbol))
48+
).map(_.map(_.dealias.widen.typeSymbol))
4949

5050
val expectedSizes = List(
5151
0,

0 commit comments

Comments
 (0)