@@ -1265,22 +1265,22 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
1265
1265
false
1266
1266
}
1267
1267
1268
- /** If symbol is deprecated, and the point of reference is not enclosed
1269
- * in either a deprecated member or a scala bridge method, issue a warning.
1270
- */
1271
- private def checkDeprecated (sym : Symbol , pos : Position ) {
1268
+ // Note: if a symbol has both @deprecated and @migration annotations and both
1269
+ // warnings are enabled, only the first one checked here will be emitted.
1270
+ // I assume that's a consequence of some code trying to avoid noise by suppressing
1271
+ // warnings after the first, but I think it'd be better if we didn't have to
1272
+ // arbitrarily choose one as more important than the other.
1273
+ private def checkUndesiredProperties (sym : Symbol , pos : Position ) {
1274
+ // If symbol is deprecated, and the point of reference is not enclosed
1275
+ // in either a deprecated member or a scala bridge method, issue a warning.
1272
1276
if (sym.isDeprecated && ! currentOwner.ownerChain.exists(x => x.isDeprecated || x.hasBridgeAnnotation)) {
1273
1277
unit.deprecationWarning(pos, " %s%s is deprecated%s" .format(
1274
1278
sym, sym.locationString, sym.deprecationMessage map (" : " + _) getOrElse " " )
1275
1279
)
1276
1280
}
1277
- }
1278
-
1279
- /** Similar to deprecation: check if the symbol is marked with @migration
1280
- * indicating it has changed semantics between versions.
1281
- */
1282
- private def checkMigration (sym : Symbol , pos : Position ) = {
1283
- if (sym.hasMigrationAnnotation) {
1281
+ // Similar to deprecation: check if the symbol is marked with @migration
1282
+ // indicating it has changed semantics between versions.
1283
+ if (sym.hasMigrationAnnotation && settings.Xmigration .value != NoScalaVersion ) {
1284
1284
val changed = try
1285
1285
settings.Xmigration .value < ScalaVersion (sym.migrationVersion.get)
1286
1286
catch {
@@ -1292,9 +1292,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
1292
1292
if (changed)
1293
1293
unit.warning(pos, s " ${sym.fullLocationString} has changed semantics in version ${sym.migrationVersion.get}: \n ${sym.migrationMessage.get}" )
1294
1294
}
1295
- }
1296
-
1297
- private def checkCompileTimeOnly (sym : Symbol , pos : Position ) = {
1295
+ // See an explanation of compileTimeOnly in its scaladoc at scala.annotation.compileTimeOnly.
1298
1296
if (sym.isCompileTimeOnly) {
1299
1297
def defaultMsg =
1300
1298
sm """ Reference to ${sym.fullLocationString} should not have survived past type checking,
@@ -1416,8 +1414,8 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
1416
1414
case TypeRef (pre, sym, args) =>
1417
1415
tree match {
1418
1416
case tt : TypeTree if tt.original == null => // SI-7783 don't warn about inferred types
1419
- case _ =>
1420
- checkDeprecated (sym, tree.pos)
1417
+ // FIXME: reconcile this check with one in resetAllAttrs
1418
+ case _ => checkUndesiredProperties (sym, tree.pos)
1421
1419
}
1422
1420
if (sym.isJavaDefined)
1423
1421
sym.typeParams foreach (_.cookJavaRawInfo())
@@ -1449,7 +1447,6 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
1449
1447
1450
1448
private def applyRefchecksToAnnotations (tree : Tree ): Unit = {
1451
1449
def applyChecks (annots : List [AnnotationInfo ]) = {
1452
- annots foreach (annot => checkCompileTimeOnly(annot.atp.typeSymbol, annot.pos))
1453
1450
checkAnnotations(annots map (_.atp), tree)
1454
1451
transformTrees(annots flatMap (_.args))
1455
1452
}
@@ -1541,16 +1538,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
1541
1538
val Select (qual, _) = tree
1542
1539
val sym = tree.symbol
1543
1540
1544
- /* Note: if a symbol has both @deprecated and @migration annotations and both
1545
- * warnings are enabled, only the first one checked here will be emitted.
1546
- * I assume that's a consequence of some code trying to avoid noise by suppressing
1547
- * warnings after the first, but I think it'd be better if we didn't have to
1548
- * arbitrarily choose one as more important than the other.
1549
- */
1550
- checkDeprecated(sym, tree.pos)
1551
- if (settings.Xmigration .value != NoScalaVersion )
1552
- checkMigration(sym, tree.pos)
1553
- checkCompileTimeOnly(sym, tree.pos)
1541
+ checkUndesiredProperties(sym, tree.pos)
1554
1542
checkDelayedInitSelect(qual, sym, tree.pos)
1555
1543
1556
1544
if (! sym.exists)
@@ -1705,7 +1693,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
1705
1693
tree
1706
1694
1707
1695
case Ident (name) =>
1708
- checkCompileTimeOnly(tree.symbol , tree.pos)
1696
+ checkUndesiredProperties(sym , tree.pos)
1709
1697
transformCaseApply(tree,
1710
1698
if (name != nme.WILDCARD && name != tpnme.WILDCARD_STAR ) {
1711
1699
assert(sym != NoSymbol , " transformCaseApply: name = " + name.debugString + " tree = " + tree + " / " + tree.getClass) // debug
0 commit comments