Skip to content

Commit 2af5d8d

Browse files
committed
replace derived{Method,Poly}Type with derivedLambdaType
1 parent 83d270a commit 2af5d8d

17 files changed

+34
-45
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ object Denotations {
312312
tp2 match {
313313
case tp2: MethodType if ctx.typeComparer.matchingParams(tp1.paramInfos, tp2.paramInfos, tp1.isJava, tp2.isJava) &&
314314
tp1.isImplicit == tp2.isImplicit =>
315-
tp1.derivedMethodType(
315+
tp1.derivedLambdaType(
316316
mergeNames(tp1.paramNames, tp2.paramNames, nme.syntheticParamName),
317317
tp1.paramInfos,
318318
infoMeet(tp1.resultType, tp2.resultType.subst(tp2, tp1)))
@@ -322,7 +322,7 @@ object Denotations {
322322
case tp1: PolyType if isTerm =>
323323
tp2 match {
324324
case tp2: PolyType if ctx.typeComparer.matchingTypeParams(tp1, tp2) =>
325-
tp1.derivedPolyType(
325+
tp1.derivedLambdaType(
326326
mergeNames(tp1.paramNames, tp2.paramNames, tpnme.syntheticTypeParamName),
327327
tp1.paramInfos,
328328
infoMeet(tp1.resultType, tp2.resultType.subst(tp2, tp1)))
@@ -476,7 +476,7 @@ object Denotations {
476476
case tp2: MethodType
477477
if ctx.typeComparer.matchingParams(tp1.paramInfos, tp2.paramInfos, tp1.isJava, tp2.isJava) &&
478478
tp1.isImplicit == tp2.isImplicit =>
479-
tp1.derivedMethodType(
479+
tp1.derivedLambdaType(
480480
mergeNames(tp1.paramNames, tp2.paramNames, nme.syntheticParamName),
481481
tp1.paramInfos, tp1.resultType | tp2.resultType.subst(tp2, tp1))
482482
case _ =>
@@ -485,7 +485,7 @@ object Denotations {
485485
case tp1: PolyType =>
486486
tp2 match {
487487
case tp2: PolyType if ctx.typeComparer.matchingTypeParams(tp1, tp2) =>
488-
tp1.derivedPolyType(
488+
tp1.derivedLambdaType(
489489
mergeNames(tp1.paramNames, tp2.paramNames, tpnme.syntheticTypeParamName),
490490
tp1.paramInfos, tp1.resultType | tp2.resultType.subst(tp2, tp1))
491491
case _ =>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ class TypeApplications(val self: Type) extends AnyVal {
428428
// In this case we should always dealias since we cannot handle
429429
// higher-kinded applications to wildcard arguments.
430430
dealiased
431-
.derivedPolyType(resType = tycon.safeDealias.appliedTo(args1))
431+
.derivedLambdaType(resType = tycon.safeDealias.appliedTo(args1))
432432
.appliedTo(args)
433433
case _ =>
434434
val reducer = new Reducer(dealiased, args)

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ object TypeErasure {
176176
val erase = erasureFn(isJava, semiEraseVCs, sym.isConstructor, wildcardOK = false)
177177

178178
def eraseParamBounds(tp: PolyType): Type =
179-
tp.derivedPolyType(
179+
tp.derivedLambdaType(
180180
tp.paramNames, tp.paramNames map (Function.const(TypeBounds.upper(defn.ObjectType))), tp.resultType)
181181

182182
if (defn.isPolymorphicAfterErasure(sym)) eraseParamBounds(sym.info.asInstanceOf[PolyType])
@@ -385,9 +385,9 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
385385
val formals = tp.paramInfos.mapConserve(paramErasure)
386386
eraseResult(tp.resultType) match {
387387
case rt: MethodType =>
388-
tp.derivedMethodType(tp.paramNames ++ rt.paramNames, formals ++ rt.paramInfos, rt.resultType)
388+
tp.derivedLambdaType(tp.paramNames ++ rt.paramNames, formals ++ rt.paramInfos, rt.resultType)
389389
case rt =>
390-
tp.derivedMethodType(tp.paramNames, formals, rt)
390+
tp.derivedLambdaType(tp.paramNames, formals, rt)
391391
}
392392
case tp @ ClassInfo(pre, cls, classParents, decls, _) =>
393393
if (cls is Package) tp

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

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,11 +2520,6 @@ object Types {
25202520
override def computeSignature(implicit ctx: Context): Signature =
25212521
resultSignature.prepend(paramInfos, isJava)
25222522

2523-
def derivedMethodType(paramNames: List[TermName] = this.paramNames,
2524-
paramInfos: List[Type] = this.paramInfos,
2525-
resType: Type = this.resType)(implicit ctx: Context) =
2526-
derivedLambdaType(paramNames, paramInfos, resType)
2527-
25282523
protected def prefixString = "MethodType"
25292524
}
25302525

@@ -2693,11 +2688,6 @@ object Types {
26932688

26942689
override def underlying(implicit ctx: Context) = resType
26952690

2696-
def derivedPolyType(paramNames: List[TypeName] = this.paramNames,
2697-
paramInfos: List[TypeBounds] = this.paramInfos,
2698-
resType: Type = this.resType)(implicit ctx: Context) =
2699-
derivedLambdaType(paramNames, paramInfos, resType)
2700-
27012691
/** Merge nested polytypes into one polytype. nested polytypes are normally not supported
27022692
* but can arise as temporary data structures.
27032693
*/
@@ -3463,12 +3453,11 @@ object Types {
34633453
tp.derivedClassInfo(pre)
34643454
protected def derivedJavaArrayType(tp: JavaArrayType, elemtp: Type): Type =
34653455
tp.derivedJavaArrayType(elemtp)
3466-
protected def derivedMethodType(tp: MethodType, formals: List[Type], restpe: Type): Type =
3467-
tp.derivedMethodType(tp.paramNames, formals, restpe)
34683456
protected def derivedExprType(tp: ExprType, restpe: Type): Type =
34693457
tp.derivedExprType(restpe)
3470-
protected def derivedPolyType(tp: PolyType, pbounds: List[TypeBounds], restpe: Type): Type =
3471-
tp.derivedPolyType(tp.paramNames, pbounds, restpe)
3458+
// note: currying needed because Scala2 does not support param-dependencies
3459+
protected def derivedLambdaType(tp: LambdaType)(formals: List[tp.PInfo], restpe: Type): Type =
3460+
tp.derivedLambdaType(tp.paramNames, formals, restpe)
34723461

34733462
/** Map this function over given type */
34743463
def mapOver(tp: Type): Type = {
@@ -3503,7 +3492,7 @@ object Types {
35033492
variance = -variance
35043493
val ptypes1 = tp.paramInfos mapConserve this
35053494
variance = -variance
3506-
derivedMethodType(tp, ptypes1, this(tp.resultType))
3495+
derivedLambdaType(tp)(ptypes1, this(tp.resultType))
35073496
}
35083497
mapOverMethod
35093498

@@ -3515,7 +3504,7 @@ object Types {
35153504
variance = -variance
35163505
val bounds1 = tp.paramInfos.mapConserve(this).asInstanceOf[List[TypeBounds]]
35173506
variance = -variance
3518-
derivedPolyType(tp, bounds1, this(tp.resultType))
3507+
derivedLambdaType(tp)(bounds1, this(tp.resultType))
35193508
}
35203509
mapOverPoly
35213510

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class ClassfileParser(
199199
def stripOuterParamFromConstructor() = innerClasses.get(currentClassName) match {
200200
case Some(entry) if !isStatic(entry.jflags) =>
201201
val mt @ MethodTpe(paramNames, paramTypes, resultType) = denot.info
202-
denot.info = mt.derivedMethodType(paramNames.tail, paramTypes.tail, resultType)
202+
denot.info = mt.derivedLambdaType(paramNames.tail, paramTypes.tail, resultType)
203203
case _ =>
204204
}
205205

@@ -209,7 +209,7 @@ class ClassfileParser(
209209
def normalizeConstructorInfo() = {
210210
val mt @ MethodType(paramNames) = denot.info
211211
val rt = classRoot.typeRef appliedTo (classRoot.typeParams map (_.typeRef))
212-
denot.info = mt.derivedMethodType(paramNames, mt.paramInfos, rt)
212+
denot.info = mt.derivedLambdaType(paramNames, mt.paramInfos, rt)
213213
addConstructorTypeParams(denot)
214214
}
215215

@@ -975,7 +975,7 @@ class ClassfileParser(
975975
if (name == nme.CONSTRUCTOR)
976976
tpe match {
977977
case tp: MethodType =>
978-
tp.derivedMethodType(tp.paramNames, tp.paramInfos, ownerTpe)
978+
tp.derivedLambdaType(tp.paramNames, tp.paramInfos, ownerTpe)
979979
}
980980
p = (name, tpe)
981981
values(index) = p

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ object Scala2Unpickler {
6565
case _ =>
6666
elemtp0
6767
}
68-
tp.derivedMethodType(
68+
tp.derivedLambdaType(
6969
tp.paramNames,
7070
tp.paramInfos.init :+ defn.RepeatedParamType.appliedTo(elemtp),
7171
tp.resultType)
7272
case tp: PolyType =>
73-
tp.derivedPolyType(tp.paramNames, tp.paramInfos, arrayToRepeated(tp.resultType))
73+
tp.derivedLambdaType(tp.paramNames, tp.paramInfos, arrayToRepeated(tp.resultType))
7474
}
7575

7676
def ensureConstructor(cls: ClassSymbol, scope: Scope)(implicit ctx: Context) =

compiler/src/dotty/tools/dotc/transform/ElimErasedValueType.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ElimErasedValueType extends MiniPhaseTransform with InfoTransformer {
4646
case tp: MethodType =>
4747
val paramTypes = tp.paramInfos.mapConserve(elimEVT)
4848
val retType = elimEVT(tp.resultType)
49-
tp.derivedMethodType(tp.paramNames, paramTypes, retType)
49+
tp.derivedLambdaType(tp.paramNames, paramTypes, retType)
5050
case _ =>
5151
tp
5252
}

compiler/src/dotty/tools/dotc/transform/ElimRepeated.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ class ElimRepeated extends MiniPhaseTransform with InfoTransformer with Annotati
5555
val last = paramTypes.last.underlyingIfRepeated(tp.isJava)
5656
paramTypes.init :+ last
5757
} else paramTypes
58-
tp.derivedMethodType(paramNames, paramTypes1, resultType1)
58+
tp.derivedLambdaType(paramNames, paramTypes1, resultType1)
5959
case tp: PolyType =>
60-
tp.derivedPolyType(tp.paramNames, tp.paramInfos, elimRepeated(tp.resultType))
60+
tp.derivedLambdaType(tp.paramNames, tp.paramInfos, elimRepeated(tp.resultType))
6161
case tp =>
6262
tp
6363
}
@@ -139,10 +139,10 @@ class ElimRepeated extends MiniPhaseTransform with InfoTransformer with Annotati
139139
/** Convert type from Scala to Java varargs method */
140140
private def toJavaVarArgs(tp: Type)(implicit ctx: Context): Type = tp match {
141141
case tp: PolyType =>
142-
tp.derivedPolyType(tp.paramNames, tp.paramInfos, toJavaVarArgs(tp.resultType))
142+
tp.derivedLambdaType(tp.paramNames, tp.paramInfos, toJavaVarArgs(tp.resultType))
143143
case tp: MethodType =>
144144
val inits :+ last = tp.paramInfos
145145
val last1 = last.underlyingIfRepeated(isJava = true)
146-
tp.derivedMethodType(tp.paramNames, inits :+ last1, tp.resultType)
146+
tp.derivedLambdaType(tp.paramNames, inits :+ last1, tp.resultType)
147147
}
148148
}

compiler/src/dotty/tools/dotc/transform/ExplicitOuter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ object ExplicitOuter {
331331
def addParam(cls: ClassSymbol, tp: Type): Type =
332332
if (hasOuterParam(cls)) {
333333
val mt @ MethodTpe(pnames, ptypes, restpe) = tp
334-
mt.derivedMethodType(
334+
mt.derivedLambdaType(
335335
nme.OUTER :: pnames, cls.owner.enclosingClass.typeRef :: ptypes, restpe)
336336
} else tp
337337

compiler/src/dotty/tools/dotc/transform/FullParameterization.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ object FullParameterization {
256256
case MethodTpe(nme.SELF :: Nil, _, restpe) =>
257257
restpe.ensureMethodic.signature
258258
case info @ MethodTpe(nme.SELF :: otherNames, thisType :: otherTypes, restpe) =>
259-
info.derivedMethodType(otherNames, otherTypes, restpe).signature
259+
info.derivedLambdaType(otherNames, otherTypes, restpe).signature
260260
case _ =>
261261
Signature.NotAMethod
262262
}

compiler/src/dotty/tools/dotc/transform/ShortcutImplicits.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ class ShortcutImplicits extends MiniPhase with IdentityDenotTransformer { thisTr
8282
* @return The type of the `apply` member of `implicit Ts => R`.
8383
*/
8484
private def directInfo(info: Type)(implicit ctx: Context): Type = info match {
85-
case info: PolyType => info.derivedPolyType(resType = directInfo(info.resultType))
86-
case info: MethodType => info.derivedMethodType(resType = directInfo(info.resultType))
85+
case info: PolyType => info.derivedLambdaType(resType = directInfo(info.resultType))
86+
case info: MethodType => info.derivedLambdaType(resType = directInfo(info.resultType))
8787
case info: ExprType => directInfo(info.resultType)
8888
case info => info.member(nme.apply).info
8989
}

compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class SuperAccessors(thisTransformer: DenotTransformer) {
178178
val accType = {
179179
def accTypeOf(tpe: Type): Type = tpe match {
180180
case tpe: PolyType =>
181-
tpe.derivedPolyType(tpe.paramNames, tpe.paramInfos, accTypeOf(tpe.resultType))
181+
tpe.derivedLambdaType(tpe.paramNames, tpe.paramInfos, accTypeOf(tpe.resultType))
182182
case _ =>
183183
MethodType(receiverType :: Nil)(mt => tpe.substThis(sym.owner.asClass, mt.newParamRef(0)))
184184
}
@@ -230,7 +230,7 @@ class SuperAccessors(thisTransformer: DenotTransformer) {
230230
else clazz.classInfo.selfType
231231
def accTypeOf(tpe: Type): Type = tpe match {
232232
case tpe: PolyType =>
233-
tpe.derivedPolyType(tpe.paramNames, tpe.paramInfos, accTypeOf(tpe.resultType))
233+
tpe.derivedLambdaType(tpe.paramNames, tpe.paramInfos, accTypeOf(tpe.resultType))
234234
case _ =>
235235
MethodType(receiverType :: Nil)(mt => tpe.substThis(sym.owner.asClass, mt.newParamRef(0)))
236236
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
11181118
case mt: ImplicitMethodType =>
11191119
resultTypeApprox(mt)
11201120
case pt: PolyType =>
1121-
pt.derivedPolyType(pt.paramNames, pt.paramInfos, stripImplicit(pt.resultType))
1121+
pt.derivedLambdaType(pt.paramNames, pt.paramInfos, stripImplicit(pt.resultType))
11221122
case _ =>
11231123
tp
11241124
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ object ErrorReporting {
105105
def whyNoMatchStr(found: Type, expected: Type) = {
106106
def dropJavaMethod(tp: Type): Type = tp match {
107107
case tp: PolyType =>
108-
tp.derivedPolyType(resType = dropJavaMethod(tp.resultType))
108+
tp.derivedLambdaType(resType = dropJavaMethod(tp.resultType))
109109
case tp: JavaMethodType =>
110110
MethodType(tp.paramNames, tp.paramInfos, dropJavaMethod(tp.resultType))
111111
case tp => tp

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ object Inliner {
108108

109109
// Add qualifier type as leading method argument to argument `tp`
110110
def addQualType(tp: Type): Type = tp match {
111-
case tp: PolyType => tp.derivedPolyType(tp.paramNames, tp.paramInfos, addQualType(tp.resultType))
111+
case tp: PolyType => tp.derivedLambdaType(tp.paramNames, tp.paramInfos, addQualType(tp.resultType))
112112
case tp: ExprType => addQualType(tp.resultType)
113113
case tp => MethodType(qualType :: Nil, tp)
114114
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ object ProtoTypes {
444444
val rt = normalize(mt.resultType, pt)
445445
pt match {
446446
case pt: IgnoredProto => mt
447-
case pt: ApplyingProto => mt.derivedMethodType(mt.paramNames, mt.paramInfos, rt)
447+
case pt: ApplyingProto => mt.derivedLambdaType(mt.paramNames, mt.paramInfos, rt)
448448
case _ =>
449449
val ft = defn.FunctionOf(mt.paramInfos, rt)
450450
if (mt.paramInfos.nonEmpty || ft <:< pt) ft else rt

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ trait TypeAssigner {
364364
if (gapBuf.isEmpty) resultType1
365365
else {
366366
val gaps = gapBuf.toList
367-
pt.derivedPolyType(
367+
pt.derivedLambdaType(
368368
gaps.map(paramNames),
369369
gaps.map(idx => transform(pt.paramInfos(idx)).bounds),
370370
resultType1)

0 commit comments

Comments
 (0)