@@ -1875,23 +1875,25 @@ object Types {
1875
1875
* @param alwaysDependent if true, always create a dependent function type.
1876
1876
*/
1877
1877
def toFunctionType (isJava : Boolean , dropLast : Int = 0 , alwaysDependent : Boolean = false )(using Context ): Type = this match {
1878
- case mt : MethodType if ! mt.isParamDependent && ! mt.hasErasedParams =>
1879
- val formals1 = if (dropLast == 0 ) mt.paramInfos else mt.paramInfos dropRight dropLast
1880
- val isContextual = mt.isContextualMethod && ! ctx.erasedTypes
1881
- val result1 = mt.nonDependentResultApprox match {
1882
- case res : MethodType => res.toFunctionType(isJava)
1883
- case res => res
1884
- }
1885
- val funType = defn.FunctionOf (
1886
- formals1 mapConserve (_.translateFromRepeated(toArray = isJava)),
1887
- result1, isContextual)
1888
- if alwaysDependent || mt.isResultDependent then
1889
- RefinedType (funType, nme.apply, mt)
1890
- else funType
1891
- case mt : MethodType if ! mt.isParamDependent =>
1892
- assert(mt.hasErasedParams)
1893
- RefinedType (defn.ErasedFunctionType , nme.apply, mt)
1894
- case poly @ PolyType (_, mt : MethodType ) if ! mt.isParamDependent =>
1878
+ case mt : MethodType =>
1879
+ assert(! mt.isParamDependent)
1880
+ def nonDependentFunType =
1881
+ val formals1 = if (dropLast == 0 ) mt.paramInfos else mt.paramInfos dropRight dropLast
1882
+ val isContextual = mt.isContextualMethod && ! ctx.erasedTypes
1883
+ val result1 = mt.nonDependentResultApprox match {
1884
+ case res : MethodType => res.toFunctionType(isJava)
1885
+ case res => res
1886
+ }
1887
+ defn.FunctionOf (
1888
+ formals1 mapConserve (_.translateFromRepeated(toArray = isJava)),
1889
+ result1, isContextual)
1890
+ if mt.hasErasedParams then
1891
+ RefinedType (defn.ErasedFunctionType , nme.apply, mt)
1892
+ else if alwaysDependent || mt.isResultDependent then
1893
+ RefinedType (nonDependentFunType, nme.apply, mt)
1894
+ else nonDependentFunType
1895
+ case poly @ PolyType (_, mt : MethodType ) =>
1896
+ assert(! mt.isParamDependent)
1895
1897
RefinedType (defn.PolyFunctionType , nme.apply, poly)
1896
1898
}
1897
1899
0 commit comments