summaryrefslogtreecommitdiff
path: root/test/files/neg
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-01-23 01:10:05 +0100
committerJason Zaugg <jzaugg@gmail.com>2013-01-23 01:13:30 +0100
commit96ed055769483d661b09f346cd1641f956f3172a (patch)
treee5e6c664639ba09edb08b712fb2e2b1d18547996 /test/files/neg
parent884737c75dc7f2765a3d769342ecc832deeddb81 (diff)
downloadscala-96ed055769483d661b09f346cd1641f956f3172a.tar.gz
scala-96ed055769483d661b09f346cd1641f956f3172a.tar.bz2
scala-96ed055769483d661b09f346cd1641f956f3172a.zip
[backport] SI-6567 Warning for Option(implicitView(foo))
commit 284bd754fa5dfc8bc626b0c5ebe85d872dd044cb Author: Jason Zaugg <jzaugg@gmail.com> Date: Sat Nov 3 16:19:46 2012 +0100 SI-6567 Warning for Option(implicitView(foo)) I've seen the reported problem before in the wild. It seems worthy of a special warning, so long as we advocate Option.apply as an alternative to `if (x == null) Some(x) else None`. It is behind -Xlint at the moment, an option that could do with some promotion. (cherry picked from commit 0bcb9e9169146e3f589c6c9f65cc4a5523b78120)
Diffstat (limited to 'test/files/neg')
-rw-r--r--test/files/neg/t6567.check7
-rw-r--r--test/files/neg/t6567.flags1
-rw-r--r--test/files/neg/t6567.scala11
3 files changed, 19 insertions, 0 deletions
diff --git a/test/files/neg/t6567.check b/test/files/neg/t6567.check
new file mode 100644
index 0000000000..4c513e64cd
--- /dev/null
+++ b/test/files/neg/t6567.check
@@ -0,0 +1,7 @@
+t6567.scala:8: error: Suspicious application of an implicit view (Test.this.a2b) in the argument to Option.apply.
+ Option[B](a)
+ ^
+t6567.scala:10: error: Suspicious application of an implicit view (Test.this.a2b) in the argument to Option.apply.
+ val b: Option[B] = Option(a)
+ ^
+two errors found
diff --git a/test/files/neg/t6567.flags b/test/files/neg/t6567.flags
new file mode 100644
index 0000000000..e93641e931
--- /dev/null
+++ b/test/files/neg/t6567.flags
@@ -0,0 +1 @@
+-Xlint -Xfatal-warnings \ No newline at end of file
diff --git a/test/files/neg/t6567.scala b/test/files/neg/t6567.scala
new file mode 100644
index 0000000000..650e5e39ae
--- /dev/null
+++ b/test/files/neg/t6567.scala
@@ -0,0 +1,11 @@
+class A
+class B
+
+object Test {
+ val a: A = null
+ implicit def a2b(a: A) = new B
+
+ Option[B](a)
+
+ val b: Option[B] = Option(a)
+}