File tree Expand file tree Collapse file tree 3 files changed +9
-1
lines changed
compiler/src/dotty/tools/dotc/typer
neg-custom-args/no-experimental Expand file tree Collapse file tree 3 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -1186,7 +1186,7 @@ object RefChecks {
11861186
11871187 /** Check that classes extending experimental classes or nested in experimental classes have the @experimental annotation. */
11881188 private def checkExperimentalInheritance (cls : ClassSymbol )(using Context ): Unit =
1189- if ! cls.hasAnnotation(defn.ExperimentalAnnot ) then
1189+ if ! cls.isAnonymousClass && ! cls. hasAnnotation(defn.ExperimentalAnnot ) then
11901190 cls.info.parents.find(_.typeSymbol.isExperimental) match
11911191 case Some (parent) =>
11921192 report.error(em " extension of experimental ${parent.typeSymbol} must have @experimental annotation " , cls.srcPos)
Original file line number Diff line number Diff line change 1+ import annotation .experimental
2+
3+ @ experimental class Foo // error: use of @experimental is experimental ...
4+
5+ def test : Unit = new Foo // error: class Foo is marked @experimental ...
Original file line number Diff line number Diff line change 1+ import annotation .experimental
2+ @ experimental class Foo
3+ val foo = new Foo
You can’t perform that action at this time.
0 commit comments