Skip to content

Commit ef4888b

Browse files
committed
Do not propagate main annotations to exported methods
1 parent 29deb05 commit ef4888b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Diff for: compiler/src/dotty/tools/dotc/typer/Namer.scala

+2
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,9 @@ class Namer { typer: Typer =>
12571257
forwarder.addAnnotations(sym.annotations.filterConserve { annot =>
12581258
annot.symbol != defn.BodyAnnot
12591259
&& annot.symbol != defn.TailrecAnnot
1260+
&& annot.symbol != defn.MainAnnot
12601261
&& !annot.symbol.derivesFrom(defn.MacroAnnotationClass)
1262+
&& !annot.symbol.derivesFrom(defn.MainAnnotationClass)
12611263
})
12621264

12631265
if forwarder.isType then

Diff for: tests/pos/export-main.scala

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object Foo:
2+
@main def baz: Int = 1
3+
4+
object Bar:
5+
export Foo.baz // export Foo.baz but not create an new main entry point

0 commit comments

Comments
 (0)