Skip to content

Commit 32f099c

Browse files
Backport "Improve assertion error message for Apply and TypeApply" to LTS (#20729)
Backports #18700 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents 8ae15d7 + ff249a7 commit 32f099c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

compiler/src/dotty/tools/dotc/ast/tpd.scala

+8-6
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,21 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
4545
def Apply(fn: Tree, args: List[Tree])(using Context): Apply = fn match
4646
case Block(Nil, expr) =>
4747
Apply(expr, args)
48-
case _: RefTree | _: GenericApply | _: Inlined | _: Hole =>
49-
ta.assignType(untpd.Apply(fn, args), fn, args)
5048
case _ =>
51-
assert(ctx.reporter.errorsReported)
49+
assert(
50+
fn.isInstanceOf[RefTree | GenericApply | Inlined | Hole] || ctx.reporter.errorsReported,
51+
s"Illegal Apply function prefix: $fn"
52+
)
5253
ta.assignType(untpd.Apply(fn, args), fn, args)
5354

5455
def TypeApply(fn: Tree, args: List[Tree])(using Context): TypeApply = fn match
5556
case Block(Nil, expr) =>
5657
TypeApply(expr, args)
57-
case _: RefTree | _: GenericApply =>
58-
ta.assignType(untpd.TypeApply(fn, args), fn, args)
5958
case _ =>
60-
assert(ctx.reporter.errorsReported)
59+
assert(
60+
fn.isInstanceOf[RefTree | GenericApply] || ctx.reporter.errorsReported,
61+
s"Illegal TypeApply function prefix: $fn"
62+
)
6163
ta.assignType(untpd.TypeApply(fn, args), fn, args)
6264

6365
def Literal(const: Constant)(using Context): Literal =

0 commit comments

Comments
 (0)