Skip to content

Commit 861eb45

Browse files
nicolasstuckiWojciechMazur
authored andcommitted
Do not propagate main annotations to exported methods
[Cherry-picked ef4888b]
1 parent 48f7d56 commit 861eb45

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
@@ -1254,7 +1254,9 @@ class Namer { typer: Typer =>
12541254
forwarder.addAnnotations(sym.annotations.filterConserve { annot =>
12551255
annot.symbol != defn.BodyAnnot
12561256
&& annot.symbol != defn.TailrecAnnot
1257+
&& annot.symbol != defn.MainAnnot
12571258
&& !annot.symbol.derivesFrom(defn.MacroAnnotationClass)
1259+
&& !annot.symbol.derivesFrom(defn.MainAnnotationClass)
12581260
})
12591261

12601262
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)