Skip to content

Commit 107ccfd

Browse files
committed
Streamline companion selection in MethodType
1 parent 2f38758 commit 107ccfd

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
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-
isImplicit = false,
134133
isContextual = name.isImplicitFunction,
134+
isImplicit = 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, isImplicit: Boolean = false, isErased: Boolean = false, isContextual: Boolean = false): MethodTypeCompanion = {
3288+
def companion(isJava: Boolean = false, isContextual: Boolean = false, isImplicit: Boolean = false, isErased: Boolean = false): MethodTypeCompanion = {
32893289
if (isJava) {
32903290
assert(!isImplicit)
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-
def isImplicit =
771-
tag == IMPLICITMETHODtpe ||
772-
params.nonEmpty && (params.head is Implicit)
773-
val maker = MethodType.maker(isImplicit = isImplicit)
770+
val maker = MethodType.companion(
771+
isImplicit = tag == IMPLICITMETHODtpe || params.nonEmpty && params.head.is(Implicit))
774772
maker.fromSymbols(params, restpe)
775773
case POLYtpe =>
776774
val restpe = readTypeRef()

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ trait NamerContextOps { this: Context =>
134134
def methodType(typeParams: List[Symbol], valueParamss: List[List[Symbol]], resultType: Type, isJava: Boolean = false)(implicit ctx: Context): Type = {
135135
val monotpe =
136136
(valueParamss :\ resultType) { (params, resultType) =>
137-
val (isImplicit, isErased, isContextual) =
137+
val (isContextual, isImplicit, isErased) =
138138
if (params.isEmpty) (false, false, false)
139-
else (params.head is Implicit, params.head is Erased, params.head.is(Given))
140-
val make = MethodType.maker(isJava = isJava, isImplicit = isImplicit, isErased = isErased, isContextual = isContextual)
139+
else (params.head.is(Given), params.head.is(Implicit), params.head.is(Erased))
140+
val make = MethodType.companion(isJava = isJava, isContextual = isContextual, isImplicit = isImplicit, 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)