File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import ErrorReporting.errorTree
2020import rewrites .Rewrites .patch
2121import util .Spans .Span
2222import Phases .refchecksPhase
23+ import Constants .Constant
2324
2425import util .SrcPos
2526import util .Spans .Span
@@ -1204,13 +1205,14 @@ trait Checking {
12041205 /** Check arguments of compiler-defined annotations */
12051206 def checkAnnotArgs (tree : Tree )(using Context ): tree.type =
12061207 val cls = Annotations .annotClass(tree)
1207- def needsStringLit (arg : Tree ) =
1208- report.error(em " @ ${cls.name} needs a string literal as argument " , arg.srcPos)
12091208 tree match
12101209 case Apply (tycon, arg :: Nil ) if cls == defn.TargetNameAnnot =>
12111210 arg match
1211+ case Literal (Constant (" " )) =>
1212+ report.error(em " target name cannot be empty " , arg.srcPos)
12121213 case Literal (_) => // ok
1213- case _ => needsStringLit(arg)
1214+ case _ =>
1215+ report.error(em " @ ${cls.name} needs a string literal as argument " , arg.srcPos)
12141216 case _ =>
12151217 tree
12161218
Original file line number Diff line number Diff line change 1+ import annotation .*
2+
3+ object Test :
4+
5+ @ targetName(" " ) // error
6+ def foo = println(" ok" )
7+
8+ foo
9+
10+
You can’t perform that action at this time.
0 commit comments