Skip to content

Commit 30faeb2

Browse files
committed
Add MethodType.nonErasedParamCount
1 parent 41d45a7 commit 30faeb2

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ object TypeErasure {
567567
functionType(info.resultType)
568568
case info: MethodType =>
569569
assert(!info.resultType.isInstanceOf[MethodicType])
570-
defn.FunctionType(n = info.erasedParams.count(_ == false))
570+
defn.FunctionType(n = info.nonErasedParamCount)
571571
}
572572
erasure(functionType(applyInfo))
573573
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4021,6 +4021,10 @@ object Types {
40214021
override def erasedParams(using Context): List[Boolean] =
40224022
paramInfos.map(p => p.hasAnnotation(defn.ErasedParamAnnot))
40234023

4024+
def nonErasedParamCount(using Context): Int =
4025+
paramInfos.count(p => !p.hasAnnotation(defn.ErasedParamAnnot))
4026+
4027+
40244028
protected def prefixString: String = companion.prefixString
40254029
}
40264030

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ object ContextFunctionResults:
8585
else
8686
val defn.ContextFunctionType(params, resTpe, erasedParams) = tp: @unchecked
8787
val rest = contextParamCount(resTpe, crCount - 1)
88-
if erasedParams.contains(true) then erasedParams.count(_ == false) + rest else params.length + rest
88+
if erasedParams.contains(true) then erasedParams.count(_ == false) + rest else params.length + rest // TODO use mt.nonErasedParamCount
8989

9090
def normalParamCount(tp: Type): Int = tp.widenExpr.stripPoly match
9191
case mt @ MethodType(pnames) =>
9292
val rest = normalParamCount(mt.resType)
9393
if mt.hasErasedParams then
94-
mt.erasedParams.count(_ == false) + rest
94+
mt.nonErasedParamCount + rest
9595
else pnames.length + rest
9696
case _ => contextParamCount(tp, contextResultCount(sym))
9797

0 commit comments

Comments
 (0)