aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/core
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core')
-rw-r--r--compiler/src/dotty/tools/dotc/core/Constants.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala4
-rw-r--r--compiler/src/dotty/tools/dotc/core/Definitions.scala4
-rw-r--r--compiler/src/dotty/tools/dotc/core/Denotations.scala14
-rw-r--r--compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/core/ParamInfo.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/core/SymDenotations.scala4
-rw-r--r--compiler/src/dotty/tools/dotc/core/TypeApplications.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/core/TypeComparer.scala12
-rw-r--r--compiler/src/dotty/tools/dotc/core/TypeErasure.scala8
-rw-r--r--compiler/src/dotty/tools/dotc/core/Types.scala203
-rw-r--r--compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala4
-rw-r--r--compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala6
-rw-r--r--compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala6
14 files changed, 138 insertions, 135 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/Constants.scala b/compiler/src/dotty/tools/dotc/core/Constants.scala
index 1892e4bdc..e8b27c0ba 100644
--- a/compiler/src/dotty/tools/dotc/core/Constants.scala
+++ b/compiler/src/dotty/tools/dotc/core/Constants.scala
@@ -174,7 +174,7 @@ object Constants {
case TypeBounds(lo, hi) =>
if (hi.classSymbol.isPrimitiveValueClass) hi //constrain further with high bound
else classBound(lo)
- case NoType => classBound(param.binder.paramBounds(param.paramNum).lo)
+ case NoType => classBound(param.binder.paramInfos(param.paramNum).lo)
case inst => classBound(inst)
}
case pt => pt
diff --git a/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala b/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala
index a12936c58..34662cbff 100644
--- a/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala
+++ b/compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala
@@ -303,7 +303,7 @@ trait ConstraintHandling {
/** The current bounds of type parameter `param` */
final def bounds(param: PolyParam): TypeBounds = {
val e = constraint.entry(param)
- if (e.exists) e.bounds else param.binder.paramBounds(param.paramNum)
+ if (e.exists) e.bounds else param.binder.paramInfos(param.paramNum)
}
/** Add polytype `pt`, possibly with type variables `tvars`, to current constraint
@@ -362,7 +362,7 @@ trait ConstraintHandling {
def apply(t: Type): Type = t match {
case t @ PolyParam(pt: PolyType, n) if comparedPolyTypes contains pt =>
val effectiveVariance = if (fromBelow) -variance else variance
- val bounds = pt.paramBounds(n)
+ val bounds = pt.paramInfos(n)
if (effectiveVariance > 0) bounds.lo
else if (effectiveVariance < 0) bounds.hi
else NoType
diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala
index c48016b67..0c1d6521d 100644
--- a/compiler/src/dotty/tools/dotc/core/Definitions.scala
+++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala
@@ -151,8 +151,8 @@ class Definitions {
private def enterPolyMethod(cls: ClassSymbol, name: TermName, typeParamCount: Int,
resultTypeFn: PolyType => Type, flags: FlagSet = EmptyFlags) = {
val tparamNames = tpnme.syntheticTypeParamNames(typeParamCount)
- val tparamBounds = tparamNames map (_ => TypeBounds.empty)
- val ptype = PolyType(tparamNames)(_ => tparamBounds, resultTypeFn)
+ val tparamInfos = tparamNames map (_ => TypeBounds.empty)
+ val ptype = PolyType(tparamNames)(_ => tparamInfos, resultTypeFn)
enterMethod(cls, name, ptype, flags)
}
diff --git a/compiler/src/dotty/tools/dotc/core/Denotations.scala b/compiler/src/dotty/tools/dotc/core/Denotations.scala
index f726cd0d1..1d7b3c94c 100644
--- a/compiler/src/dotty/tools/dotc/core/Denotations.scala
+++ b/compiler/src/dotty/tools/dotc/core/Denotations.scala
@@ -213,7 +213,7 @@ object Denotations {
def requiredMethod(name: PreName, argTypes: List[Type])(implicit ctx: Context): TermSymbol =
info.member(name.toTermName).requiredSymbol(x=>
- (x is Method) && x.info.paramTypess == List(argTypes)
+ (x is Method) && x.info.paramInfoss == List(argTypes)
).asTerm
def requiredMethodRef(name: PreName, argTypes: List[Type])(implicit ctx: Context): TermRef =
requiredMethod(name, argTypes).termRef
@@ -310,11 +310,11 @@ object Denotations {
}
case tp1: MethodType if isTerm =>
tp2 match {
- case tp2: MethodType if ctx.typeComparer.matchingParams(tp1.paramTypes, tp2.paramTypes, tp1.isJava, tp2.isJava) &&
+ case tp2: MethodType if ctx.typeComparer.matchingParams(tp1.paramInfos, tp2.paramInfos, tp1.isJava, tp2.isJava) &&
tp1.isImplicit == tp2.isImplicit =>
tp1.derivedMethodType(
mergeNames(tp1.paramNames, tp2.paramNames, nme.syntheticParamName),
- tp1.paramTypes,
+ tp1.paramInfos,
infoMeet(tp1.resultType, tp2.resultType.subst(tp2, tp1)))
case _ =>
mergeConflict(tp1, tp2)
@@ -324,7 +324,7 @@ object Denotations {
case tp2: PolyType if ctx.typeComparer.matchingTypeParams(tp1, tp2) =>
tp1.derivedPolyType(
mergeNames(tp1.paramNames, tp2.paramNames, tpnme.syntheticTypeParamName),
- tp1.paramBounds,
+ tp1.paramInfos,
infoMeet(tp1.resultType, tp2.resultType.subst(tp2, tp1)))
case _: MethodicType =>
mergeConflict(tp1, tp2)
@@ -474,11 +474,11 @@ object Denotations {
case tp1: MethodType =>
tp2 match {
case tp2: MethodType
- if ctx.typeComparer.matchingParams(tp1.paramTypes, tp2.paramTypes, tp1.isJava, tp2.isJava) &&
+ if ctx.typeComparer.matchingParams(tp1.paramInfos, tp2.paramInfos, tp1.isJava, tp2.isJava) &&
tp1.isImplicit == tp2.isImplicit =>
tp1.derivedMethodType(
mergeNames(tp1.paramNames, tp2.paramNames, nme.syntheticParamName),
- tp1.paramTypes, tp1.resultType | tp2.resultType.subst(tp2, tp1))
+ tp1.paramInfos, tp1.resultType | tp2.resultType.subst(tp2, tp1))
case _ =>
mergeConflict(tp1, tp2)
}
@@ -487,7 +487,7 @@ object Denotations {
case tp2: PolyType if ctx.typeComparer.matchingTypeParams(tp1, tp2) =>
tp1.derivedPolyType(
mergeNames(tp1.paramNames, tp2.paramNames, tpnme.syntheticTypeParamName),
- tp1.paramBounds, tp1.resultType | tp2.resultType.subst(tp2, tp1))
+ tp1.paramInfos, tp1.resultType | tp2.resultType.subst(tp2, tp1))
case _ =>
mergeConflict(tp1, tp2)
}
diff --git a/compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala b/compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala
index 61dd5a445..3387f20e3 100644
--- a/compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala
+++ b/compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala
@@ -284,7 +284,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
assert(!contains(poly))
val nparams = poly.paramNames.length
val entries1 = new Array[Type](nparams * 2)
- poly.paramBounds.copyToArray(entries1, 0)
+ poly.paramInfos.copyToArray(entries1, 0)
tvars.copyToArray(entries1, nparams)
newConstraint(boundsMap.updated(poly, entries1), lowerMap, upperMap).init(poly)
}
diff --git a/compiler/src/dotty/tools/dotc/core/ParamInfo.scala b/compiler/src/dotty/tools/dotc/core/ParamInfo.scala
index efae24916..f824c3e9c 100644
--- a/compiler/src/dotty/tools/dotc/core/ParamInfo.scala
+++ b/compiler/src/dotty/tools/dotc/core/ParamInfo.scala
@@ -22,7 +22,7 @@ trait ParamInfo {
/** The info of the type parameter as seen from a prefix type.
* For type parameter symbols, this is the `memberInfo` as seen from `prefix`.
- * For type lambda parameters, it's the same as `paramBounds` as
+ * For type lambda parameters, it's the same as `paramInfos` as
* `asSeenFrom` has already been applied to the whole type lambda.
*/
def paramInfoAsSeenFrom(pre: Type)(implicit ctx: Context): Type
diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala
index 27782698d..c126b5500 100644
--- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -1146,8 +1146,8 @@ object SymDenotations {
case tp: NamedType => hasSkolems(tp.prefix)
case tp: RefinedType => hasSkolems(tp.parent) || hasSkolems(tp.refinedInfo)
case tp: RecType => hasSkolems(tp.parent)
- case tp: PolyType => tp.paramBounds.exists(hasSkolems) || hasSkolems(tp.resType)
- case tp: MethodType => tp.paramTypes.exists(hasSkolems) || hasSkolems(tp.resType)
+ case tp: PolyType => tp.paramInfos.exists(hasSkolems) || hasSkolems(tp.resType)
+ case tp: MethodType => tp.paramInfos.exists(hasSkolems) || hasSkolems(tp.resType)
case tp: ExprType => hasSkolems(tp.resType)
case tp: HKApply => hasSkolems(tp.tycon) || tp.args.exists(hasSkolems)
case tp: AndOrType => hasSkolems(tp.tp1) || hasSkolems(tp.tp2)
diff --git a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala
index 9a1a3359e..931f0dc74 100644
--- a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala
+++ b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala
@@ -369,7 +369,7 @@ class TypeApplications(val self: Type) extends AnyVal {
PolyType(
(tparams, hkParams).zipped.map((tparam, hkparam) =>
tparam.paramName.withVariance(hkparam.paramVariance)))(
- tl => arg.paramBounds.map(_.subst(arg, tl).bounds),
+ tl => arg.paramInfos.map(_.subst(arg, tl).bounds),
tl => arg.resultType.subst(arg, tl)
)
case arg @ TypeAlias(alias) =>
diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala
index fb16a6772..9f4db5edd 100644
--- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -488,7 +488,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
def compareMethod = tp1 match {
case tp1: MethodType =>
(tp1.signature consistentParams tp2.signature) &&
- matchingParams(tp1.paramTypes, tp2.paramTypes, tp1.isJava, tp2.isJava) &&
+ matchingParams(tp1.paramInfos, tp2.paramInfos, tp1.isJava, tp2.isJava) &&
(tp1.isImplicit == tp2.isImplicit) &&
isSubType(tp1.resultType, tp2.resultType.subst(tp2, tp1))
case _ =>
@@ -1021,7 +1021,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
tp2.widen match {
case tp2: MethodType =>
// implicitness is ignored when matching
- matchingParams(tp1.paramTypes, tp2.paramTypes, tp1.isJava, tp2.isJava) &&
+ matchingParams(tp1.paramInfos, tp2.paramInfos, tp1.isJava, tp2.isJava) &&
matchesType(tp1.resultType, tp2.resultType.subst(tp2, tp1), relaxed)
case tp2 =>
relaxed && tp1.paramNames.isEmpty &&
@@ -1067,7 +1067,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
* have the same bounds (after renaming one set to the other)?
*/
def matchingTypeParams(poly1: PolyType, poly2: PolyType): Boolean =
- (poly1.paramBounds corresponds poly2.paramBounds)((b1, b2) =>
+ (poly1.paramInfos corresponds poly2.paramInfos)((b1, b2) =>
isSameType(b1, b2.subst(poly2, poly1)))
// Type equality =:=
@@ -1284,7 +1284,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
paramNames = (tpnme.syntheticTypeParamNames(tparams1.length), tparams1, tparams2)
.zipped.map((pname, tparam1, tparam2) =>
pname.withVariance((tparam1.paramVariance + tparam2.paramVariance) / 2)))(
- paramBoundsExp = tl => (tparams1, tparams2).zipped.map((tparam1, tparam2) =>
+ paramInfosExp = tl => (tparams1, tparams2).zipped.map((tparam1, tparam2) =>
tl.lifted(tparams1, tparam1.paramInfoAsSeenFrom(tp1)).bounds &
tl.lifted(tparams2, tparam2.paramInfoAsSeenFrom(tp2)).bounds),
resultTypeExp = tl =>
@@ -1392,8 +1392,8 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
case tp2: MethodType =>
def asGoodParams(formals1: List[Type], formals2: List[Type]) =
(formals2 corresponds formals1)(isSubTypeWhenFrozen)
- asGoodParams(tp1.paramTypes, tp2.paramTypes) &&
- (!asGoodParams(tp2.paramTypes, tp1.paramTypes) ||
+ asGoodParams(tp1.paramInfos, tp2.paramInfos) &&
+ (!asGoodParams(tp2.paramInfos, tp1.paramInfos) ||
isAsGood(tp1.resultType, tp2.resultType))
case _ =>
false
diff --git a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala
index fe3396fcb..b716318c1 100644
--- a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala
+++ b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala
@@ -55,7 +55,7 @@ object TypeErasure {
case ThisType(tref) =>
isErasedType(tref)
case tp: MethodType =>
- tp.paramTypes.forall(isErasedType) && isErasedType(tp.resultType)
+ tp.paramInfos.forall(isErasedType) && isErasedType(tp.resultType)
case tp @ ClassInfo(pre, _, parents, decls, _) =>
isErasedType(pre) && parents.forall(isErasedType) //&& decls.forall(sym => isErasedType(sym.info)) && isErasedType(tp.selfType)
case NoType | NoPrefix | WildcardType | _: ErrorType | SuperType(_, _) =>
@@ -186,7 +186,7 @@ object TypeErasure {
case einfo: MethodType =>
if (sym.isGetter && einfo.resultType.isRef(defn.UnitClass))
MethodType(Nil, defn.BoxedUnitType)
- else if (sym.isAnonymousFunction && einfo.paramTypes.length > MaxImplementedFunctionArity)
+ else if (sym.isAnonymousFunction && einfo.paramInfos.length > MaxImplementedFunctionArity)
MethodType(nme.ALLARGS :: Nil, JavaArrayType(defn.ObjectType) :: Nil, einfo.resultType)
else
einfo
@@ -382,10 +382,10 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
case tp: MethodType =>
def paramErasure(tpToErase: Type) =
erasureFn(tp.isJava, semiEraseVCs, isConstructor, wildcardOK)(tpToErase)
- val formals = tp.paramTypes.mapConserve(paramErasure)
+ val formals = tp.paramInfos.mapConserve(paramErasure)
eraseResult(tp.resultType) match {
case rt: MethodType =>
- tp.derivedMethodType(tp.paramNames ++ rt.paramNames, formals ++ rt.paramTypes, rt.resultType)
+ tp.derivedMethodType(tp.paramNames ++ rt.paramNames, formals ++ rt.paramInfos, rt.resultType)
case rt =>
tp.derivedMethodType(tp.paramNames, formals, rt)
}
diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala
index 17879f168..60d77446d 100644
--- a/compiler/src/dotty/tools/dotc/core/Types.scala
+++ b/compiler/src/dotty/tools/dotc/core/Types.scala
@@ -217,7 +217,7 @@ object Types {
*/
def isVarArgsMethod(implicit ctx: Context): Boolean = this match {
case tp: PolyType => tp.resultType.isVarArgsMethod
- case mt: MethodType => mt.paramTypes.nonEmpty && mt.paramTypes.last.isRepeatedParam
+ case mt: MethodType => mt.paramInfos.nonEmpty && mt.paramInfos.last.isRepeatedParam
case _ => false
}
@@ -443,7 +443,7 @@ object Types {
case tp: TermRef =>
go (tp.underlying match {
case mt: MethodType
- if mt.paramTypes.isEmpty && (tp.symbol is Stable) => mt.resultType
+ if mt.paramInfos.isEmpty && (tp.symbol is Stable) => mt.resultType
case tp1 => tp1
})
case tp: PolyParam =>
@@ -543,7 +543,7 @@ object Types {
def goApply(tp: HKApply) = tp.tycon match {
case tl: PolyType =>
go(tl.resType).mapInfo(info =>
- tl.derivedLambdaAbstraction(tl.paramNames, tl.paramBounds, info).appliedTo(tp.args))
+ tl.derivedLambdaAbstraction(tl.paramNames, tl.paramInfos, info).appliedTo(tp.args))
case _ =>
go(tp.superType)
}
@@ -1088,9 +1088,9 @@ object Types {
}
/** The parameter types of a PolyType or MethodType, Empty list for others */
- final def paramTypess(implicit ctx: Context): List[List[Type]] = this match {
- case mt: MethodType => mt.paramTypes :: mt.resultType.paramTypess
- case pt: PolyType => pt.resultType.paramTypess
+ final def paramInfoss(implicit ctx: Context): List[List[Type]] = this match {
+ case mt: MethodType => mt.paramInfos :: mt.resultType.paramInfoss
+ case pt: PolyType => pt.resultType.paramInfoss
case _ => Nil
}
@@ -1103,14 +1103,14 @@ object Types {
/** The parameter types in the first parameter section of a generic type or MethodType, Empty list for others */
- @tailrec final def firstParamTypes(implicit ctx: Context): List[Type] = this match {
- case mt: MethodType => mt.paramTypes
+ final def firstParamTypes(implicit ctx: Context): List[Type] = this match {
+ case mt: MethodType => mt.paramInfos
case pt: PolyType => pt.resultType.firstParamTypes
case _ => Nil
}
/** Is this either not a method at all, or a parameterless method? */
- @tailrec final def isParameterless(implicit ctx: Context): Boolean = this match {
+ final def isParameterless(implicit ctx: Context): Boolean = this match {
case mt: MethodType => false
case pt: PolyType => pt.resultType.isParameterless
case _ => true
@@ -1220,7 +1220,7 @@ object Types {
*/
def toFunctionType(dropLast: Int = 0)(implicit ctx: Context): Type = this match {
case mt: MethodType if !mt.isDependent || ctx.mode.is(Mode.AllowDependentFunctions) =>
- val formals1 = if (dropLast == 0) mt.paramTypes else mt.paramTypes dropRight dropLast
+ val formals1 = if (dropLast == 0) mt.paramInfos else mt.paramInfos dropRight dropLast
defn.FunctionOf(
formals1 mapConserve (_.underlyingIfRepeated(mt.isJava)), mt.resultType, mt.isImplicit && !ctx.erasedTypes)
}
@@ -2324,12 +2324,12 @@ object Types {
* Proxy (hk) | HKTermLambda | HKTypeLambda
* Ground (*) | MethodType | PolyType
*/
- trait LambdaType extends BindingType with MethodOrPoly {
+ trait LambdaType[PInfo <: Type] extends BindingType with MethodOrPoly {
def paramNames: List[TermName]
- def paramTypes: List[Type]
+ def paramInfos: List[PInfo]
def resType: Type
- def newLikeThis(paramNames: List[Name], paramBounds: List[Type], resType: Type)(implicit ctx: Context): LambdaType
- def newParamRef(n: Int): ParamRef
+ def newLikeThis(paramNames: List[Name], paramInfos: List[PInfo], resType: Type)(implicit ctx: Context): LambdaType[PInfo]
+ def newParamRef(n: Int): ParamRef[PInfo]
override def resultType(implicit ctx: Context) = resType
@@ -2339,29 +2339,29 @@ object Types {
final def isTypeLambda = paramNames.head.isTypeName
final def isHigherKinded = isInstanceOf[TypeProxy]
- lazy val paramRefs: List[ParamRef] = paramNames.indices.toList.map(newParamRef)
+ lazy val paramRefs: List[ParamRef[PInfo]] = paramNames.indices.toList.map(newParamRef)
def instantiate(argTypes: => List[Type])(implicit ctx: Context): Type =
if (isDependent) resultType.substParams(this, argTypes)
else resultType
def derivedLambdaType(paramNames: List[Name] = this.paramNames,
- paramTypes: List[Type] = this.paramTypes,
+ paramInfos: List[PInfo] = this.paramInfos,
resType: Type = this.resType)(implicit ctx: Context) =
- if ((paramNames eq this.paramNames) && (paramTypes eq this.paramTypes) && (resType eq this.resType)) this
- else newLikeThis(paramNames, paramTypes, resType)
+ if ((paramNames eq this.paramNames) && (paramInfos eq this.paramInfos) && (resType eq this.resType)) this
+ else newLikeThis(paramNames, paramInfos, resType)
override def equals(that: Any) = that match {
- case that: LambdaType =>
+ case that: LambdaType[_] =>
this.paramNames == that.paramNames &&
- this.paramTypes == that.paramTypes &&
+ this.paramInfos == that.paramInfos &&
this.resType == that.resType
case _ =>
false
}
}
- trait LambdaOverTerms extends LambdaType { thisLambdaType =>
+ trait LambdaOverTerms extends LambdaType[Type] { thisLambdaType =>
import LambdaOverTerms._
override def resultType(implicit ctx: Context): Type =
@@ -2435,8 +2435,8 @@ object Types {
if (myParamDependencyStatus != Unknown) myParamDependencyStatus
else {
val result =
- if (paramTypes.isEmpty) NoDeps
- else (NoDeps /: paramTypes.tail)(depStatus(_, _))
+ if (paramInfos.isEmpty) NoDeps
+ else (NoDeps /: paramInfos.tail)(depStatus(_, _))
if ((result & Provisional) == 0) myParamDependencyStatus = result
(result & StatusMask).toByte
}
@@ -2452,10 +2452,10 @@ object Types {
*/
def isParamDependent(implicit ctx: Context): Boolean = paramDependencyStatus == TrueDeps
- def newParamRef(n: Int): ParamRef = new TermParamRef(this, n)
+ def newParamRef(n: Int): ParamRef[Type] = new TermParamRef(this, n)
}
- trait LambdaOverTypes extends LambdaType { thisLambdaType =>
+ trait LambdaOverTypes extends LambdaType[TypeBounds] { thisLambdaType =>
}
object LambdaOverTerms {
@@ -2469,47 +2469,47 @@ object Types {
}
abstract case class MethodType(paramNames: List[TermName])(
- paramTypesExp: MethodType => List[Type],
+ paramInfosExp: MethodType => List[Type],
resultTypeExp: MethodType => Type)
extends CachedGroundType with TermType with LambdaOverTerms with NarrowCached { thisMethodType =>
import MethodType._
- protected def companion: LambdaTypeCompanion[MethodType]
+ protected def companion: MethodTypeCompanion
def isJava = false
def isImplicit = false
- val paramTypes = paramTypesExp(this)
+ val paramInfos = paramInfosExp(this)
val resType = resultTypeExp(this)
assert(resType.exists)
protected def computeSignature(implicit ctx: Context): Signature =
- resultSignature.prepend(paramTypes, isJava)
+ resultSignature.prepend(paramInfos, isJava)
def derivedMethodType(paramNames: List[TermName] = this.paramNames,
- paramTypes: List[Type] = this.paramTypes,
+ paramInfos: List[Type] = this.paramInfos,
resType: Type = this.resType)(implicit ctx: Context) =
- derivedLambdaType(paramNames, paramTypes, resType)
+ derivedLambdaType(paramNames, paramInfos, resType)
- def newLikeThis(paramNames: List[Name], paramTypes: List[Type], resType: Type)(implicit ctx: Context): MethodType =
+ def newLikeThis(paramNames: List[Name], paramInfos: List[Type], resType: Type)(implicit ctx: Context): MethodType =
companion(paramNames.asInstanceOf[List[TermName]])(
- x => paramTypes.mapConserve(_.subst(this, x)),
+ x => paramInfos.mapConserve(_.subst(this, x)),
x => resType.subst(this, x))
- override def computeHash = doHash(paramNames, resType, paramTypes)
+ override def computeHash = doHash(paramNames, resType, paramInfos)
protected def prefixString = "MethodType"
- override def toString = s"$prefixString($paramNames, $paramTypes, $resType)"
+ override def toString = s"$prefixString($paramNames, $paramInfos, $resType)"
}
- final class CachedMethodType(paramNames: List[TermName])(paramTypesExp: MethodType => List[Type], resultTypeExp: MethodType => Type)
- extends MethodType(paramNames)(paramTypesExp, resultTypeExp) {
+ final class CachedMethodType(paramNames: List[TermName])(paramInfosExp: MethodType => List[Type], resultTypeExp: MethodType => Type)
+ extends MethodType(paramNames)(paramInfosExp, resultTypeExp) {
def companion = MethodType
override def equals(that: Any) = super.equals(that) && that.isInstanceOf[CachedMethodType]
}
- final class JavaMethodType(paramNames: List[TermName])(paramTypesExp: MethodType => List[Type], resultTypeExp: MethodType => Type)
- extends MethodType(paramNames)(paramTypesExp, resultTypeExp) {
+ final class JavaMethodType(paramNames: List[TermName])(paramInfosExp: MethodType => List[Type], resultTypeExp: MethodType => Type)
+ extends MethodType(paramNames)(paramInfosExp, resultTypeExp) {
def companion = JavaMethodType
override def isJava = true
override def equals(that: Any) = super.equals(that) && that.isInstanceOf[JavaMethodType]
@@ -2517,8 +2517,8 @@ object Types {
override protected def prefixString = "JavaMethodType"
}
- final class ImplicitMethodType(paramNames: List[TermName])(paramTypesExp: MethodType => List[Type], resultTypeExp: MethodType => Type)
- extends MethodType(paramNames)(paramTypesExp, resultTypeExp) {
+ final class ImplicitMethodType(paramNames: List[TermName])(paramInfosExp: MethodType => List[Type], resultTypeExp: MethodType => Type)
+ extends MethodType(paramNames)(paramInfosExp, resultTypeExp) {
def companion = ImplicitMethodType
override def isImplicit = true
override def equals(that: Any) = super.equals(that) && that.isInstanceOf[ImplicitMethodType]
@@ -2526,15 +2526,17 @@ object Types {
override protected def prefixString = "ImplicitMethodType"
}
- abstract class LambdaTypeCompanion[LT <: LambdaType] {
- def apply(paramNames: List[TermName])(paramTypesExp: LT => List[Type], resultTypeExp: LT => Type)(implicit ctx: Context): LT
- def apply(paramNames: List[TermName], paramTypes: List[Type], resultType: Type)(implicit ctx: Context): LT =
- apply(paramNames)(_ => paramTypes, _ => resultType)
- def apply(paramTypes: List[Type])(resultTypeExp: LT => Type)(implicit ctx: Context): LT =
- apply(nme.syntheticParamNames(paramTypes.length))(_ => paramTypes, resultTypeExp)
- def apply(paramTypes: List[Type], resultType: Type)(implicit ctx: Context): LT =
- apply(nme.syntheticParamNames(paramTypes.length), paramTypes, resultType)
+ abstract class LambdaTypeCompanion[PInfo <: Type, LT <: LambdaType[PInfo]] {
+ def apply(paramNames: List[TermName])(paramInfosExp: LT => List[PInfo], resultTypeExp: LT => Type)(implicit ctx: Context): LT
+ def apply(paramNames: List[TermName], paramInfos: List[PInfo], resultType: Type)(implicit ctx: Context): LT =
+ apply(paramNames)(_ => paramInfos, _ => resultType)
+ def apply(paramInfos: List[PInfo])(resultTypeExp: LT => Type)(implicit ctx: Context): LT =
+ apply(nme.syntheticParamNames(paramInfos.length))(_ => paramInfos, resultTypeExp)
+ def apply(paramInfos: List[PInfo], resultType: Type)(implicit ctx: Context): LT =
+ apply(nme.syntheticParamNames(paramInfos.length), paramInfos, resultType)
+ }
+ abstract class MethodTypeCompanion extends LambdaTypeCompanion[Type, MethodType] {
/** Produce method type from parameter symbols, with special mappings for repeated
* and inline parameters.
*/
@@ -2554,8 +2556,9 @@ object Types {
case _: ExprType => tp
case _ => AnnotatedType(tp, Annotation(defn.InlineParamAnnot))
}
- def integrate(tp: Type, mt: LT) =
+ def integrate(tp: Type, mt: MethodType): Type =
tp.subst(params, params.indices.toList.map(mt.newParamRef))
+
def paramInfo(param: Symbol): Type = {
val paramType = translateRepeated(param.info)
if (param.is(Inline)) translateInline(paramType) else paramType
@@ -2565,10 +2568,10 @@ object Types {
mt => integrate(resultType, mt))
}
- def checkValid(mt: LT)(implicit ctx: Context): mt.type = {
- if (Config.checkMethodTypes && mt.isTermLambda)
- for ((paramType, idx) <- mt.paramTypes.zipWithIndex)
- paramType.foreachPart {
+ def checkValid(mt: MethodType)(implicit ctx: Context): mt.type = {
+ if (Config.checkMethodTypes)
+ for ((paramInfo, idx) <- mt.paramInfos.zipWithIndex)
+ paramInfo.foreachPart {
case ParamRef(`mt`, j) => assert(j < idx, mt)
case _ =>
}
@@ -2576,25 +2579,25 @@ object Types {
}
}
- object MethodType extends LambdaTypeCompanion[MethodType] {
- def apply(paramNames: List[TermName])(paramTypesExp: MethodType => List[Type], resultTypeExp: MethodType => Type)(implicit ctx: Context): MethodType =
- checkValid(unique(new CachedMethodType(paramNames)(paramTypesExp, resultTypeExp)))
+ object MethodType extends MethodTypeCompanion {
+ def apply(paramNames: List[TermName])(paramInfosExp: MethodType => List[Type], resultTypeExp: MethodType => Type)(implicit ctx: Context): MethodType =
+ checkValid(unique(new CachedMethodType(paramNames)(paramInfosExp, resultTypeExp)))
}
- object JavaMethodType extends LambdaTypeCompanion[MethodType] {
- def apply(paramNames: List[TermName])(paramTypesExp: MethodType => List[Type], resultTypeExp: MethodType => Type)(implicit ctx: Context): MethodType =
- unique(new JavaMethodType(paramNames)(paramTypesExp, resultTypeExp))
+ object JavaMethodType extends MethodTypeCompanion {
+ def apply(paramNames: List[TermName])(paramInfosExp: MethodType => List[Type], resultTypeExp: MethodType => Type)(implicit ctx: Context): MethodType =
+ unique(new JavaMethodType(paramNames)(paramInfosExp, resultTypeExp))
}
- object ImplicitMethodType extends LambdaTypeCompanion[MethodType] {
- def apply(paramNames: List[TermName])(paramTypesExp: MethodType => List[Type], resultTypeExp: MethodType => Type)(implicit ctx: Context): MethodType =
- checkValid(unique(new ImplicitMethodType(paramNames)(paramTypesExp, resultTypeExp)))
+ object ImplicitMethodType extends MethodTypeCompanion {
+ def apply(paramNames: List[TermName])(paramInfosExp: MethodType => List[Type], resultTypeExp: MethodType => Type)(implicit ctx: Context): MethodType =
+ checkValid(unique(new ImplicitMethodType(paramNames)(paramInfosExp, resultTypeExp)))
}
/** A ternary extractor for MethodType */
object MethodTpe {
def unapply(mt: MethodType)(implicit ctx: Context) =
- Some((mt.paramNames, mt.paramTypes, mt.resultType))
+ Some((mt.paramNames, mt.paramInfos, mt.resultType))
}
/** A by-name parameter type of the form `=> T`, or the type of a method with no parameter list. */
@@ -2625,17 +2628,17 @@ object Types {
* and every other name designates a non-variant parameter.
*
* @param paramNames The names `X_0`, ..., `X_n`
- * @param paramBoundsExp A function that, given the polytype itself, returns the
+ * @param paramInfosExp A function that, given the polytype itself, returns the
* parameter bounds `B_1`, ..., `B_n`
* @param resultTypeExp A function that, given the polytype itself, returns the
* result type `T`.
*/
class PolyType(val paramNames: List[TypeName])(
- paramBoundsExp: PolyType => List[TypeBounds], resultTypeExp: PolyType => Type)
+ paramInfosExp: PolyType => List[TypeBounds], resultTypeExp: PolyType => Type)
extends CachedProxyType with BindingType with MethodOrPoly {
/** The bounds of the type parameters */
- val paramTypes: List[Type] = paramBoundsExp(this)
+ val paramInfos: List[TypeBounds] = paramInfosExp(this)
/** The result type of a PolyType / body of a type lambda */
val resType: Type = resultTypeExp(this)
@@ -2660,29 +2663,29 @@ object Types {
/** Instantiate parameter bounds by substituting parameters with given arguments */
final def instantiateBounds(argTypes: List[Type])(implicit ctx: Context): List[Type] =
- paramTypes.mapConserve(_.substParams(this, argTypes))
+ paramInfos.mapConserve(_.substParams(this, argTypes))
- def newLikeThis(paramNames: List[TypeName], paramBounds: List[TypeBounds], resType: Type)(implicit ctx: Context): PolyType =
+ def newLikeThis(paramNames: List[TypeName], paramInfos: List[TypeBounds], resType: Type)(implicit ctx: Context): PolyType =
PolyType.apply(paramNames)(
- x => paramBounds mapConserve (_.subst(this, x).bounds),
+ x => paramInfos.mapConserve(_.subst(this, x).bounds),
x => resType.subst(this, x))
def derivedPolyType(paramNames: List[TypeName] = this.paramNames,
- paramBounds: List[TypeBounds] = this.paramBounds,
+ paramInfos: List[TypeBounds] = this.paramInfos,
resType: Type = this.resType)(implicit ctx: Context) =
- if ((paramNames eq this.paramNames) && (paramBounds eq this.paramBounds) && (resType eq this.resType)) this
- else newLikeThis(paramNames, paramBounds, resType)
+ if ((paramNames eq this.paramNames) && (paramInfos eq this.paramInfos) && (resType eq this.resType)) this
+ else newLikeThis(paramNames, paramInfos, resType)
- def derivedLambdaAbstraction(paramNames: List[TypeName], paramBounds: List[TypeBounds], resType: Type)(implicit ctx: Context): Type =
+ def derivedLambdaAbstraction(paramNames: List[TypeName], paramInfos: List[TypeBounds], resType: Type)(implicit ctx: Context): Type =
resType match {
case resType @ TypeAlias(alias) =>
- resType.derivedTypeAlias(newLikeThis(paramNames, paramBounds, alias))
+ resType.derivedTypeAlias(newLikeThis(paramNames, paramInfos, alias))
case resType @ TypeBounds(lo, hi) =>
resType.derivedTypeBounds(
- if (lo.isRef(defn.NothingClass)) lo else newLikeThis(paramNames, paramBounds, lo),
- newLikeThis(paramNames, paramBounds, hi))
+ if (lo.isRef(defn.NothingClass)) lo else newLikeThis(paramNames, paramInfos, lo),
+ newLikeThis(paramNames, paramInfos, hi))
case _ =>
- derivedPolyType(paramNames, paramBounds, resType)
+ derivedPolyType(paramNames, paramInfos, resType)
}
/** Merge nested polytypes into one polytype. nested polytypes are normally not supported
@@ -2697,8 +2700,8 @@ object Types {
}
}
PolyType(paramNames ++ that.paramNames)(
- x => this.paramBounds.mapConserve(_.subst(this, x).bounds) ++
- that.paramBounds.mapConserve(shift(_).subst(that, x).bounds),
+ x => this.paramInfos.mapConserve(_.subst(this, x).bounds) ++
+ that.paramInfos.mapConserve(shift(_).subst(that, x).bounds),
x => shift(that.resultType).subst(that, x).subst(this, x))
case _ => this
}
@@ -2715,21 +2718,21 @@ object Types {
override def equals(other: Any) = other match {
case other: PolyType =>
other.paramNames == this.paramNames &&
- other.paramBounds == this.paramBounds &&
+ other.paramInfos == this.paramInfos &&
other.resType == this.resType
case _ => false
}
- override def toString = s"PolyType($paramNames, $paramTypes, $resType)"
+ override def toString = s"PolyType($paramNames, $paramInfos, $resType)"
- override def computeHash = doHash(paramNames, resType, paramTypes)
+ override def computeHash = doHash(paramNames, resType, paramInfos)
}
object PolyType {
def apply(paramNames: List[TypeName])(
- paramBoundsExp: PolyType => List[TypeBounds],
+ paramInfosExp: PolyType => List[TypeBounds],
resultTypeExp: PolyType => Type)(implicit ctx: Context): PolyType = {
- unique(new PolyType(paramNames)(paramBoundsExp, resultTypeExp))
+ unique(new PolyType(paramNames)(paramInfosExp, resultTypeExp))
}
def unapply(tl: PolyType): Some[(List[LambdaParam], Type)] =
@@ -2746,7 +2749,7 @@ object Types {
case class LambdaParam(tl: PolyType, n: Int) extends ParamInfo {
def isTypeParam(implicit ctx: Context) = tl.paramNames.head.isTypeName
def paramName(implicit ctx: Context): TypeName = tl.paramNames(n)
- def paramInfo(implicit ctx: Context): Type = tl.paramBounds(n)
+ def paramInfo(implicit ctx: Context): Type = tl.paramInfos(n)
def paramInfoAsSeenFrom(pre: Type)(implicit ctx: Context): Type = paramInfo
def paramInfoOrCompleter(implicit ctx: Context): Type = paramInfo
def paramVariance(implicit ctx: Context): Int = tl.paramNames(n).variance
@@ -2841,17 +2844,17 @@ object Types {
def paramName: Name
}
- abstract case class ParamRef(binder: LambdaType, paramNum: Int) extends ParamType {
- type BT = LambdaType
+ abstract case class ParamRef[PInfo <: Type](binder: LambdaType[PInfo], paramNum: Int) extends ParamType {
+ type BT = LambdaType[PInfo]
def paramName = binder.paramNames(paramNum)
- override def underlying(implicit ctx: Context): Type = binder.paramTypes(paramNum)
+ override def underlying(implicit ctx: Context): Type = binder.paramInfos(paramNum)
// need to customize hashCode and equals to prevent infinite recursion for dep meth types.
override def computeHash = addDelta(binder.identityHash, paramNum)
override def equals(that: Any) = that match {
- case that: ParamRef =>
+ case that: ParamRef[_] =>
(this.binder eq that.binder) && this.paramNum == that.paramNum
case _ =>
false
@@ -2860,13 +2863,13 @@ object Types {
override def toString = s"ParamRef($paramName)"
}
- class TermParamRef(binder: LambdaType, paramNum: Int)
- extends ParamRef(binder, paramNum) with SingletonType {
+ class TermParamRef(binder: LambdaType[Type], paramNum: Int)
+ extends ParamRef[Type](binder, paramNum) with SingletonType {
def copyBoundType(bt: BT) = new TermParamRef(bt, paramNum)
}
object TermParamRef {
- def apply(binder: LambdaType, paramNum: Int)(implicit ctx: Context): TermParamRef = {
+ def apply(binder: LambdaType[Type], paramNum: Int)(implicit ctx: Context): TermParamRef = {
assertUnerased()
new TermParamRef(binder, paramNum)
}
@@ -2893,7 +2896,7 @@ object Types {
def paramName = binder.paramNames(paramNum)
override def underlying(implicit ctx: Context): Type = {
- val bounds = binder.paramBounds
+ val bounds = binder.paramInfos
if (bounds == null) NoType // this can happen if the referenced generic type is not initialized yet
else bounds(paramNum)
}
@@ -3396,7 +3399,7 @@ object Types {
case tp: ClassInfo =>
def zeroParams(tp: Type): Boolean = tp match {
case pt: PolyType => zeroParams(pt.resultType)
- case mt: MethodType => mt.paramTypes.isEmpty && !mt.resultType.isInstanceOf[MethodType]
+ case mt: MethodType => mt.paramInfos.isEmpty && !mt.resultType.isInstanceOf[MethodType]
case et: ExprType => true
case _ => false
}
@@ -3517,7 +3520,7 @@ object Types {
case tp: MethodType =>
def mapOverMethod = {
variance = -variance
- val ptypes1 = tp.paramTypes mapConserve this
+ val ptypes1 = tp.paramInfos mapConserve this
variance = -variance
derivedMethodType(tp, ptypes1, this(tp.resultType))
}
@@ -3529,7 +3532,7 @@ object Types {
case tp: PolyType =>
def mapOverPoly = {
variance = -variance
- val bounds1 = tp.paramBounds.mapConserve(this).asInstanceOf[List[TypeBounds]]
+ val bounds1 = tp.paramInfos.mapConserve(this).asInstanceOf[List[TypeBounds]]
variance = -variance
derivedPolyType(tp, bounds1, this(tp.resultType))
}
@@ -3744,7 +3747,7 @@ object Types {
case tp: MethodType =>
variance = -variance
- val y = foldOver(x, tp.paramTypes)
+ val y = foldOver(x, tp.paramInfos)
variance = -variance
this(y, tp.resultType)
@@ -3753,7 +3756,7 @@ object Types {
case tp: PolyType =>
variance = -variance
- val y = foldOver(x, tp.paramBounds)
+ val y = foldOver(x, tp.paramInfos)
variance = -variance
this(y, tp.resultType)
@@ -3857,7 +3860,7 @@ object Types {
apply(x, tp.tref)
case tp: ConstantType =>
apply(x, tp.underlying)
- case tp: ParamRef =>
+ case tp: ParamRef[_] =>
apply(x, tp.underlying)
case tp: PolyParam =>
apply(x, tp.underlying)
diff --git a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
index e0b233ce8..2bb929bf3 100644
--- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
+++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
@@ -209,7 +209,7 @@ class ClassfileParser(
def normalizeConstructorInfo() = {
val mt @ MethodType(paramNames) = denot.info
val rt = classRoot.typeRef appliedTo (classRoot.typeParams map (_.typeRef))
- denot.info = mt.derivedMethodType(paramNames, mt.paramTypes, rt)
+ denot.info = mt.derivedMethodType(paramNames, mt.paramInfos, rt)
addConstructorTypeParams(denot)
}
@@ -975,7 +975,7 @@ class ClassfileParser(
if (name == nme.CONSTRUCTOR)
tpe match {
case tp: MethodType =>
- tp.derivedMethodType(tp.paramNames, tp.paramTypes, ownerTpe)
+ tp.derivedMethodType(tp.paramNames, tp.paramInfos, ownerTpe)
}
p = (name, tpe)
values(index) = p
diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala
index d0d0e1863..8801eb19b 100644
--- a/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala
+++ b/compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala
@@ -255,10 +255,10 @@ class TreePickler(pickler: TastyPickler) {
pickleType(tpe.underlying)
case tpe: PolyType =>
writeByte(POLYtype)
- pickleMethodic(tpe.resultType, tpe.paramNames, tpe.paramBounds)
+ pickleMethodic(tpe.resultType, tpe.paramNames, tpe.paramInfos)
case tpe: MethodType if richTypes =>
writeByte(METHODtype)
- pickleMethodic(tpe.resultType, tpe.paramNames, tpe.paramTypes)
+ pickleMethodic(tpe.resultType, tpe.paramNames, tpe.paramInfos)
case tpe: PolyParam =>
if (!pickleParamType(tpe))
// TODO figure out why this case arises in e.g. pickling AbstractFileReader.
@@ -266,7 +266,7 @@ class TreePickler(pickler: TastyPickler) {
case TypeBounds(lo, hi) if lo eq hi => pickleNewType(lo, richTypes)
case _ => assert(false, s"orphan poly parameter: $tpe")
}
- case tpe: ParamRef =>
+ case tpe: ParamRef[_] =>
assert(pickleParamType(tpe), s"orphan method parameter: $tpe")
case tpe: LazyRef =>
pickleType(tpe.ref)
diff --git a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
index 688a2d007..fad516da7 100644
--- a/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
+++ b/compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala
@@ -56,7 +56,7 @@ object Scala2Unpickler {
*/
def arrayToRepeated(tp: Type)(implicit ctx: Context): Type = tp match {
case tp: MethodType =>
- val lastArg = tp.paramTypes.last
+ val lastArg = tp.paramInfos.last
assert(lastArg isRef defn.ArrayClass)
val elemtp0 :: Nil = lastArg.baseArgInfos(defn.ArrayClass)
val elemtp = elemtp0 match {
@@ -67,10 +67,10 @@ object Scala2Unpickler {
}
tp.derivedMethodType(
tp.paramNames,
- tp.paramTypes.init :+ defn.RepeatedParamType.appliedTo(elemtp),
+ tp.paramInfos.init :+ defn.RepeatedParamType.appliedTo(elemtp),
tp.resultType)
case tp: PolyType =>
- tp.derivedPolyType(tp.paramNames, tp.paramBounds, arrayToRepeated(tp.resultType))
+ tp.derivedPolyType(tp.paramNames, tp.paramInfos, arrayToRepeated(tp.resultType))
}
def ensureConstructor(cls: ClassSymbol, scope: Scope)(implicit ctx: Context) =