Skip to content

Commit 3e0551d

Browse files
committed
Streamline companion selection in MethodType
1 parent 6792b34 commit 3e0551d

File tree

5 files changed

+7
-9
lines changed

5 files changed

+7
-9
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ class Definitions {
128128
enterTypeParam(cls, paramNamePrefix ++ "T" ++ (i + 1).toString, Contravariant, decls).typeRef
129129
}
130130
val resParamRef = enterTypeParam(cls, paramNamePrefix ++ "R", Covariant, decls).typeRef
131-
val methodType = MethodType.maker(
131+
val methodType = MethodType.companion(
132132
isJava = false,
133-
isOldImplicit = false,
134133
isContextual = name.isImplicitFunction,
134+
isOldImplicit = false,
135135
isErased = name.isErasedFunction)
136136
decls.enter(newMethod(cls, nme.apply, methodType(argParamRefs, resParamRef), Deferred))
137137
denot.info =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3285,7 +3285,7 @@ object Types {
32853285
}
32863286

32873287
object MethodType extends MethodTypeCompanion("MethodType") {
3288-
def maker(isJava: Boolean = false, isOldImplicit: Boolean = false, isErased: Boolean = false, isContextual: Boolean = false): MethodTypeCompanion = {
3288+
def companion(isJava: Boolean = false, isContextual: Boolean = false, isOldImplicit: Boolean = false, isErased: Boolean = false): MethodTypeCompanion = {
32893289
if (isJava) {
32903290
assert(!isOldImplicit)
32913291
assert(!isErased)

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -767,10 +767,8 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
767767
case METHODtpe | IMPLICITMETHODtpe =>
768768
val restpe = readTypeRef()
769769
val params = until(end, () => readSymbolRef())
770-
val isOldImplicit =
771-
tag == IMPLICITMETHODtpe ||
772-
params.nonEmpty && (params.head is OldImplicit)
773-
val maker = MethodType.maker(isOldImplicit = isOldImplicit)
770+
val maker = MethodType.companion(
771+
isOldImplicit = tag == IMPLICITMETHODtpe || params.nonEmpty && (params.head is OldImplicit))
774772
maker.fromSymbols(params, restpe)
775773
case POLYtpe =>
776774
val restpe = readTypeRef()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ trait NamerContextOps { this: Context =>
137137
val (isOldImplicit, isErased, isContextual) =
138138
if (params.isEmpty) (false, false, false)
139139
else (params.head is OldImplicit, params.head is Erased, params.head.is(Given))
140-
val make = MethodType.maker(isJava = isJava, isOldImplicit = isOldImplicit, isErased = isErased, isContextual = isContextual)
140+
val make = MethodType.companion(isJava = isJava, isContextual = isContextual, isOldImplicit = isOldImplicit, isErased = isErased)
141141
if (isJava)
142142
for (param <- params)
143143
if (param.info.isDirectRef(defn.ObjectClass)) param.info = defn.AnyType

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ class Typer extends Namer
819819
if (!funFlags.isEmpty)
820820
params1.foreach(_.symbol.setFlag(funFlags))
821821
val resultTpt = typed(body)
822-
val companion = MethodType.maker(
822+
val companion = MethodType.companion(
823823
isContextual = funFlags.is(Given), isErased = funFlags.is(Erased))
824824
val mt = companion.fromSymbols(params1.map(_.symbol), resultTpt.tpe)
825825
if (mt.isParamDependent)

0 commit comments

Comments
 (0)