@@ -68,7 +68,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
6868 override def isType : Boolean = body.isType
6969 }
7070
71- /** A function type with `implicit`, `erased`, or `contextual ` modifiers */
71+ /** A function type with `implicit`, `erased`, or `given ` modifiers */
7272 class FunctionWithMods (args : List [Tree ], body : Tree , val mods : Modifiers )(implicit @ constructorOnly src : SourceFile )
7373 extends Function (args, body)
7474
@@ -343,7 +343,13 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
343343 * navigation into these arguments from the IDE, and to do the right thing in
344344 * PrepareInlineable.
345345 */
346- def New (tpt : Tree , argss : List [List [Tree ]])(implicit ctx : Context ): Tree = {
346+ def New (tpt : Tree , argss : List [List [Tree ]])(implicit ctx : Context ): Tree =
347+ ensureApplied((makeNew(tpt) /: argss)(Apply (_, _)))
348+
349+ /** A new expression with constrictor and possibly type arguments. See
350+ * `New(tpt, argss)` for details.
351+ */
352+ def makeNew (tpt : Tree )(implicit ctx : Context ): Tree = {
347353 val (tycon, targs) = tpt match {
348354 case AppliedTypeTree (tycon, targs) =>
349355 (tycon, targs)
@@ -354,9 +360,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
354360 case _ =>
355361 (tpt, Nil )
356362 }
357- var prefix : Tree = Select (New (tycon), nme.CONSTRUCTOR )
358- if (targs.nonEmpty) prefix = TypeApply (prefix, targs)
359- ensureApplied((prefix /: argss)(Apply (_, _)))
363+ val nu : Tree = Select (New (tycon), nme.CONSTRUCTOR )
364+ if (targs.nonEmpty) TypeApply (nu, targs) else nu
360365 }
361366
362367 def Block (stat : Tree , expr : Tree )(implicit src : SourceFile ): Block =
0 commit comments