Skip to content

Commit 778ba12

Browse files
committed
Simplify newExpr
Formulate newExpr without recourse to IntegratedTypeArgs. Since with #10950 extension methods no lonnger require IntegratedTypeArgs either it means we will be able to drop it altogether.
1 parent 141bf9e commit 778ba12

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3589,26 +3589,17 @@ class Typer extends Namer
35893589

35903590
/** Convert constructor proxy reference to a new expression */
35913591
def newExpr =
3592-
def recur(tpt: Tree, pt: Type): Tree = pt.revealIgnored match
3593-
case PolyProto(targs, pt1) =>
3594-
if targs.exists(_.isInstanceOf[NamedArg]) then
3595-
errorTree(tpt, "Named type argument not allowed in constructor application")
3596-
else
3597-
IntegratedTypeArgs(recur(AppliedTypeTree(tpt, targs), pt1))
3598-
case _ =>
3599-
typed(untpd.Select(untpd.New(untpd.TypedSplice(tpt)), nme.CONSTRUCTOR), pt)
3600-
3601-
tree match
3602-
case Select(qual, nme.apply) =>
3603-
val tycon = tree.tpe.widen.finalResultType.underlyingClassRef(refinementOK = false)
3604-
val tpt = qual match
3605-
case Ident(name) => cpy.Ident(qual)(name.toTypeName)
3606-
case Select(pre, name) => cpy.Select(qual)(pre, name.toTypeName)
3607-
recur(tpt.withType(tycon), pt)
3608-
.showing(i"convert creator $tree -> $result", typr)
3609-
case _ =>
3610-
throw AssertionError(i"bad case for newExpr: $tree, $pt")
3611-
end newExpr
3592+
val Select(qual, nme.apply) = tree; @unchecked
3593+
val tycon = tree.tpe.widen.finalResultType.underlyingClassRef(refinementOK = false)
3594+
val tpt = qual match
3595+
case Ident(name) => cpy.Ident(qual)(name.toTypeName)
3596+
case Select(pre, name) => cpy.Select(qual)(pre, name.toTypeName)
3597+
typed(
3598+
untpd.Select(
3599+
untpd.New(untpd.TypedSplice(tpt.withType(tycon))),
3600+
nme.CONSTRUCTOR),
3601+
pt)
3602+
.showing(i"convert creator $tree -> $result", typr)
36123603

36133604
tree match {
36143605
case _: MemberDef | _: PackageDef | _: Import | _: WithoutTypeOrPos[?] | _: Closure => tree

0 commit comments

Comments
 (0)