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
1010
1111object Annotations {
1212
13+ def annotClass (tree : Tree ) given Context =
14+ if (tree.symbol.isConstructor) tree.symbol.owner
15+ else tree.tpe.typeSymbol
16+
1317 abstract class Annotation {
1418 def tree (implicit ctx : Context ): Tree
1519
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)
1921
2022 def matches (cls : Symbol )(implicit ctx : Context ): Boolean = symbol.derivesFrom(cls)
2123
Original file line number Diff line number Diff line change @@ -1139,8 +1139,9 @@ trait Checking {
11391139 /** check that annotation `annot` is applicable to symbol `sym` */
11401140 def checkAnnotApplicable (annot : Tree , sym : Symbol ) given (ctx : Context ): Boolean =
11411141 ! ctx.reporter.reportsErrorsFor { implicit ctx =>
1142+ val annotCls = Annotations .annotClass(annot)
11421143 val pos = annot.sourcePos
1143- if (annot.symbol == defn.MainAnnot ) {
1144+ if (annotCls == defn.MainAnnot ) {
11441145 if (! sym.isRealMethod)
11451146 ctx.error(em " @main annotation cannot be applied to $sym" , pos)
11461147 if (! sym.owner.is(Module ) || ! sym.owner.isStatic)
You can’t perform that action at this time.
0 commit comments