Skip to content

Commit a8ffa57

Browse files
committed
Split dealias 2.1 WIP
1 parent b3c3bf7 commit a8ffa57

10 files changed

+22
-22
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ object desugar {
7878
case tp: NamedType if tp.symbol.exists && (tp.symbol.owner eq originalOwner) =>
7979
val defctx = ctx.outersIterator.dropWhile(_.scope eq ctx.scope).next()
8080
var local = defctx.denotNamed(tp.name ++ suffix).suchThat(_.isParamOrAccessor).symbol
81-
if (local.exists) (defctx.owner.thisType select local).dealias
81+
if (local.exists) (defctx.owner.thisType select local).dealiasKeepAnnots
8282
else {
8383
def msg =
8484
s"no matching symbol for ${tp.symbol.showLocated} in ${defctx.owner} / ${defctx.effectiveScope.toList}"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
691691
*/
692692
def isStructuralTermSelect(tree: Tree)(implicit ctx: Context) = tree match {
693693
case tree: Select =>
694-
def hasRefinement(qualtpe: Type): Boolean = qualtpe.dealias match {
694+
def hasRefinement(qualtpe: Type): Boolean = qualtpe.dealiasStripAnnots match {
695695
case RefinedType(parent, rname, rinfo) =>
696696
rname == tree.name || hasRefinement(parent)
697697
case tp: TypeProxy =>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
353353
Ident(tp)
354354
else {
355355
val pre = tp.prefix
356-
if (pre.isSingleton) followOuterLinks(singleton(pre.dealias)).select(tp)
356+
if (pre.isSingleton) followOuterLinks(singleton(pre.dealiasStripAnnots)).select(tp)
357357
else Select(TypeTree(pre), tp)
358358
}
359359

@@ -791,7 +791,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
791791
applyOverloaded(tree, nme.EQ, that :: Nil, Nil, defn.BooleanType)
792792

793793
/** `tree.isInstanceOf[tp]`, with special treatment of singleton types */
794-
def isInstance(tp: Type)(implicit ctx: Context): Tree = tp.dealias match {
794+
def isInstance(tp: Type)(implicit ctx: Context): Tree = tp.dealiasStripAnnots match {
795795
case tp: SingletonType =>
796796
if (tp.widen.derivesFrom(defn.ObjectClass))
797797
tree.ensureConforms(defn.ObjectType).select(defn.Object_eq).appliedTo(singleton(tp))

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class CheckRealizable(implicit ctx: Context) {
6969
private def isLateInitialized(sym: Symbol) = sym.is(Lazy, butNot = Module)
7070

7171
/** The realizability status of given type `tp`*/
72-
def realizability(tp: Type): Realizability = tp.dealias match {
72+
def realizability(tp: Type): Realizability = tp.dealiasStripAnnots match {
7373
case tp: TermRef =>
7474
val sym = tp.symbol
7575
if (sym.is(Stable)) realizability(tp.prefix)
@@ -85,7 +85,7 @@ class CheckRealizable(implicit ctx: Context) {
8585
case _: SingletonType | NoPrefix =>
8686
Realizable
8787
case tp =>
88-
def isConcrete(tp: Type): Boolean = tp.dealias match {
88+
def isConcrete(tp: Type): Boolean = tp.dealiasStripAnnots match {
8989
case tp: TypeRef => tp.symbol.isClass
9090
case tp: TypeProxy => isConcrete(tp.underlying)
9191
case tp: AndType => isConcrete(tp.tp1) && isConcrete(tp.tp2)
@@ -96,7 +96,7 @@ class CheckRealizable(implicit ctx: Context) {
9696
else boundsRealizability(tp).andAlso(memberRealizability(tp))
9797
}
9898

99-
private def refinedNames(tp: Type): Set[Name] = tp.dealias match {
99+
private def refinedNames(tp: Type): Set[Name] = tp.dealiasStripAnnots match {
100100
case tp: RefinedType => refinedNames(tp.parent) + tp.refinedName
101101
case tp: AndType => refinedNames(tp.tp1) ++ refinedNames(tp.tp2)
102102
case tp: OrType => refinedNames(tp.tp1) ++ refinedNames(tp.tp2)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ object Constants {
152152
/** Convert constant value to conform to given type.
153153
*/
154154
def convertTo(pt: Type)(implicit ctx: Context): Constant = {
155-
def classBound(pt: Type): Type = pt.dealias.stripTypeVar match {
155+
def classBound(pt: Type): Type = pt.dealiasStripAnnots.stripTypeVar match {
156156
case tref: TypeRef if !tref.symbol.isClass && tref.info.exists =>
157157
classBound(tref.info.bounds.lo)
158158
case param: TypeParamRef =>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ trait ConstraintHandling {
5050
private def addOneBound(param: TypeParamRef, bound: Type, isUpper: Boolean): Boolean =
5151
!constraint.contains(param) || {
5252
def occursIn(bound: Type): Boolean = {
53-
val b = bound.dealias
53+
val b = bound.dealiasStripAnnots
5454
(b eq param) || {
5555
b match {
5656
case b: AndType => occursIn(b.tp1) || occursIn(b.tp2)
@@ -275,7 +275,7 @@ trait ConstraintHandling {
275275
case tp: OrType => isFullyDefined(tp.tp1) && isFullyDefined(tp.tp2)
276276
case _ => true
277277
}
278-
def isOrType(tp: Type): Boolean = tp.stripTypeVar.dealias match {
278+
def isOrType(tp: Type): Boolean = tp.dealiasStripAnnots match {
279279
case tp: OrType => true
280280
case tp: RefinedOrRecType => isOrType(tp.parent)
281281
case AndType(tp1, tp2) => isOrType(tp1) | isOrType(tp2)

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ class Definitions {
797797
def unapply(ft: Type)(implicit ctx: Context) = {
798798
val tsym = ft.typeSymbol
799799
if (isFunctionClass(tsym)) {
800-
val targs = ft.dealias.argInfos
800+
val targs = ft.dealiasStripAnnots.argInfos
801801
if (targs.isEmpty) None
802802
else Some(targs.init, targs.last, tsym.name.isImplicitFunction, tsym.name.isErasedFunction)
803803
}
@@ -810,7 +810,7 @@ class Definitions {
810810
PartialFunctionType.appliedTo(arg :: result :: Nil)
811811
def unapply(pft: Type)(implicit ctx: Context) = {
812812
if (pft.isRef(PartialFunctionClass)) {
813-
val targs = pft.dealias.argInfos
813+
val targs = pft.dealiasStripAnnots.argInfos
814814
if (targs.length == 2) Some((targs.head, targs.tail)) else None
815815
}
816816
else None
@@ -821,7 +821,7 @@ class Definitions {
821821
def apply(elem: Type)(implicit ctx: Context) =
822822
if (ctx.erasedTypes) JavaArrayType(elem)
823823
else ArrayType.appliedTo(elem :: Nil)
824-
def unapply(tp: Type)(implicit ctx: Context): Option[Type] = tp.dealias match {
824+
def unapply(tp: Type)(implicit ctx: Context): Option[Type] = tp.dealiasStripAnnots match {
825825
case AppliedType(at, arg :: Nil) if at isRef ArrayType.symbol => Some(arg)
826826
case _ => None
827827
}
@@ -842,7 +842,7 @@ class Definitions {
842842
if (ndims == 0) elem else ArrayOf(apply(elem, ndims - 1))
843843
def unapply(tp: Type)(implicit ctx: Context): Option[(Type, Int)] = tp match {
844844
case ArrayOf(elemtp) =>
845-
def recur(elemtp: Type): Option[(Type, Int)] = elemtp.dealias match {
845+
def recur(elemtp: Type): Option[(Type, Int)] = elemtp.dealiasStripAnnots match {
846846
case TypeBounds(lo, hi) => recur(hi)
847847
case MultiArrayOf(finalElemTp, n) => Some(finalElemTp, n + 1)
848848
case _ => Some(elemtp, 1)
@@ -1022,7 +1022,7 @@ class Definitions {
10221022
(sym eq Any_isInstanceOf) || (sym eq Any_asInstanceOf)
10231023

10241024
def isTupleType(tp: Type)(implicit ctx: Context) = {
1025-
val arity = tp.dealias.argInfos.length
1025+
val arity = tp.dealiasStripAnnots.argInfos.length
10261026
arity <= MaxTupleArity && TupleType(arity) != null && (tp isRef TupleType(arity).symbol)
10271027
}
10281028

@@ -1038,7 +1038,7 @@ class Definitions {
10381038
*/
10391039
def isNonDepFunctionType(tp: Type)(implicit ctx: Context) = {
10401040
val arity = functionArity(tp)
1041-
val sym = tp.dealias.typeSymbol
1041+
val sym = tp.dealiasStripAnnots.typeSymbol
10421042
arity >= 0 && isFunctionClass(sym) && tp.isRef(FunctionType(arity, sym.name.isImplicitFunction, sym.name.isErasedFunction).typeSymbol)
10431043
}
10441044

@@ -1084,7 +1084,7 @@ class Definitions {
10841084
false
10851085
})
10861086

1087-
def functionArity(tp: Type)(implicit ctx: Context) = tp.dealias.argInfos.length - 1
1087+
def functionArity(tp: Type)(implicit ctx: Context) = tp.dealiasStripAnnots.argInfos.length - 1
10881088

10891089
/** Return underlying immplicit function type (i.e. instance of an ImplicitFunctionN class)
10901090
* or NoType if none exists. The following types are considered as underlying types:
@@ -1093,7 +1093,7 @@ class Definitions {
10931093
* - the upper bound of a TypeParamRef in the current constraint
10941094
*/
10951095
def asImplicitFunctionType(tp: Type)(implicit ctx: Context): Type =
1096-
tp.stripTypeVar.dealias match {
1096+
tp.stripTypeVar.dealiasStripAnnots match {
10971097
case tp1: TypeParamRef if ctx.typerState.constraint.contains(tp1) =>
10981098
asImplicitFunctionType(ctx.typeComparer.bounds(tp1).hiBound)
10991099
case tp1 =>
@@ -1106,7 +1106,7 @@ class Definitions {
11061106
asImplicitFunctionType(tp).exists
11071107

11081108
def isErasedFunctionType(tp: Type)(implicit ctx: Context) =
1109-
isFunctionType(tp) && tp.dealias.typeSymbol.name.isErasedFunction
1109+
isFunctionType(tp) && tp.dealiasStripAnnots.typeSymbol.name.isErasedFunction
11101110

11111111
// ----- primitive value class machinery ------------------------------------------
11121112

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
387387
* that are not top-level are not affected.
388388
*/
389389
def replace(param: TypeParamRef, tp: Type)(implicit ctx: Context): OrderingConstraint = {
390-
val replacement = tp.dealias.stripTypeVar
390+
val replacement = tp.dealiasKeepAnnots.stripTypeVar
391391
if (param == replacement) this
392392
else {
393393
assert(replacement.isValueTypeOrLambda)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ trait Symbols { this: Context =>
125125
def complete(denot: SymDenotation)(implicit ctx: Context): Unit = {
126126
val cls = denot.asClass.classSymbol
127127
val decls = newScope
128-
denot.info = ClassInfo(owner.thisType, cls, parentTypes.map(_.dealias), decls)
128+
denot.info = ClassInfo(owner.thisType, cls, parentTypes.map(_.dealiasStripAnnots), decls)
129129
}
130130
}
131131
newClassSymbol(owner, name, flags, completer, privateWithin, coord, assocFile)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ class TypeApplications(val self: Type) extends AnyVal {
220220
/** If self type is higher-kinded, its result type, otherwise NoType.
221221
* Note: The hkResult of an any-kinded type is again AnyKind.
222222
*/
223-
def hkResult(implicit ctx: Context): Type = self.dealias match {
223+
def hkResult(implicit ctx: Context): Type = self.dealiasStripAnnots match {
224224
case self: TypeRef =>
225225
if (self.symbol == defn.AnyKindClass) self else self.info.hkResult
226226
case self: AppliedType =>

0 commit comments

Comments
 (0)