@@ -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 =
0 commit comments