Skip to content

Commit e6d1242

Browse files
committed
Make checkExperimentalDef work for members of experimental objects
1 parent 82e6abb commit e6d1242

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

compiler/src/dotty/tools/dotc/config/Feature.scala

+12-10
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,20 @@ object Feature:
137137
report.error(em"Experimental $which may only be used with a nightly or snapshot version of the compiler$note", srcPos)
138138

139139
private def ccException(sym: Symbol)(using Context): Boolean =
140-
ccEnabled && defn.ccExperimental.contains(sym)
140+
ccEnabled && defn.ccExperimental.contains(sym)
141141

142142
def checkExperimentalDef(sym: Symbol, srcPos: SrcPos)(using Context) =
143-
if !isExperimentalEnabled && !ccException(sym) then
144-
val symMsg =
145-
if sym.hasAnnotation(defn.ExperimentalAnnot) then
146-
i"$sym is marked @experimental"
147-
else if sym.owner.hasAnnotation(defn.ExperimentalAnnot) then
148-
i"${sym.owner} is marked @experimental"
149-
else
150-
i"$sym inherits @experimental"
151-
report.error(em"$symMsg and therefore may only be used in an experimental scope.", srcPos)
143+
if !isExperimentalEnabled then
144+
val experimentalSym =
145+
if sym.hasAnnotation(defn.ExperimentalAnnot) then sym
146+
else if sym.owner.hasAnnotation(defn.ExperimentalAnnot) then sym.owner
147+
else NoSymbol
148+
if !ccException(experimentalSym) then
149+
val symMsg =
150+
if experimentalSym.exists
151+
then i"$experimentalSym is marked @experimental"
152+
else i"$sym inherits @experimental"
153+
report.error(em"$symMsg and therefore may only be used in an experimental scope.", srcPos)
152154

153155
/** Check that experimental compiler options are only set for snapshot or nightly compiler versions. */
154156
def checkExperimentalSettings(using Context): Unit =
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import language.experimenal.captureChecking
1+
import language.experimental.captureChecking
22
object test {
33

44
val x = caps.cap
55

66
}
7-

0 commit comments

Comments
 (0)