diff options
Diffstat (limited to 'compiler/src/dotty/tools/dotc/typer')
7 files changed, 18 insertions, 18 deletions
diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index d1a73fd65..ceaf3471a 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -195,7 +195,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic => } /** The function's type after widening and instantiating polytypes - * with polyparams in constraint set + * with TypeParamRefs in constraint set */ val methType = funType.widen match { case funType: MethodType => funType diff --git a/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala b/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala index ff998e233..5f9eae3da 100644 --- a/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala +++ b/compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala @@ -121,12 +121,12 @@ object ErrorReporting { } def typeMismatchMsg(found: Type, expected: Type, postScript: String = "") = { - // replace constrained polyparams and their typevars by their bounds where possible + // replace constrained TypeParamRefs and their typevars by their bounds where possible object reported extends TypeMap { def setVariance(v: Int) = variance = v val constraint = ctx.typerState.constraint def apply(tp: Type): Type = tp match { - case tp: PolyParam => + case tp: TypeParamRef => constraint.entry(tp) match { case bounds: TypeBounds => if (variance < 0) apply(constraint.fullUpperBound(tp)) diff --git a/compiler/src/dotty/tools/dotc/typer/Inferencing.scala b/compiler/src/dotty/tools/dotc/typer/Inferencing.scala index 20efd4083..18a1982e1 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inferencing.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inferencing.scala @@ -176,7 +176,7 @@ object Inferencing { * -1 (minimize) if constraint is uniformly from below, * 0 if unconstrained, or constraint is from below and above. */ - private def instDirection(param: PolyParam)(implicit ctx: Context): Int = { + private def instDirection(param: TypeParamRef)(implicit ctx: Context): Int = { val constrained = ctx.typerState.constraint.fullBounds(param) val original = param.binder.paramInfos(param.paramNum) val cmp = ctx.typeComparer diff --git a/compiler/src/dotty/tools/dotc/typer/Inliner.scala b/compiler/src/dotty/tools/dotc/typer/Inliner.scala index 8520dcdfc..cf3076fce 100644 --- a/compiler/src/dotty/tools/dotc/typer/Inliner.scala +++ b/compiler/src/dotty/tools/dotc/typer/Inliner.scala @@ -358,7 +358,7 @@ class Inliner(call: tpd.Tree, rhs: tpd.Tree)(implicit ctx: Context) { * 2. If given type refers to a parameter, make `paramProxy` refer to the entry stored * in `paramNames` under the parameter's name. This roundabout way to bind parameter * references to proxies is done because we not known a priori what the parameter - * references of a method are (we only know the method's type, but that contains PolyParams + * references of a method are (we only know the method's type, but that contains TypeParamRefs * and MethodParams, not TypeRefs or TermRefs. */ private def registerType(tpe: Type): Unit = tpe match { diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala index 89e4f93e2..2dccbbcc1 100644 --- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala +++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala @@ -192,7 +192,7 @@ object ProtoTypes { /** Forget the types of any arguments that have been typed producing a constraint in a * typer state that is not yet committed into the one of the current context `ctx`. - * This is necessary to avoid "orphan" PolyParams that are referred to from + * This is necessary to avoid "orphan" TypeParamRefs that are referred to from * type variables in the typed arguments, but that are not registered in the * current constraint. A test case is pos/t1756.scala. * @return True if all arguments have types (in particular, no types were forgotten). @@ -385,7 +385,7 @@ object ProtoTypes { for (n <- (0 until pt.paramNames.length).toList) yield { val tt = new TypeTree().withPos(owningTree.pos) - tt.withType(new TypeVar(PolyParam(pt, n), state, tt, ctx.owner)) + tt.withType(new TypeVar(TypeParamRef(pt, n), state, tt, ctx.owner)) } val added = @@ -399,22 +399,22 @@ object ProtoTypes { /** Same as `constrained(pt, EmptyTree)`, but returns just the created polytype */ def constrained(pt: PolyType)(implicit ctx: Context): PolyType = constrained(pt, EmptyTree)._1 - /** Create a new polyparam that represents a dependent method parameter singleton */ - def newDepPolyParam(tp: Type)(implicit ctx: Context): PolyParam = { + /** Create a new TypeParamRef that represents a dependent method parameter singleton */ + def newDepTypeParamRef(tp: Type)(implicit ctx: Context): TypeParamRef = { val poly = PolyType(ctx.freshName(nme.DEP_PARAM_PREFIX).toTypeName :: Nil)( pt => TypeBounds.upper(AndType(tp, defn.SingletonType)) :: Nil, pt => defn.AnyType) ctx.typeComparer.addToConstraint(poly, Nil) - PolyParam(poly, 0) + TypeParamRef(poly, 0) } /** The result type of `mt`, where all references to parameters of `mt` are - * replaced by either wildcards (if typevarsMissContext) or polyparams. + * replaced by either wildcards (if typevarsMissContext) or TypeParamRefs. */ def resultTypeApprox(mt: MethodType)(implicit ctx: Context): Type = if (mt.isDependent) { def replacement(tp: Type) = - if (ctx.mode.is(Mode.TypevarsMissContext)) WildcardType else newDepPolyParam(tp) + if (ctx.mode.is(Mode.TypevarsMissContext)) WildcardType else newDepTypeParamRef(tp) mt.resultType.substParams(mt, mt.paramInfos.map(replacement)) } else mt.resultType @@ -458,7 +458,7 @@ object ProtoTypes { /** Approximate occurrences of parameter types and uninstantiated typevars * by wildcard types. */ - final def wildApprox(tp: Type, theMap: WildApproxMap, seen: Set[PolyParam])(implicit ctx: Context): Type = tp match { + final def wildApprox(tp: Type, theMap: WildApproxMap, seen: Set[TypeParamRef])(implicit ctx: Context): Type = tp match { case tp: NamedType => // default case, inlined for speed if (tp.symbol.isStatic) tp else tp.derivedSelect(wildApprox(tp.prefix, theMap, seen)) @@ -469,7 +469,7 @@ object ProtoTypes { wildApprox(tp.refinedInfo, theMap, seen)) case tp: TypeAlias => // default case, inlined for speed tp.derivedTypeAlias(wildApprox(tp.alias, theMap, seen)) - case tp @ PolyParam(poly, pnum) => + case tp @ TypeParamRef(poly, pnum) => def wildApproxBounds(bounds: TypeBounds) = if (bounds.lo.isInstanceOf[NamedType] && bounds.hi.isInstanceOf[NamedType]) WildcardType(wildApprox(bounds, theMap, seen).bounds) @@ -532,7 +532,7 @@ object ProtoTypes { @sharable object AssignProto extends UncachedGroundType with MatchAlways - private[ProtoTypes] class WildApproxMap(val seen: Set[PolyParam])(implicit ctx: Context) extends TypeMap { + private[ProtoTypes] class WildApproxMap(val seen: Set[TypeParamRef])(implicit ctx: Context) extends TypeMap { def apply(tp: Type) = wildApprox(tp, this, seen) } diff --git a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala index 717429848..ed71f2239 100644 --- a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -348,7 +348,7 @@ trait TypeAssigner { val newIndex = gapBuf.length gapBuf += idx // Re-index unassigned type arguments that remain after transformation - PolyParam(pt, newIndex) + TypeParamRef(pt, newIndex) } // Type parameters after naming assignment, conserving paramNames order @@ -358,7 +358,7 @@ trait TypeAssigner { val transform = new TypeMap { def apply(t: Type) = t match { - case PolyParam(`pt`, idx) => normArgs(idx) + case TypeParamRef(`pt`, idx) => normArgs(idx) case _ => mapOver(t) } } diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 5e845a807..145410f65 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1871,7 +1871,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit case TypeBounds(lo, hi) if (lo eq hi) || (hi <:< lo)(ctx.fresh.setExploreTyperState) => inst(lo) - case tp: PolyParam => + case tp: TypeParamRef => constraint.typeVarOfParam(tp).orElse(tp) case _ => tp } |