@@ -805,49 +805,46 @@ object Erasure {
805
805
*/
806
806
override def typedApply (tree : untpd.Apply , pt : Type )(using Context ): Tree =
807
807
val Apply (fun, args) = tree
808
- if fun.symbol == defn.cbnArg then
809
- typedUnadapted(args.head, pt)
810
- else
811
- val origFun = fun.asInstanceOf [tpd.Tree ]
812
- val origFunType = origFun.tpe.widen(using preErasureCtx)
813
- val ownArgs = if origFunType.isErasedMethod then Nil else args
814
- val fun1 = typedExpr(fun, AnyFunctionProto )
815
- fun1.tpe.widen match
816
- case mt : MethodType =>
817
- val (xmt, // A method type like `mt` but with bunched arguments expanded to individual ones
818
- bunchArgs, // whether arguments are bunched
819
- outers) = // the outer reference parameter(s)
820
- if fun1.isInstanceOf [Apply ] then
821
- (mt, fun1.removeAttachment(BunchedArgs ).isDefined, Nil )
822
- else
823
- val xmt = expandedMethodType(mt, origFun)
824
- (xmt, xmt ne mt, outer.args(origFun))
825
-
826
- val args0 = outers ::: ownArgs
827
- val args1 = args0.zipWithConserve(xmt.paramInfos)(typedExpr)
828
- .asInstanceOf [List [Tree ]]
829
-
830
- def mkApply (finalFun : Tree , finalArgs : List [Tree ]) =
831
- val app = untpd.cpy.Apply (tree)(finalFun, finalArgs)
832
- .withType(applyResultType(xmt, args1))
833
- if bunchArgs then app.withAttachment(BunchedArgs , ()) else app
834
-
835
- def app (fun1 : Tree ): Tree = fun1 match
836
- case Block (stats, expr) =>
837
- cpy.Block (fun1)(stats, app(expr))
838
- case Apply (fun2, SeqLiteral (prevArgs, argTpt) :: _) if bunchArgs =>
839
- mkApply(fun2, JavaSeqLiteral (prevArgs ++ args1, argTpt) :: Nil )
840
- case Apply (fun2, prevArgs) =>
841
- mkApply(fun2, prevArgs ++ args1)
842
- case _ if bunchArgs =>
843
- mkApply(fun1, JavaSeqLiteral (args1, TypeTree (defn.ObjectType )) :: Nil )
844
- case _ =>
845
- mkApply(fun1, args1)
846
-
847
- app(fun1)
848
- case t =>
849
- if ownArgs.isEmpty then fun1
850
- else throw new MatchError (i " tree $tree has unexpected type of function $fun/ $fun1: $t, was $origFunType, args = $ownArgs" )
808
+ val origFun = fun.asInstanceOf [tpd.Tree ]
809
+ val origFunType = origFun.tpe.widen(using preErasureCtx)
810
+ val ownArgs = if origFunType.isErasedMethod then Nil else args
811
+ val fun1 = typedExpr(fun, AnyFunctionProto )
812
+ fun1.tpe.widen match
813
+ case mt : MethodType =>
814
+ val (xmt, // A method type like `mt` but with bunched arguments expanded to individual ones
815
+ bunchArgs, // whether arguments are bunched
816
+ outers) = // the outer reference parameter(s)
817
+ if fun1.isInstanceOf [Apply ] then
818
+ (mt, fun1.removeAttachment(BunchedArgs ).isDefined, Nil )
819
+ else
820
+ val xmt = expandedMethodType(mt, origFun)
821
+ (xmt, xmt ne mt, outer.args(origFun))
822
+
823
+ val args0 = outers ::: ownArgs
824
+ val args1 = args0.zipWithConserve(xmt.paramInfos)(typedExpr)
825
+ .asInstanceOf [List [Tree ]]
826
+
827
+ def mkApply (finalFun : Tree , finalArgs : List [Tree ]) =
828
+ val app = untpd.cpy.Apply (tree)(finalFun, finalArgs)
829
+ .withType(applyResultType(xmt, args1))
830
+ if bunchArgs then app.withAttachment(BunchedArgs , ()) else app
831
+
832
+ def app (fun1 : Tree ): Tree = fun1 match
833
+ case Block (stats, expr) =>
834
+ cpy.Block (fun1)(stats, app(expr))
835
+ case Apply (fun2, SeqLiteral (prevArgs, argTpt) :: _) if bunchArgs =>
836
+ mkApply(fun2, JavaSeqLiteral (prevArgs ++ args1, argTpt) :: Nil )
837
+ case Apply (fun2, prevArgs) =>
838
+ mkApply(fun2, prevArgs ++ args1)
839
+ case _ if bunchArgs =>
840
+ mkApply(fun1, JavaSeqLiteral (args1, TypeTree (defn.ObjectType )) :: Nil )
841
+ case _ =>
842
+ mkApply(fun1, args1)
843
+
844
+ app(fun1)
845
+ case t =>
846
+ if ownArgs.isEmpty then fun1
847
+ else throw new MatchError (i " tree $tree has unexpected type of function $fun/ $fun1: $t, was $origFunType, args = $ownArgs" )
851
848
end typedApply
852
849
853
850
// The following four methods take as the proto-type the erasure of the pre-existing type,
0 commit comments