diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 9a4b53d4112c..f94ff68d0698 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -3,6 +3,7 @@ package dotc package printing import core._ +import Constants.* import Texts._ import Types._ import Flags._ @@ -286,14 +287,10 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { case tp: ViewProto => toText(tp.argType) ~ " ?=>? " ~ toText(tp.resultType) case tp @ FunProto(args, resultType) => - val argsText = args match { - case dummyTreeOfType(tp) :: Nil if !(tp isRef defn.NullClass) => "null: " ~ toText(tp) - case _ => toTextGlobal(args, ", ") - } "[applied to (" ~ keywordText("using ").provided(tp.isContextualMethod) ~ keywordText("erased ").provided(tp.isErasedMethod) - ~ argsText + ~ argsTreeText(args) ~ ") returning " ~ toText(resultType) ~ "]" @@ -309,6 +306,10 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { protected def exprToText(tp: ExprType): Text = "=> " ~ toText(tp.resType) + protected def argsTreeText(args: List[untpd.Tree]): Text = args match + case dummyTreeOfType(tp) :: Nil if !tp.isRef(defn.NullClass) && !homogenizedView => toText(Constant(null)) ~ ": " ~ toText(tp) + case _ => toTextGlobal(args, ", ") + protected def blockToText[T <: Untyped](block: Block[T]): Text = blockText(block.stats :+ block.expr) @@ -442,7 +443,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { toTextLocal(fun) ~ "(" ~ Str("using ").provided(app.applyKind == ApplyKind.Using && !homogenizedView) - ~ toTextGlobal(args, ", ") + ~ argsTreeText(args) ~ ")" case tree: TypeApply => typeApplyText(tree) diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala index 8ba842ad695f..15da3c2ccc22 100644 --- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala +++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala @@ -671,10 +671,12 @@ object ProtoTypes { * * [] _ */ - @sharable object AnyFunctionProto extends UncachedGroundType with MatchAlways + @sharable object AnyFunctionProto extends UncachedGroundType with MatchAlways: + override def toString = "AnyFunctionProto" /** A prototype for type constructors that are followed by a type application */ - @sharable object AnyTypeConstructorProto extends UncachedGroundType with MatchAlways + @sharable object AnyTypeConstructorProto extends UncachedGroundType with MatchAlways: + override def toString = "AnyTypeConstructorProto" extension (pt: Type) def isExtensionApplyProto: Boolean = pt match @@ -946,8 +948,8 @@ object ProtoTypes { object dummyTreeOfType { def apply(tp: Type)(implicit src: SourceFile): Tree = untpd.Literal(Constant(null)) withTypeUnchecked tp - def unapply(tree: untpd.Tree): Option[Type] = tree match { - case Literal(Constant(null)) => Some(tree.typeOpt) + def unapply(tree: untpd.Tree): Option[Type] = untpd.unsplice(tree) match { + case tree @ Literal(Constant(null)) => Some(tree.typeOpt) case _ => None } }