@@ -2800,55 +2800,6 @@ class Typer extends Namer
28002800 case _ => false
28012801 }
28022802
2803- /** Try to rename `tpt` to a type `T` and typecheck `new T` with given expected type `pt`.
2804- * The operation is called from either `adapt` or `typedApply`. `adapt` gets to call `tryNew`
2805- * for calls `p.C(..)` if there is a value `p.C`. `typedApply` calls `tryNew` as a fallback
2806- * in case typing `p.C` fails since there is no value with path `p.C`. The call from `adapt`
2807- * is more efficient since it re-uses the prefix `p` in typed form.
2808- */
2809- def tryNew [T >: Untyped <: Type ]
2810- (treesInst : Instance [T ])(tree : Trees .Tree [T ], pt : Type , fallBack : TyperState => Tree )(using Context ): Tree = {
2811-
2812- def tryWithType (tpt : untpd.Tree ): Tree =
2813- tryEither {
2814- val tycon = typed(tpt)
2815- if (summon[Context ].reporter.hasErrors)
2816- EmptyTree // signal that we should return the error in fallBack
2817- else {
2818- def recur (tpt : Tree , pt : Type ): Tree = pt.revealIgnored match {
2819- case PolyProto (targs, pt1) if ! targs.exists(_.isInstanceOf [NamedArg ]) =>
2820- // Applications with named arguments cannot be converted, since new expressions
2821- // don't accept named arguments
2822- IntegratedTypeArgs (recur(AppliedTypeTree (tpt, targs), pt1))
2823- case _ =>
2824- typed(untpd.Select (untpd.New (untpd.TypedSplice (tpt)), nme.CONSTRUCTOR ), pt)
2825- }
2826- recur(tycon, pt)
2827- .showing(i " try new $tree -> $result" , typr)
2828- }
2829- } { (nu, nuState) =>
2830- if (nu.isEmpty) fallBack(nuState)
2831- else {
2832- // we found a type constructor, signal the error in its application instead of the original one
2833- nuState.commit()
2834- nu
2835- }
2836- }
2837-
2838- tree match {
2839- case Ident (name) =>
2840- tryWithType(cpy.Ident (tree)(name.toTypeName))
2841- case Select (qual, name) =>
2842- val qual1 = treesInst match {
2843- case `tpd` => untpd.TypedSplice (qual)
2844- case `untpd` => qual
2845- }
2846- tryWithType(cpy.Select (tree)(qual1, name.toTypeName))
2847- case _ =>
2848- fallBack(ctx.typerState)
2849- }
2850- }
2851-
28522803 /** Potentially add apply node or implicit conversions. Before trying either,
28532804 * if the function is applied to an empty parameter list (), we try
28542805 *
@@ -2885,10 +2836,7 @@ class Typer extends Namer
28852836 }
28862837
28872838 def tryImplicit (fallBack : => Tree ) =
2888- tryInsertImplicitOnQualifier(tree, pt.withContext(ctx), locked)
2889- .getOrElse(
2890- if Config .addConstructorProxies then fallBack
2891- else tryNew(tpd)(tree, pt, _ => fallBack))
2839+ tryInsertImplicitOnQualifier(tree, pt.withContext(ctx), locked).getOrElse(fallBack)
28922840
28932841 if (ctx.mode.is(Mode .SynthesizeExtMethodReceiver ))
28942842 // Suppress insertion of apply or implicit conversion on extension method receiver
@@ -3660,10 +3608,8 @@ class Typer extends Namer
36603608 adaptOverloaded(ref)
36613609 }
36623610 case poly : PolyType if ! (ctx.mode is Mode .Type ) =>
3663- if tree.symbol.isAllOf(ApplyProxyFlags ) && Config .addConstructorProxies then
3664- newExpr
3665- else if pt.isInstanceOf [PolyProto ] then
3666- tree
3611+ if tree.symbol.isAllOf(ApplyProxyFlags ) then newExpr
3612+ else if pt.isInstanceOf [PolyProto ] then tree
36673613 else
36683614 var typeArgs = tree match
36693615 case Select (qual, nme.CONSTRUCTOR ) => qual.tpe.widenDealias.argTypesLo.map(TypeTree )
@@ -3676,7 +3622,7 @@ class Typer extends Namer
36763622 readaptSimplified(handleStructural(tree))
36773623 else pt match {
36783624 case pt : FunProto =>
3679- if tree.symbol.isAllOf(ApplyProxyFlags ) && Config .addConstructorProxies then newExpr
3625+ if tree.symbol.isAllOf(ApplyProxyFlags ) then newExpr
36803626 else adaptToArgs(wtp, pt)
36813627 case pt : PolyProto =>
36823628 tree match {
0 commit comments