@@ -12,6 +12,7 @@ import ast.tpd
12
12
13
13
class CrossVersionChecks extends MiniPhase :
14
14
import tpd .*
15
+ import CrossVersionChecks .*
15
16
16
17
override def phaseName : String = CrossVersionChecks .name
17
18
@@ -27,7 +28,7 @@ class CrossVersionChecks extends MiniPhase:
27
28
// arbitrarily choose one as more important than the other.
28
29
private def checkUndesiredProperties (sym : Symbol , pos : SrcPos )(using Context ): Unit =
29
30
checkDeprecated(sym, pos)
30
- checkExperimental (sym, pos)
31
+ checkExperimentalRef (sym, pos)
31
32
checkSinceAnnot(sym, pos)
32
33
33
34
val xMigrationValue = ctx.settings.Xmigration .value
@@ -69,10 +70,6 @@ class CrossVersionChecks extends MiniPhase:
69
70
val since = annot.argumentConstant(1 ).map(" since " + _.stringValue).getOrElse(" " )
70
71
report.deprecationWarning(s " ${sym.showLocated} is deprecated ${since}${msg}" , pos)
71
72
72
- private def checkExperimental (sym : Symbol , pos : SrcPos )(using Context ): Unit =
73
- if sym.isExperimental && ! ctx.owner.isInExperimentalScope then
74
- Feature .checkExperimentalDef(sym, pos)
75
-
76
73
private def checkExperimentalSignature (sym : Symbol , pos : SrcPos )(using Context ): Unit =
77
74
class Checker extends TypeTraverser :
78
75
def traverse (tp : Type ): Unit =
@@ -192,11 +189,11 @@ class CrossVersionChecks extends MiniPhase:
192
189
tpe.foreachPart {
193
190
case TypeRef (_, sym : Symbol ) =>
194
191
checkDeprecated(sym, tree.srcPos)
195
- checkExperimental (sym, tree.srcPos)
192
+ checkExperimentalRef (sym, tree.srcPos)
196
193
checkSinceAnnot(sym, tree.srcPos)
197
194
case TermRef (_, sym : Symbol ) =>
198
195
checkDeprecated(sym, tree.srcPos)
199
- checkExperimental (sym, tree.srcPos)
196
+ checkExperimentalRef (sym, tree.srcPos)
200
197
checkSinceAnnot(sym, tree.srcPos)
201
198
case _ =>
202
199
}
@@ -214,3 +211,10 @@ end CrossVersionChecks
214
211
object CrossVersionChecks :
215
212
val name : String = " crossVersionChecks"
216
213
val description : String = " check issues related to deprecated and experimental"
214
+
215
+ /** Check that a reference to an experimental definition with symbol `sym` is only
216
+ * used in an experimental scope
217
+ */
218
+ def checkExperimentalRef (sym : Symbol , pos : SrcPos )(using Context ): Unit =
219
+ if sym.isExperimental && ! ctx.owner.isInExperimentalScope then
220
+ Feature .checkExperimentalDef(sym, pos)
0 commit comments