Skip to content

Commit fd1943d

Browse files
committed
Drop AnyAppliedType
1 parent 9f41699 commit fd1943d

File tree

9 files changed

+12
-51
lines changed

9 files changed

+12
-51
lines changed

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

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -64,48 +64,11 @@ object TypeApplications {
6464
}
6565

6666
def unapply(tp: Type)(implicit ctx: Context): Option[TypeRef] = tp match {
67-
case tp @ HKTypeLambda(tparams, AnyAppliedType(fn: TypeRef, args)) if (args == tparams.map(_.paramRef)) => Some(fn)
67+
case tp @ HKTypeLambda(tparams, AppliedType(fn: TypeRef, args)) if (args == tparams.map(_.paramRef)) => Some(fn)
6868
case _ => None
6969
}
7070
}
7171

72-
/** Extractor for type application T[U_1, ..., U_n]. This is the refined type
73-
*
74-
* T { type p_1 v_1= U_1; ...; type p_n v_n= U_n }
75-
*
76-
* where v_i, p_i are the variances and names of the type parameters of T.
77-
*/
78-
object AnyAppliedType { // @!!! drop
79-
def apply(tp: Type, args: List[Type])(implicit ctx: Context): Type = tp.appliedTo(args)
80-
81-
def unapply(tp: Type)(implicit ctx: Context): Option[(Type, List[Type])] = tp match {
82-
case tp: RefinedType =>
83-
var refinements: List[RefinedType] = Nil
84-
var tycon = tp.stripTypeVar
85-
while (tycon.isInstanceOf[RefinedType]) {
86-
val rt = tycon.asInstanceOf[RefinedType]
87-
refinements = rt :: refinements
88-
tycon = rt.parent.stripTypeVar
89-
}
90-
def collectArgs(tparams: List[TypeParamInfo],
91-
refinements: List[RefinedType],
92-
argBuf: mutable.ListBuffer[Type]): Option[(Type, List[Type])] = refinements match {
93-
case Nil if tparams.isEmpty && argBuf.nonEmpty =>
94-
Some((tycon, argBuf.toList))
95-
case RefinedType(_, rname, rinfo) :: refinements1
96-
if tparams.nonEmpty && rname == tparams.head.paramName =>
97-
collectArgs(tparams.tail, refinements1, argBuf += rinfo.argInfo)
98-
case _ =>
99-
None
100-
}
101-
collectArgs(tycon.typeParams, refinements, new mutable.ListBuffer[Type])
102-
case AppliedType(tycon, args) =>
103-
Some((tycon, args))
104-
case _ =>
105-
None
106-
}
107-
}
108-
10972
/** Adapt all arguments to possible higher-kinded type parameters using etaExpandIfHK
11073
*/
11174
def EtaExpandIfHK(tparams: List[TypeParamInfo], args: List[Type])(implicit ctx: Context): List[Type] =
@@ -400,7 +363,7 @@ class TypeApplications(val self: Type) extends AnyVal {
400363
if (!args.exists(_.isInstanceOf[TypeBounds])) {
401364
val followAlias = Config.simplifyApplications && {
402365
dealiased.resType match {
403-
case AnyAppliedType(tyconBody, dealiasedArgs) =>
366+
case AppliedType(tyconBody, dealiasedArgs) =>
404367
// Reduction should not affect type inference when it's
405368
// just eta-reduction (ignoring variance annotations).
406369
// See i2201*.scala for examples where more aggressive
@@ -413,7 +376,7 @@ class TypeApplications(val self: Type) extends AnyVal {
413376
else AppliedType(self, args)
414377
}
415378
else dealiased.resType match {
416-
case AnyAppliedType(tycon, args1) if tycon.safeDealias ne tycon =>
379+
case AppliedType(tycon, args1) if tycon.safeDealias ne tycon =>
417380
// In this case we should always dealias since we cannot handle
418381
// higher-kinded applications to wildcard arguments.
419382
dealiased
@@ -504,7 +467,7 @@ class TypeApplications(val self: Type) extends AnyVal {
504467
* Existential types in arguments are returned as TypeBounds instances.
505468
*/
506469
final def argInfos(implicit ctx: Context): List[Type] = self match {
507-
case AnyAppliedType(tycon, args) => args
470+
case AppliedType(tycon, args) => args
508471
case _ => Nil
509472
}
510473

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
790790
tycon1 match {
791791
case param1: TypeParamRef =>
792792
def canInstantiate = tp2 match {
793-
case AnyAppliedType(tycon2, args2) =>
793+
case AppliedType(tycon2, args2) =>
794794
tryInstantiate(param1, tycon2.ensureHK) && isSubArgs(args1, args2, tp1, tycon2.typeParams)
795795
case _ =>
796796
false

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ object Types {
150150
}
151151

152152
def isInfixType(implicit ctx: Context): Boolean = this match {
153-
case TypeApplications.AnyAppliedType(tycon, args) =>
153+
case AppliedType(tycon, args) =>
154154
args.length == 2 &&
155155
!Character.isUnicodeIdentifierStart(tycon.typeSymbol.name.toString.head)
156156
// TODO: Once we use the 2.12 stdlib, also check the @showAsInfix annotation

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class TreePickler(pickler: TastyPickler) {
139139
}
140140

141141
private def pickleNewType(tpe: Type, richTypes: Boolean)(implicit ctx: Context): Unit = tpe match {
142-
case AnyAppliedType(tycon, args) =>
142+
case AppliedType(tycon, args) =>
143143
writeByte(APPLIEDtype)
144144
withLength { pickleType(tycon); args.foreach(pickleType(_)) }
145145
case ConstantType(value) =>

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package printing
44
import core._
55
import Texts._, Types._, Flags._, Names._, Symbols._, NameOps._, Constants._, Denotations._
66
import Contexts.Context, Scopes.Scope, Denotations.Denotation, Annotations.Annotation
7-
import TypeApplications.AnyAppliedType
87
import StdNames.{nme, tpnme}
98
import ast.Trees._, ast._
109
import typer.Implicits._
@@ -133,7 +132,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
133132
*/
134133
private def refinementChain(tp: Type): List[Type] =
135134
tp :: (tp match {
136-
case AnyAppliedType(_, _) => Nil // @!!!
135+
case AppliedType(_, _) => Nil // @!!!
137136
case tp: RefinedType => refinementChain(tp.parent.stripTypeVar)
138137
case _ => Nil
139138
})
@@ -152,7 +151,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
152151
toTextLocal(tp.underlying) ~ "(" ~ toTextRef(tp) ~ ")"
153152
case tp: TypeRef =>
154153
toTextPrefix(tp.prefix) ~ selectionString(tp)
155-
case AnyAppliedType(tycon, args) =>
154+
case AppliedType(tycon, args) =>
156155
(toTextLocal(tycon) ~ "[" ~ Text(args map argText, ", ") ~ "]").close
157156
case tp: RefinedType =>
158157
val parent :: (refined: List[RefinedType @unchecked]) =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
141141
homogenize(tp) match {
142142
case x: ConstantType if homogenizedView =>
143143
return toText(x.widen)
144-
case AnyAppliedType(tycon, args) =>
144+
case AppliedType(tycon, args) =>
145145
val cls = tycon.typeSymbol
146146
if (tycon.isRepeatedParam) return toTextLocal(args.head) ~ "*"
147147
if (defn.isFunctionClass(cls)) return toTextFunction(args, cls.name.isImplicitFunction)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
370370
else
371371
tp.prefix
372372
new api.Projection(simpleType(prefix), sym.name.toString)
373-
case TypeApplications.AnyAppliedType(tycon, args) =>
373+
case AppliedType(tycon, args) =>
374374
def processArg(arg: Type): api.Type = arg match {
375375
case arg @ TypeBounds(lo, hi) => // Handle wildcard parameters
376376
if (lo.isDirectRef(defn.NothingClass) && hi.isDirectRef(defn.AnyClass))

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import core._
66
import ast._
77
import Scopes._, Contexts._, Constants._, Types._, Symbols._, Names._, Flags._, Decorators._
88
import ErrorReporting._, Annotations._, Denotations._, SymDenotations._, StdNames._, TypeErasure._
9-
import TypeApplications.AnyAppliedType
109
import util.Positions._
1110
import config.Printers.typr
1211
import ast.Trees._

doc-tool/src/dotty/tools/dottydoc/model/factories.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ object factories {
5757
}
5858

5959
def expandTpe(t: Type, params: List[Reference] = Nil): Reference = t match {
60-
case AnyAppliedType(tycon, args) => {
60+
case AppliedType(tycon, args) => {
6161
val cls = tycon.typeSymbol
6262

6363
if (defn.isFunctionClass(cls))

0 commit comments

Comments
 (0)