From c3bcad807db47ee4ab27ac4a725ba5f402667b4d Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 18 Jun 2015 15:15:42 +0200 Subject: Do not check for ambiguous implicits in viewExists Previously `viewExists(X, Y)` failed if there were ambiguous implicit conversions from X to Y. This is too fragile, as demonstrated by test case run/array-addition.scala. Here, the `genericArrayOps` implicit was not inserted because its result type `Array[?T]` was deemed to be incompatible with `? { +: : ? }`. It was incompatible because there were multiple implicits that added :+ to arrays of various element types. But once `genericArrayOps` gets applied, the type parameter `?T` of the array result is fixed, and the ambuity goes away. The scenario shows that we should not test for ambiguous implicits in viewExists. Such a test is fragile because it depends on the progress of type inference when the test is made. It's preferable to just test for any implicit conversion to exist and to check for ambiguities later, when the implicit conversion is actually applied. This has also the potential of speeding up implicit search in situations where `viewExists` is called often (e.g. when coupled with overloading resolution). --- tests/pending/run/array-addition.check | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 tests/pending/run/array-addition.check (limited to 'tests/pending/run/array-addition.check') diff --git a/tests/pending/run/array-addition.check b/tests/pending/run/array-addition.check deleted file mode 100644 index 7bfbd9c71..000000000 --- a/tests/pending/run/array-addition.check +++ /dev/null @@ -1,4 +0,0 @@ -Array(1, 2, 3, 4) -Array(1, 2, 3, 4) -Array(1) -Array(1) -- cgit v1.2.3