aboutsummaryrefslogtreecommitdiff
path: root/tests/neg
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-03-08 11:35:05 +0100
committerMartin Odersky <odersky@gmail.com>2017-03-08 17:50:20 +0100
commitf07697b25294eaafb1c86698c44a699ec1c0d1ba (patch)
tree5a08ac595fc61bfa467ce987728bee6d51839306 /tests/neg
parentc84480960cf618c29705dbaab9332d304a081524 (diff)
downloaddotty-f07697b25294eaafb1c86698c44a699ec1c0d1ba.tar.gz
dotty-f07697b25294eaafb1c86698c44a699ec1c0d1ba.tar.bz2
dotty-f07697b25294eaafb1c86698c44a699ec1c0d1ba.zip
Disallow subtypes of Function1 acting as implicit conversions
The new test `falseView.scala` shows the problem. We might create an implicit value of some type that happens to be a subtype of Function1. We might now expect that this gives us an implicit conversion, this is most often unintended and surprising. See the comment in Implicits#discardForView for a discussion why we picked the particular scheme implemented here.
Diffstat (limited to 'tests/neg')
-rw-r--r--tests/neg/falseView.scala7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/neg/falseView.scala b/tests/neg/falseView.scala
new file mode 100644
index 000000000..613abe3f1
--- /dev/null
+++ b/tests/neg/falseView.scala
@@ -0,0 +1,7 @@
+object Test {
+
+ private implicit val xs: Map[String, Int] = ???
+
+ val x: Int = "abc" // error
+
+}