@@ -20,7 +20,7 @@ object ContextFunctionResults:
20
20
*/
21
21
def annotateContextResults (mdef : DefDef )(using Context ): Unit =
22
22
def contextResultCount (rhs : Tree , tp : Type ): Int = tp match
23
- case defn.ContextFunctionType (_, resTpe, _ ) =>
23
+ case defn.ContextFunctionType (_, resTpe) =>
24
24
rhs match
25
25
case closureDef(meth) => 1 + contextResultCount(meth.rhs, resTpe)
26
26
case _ => 0
@@ -58,7 +58,8 @@ object ContextFunctionResults:
58
58
*/
59
59
def contextResultsAreErased (sym : Symbol )(using Context ): Boolean =
60
60
def allErased (tp : Type ): Boolean = tp.dealias match
61
- case defn.ContextFunctionType (_, resTpe, erasedParams) => ! erasedParams.contains(false ) && allErased(resTpe)
61
+ case defn.ContextFunctionType (argTpes, resTpe) =>
62
+ argTpes.forall(_.hasAnnotation(defn.ErasedParamAnnot )) && allErased(resTpe)
62
63
case _ => true
63
64
contextResultCount(sym) > 0 && allErased(sym.info.finalResultType)
64
65
@@ -72,7 +73,7 @@ object ContextFunctionResults:
72
73
integrateContextResults(rt, crCount)
73
74
case tp : MethodOrPoly =>
74
75
tp.derivedLambdaType(resType = integrateContextResults(tp.resType, crCount))
75
- case defn.ContextFunctionType (argTypes, resType, erasedParams ) =>
76
+ case defn.ContextFunctionType (argTypes, resType) =>
76
77
MethodType (argTypes, integrateContextResults(resType, crCount - 1 ))
77
78
78
79
/** The total number of parameters of method `sym`, not counting
@@ -83,9 +84,10 @@ object ContextFunctionResults:
83
84
def contextParamCount (tp : Type , crCount : Int ): Int =
84
85
if crCount == 0 then 0
85
86
else
86
- val defn .ContextFunctionType (params, resTpe, erasedParams ) = tp : @ unchecked
87
+ val defn .ContextFunctionType (params, resTpe) = tp : @ unchecked
87
88
val rest = contextParamCount(resTpe, crCount - 1 )
88
- if erasedParams.contains(true ) then erasedParams.count(_ == false ) + rest else params.length + rest
89
+ val nonErasedParams = params.count(! _.hasAnnotation(defn.ErasedParamAnnot ))
90
+ nonErasedParams + rest
89
91
90
92
def normalParamCount (tp : Type ): Int = tp.widenExpr.stripPoly match
91
93
case mt @ MethodType (pnames) =>
@@ -103,7 +105,7 @@ object ContextFunctionResults:
103
105
def recur (tp : Type , n : Int ): Type =
104
106
if n == 0 then tp
105
107
else tp match
106
- case defn.ContextFunctionType (_, resTpe, _ ) => recur(resTpe, n - 1 )
108
+ case defn.ContextFunctionType (_, resTpe) => recur(resTpe, n - 1 )
107
109
recur(meth.info.finalResultType, depth)
108
110
109
111
/** Should selection `tree` be eliminated since it refers to an `apply`
@@ -118,7 +120,7 @@ object ContextFunctionResults:
118
120
case Select (qual, name) =>
119
121
if name == nme.apply then
120
122
qual.tpe match
121
- case defn.ContextFunctionType (_, _, _ ) =>
123
+ case defn.ContextFunctionType (_, _) =>
122
124
integrateSelect(qual, n + 1 )
123
125
case _ if defn.isContextFunctionClass(tree.symbol.maybeOwner) => // for TermRefs
124
126
integrateSelect(qual, n + 1 )
0 commit comments