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

0 commit comments

Comments
 (0)