File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -10,12 +10,14 @@ import util.Spans.Span
10
10
11
11
object Annotations {
12
12
13
+ def annotClass (tree : Tree ) given Context =
14
+ if (tree.symbol.isConstructor) tree.symbol.owner
15
+ else tree.tpe.typeSymbol
16
+
13
17
abstract class Annotation {
14
18
def tree (implicit ctx : Context ): Tree
15
19
16
- def symbol (implicit ctx : Context ): Symbol =
17
- if (tree.symbol.isConstructor) tree.symbol.owner
18
- else tree.tpe.typeSymbol
20
+ def symbol (implicit ctx : Context ): Symbol = annotClass(tree)
19
21
20
22
def matches (cls : Symbol )(implicit ctx : Context ): Boolean = symbol.derivesFrom(cls)
21
23
Original file line number Diff line number Diff line change @@ -1139,8 +1139,9 @@ trait Checking {
1139
1139
/** check that annotation `annot` is applicable to symbol `sym` */
1140
1140
def checkAnnotApplicable (annot : Tree , sym : Symbol ) given (ctx : Context ): Boolean =
1141
1141
! ctx.reporter.reportsErrorsFor { implicit ctx =>
1142
+ val annotCls = Annotations .annotClass(annot)
1142
1143
val pos = annot.sourcePos
1143
- if (annot.symbol == defn.MainAnnot ) {
1144
+ if (annotCls == defn.MainAnnot ) {
1144
1145
if (! sym.isRealMethod)
1145
1146
ctx.error(em " @main annotation cannot be applied to $sym" , pos)
1146
1147
if (! sym.owner.is(Module ) || ! sym.owner.isStatic)
You can’t perform that action at this time.
0 commit comments