Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

Commit a66f5df

Browse files
committed
Merge pull request scala#3932 from gourlaysama/wip/t8498
SI-8498 @compileTimeOnly should be aware of bridge methods.
2 parents 266c210 + 984025b commit a66f5df

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/compiler/scala/tools/nsc/typechecker/RefChecks.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
12871287
private def checkUndesiredProperties(sym: Symbol, pos: Position) {
12881288
// If symbol is deprecated, and the point of reference is not enclosed
12891289
// in either a deprecated member or a scala bridge method, issue a warning.
1290+
// TODO: x.hasBridgeAnnotation doesn't seem to be needed here...
12901291
if (sym.isDeprecated && !currentOwner.ownerChain.exists(x => x.isDeprecated || x.hasBridgeAnnotation))
12911292
currentRun.reporting.deprecationWarning(pos, sym)
12921293

@@ -1305,7 +1306,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
13051306
reporter.warning(pos, s"${sym.fullLocationString} has changed semantics in version ${sym.migrationVersion.get}:\n${sym.migrationMessage.get}")
13061307
}
13071308
// See an explanation of compileTimeOnly in its scaladoc at scala.annotation.compileTimeOnly.
1308-
if (sym.isCompileTimeOnly) {
1309+
if (sym.isCompileTimeOnly && !currentOwner.ownerChain.exists(x => x.isCompileTimeOnly)) {
13091310
def defaultMsg =
13101311
sm"""Reference to ${sym.fullLocationString} should not have survived past type checking,
13111312
|it should have been processed and eliminated during expansion of an enclosing macro."""

test/files/neg/compile-time-only-a.check

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ compile-time-only-a.scala:10: error: C3
44
compile-time-only-a.scala:12: error: C4
55
@compileTimeOnly("C4") case class C4(x: Int)
66
^
7-
compile-time-only-a.scala:17: error: C5
8-
implicit class C5(val x: Int) {
9-
^
107
compile-time-only-a.scala:32: error: C1
118
new C1()
129
^
@@ -76,4 +73,4 @@ compile-time-only-a.scala:75: error: placebo
7673
compile-time-only-a.scala:75: error: placebo
7774
@placebo def x = (2: @placebo)
7875
^
79-
26 errors found
76+
25 errors found

test/files/pos/t8498.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import scala.annotation.compileTimeOnly
2+
3+
class C(val s: String) extends AnyVal {
4+
@compileTimeOnly("error")
5+
def error = ???
6+
}

0 commit comments

Comments
 (0)