File tree 4 files changed +14
-14
lines changed
compiler/src/dotty/tools/dotc
4 files changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -567,7 +567,7 @@ object TypeErasure {
567
567
functionType(info.resultType)
568
568
case info : MethodType =>
569
569
assert(! info.resultType.isInstanceOf [MethodicType ])
570
- defn.FunctionType (n = info.erasedParams.count(_ == false ) )
570
+ defn.FunctionType (n = info.nonErasedParamCount )
571
571
}
572
572
erasure(functionType(applyInfo))
573
573
}
Original file line number Diff line number Diff line change @@ -3724,8 +3724,6 @@ object Types {
3724
3724
3725
3725
def companion : LambdaTypeCompanion [ThisName , PInfo , This ]
3726
3726
3727
- def erasedParams (using Context ) = List .fill(paramInfos.size)(false )
3728
-
3729
3727
/** The type `[tparams := paramRefs] tp`, where `tparams` can be
3730
3728
* either a list of type parameter symbols or a list of lambda parameters
3731
3729
*
@@ -4017,13 +4015,18 @@ object Types {
4017
4015
final override def isImplicitMethod : Boolean =
4018
4016
companion.eq(ImplicitMethodType ) || isContextualMethod
4019
4017
final override def hasErasedParams (using Context ): Boolean =
4020
- erasedParams.contains(true )
4018
+ paramInfos.exists(p => p.hasAnnotation(defn.ErasedParamAnnot ))
4019
+
4021
4020
final override def isContextualMethod : Boolean =
4022
4021
companion.eq(ContextualMethodType )
4023
4022
4024
- override def erasedParams (using Context ): List [Boolean ] =
4023
+ def erasedParams (using Context ): List [Boolean ] =
4025
4024
paramInfos.map(p => p.hasAnnotation(defn.ErasedParamAnnot ))
4026
4025
4026
+ def nonErasedParamCount (using Context ): Int =
4027
+ paramInfos.count(p => ! p.hasAnnotation(defn.ErasedParamAnnot ))
4028
+
4029
+
4027
4030
protected def prefixString : String = companion.prefixString
4028
4031
}
4029
4032
Original file line number Diff line number Diff line change @@ -297,10 +297,10 @@ class PlainPrinter(_ctx: Context) extends Printer {
297
297
" (" ~ toTextRef(tp) ~ " : " ~ toTextGlobal(tp.underlying) ~ " )"
298
298
299
299
protected def paramsText (lam : LambdaType ): Text = {
300
- val erasedParams = lam.erasedParams
301
- def paramText ( ref : ParamRef , erased : Boolean ) =
300
+ def paramText ( ref : ParamRef ) =
301
+ val erased = ref.underlying.hasAnnotation(defn. ErasedParamAnnot )
302
302
keywordText(" erased " ).provided(erased) ~ ParamRefNameString (ref) ~ lambdaHash(lam) ~ toTextRHS(ref.underlying, isParameter = true )
303
- Text (lam.paramRefs.lazyZip(erasedParams). map(paramText), " , " )
303
+ Text (lam.paramRefs.map(paramText), " , " )
304
304
}
305
305
306
306
protected def ParamRefNameString (name : Name ): String = nameString(name)
Original file line number Diff line number Diff line change @@ -85,14 +85,11 @@ object ContextFunctionResults:
85
85
else
86
86
val defn .ContextFunctionType (params, resTpe, erasedParams) = tp : @ unchecked
87
87
val rest = contextParamCount(resTpe, crCount - 1 )
88
- if erasedParams.contains(true ) then erasedParams.count(_ == false ) + rest else params.length + rest
88
+ // TODO use mt.nonErasedParamCount
89
+ if erasedParams.contains(true ) then erasedParams.count(_ == false ) + rest else params.length + rest // TODO use mt.nonErasedParamCount
89
90
90
91
def normalParamCount (tp : Type ): Int = tp.widenExpr.stripPoly match
91
- case mt @ MethodType (pnames) =>
92
- val rest = normalParamCount(mt.resType)
93
- if mt.hasErasedParams then
94
- mt.erasedParams.count(_ == false ) + rest
95
- else pnames.length + rest
92
+ case mt @ MethodType (pnames) => mt.nonErasedParamCount + normalParamCount(mt.resType)
96
93
case _ => contextParamCount(tp, contextResultCount(sym))
97
94
98
95
normalParamCount(sym.info)
You can’t perform that action at this time.
0 commit comments