summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2016-11-17 13:20:30 -0800
committerSom Snytt <som.snytt@gmail.com>2016-12-14 10:04:47 -0800
commit582c8a2fdd1d5b3cacff982b0c4af0a7dd37b651 (patch)
tree7c9a86656b17a1c715c87ad92a634dc2fb4f8af5 /src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
parentb91b415b4fccfc46520dcd3f128b4b09d19d74f0 (diff)
downloadscala-582c8a2fdd1d5b3cacff982b0c4af0a7dd37b651.tar.gz
scala-582c8a2fdd1d5b3cacff982b0c4af0a7dd37b651.tar.bz2
scala-582c8a2fdd1d5b3cacff982b0c4af0a7dd37b651.zip
SI-10068 Only permit elidable methods
In refchecks, check that symbol with `@elidable` is a method. When eliding in uncurry, doublecheck. The check is enabled under `-Xsource:2.13`.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/RefChecks.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 08cd5e5450..296d9c6bca 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -1412,6 +1412,12 @@ abstract class RefChecks extends Transform {
transformTrees(annots flatMap (_.args))
}
+ def checkIsElisible(sym: Symbol) = if (sym ne null) sym.elisionLevel.foreach { level =>
+ if (!sym.isMethod || sym.isAccessor || sym.isLazy || sym.isDeferred)
+ reporter.error(sym.pos, s"${sym.name}: Only methods can be marked @elidable.")
+ }
+ if (settings.isScala213) checkIsElisible(tree.symbol)
+
tree match {
case m: MemberDef =>
val sym = m.symbol
@@ -1425,7 +1431,7 @@ abstract class RefChecks extends Transform {
analyzer.ImplicitAmbiguousMsg.check(sym) foreach messageWarning("implicitAmbiguous")
case tpt@TypeTree() =>
- if(tpt.original != null) {
+ if (tpt.original != null) {
tpt.original foreach {
case dc@TypeTreeWithDeferredRefCheck() =>
applyRefchecksToAnnotations(dc.check()) // #2416