@@ -20,7 +20,7 @@ object ContextFunctionResults:
2020 */
2121 def annotateContextResults (mdef : DefDef )(using Context ): Unit =
2222 def contextResultCount (rhs : Tree , tp : Type ): Int = tp match
23- case defn.ContextFunctionType (_, resTpe, _ ) =>
23+ case defn.ContextFunctionType (_, resTpe) =>
2424 rhs match
2525 case closureDef(meth) => 1 + contextResultCount(meth.rhs, resTpe)
2626 case _ => 0
@@ -58,7 +58,8 @@ object ContextFunctionResults:
5858 */
5959 def contextResultsAreErased (sym : Symbol )(using Context ): Boolean =
6060 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)
6263 case _ => true
6364 contextResultCount(sym) > 0 && allErased(sym.info.finalResultType)
6465
@@ -72,7 +73,7 @@ object ContextFunctionResults:
7273 integrateContextResults(rt, crCount)
7374 case tp : MethodOrPoly =>
7475 tp.derivedLambdaType(resType = integrateContextResults(tp.resType, crCount))
75- case defn.ContextFunctionType (argTypes, resType, erasedParams ) =>
76+ case defn.ContextFunctionType (argTypes, resType) =>
7677 MethodType (argTypes, integrateContextResults(resType, crCount - 1 ))
7778
7879 /** The total number of parameters of method `sym`, not counting
@@ -83,10 +84,10 @@ object ContextFunctionResults:
8384 def contextParamCount (tp : Type , crCount : Int ): Int =
8485 if crCount == 0 then 0
8586 else
86- val defn .ContextFunctionType (params, resTpe, erasedParams ) = tp : @ unchecked
87+ val defn .ContextFunctionType (params, resTpe) = tp : @ unchecked
8788 val rest = contextParamCount(resTpe, crCount - 1 )
88- // TODO use mt.nonErasedParamCount
89- if erasedParams.contains( true ) then erasedParams.count(_ == false ) + rest else params.length + rest // TODO use mt.nonErasedParamCount
89+ val nonErasedParams = params.count( ! _.hasAnnotation(defn. ErasedParamAnnot ))
90+ nonErasedParams + rest
9091
9192 def normalParamCount (tp : Type ): Int = tp.widenExpr.stripPoly match
9293 case mt @ MethodType (pnames) => mt.nonErasedParamCount + normalParamCount(mt.resType)
@@ -100,7 +101,7 @@ object ContextFunctionResults:
100101 def recur (tp : Type , n : Int ): Type =
101102 if n == 0 then tp
102103 else tp match
103- case defn.ContextFunctionType (_, resTpe, _ ) => recur(resTpe, n - 1 )
104+ case defn.ContextFunctionType (_, resTpe) => recur(resTpe, n - 1 )
104105 recur(meth.info.finalResultType, depth)
105106
106107 /** Should selection `tree` be eliminated since it refers to an `apply`
@@ -115,7 +116,7 @@ object ContextFunctionResults:
115116 case Select (qual, name) =>
116117 if name == nme.apply then
117118 qual.tpe match
118- case defn.ContextFunctionType (_, _, _ ) =>
119+ case defn.ContextFunctionType (_, _) =>
119120 integrateSelect(qual, n + 1 )
120121 case _ if defn.isContextFunctionClass(tree.symbol.maybeOwner) => // for TermRefs
121122 integrateSelect(qual, n + 1 )
0 commit comments