Skip to content

Commit

Permalink
Do not propagate main annotations to exported methods
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Jan 23, 2024
1 parent 29deb05 commit ef4888b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,9 @@ class Namer { typer: Typer =>
forwarder.addAnnotations(sym.annotations.filterConserve { annot =>
annot.symbol != defn.BodyAnnot
&& annot.symbol != defn.TailrecAnnot
&& annot.symbol != defn.MainAnnot
&& !annot.symbol.derivesFrom(defn.MacroAnnotationClass)
&& !annot.symbol.derivesFrom(defn.MainAnnotationClass)
})

if forwarder.isType then
Expand Down
5 changes: 5 additions & 0 deletions tests/pos/export-main.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
object Foo:
@main def baz: Int = 1

object Bar:
export Foo.baz // export Foo.baz but not create an new main entry point

0 comments on commit ef4888b

Please sign in to comment.