Skip to content

Commit 09aa88d

Browse files
mbovelKacperFKorban
authored andcommitted
Add support for applied constructor sugar
1 parent 7ac31d0 commit 09aa88d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2515,17 +2515,19 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
25152515
}
25162516

25172517
def typedAppliedTypeTree(tree: untpd.AppliedTypeTree)(using Context): Tree = {
2518+
val tpt1 = withoutMode(Mode.Pattern):
2519+
typed(tree.tpt, AnyTypeConstructorProto)
2520+
25182521
tree.args match
25192522
case arg :: _ if arg.isTerm =>
25202523
if Feature.dependentEnabled then
2521-
return errorTree(tree, em"Not yet implemented: T(...)")
2524+
tpt1.tpe.typeSymbol.primaryConstructor.typeRef.underlying match
2525+
case mt: MethodType =>
2526+
return TypeTree(mt.instantiate(tree.args.map((typedExpr(_).tpe))))
25222527
else
25232528
return errorTree(tree, dependentMsg)
25242529
case _ =>
2525-
2526-
val tpt1 = withoutMode(Mode.Pattern) {
2527-
typed(tree.tpt, AnyTypeConstructorProto)
2528-
}
2530+
25292531
val tparams = tpt1.tpe.typeParams
25302532
if tpt1.tpe.isError then
25312533
val args1 = tree.args.mapconserve(typedType(_))

0 commit comments

Comments
 (0)