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
20
20
import rewrites .Rewrites .patch
21
21
import util .Spans .Span
22
22
import Phases .refchecksPhase
23
+ import Constants .Constant
23
24
24
25
import util .SrcPos
25
26
import util .Spans .Span
@@ -1204,13 +1205,14 @@ trait Checking {
1204
1205
/** Check arguments of compiler-defined annotations */
1205
1206
def checkAnnotArgs (tree : Tree )(using Context ): tree.type =
1206
1207
val cls = Annotations .annotClass(tree)
1207
- def needsStringLit (arg : Tree ) =
1208
- report.error(em " @ ${cls.name} needs a string literal as argument " , arg.srcPos)
1209
1208
tree match
1210
1209
case Apply (tycon, arg :: Nil ) if cls == defn.TargetNameAnnot =>
1211
1210
arg match
1211
+ case Literal (Constant (" " )) =>
1212
+ report.error(em " target name cannot be empty " , arg.srcPos)
1212
1213
case Literal (_) => // ok
1213
- case _ => needsStringLit(arg)
1214
+ case _ =>
1215
+ report.error(em " @ ${cls.name} needs a string literal as argument " , arg.srcPos)
1214
1216
case _ =>
1215
1217
tree
1216
1218
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