Skip to content

Commit

Permalink
Backport "Improve assertion error message for Apply and TypeApply
Browse files Browse the repository at this point in the history
…" to LTS (#20729)

Backports #18700 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jun 22, 2024
2 parents 8ae15d7 + ff249a7 commit 32f099c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions compiler/src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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] || ctx.reporter.errorsReported,
s"Illegal TypeApply function prefix: $fn"
)
ta.assignType(untpd.TypeApply(fn, args), fn, args)

def Literal(const: Constant)(using Context): Literal =
Expand Down

0 comments on commit 32f099c

Please sign in to comment.