summaryrefslogtreecommitdiff
path: root/test/files/neg
diff options
context:
space:
mode:
authorGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2013-06-19 16:51:42 -0700
committerGrzegorz Kossakowski <grzegorz.kossakowski@gmail.com>2013-06-19 16:51:42 -0700
commite2aaf80aea2fc1a2ebc6f9a91163b346cb9882ee (patch)
tree3c90ec3b62d08c6ca57ef5bc92f3fcfc8ffab65c /test/files/neg
parent319c260c7af1fae843fc7c5677de0bc20051f51e (diff)
parent2f0e5ec1e96a6e4806841069736eda844d3a8dd6 (diff)
downloadscala-e2aaf80aea2fc1a2ebc6f9a91163b346cb9882ee.tar.gz
scala-e2aaf80aea2fc1a2ebc6f9a91163b346cb9882ee.tar.bz2
scala-e2aaf80aea2fc1a2ebc6f9a91163b346cb9882ee.zip
Merge pull request #2625 from paulp/pr/no-useless-implicits
SI-6899, prohibit dangerous, useless implicit conversions.
Diffstat (limited to 'test/files/neg')
-rw-r--r--test/files/neg/no-implicit-to-anyref.check8
-rw-r--r--test/files/neg/t4158.check16
-rw-r--r--test/files/neg/t4727.check8
-rw-r--r--test/files/neg/t6889.check7
-rw-r--r--test/files/neg/t6889.scala18
5 files changed, 29 insertions, 28 deletions
diff --git a/test/files/neg/no-implicit-to-anyref.check b/test/files/neg/no-implicit-to-anyref.check
index d94b57a30a..fe417ad8b0 100644
--- a/test/files/neg/no-implicit-to-anyref.check
+++ b/test/files/neg/no-implicit-to-anyref.check
@@ -1,10 +1,4 @@
-no-implicit-to-anyref.scala:11: error: type mismatch;
- found : Int(1)
- required: AnyRef
-Note: an implicit exists from scala.Int => java.lang.Integer, but
-methods inherited from Object are rendered ambiguous. This is to avoid
-a blanket implicit which would convert any scala.Int to any AnyRef.
-You may wish to use a type ascription: `x: java.lang.Integer`.
+no-implicit-to-anyref.scala:11: error: the result type of an implicit conversion must be more specific than AnyRef
1: AnyRef
^
no-implicit-to-anyref.scala:17: error: type mismatch;
diff --git a/test/files/neg/t4158.check b/test/files/neg/t4158.check
index 3ee2627c5b..af281c52cd 100644
--- a/test/files/neg/t4158.check
+++ b/test/files/neg/t4158.check
@@ -1,19 +1,7 @@
-t4158.scala:3: error: type mismatch;
- found : Null(null)
- required: Int
-Note that implicit conversions are not applicable because they are ambiguous:
- both method Integer2intNullConflict in class LowPriorityImplicits of type (x: Null)Int
- and method Integer2int in object Predef of type (x: Integer)Int
- are possible conversion functions from Null(null) to Int
+t4158.scala:3: error: an expression of type Null is ineligible for implicit conversion
var y = null: Int
^
-t4158.scala:2: error: type mismatch;
- found : Null(null)
- required: Int
-Note that implicit conversions are not applicable because they are ambiguous:
- both method Integer2intNullConflict in class LowPriorityImplicits of type (x: Null)Int
- and method Integer2int in object Predef of type (x: Integer)Int
- are possible conversion functions from Null(null) to Int
+t4158.scala:2: error: an expression of type Null is ineligible for implicit conversion
var x: Int = null
^
two errors found
diff --git a/test/files/neg/t4727.check b/test/files/neg/t4727.check
index 8a4536fec3..a17cdde044 100644
--- a/test/files/neg/t4727.check
+++ b/test/files/neg/t4727.check
@@ -1,10 +1,4 @@
-t4727.scala:5: error: type mismatch;
- found : Null
- required: Int
-Note that implicit conversions are not applicable because they are ambiguous:
- both method Integer2intNullConflict in class LowPriorityImplicits of type (x: Null)Int
- and method Integer2int in object Predef of type (x: Integer)Int
- are possible conversion functions from Null to Int
+t4727.scala:5: error: an expression of type Null is ineligible for implicit conversion
Error occurred in an application involving default arguments.
new C[Int]
^
diff --git a/test/files/neg/t6889.check b/test/files/neg/t6889.check
new file mode 100644
index 0000000000..a77e8a010c
--- /dev/null
+++ b/test/files/neg/t6889.check
@@ -0,0 +1,7 @@
+t6889.scala:16: error: the result type of an implicit conversion must be more specific than AnyRef
+ def f(x: Dingo): AnyRef = x // fail - no conversion to AnyRef
+ ^
+t6889.scala:17: error: an expression of type Null is ineligible for implicit conversion
+ var x: Int = null // fail - no conversion from Null
+ ^
+two errors found
diff --git a/test/files/neg/t6889.scala b/test/files/neg/t6889.scala
new file mode 100644
index 0000000000..ef1963669c
--- /dev/null
+++ b/test/files/neg/t6889.scala
@@ -0,0 +1,18 @@
+package bippy {
+ trait Bippy[A] extends Any
+}
+package foo {
+ package object unrelated {
+ implicit def bippyDingo[A](x: bippy.Bippy[A]): AnyRef = Nil
+ }
+ package unrelated {
+ trait Unrelated
+ }
+}
+
+object Test {
+ trait Dingo extends Any with bippy.Bippy[foo.unrelated.Unrelated]
+
+ def f(x: Dingo): AnyRef = x // fail - no conversion to AnyRef
+ var x: Int = null // fail - no conversion from Null
+}