Skip to content

Commit 66b315d

Browse files
Merge pull request #12376 from dotty-staging/fix-12361
Fix #12361: Handle MacroTree from ill-formed code
2 parents ae3f58e + 48d0b0d commit 66b315d

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2724,6 +2724,7 @@ class Typer extends Namer
27242724
case tree: untpd.Quote => typedQuote(tree, pt)
27252725
case tree: untpd.Splice => typedSplice(tree, pt)
27262726
case tree: untpd.TypSplice => typedTypSplice(tree, pt)
2727+
case tree: untpd.MacroTree => report.error("Unexpected macro", tree.srcPos); tpd.nullLiteral // ill-formed code may reach here
27272728
case _ => typedUnadapted(desugar(tree), pt, locked)
27282729
}
27292730

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
val a = macro ??? // error

tests/neg/i12361.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object Test {
2+
foo = macro Impls . foo [ U ] += // error // error
3+
}

0 commit comments

Comments
 (0)