summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorJosh Suereth <Joshua.Suereth@gmail.com>2012-11-04 09:14:38 -0800
committerJosh Suereth <Joshua.Suereth@gmail.com>2012-11-04 09:14:38 -0800
commit2c6777fd53b93b95a261aadc87a5cbc03c14d503 (patch)
tree40a987d82aae9aa48ed37f118d14dbfbc6cc4f9c /src/compiler
parent98ccb9fea2ef3b4ce2a519ccc55ad61be84a0508 (diff)
parent0bcb9e9169146e3f589c6c9f65cc4a5523b78120 (diff)
downloadscala-2c6777fd53b93b95a261aadc87a5cbc03c14d503.tar.gz
scala-2c6777fd53b93b95a261aadc87a5cbc03c14d503.tar.bz2
scala-2c6777fd53b93b95a261aadc87a5cbc03c14d503.zip
Merge pull request #1565 from retronym/ticket/6567
SI-6567 Warning for Option(implicitView(foo))
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 5b2fbb4fd0..905ec98113 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -1051,6 +1051,12 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
def apply(tp: Type) = mapOver(tp).normalize
}
+ def checkImplicitViewOptionApply(pos: Position, fn: Tree, args: List[Tree]): Unit = if (settings.lint.value) (fn, args) match {
+ case (tap@TypeApply(fun, targs), List(view: ApplyImplicitView)) if fun.symbol == Option_apply =>
+ unit.warning(pos, s"Suspicious application of an implicit view (${view.fun}) in the argument to Option.apply.") // SI-6567
+ case _ =>
+ }
+
def checkSensible(pos: Position, fn: Tree, args: List[Tree]) = fn match {
case Select(qual, name @ (nme.EQ | nme.NE | nme.eq | nme.ne)) if args.length == 1 =>
def isReferenceOp = name == nme.eq || name == nme.ne
@@ -1535,7 +1541,10 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
case Apply(fn, args) =>
// sensicality should be subsumed by the unreachability/exhaustivity/irrefutability analyses in the pattern matcher
- if (!inPattern) checkSensible(tree.pos, fn, args)
+ if (!inPattern) {
+ checkImplicitViewOptionApply(tree.pos, fn, args)
+ checkSensible(tree.pos, fn, args)
+ }
currentApplication = tree
tree
}