Skip to content

Commit 366fa62

Browse files
committed
Check for experimental annotations only in non-experimental scopes
1 parent 5cad4c2 commit 366fa62

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ object RefChecks {
962962
new Checker().traverse(sym.info)
963963

964964
private def checkExperimentalAnnots(sym: Symbol)(using Context): Unit =
965-
if !sym.isExperimental then
965+
if !sym.isInExperimentalScope then
966966
for annot <- sym.annotations if annot.symbol.isExperimental do
967967
Feature.checkExperimentalDef(annot.symbol, annot.tree)
968968

tests/neg-custom-args/no-experimental/experimentalAnnot.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,15 @@ def test1: Unit = ()
88
@experimental
99
@myExperimentalAnnot
1010
def test2: Unit = ()
11+
12+
@experimental
13+
class Foo {
14+
@myExperimentalAnnot
15+
def test3: Unit = ()
16+
17+
def test4: Unit = {
18+
@myExperimentalAnnot
19+
val f: Unit = ()
20+
f
21+
}
22+
}

0 commit comments

Comments
 (0)