From 7c7d2996e236ea785c1ae909d4f8e82629a8f7e6 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 16 Oct 2023 08:46:06 +0200 Subject: [PATCH] Avoid error on TypeApply with Inline or Hole prefix These are valid prefixes for a TypeApply in the same way they are for an Apply. See https://github.com/lampepfl/dotty/issues/16861#issuecomment-1763200624 --- compiler/src/dotty/tools/dotc/ast/tpd.scala | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/ast/tpd.scala b/compiler/src/dotty/tools/dotc/ast/tpd.scala index 973af0e8781d..17e707b4a9c3 100644 --- a/compiler/src/dotty/tools/dotc/ast/tpd.scala +++ b/compiler/src/dotty/tools/dotc/ast/tpd.scala @@ -45,19 +45,21 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { def Apply(fn: Tree, args: List[Tree])(using Context): Apply = fn match case Block(Nil, expr) => Apply(expr, args) - case _: RefTree | _: GenericApply | _: Inlined | _: Hole => - ta.assignType(untpd.Apply(fn, args), fn, args) case _ => - assert(ctx.reporter.errorsReported) + assert( + fn.isInstanceOf[RefTree | GenericApply | Inlined | Hole] || ctx.reporter.errorsReported, + s"Illegal Apply function prefix: $fn" + ) ta.assignType(untpd.Apply(fn, args), fn, args) def TypeApply(fn: Tree, args: List[Tree])(using Context): TypeApply = fn match case Block(Nil, expr) => TypeApply(expr, args) - case _: RefTree | _: GenericApply => - ta.assignType(untpd.TypeApply(fn, args), fn, args) case _ => - assert(ctx.reporter.errorsReported) + assert( + fn.isInstanceOf[RefTree | GenericApply | Inlined | Hole] || ctx.reporter.errorsReported, + s"Illegal TypeApply function prefix: $fn" + ) ta.assignType(untpd.TypeApply(fn, args), fn, args) def Literal(const: Constant)(using Context): Literal =