From cdfc0f42e841469054ca3cfd5c24194b961c5fb3 Mon Sep 17 00:00:00 2001 From: odersky Date: Mon, 26 Sep 2022 09:53:47 +0200 Subject: [PATCH] Let accesors inherit @experimental annotations from accessed symvbols Fixes #16091 --- .../src/dotty/tools/dotc/transform/AccessProxies.scala | 2 ++ tests/pos-custom-args/no-experimental/i16091.scala | 9 +++++++++ 2 files changed, 11 insertions(+) create mode 100644 tests/pos-custom-args/no-experimental/i16091.scala diff --git a/compiler/src/dotty/tools/dotc/transform/AccessProxies.scala b/compiler/src/dotty/tools/dotc/transform/AccessProxies.scala index 5908bce97994..14362260d032 100644 --- a/compiler/src/dotty/tools/dotc/transform/AccessProxies.scala +++ b/compiler/src/dotty/tools/dotc/transform/AccessProxies.scala @@ -80,6 +80,8 @@ abstract class AccessProxies { val sym = newSymbol(owner, name, Synthetic | Method, info, coord = accessed.span).entered if accessed.is(Private) then sym.setFlag(Final) else if sym.allOverriddenSymbols.exists(!_.is(Deferred)) then sym.setFlag(Override) + if accessed.hasAnnotation(defn.ExperimentalAnnot) then + sym.addAnnotation(defn.ExperimentalAnnot) sym } diff --git a/tests/pos-custom-args/no-experimental/i16091.scala b/tests/pos-custom-args/no-experimental/i16091.scala new file mode 100644 index 000000000000..0324aeacccc9 --- /dev/null +++ b/tests/pos-custom-args/no-experimental/i16091.scala @@ -0,0 +1,9 @@ +import scala.annotation.experimental + +object Macro { + @experimental + inline def foo() = fooImpl + + @experimental + private def fooImpl = () +} \ No newline at end of file