@@ -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
@@ -352,7 +352,13 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
352352 * navigation into these arguments from the IDE, and to do the right thing in
353353 * PrepareInlineable.
354354 */
355- def New (tpt : Tree , argss : List [List [Tree ]])(implicit ctx : Context ): Tree = {
355+ def New (tpt : Tree , argss : List [List [Tree ]])(implicit ctx : Context ): Tree =
356+ ensureApplied((makeNew(tpt) /: argss)(Apply (_, _)))
357+
358+ /** A new expression with constrictor and possibly type arguments. See
359+ * `New(tpt, argss)` for details.
360+ */
361+ def makeNew (tpt : Tree )(implicit ctx : Context ): Tree = {
356362 val (tycon, targs) = tpt match {
357363 case AppliedTypeTree (tycon, targs) =>
358364 (tycon, targs)
@@ -363,9 +369,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
363369 case _ =>
364370 (tpt, Nil )
365371 }
366- var prefix : Tree = Select (New (tycon), nme.CONSTRUCTOR )
367- if (targs.nonEmpty) prefix = TypeApply (prefix, targs)
368- ensureApplied((prefix /: argss)(Apply (_, _)))
372+ val nu : Tree = Select (New (tycon), nme.CONSTRUCTOR )
373+ if (targs.nonEmpty) TypeApply (nu, targs) else nu
369374 }
370375
371376 def Block (stat : Tree , expr : Tree )(implicit src : SourceFile ): Block =
0 commit comments