-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix implicit search failure reporting
- Loading branch information
Showing
14 changed files
with
151 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- [E172] Type Error: tests/neg/19414-desugared.scala:22:34 ------------------------------------------------------------ | ||
22 | summon[BodySerializer[JsObject]] // error: Ambiguous given instances | ||
| ^ | ||
|Ambiguous given instances: both given instance given_Writer_JsValue and given instance given_Writer_JsObject match type Writer[B] of parameter writer of given instance given_BodySerializer_B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
trait JsValue | ||
trait JsObject extends JsValue | ||
|
||
trait Writer[T] | ||
trait BodySerializer[-B] | ||
|
||
class Printer | ||
|
||
given Writer[JsValue] = ??? | ||
given Writer[JsObject] = ??? | ||
|
||
// This is not an exact desugaring of the original code: currently the compiler | ||
// actually changes the modifier of the parameter list from `using` to | ||
// `implicit` when desugaring the context-bound `B: Writer` to `implicit writer: | ||
// Writer[B]`, but we can't write it in user code as this is not valid syntax. | ||
given [B](using | ||
writer: Writer[B], | ||
printer: Printer = new Printer | ||
): BodySerializer[B] = ??? | ||
|
||
def f: Unit = | ||
summon[BodySerializer[JsObject]] // error: Ambiguous given instances |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- [E172] Type Error: tests/neg/19414.scala:15:34 ---------------------------------------------------------------------- | ||
15 | summon[BodySerializer[JsObject]] // error: Ambiguous given instances | ||
| ^ | ||
|Ambiguous given instances: both given instance given_Writer_JsValue and given instance given_Writer_JsObject match type Writer[B] of a context parameter of given instance given_BodySerializer_B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
trait JsValue | ||
trait JsObject extends JsValue | ||
|
||
trait Writer[T] | ||
trait BodySerializer[-B] | ||
|
||
class Printer | ||
|
||
given Writer[JsValue] = ??? | ||
given Writer[JsObject] = ??? | ||
|
||
given [B: Writer](using printer: Printer = new Printer): BodySerializer[B] = ??? | ||
|
||
def f: Unit = | ||
summon[BodySerializer[JsObject]] // error: Ambiguous given instances |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- [E172] Type Error: tests/neg/given-ambiguous-default-1.scala:18:23 -------------------------------------------------- | ||
18 |def f: Unit = summon[B] // error: Ambiguous given instances | ||
| ^ | ||
|Ambiguous given instances: both given instance a1 and given instance a2 match type A of parameter a of given instance given_B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** This test checks that provided ambiguous given instances take precedence | ||
* over default given arguments. In the following code, the compiler must | ||
* report an "Ambiguous implicits" error for the parameter `a`, and must not | ||
* use its default value. | ||
* | ||
* See also: | ||
* - tests/neg/19414.scala | ||
* - tests/neg/19414-desugared.scala | ||
* - tests/neg/given-ambiguous-default-2.scala | ||
*/ | ||
|
||
class A | ||
class B | ||
given a1: A = ??? | ||
given a2: A = ??? | ||
given (using a: A = A()): B = ??? | ||
|
||
def f: Unit = summon[B] // error: Ambiguous given instances |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- [E172] Type Error: tests/neg/given-ambiguous-default-2.scala:18:23 -------------------------------------------------- | ||
18 |def f: Unit = summon[C] // error: Ambiguous given instances | ||
| ^ | ||
|Ambiguous given instances: both given instance a1 and given instance a2 match type A of parameter a of given instance given_C |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** This test checks that provided given instances take precedence over default | ||
* given arguments, even when there are multiple default arguments. Before the | ||
* fix for issue #19414, this code would compile without errors. | ||
* | ||
* See also: | ||
* - tests/neg/given-ambiguous-default-1.scala | ||
* - tests/neg/19414.scala | ||
* - tests/neg/19414-desugared.scala | ||
*/ | ||
|
||
class A | ||
class B | ||
class C | ||
given a1: A = ??? | ||
given a2: A = ??? | ||
given (using a: A = A(), b: B = B()): C = ??? | ||
|
||
def f: Unit = summon[C] // error: Ambiguous given instances |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
-- [E172] Type Error: tests/neg/missing-implicit3.scala:13:36 ---------------------------------------------------------- | ||
13 |val sortedFoos = sort(List(new Foo)) // error | ||
| ^ | ||
| No given instance of type ord.Ord[ord.Foo] was found for a context parameter of method sort in package ord. | ||
| I found: | ||
|No given instance of type ord.Foo => Comparable[? >: ord.Foo] was found for parameter x$1 of given instance ordered in object Ord | ||
| | ||
| ord.Ord.ordered[ord.Foo](/* missing */summon[ord.Foo => Comparable[? >: ord.Foo]]) | ||
|The following import might make progress towards fixing the problem: | ||
| | ||
| But no implicit values were found that match type ord.Foo => Comparable[? >: ord.Foo]. | ||
| | ||
| The following import might make progress towards fixing the problem: | ||
| | ||
| import scala.math.Ordered.orderingToOrdered | ||
| import scala.math.Ordered.orderingToOrdered | ||
| |