Skip to content

Commit f809ec4

Browse files
committed
Correct handling of overloaded methods with PolyFunction args
Overloaded methods must have distinct signatures after erasure. The check for this happens before PolyFunctions have been mapped to the corresponding FunctionN so will always be considered as erasing to the same type (PolyFunction without any refinement). To avoid this we perform the PolyFunction to FunctionN mapping in the method signature computation.
1 parent 6db3ba4 commit f809ec4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3194,8 +3194,17 @@ object Types {
31943194
companion.eq(ContextualMethodType) ||
31953195
companion.eq(ErasedContextualMethodType)
31963196

3197+
31973198
def computeSignature(implicit ctx: Context): Signature = {
3198-
val params = if (isErasedMethod) Nil else paramInfos
3199+
def polyFunctionSignature(tp: Type): Type = tp match {
3200+
case RefinedType(parent, nme.apply, refinedInfo) if parent.typeSymbol eq defn.PolyFunctionClass =>
3201+
val res = refinedInfo.resultType
3202+
val paramss = res.paramNamess
3203+
defn.FunctionType(paramss.head.length)
3204+
case _ => tp
3205+
}
3206+
3207+
val params = if (isErasedMethod) Nil else paramInfos.mapConserve(polyFunctionSignature)
31993208
resultSignature.prepend(params, isJavaMethod)
32003209
}
32013210

0 commit comments

Comments
 (0)