From f07697b25294eaafb1c86698c44a699ec1c0d1ba Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 8 Mar 2017 11:35:05 +0100 Subject: 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. --- tests/pos/t2421_delitedsl.scala | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/pos/t2421_delitedsl.scala') diff --git a/tests/pos/t2421_delitedsl.scala b/tests/pos/t2421_delitedsl.scala index 22f1ecd85..bde3593c9 100644 --- a/tests/pos/t2421_delitedsl.scala +++ b/tests/pos/t2421_delitedsl.scala @@ -1,6 +1,9 @@ trait DeliteDSL { abstract class <~<[-From, +To] extends (From => To) + implicit def trivial[A]: A <~< A = new (A <~< A) {def apply(x: A) = x} + implicit def convert_<-<[A, B](x: A)(implicit ev: A <~< B): B = ev(x) + trait Forcible[T] object Forcible { -- cgit v1.2.3