@@ -3982,22 +3982,26 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3982
3982
3983
3983
/** Convert constructor proxy reference to a new expression */
3984
3984
def newExpr =
3985
- val Select (qual, nme.apply) = tree : @ unchecked
3986
- val tycon = tree.tpe.widen.finalResultType.underlyingClassRef(refinementOK = false )
3985
+ val qual = qualifier(tree)
3987
3986
val tpt = qual match
3988
3987
case Ident (name) =>
3989
3988
cpy.Ident (qual)(name.toTypeName)
3990
3989
case Select (pre, name) =>
3991
3990
cpy.Select (qual)(pre, name.toTypeName)
3992
3991
case qual : This if qual.symbol.is(ModuleClass ) =>
3993
3992
cpy.Ident (qual)(qual.symbol.name.sourceModuleName.toTypeName)
3993
+ val tycon = tree.tpe.widen.finalResultType.underlyingClassRef(refinementOK = false )
3994
3994
typed(
3995
3995
untpd.Select (
3996
3996
untpd.New (untpd.TypedSplice (tpt.withType(tycon))),
3997
3997
nme.CONSTRUCTOR ),
3998
3998
pt)
3999
3999
.showing(i " convert creator $tree -> $result" , typr)
4000
4000
4001
+ def isApplyProxy (tree : Tree ) = tree match
4002
+ case Select (_, nme.apply) => tree.symbol.isAllOf(ApplyProxyFlags )
4003
+ case _ => false
4004
+
4001
4005
tree match {
4002
4006
case _ : MemberDef | _ : PackageDef | _ : Import | _ : WithoutTypeOrPos [? ] | _ : Closure => tree
4003
4007
case _ => tree.tpe.widen match {
@@ -4013,7 +4017,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
4013
4017
adaptOverloaded(ref)
4014
4018
}
4015
4019
case poly : PolyType if ! (ctx.mode is Mode .Type ) =>
4016
- if tree.symbol.isAllOf( ApplyProxyFlags ) then newExpr
4020
+ if isApplyProxy(tree ) then newExpr
4017
4021
else if pt.isInstanceOf [PolyProto ] then tree
4018
4022
else
4019
4023
var typeArgs = tree match
@@ -4027,7 +4031,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
4027
4031
readaptSimplified(handleStructural(tree))
4028
4032
else pt match {
4029
4033
case pt : FunProto =>
4030
- if tree.symbol.isAllOf( ApplyProxyFlags ) then newExpr
4034
+ if isApplyProxy(tree ) then newExpr
4031
4035
else adaptToArgs(wtp, pt)
4032
4036
case pt : PolyProto if ! wtp.isImplicitMethod =>
4033
4037
tryInsertApplyOrImplicit(tree, pt, locked)(tree) // error will be reported in typedTypeApply
0 commit comments