Skip to content

Commit 9421ff0

Browse files
committed
Avoid printing typeargs of new twice
1 parent b40b519 commit 9421ff0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

+7-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,13 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
254254
protected def typeApplyText[T >: Untyped](tree: TypeApply[T]): Text = {
255255
val isQuote = tree.fun.hasType && tree.fun.symbol == defn.InternalQuoted_typeQuote
256256
val (open, close) = if (isQuote) (keywordStr("'["), keywordStr("]")) else ("[", "]")
257-
toTextLocal(tree.fun).provided(!isQuote) ~ open ~ toTextGlobal(tree.args, ", ") ~ close
257+
val funText = toTextLocal(tree.fun).provided(!isQuote)
258+
tree.fun match {
259+
case Select(New(tpt), nme.CONSTRUCTOR) if tpt.typeOpt.dealias.isInstanceOf[AppliedType] =>
260+
funText // type was already printed by toText(new)
261+
case _ =>
262+
funText ~ open ~ toTextGlobal(tree.args, ", ") ~ close
263+
}
258264
}
259265

260266
protected def toTextCore[T >: Untyped](tree: Tree[T]): Text = {

0 commit comments

Comments
 (0)