Skip to content

Commit 4900ace

Browse files
authored
Merge pull request #10973 from dotty-staging/drop-integratedTypeargs
Simplify newExpr
2 parents 74a653d + 778ba12 commit 4900ace

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
@@ -3592,26 +3592,17 @@ class Typer extends Namer
35923592

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

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

0 commit comments

Comments
 (0)