Skip to content

refactor: align "given instance" language instead of implicit #14718

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,13 @@ class ImplicitSearchError(

private def location(preposition: String) = if (where.isEmpty) "" else s" $preposition $where"

private def defaultAmbiguousImplicitMsg(ambi: AmbiguousImplicits) = {
formatMsg(s"ambiguous implicit arguments: ${ambi.explanation}${location("of")}")(
s"ambiguous implicit arguments of type ${pt.show} found${location("for")}"
private def defaultAmbiguousImplicitMsg(ambi: AmbiguousImplicits) =
formatMsg(s"ambiguous given instances: ${ambi.explanation}${location("of")}")(
s"ambiguous given instances of type ${pt.show} found${location("for")}"
)
}

private def defaultImplicitNotFoundMessage = {
ex"no implicit argument of type $pt was found${location("for")}"
}
private def defaultImplicitNotFoundMessage =
ex"no given instance of type $pt was found${location("for")}"

/** Construct a custom error message given an ambiguous implicit
* candidate `alt` and a user defined message `raw`.
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/i13838.check
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- Error: tests/neg-custom-args/i13838.scala:10:5 ----------------------------------------------------------------------
10 | foo // error
| ^
|no implicit argument of type Order[X] was found for parameter x$1 of method foo in object FooT
|no given instance of type Order[X] was found for parameter x$1 of method foo in object FooT
|
|where: X is a type variable
|.
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/i6436.check
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- Error: tests/neg-macros/i6436.scala:5:9 -----------------------------------------------------------------------------
5 | case '{ StringContext(${Varargs(parts)}*) } => // error
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| no implicit argument of type scala.quoted.Quotes was found
| no given instance of type scala.quoted.Quotes was found
-- [E006] Not Found Error: tests/neg-macros/i6436.scala:6:34 -----------------------------------------------------------
6 | val ps: Seq[Expr[String]] = parts // error
| ^^^^^
Expand Down
8 changes: 4 additions & 4 deletions tests/neg-macros/i9014b.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
-- Error: tests/neg-macros/i9014b/Test_2.scala:1:23 --------------------------------------------------------------------
1 |val tests = summon[Bar] // error
| ^
| no implicit argument of type Bar was found for parameter x of method summon in object Predef.
| I found:
| no given instance of type Bar was found for parameter x of method summon in object Predef.
| I found:
|
| given_Bar
| given_Bar
|
| But given instance given_Bar does not match type Bar.
| But given instance given_Bar does not match type Bar.
6 changes: 3 additions & 3 deletions tests/neg-scalajs/jsconstructortag-error-in-typer.check
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- Error: tests/neg-scalajs/jsconstructortag-error-in-typer.scala:9:39 -------------------------------------------------
9 | val a = js.constructorTag[ScalaClass] // error
| ^
|no implicit argument of type scala.scalajs.js.ConstructorTag[ScalaClass] was found for parameter tag of method constructorTag in package scala.scalajs.js.
|no given instance of type scala.scalajs.js.ConstructorTag[ScalaClass] was found for parameter tag of method constructorTag in package scala.scalajs.js.
|I found:
|
| scala.scalajs.js.ConstructorTag.materialize[T]
Expand All @@ -10,7 +10,7 @@
-- Error: tests/neg-scalajs/jsconstructortag-error-in-typer.scala:10:39 ------------------------------------------------
10 | val b = js.constructorTag[ScalaTrait] // error
| ^
|no implicit argument of type scala.scalajs.js.ConstructorTag[ScalaTrait] was found for parameter tag of method constructorTag in package scala.scalajs.js.
|no given instance of type scala.scalajs.js.ConstructorTag[ScalaTrait] was found for parameter tag of method constructorTag in package scala.scalajs.js.
|I found:
|
| scala.scalajs.js.ConstructorTag.materialize[T]
Expand All @@ -19,7 +19,7 @@
-- Error: tests/neg-scalajs/jsconstructortag-error-in-typer.scala:11:45 ------------------------------------------------
11 | val c = js.constructorTag[ScalaObject.type] // error
| ^
|no implicit argument of type scala.scalajs.js.ConstructorTag[ScalaObject.type] was found for parameter tag of method constructorTag in package scala.scalajs.js.
|no given instance of type scala.scalajs.js.ConstructorTag[ScalaObject.type] was found for parameter tag of method constructorTag in package scala.scalajs.js.
|I found:
|
| scala.scalajs.js.ConstructorTag.materialize[T]
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i10603a.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Error: tests/neg/i10603a.scala:2:35 ---------------------------------------------------------------------------------
2 | val x = implicitly[List[Boolean]] // error
| ^
| no implicit argument of type List[Boolean] was found for parameter e of method implicitly in object Predef
| no given instance of type List[Boolean] was found for parameter e of method implicitly in object Predef
2 changes: 1 addition & 1 deletion tests/neg/i10901.check
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
|
| Test.foo("abc")(/* missing */summon[C]) failed with
|
| no implicit argument of type C was found for parameter x$2 of method foo in object Test
| no given instance of type C was found for parameter x$2 of method foo in object Test
2 changes: 1 addition & 1 deletion tests/neg/i11066.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Error: tests/neg/i11066.scala:15:37 ---------------------------------------------------------------------------------
15 |val x = Greeter.greet("Who's there?") // error
| ^
|ambiguous implicit arguments: both given instance joesPrompt in object JoesPrefs and given instance jillsPrompt in object JillsPrefs match type PreferredPrompt of parameter prompt of method greet in object Greeter
|ambiguous given instances: both given instance joesPrompt in object JoesPrefs and given instance jillsPrompt in object JillsPrefs match type PreferredPrompt of parameter prompt of method greet in object Greeter
10 changes: 5 additions & 5 deletions tests/neg/i11897.check
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@
-- Error: tests/neg/i11897.scala:16:18 ---------------------------------------------------------------------------------
16 | assert(summon[A] == A(23)) // error
| ^
| no implicit argument of type A was found for parameter x of method summon in object Predef
| no given instance of type A was found for parameter x of method summon in object Predef
-- Error: tests/neg/i11897.scala:17:18 ---------------------------------------------------------------------------------
17 | assert(summon[B] == B(false)) // error
| ^
| no implicit argument of type B was found for parameter x of method summon in object Predef
| no given instance of type B was found for parameter x of method summon in object Predef
-- Error: tests/neg/i11897.scala:18:18 ---------------------------------------------------------------------------------
18 | assert(summon[C] == C("c")) // error
| ^
| no implicit argument of type C was found for parameter x of method summon in object Predef
| no given instance of type C was found for parameter x of method summon in object Predef
-- Error: tests/neg/i11897.scala:19:18 ---------------------------------------------------------------------------------
19 | assert(summon[E] == E(93)) // error
| ^
| no implicit argument of type E was found for parameter x of method summon in object Predef
| no given instance of type E was found for parameter x of method summon in object Predef
-- Error: tests/neg/i11897.scala:20:18 ---------------------------------------------------------------------------------
20 | assert(summon[G] == G(101)) // error
| ^
| no implicit argument of type G was found for parameter x of method summon in object Predef
| no given instance of type G was found for parameter x of method summon in object Predef
16 changes: 8 additions & 8 deletions tests/neg/i12049.check
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@
-- Error: tests/neg/i12049.scala:24:20 ---------------------------------------------------------------------------------
24 |val _ = summon[M[B]] // error
| ^
| no implicit argument of type M[B] was found for parameter x of method summon in object Predef
| no given instance of type M[B] was found for parameter x of method summon in object Predef
|
| Note: a match type could not be fully reduced:
| Note: a match type could not be fully reduced:
|
| trying to reduce M[B]
| failed since selector B
| does not match case A => Int
| and cannot be shown to be disjoint from it either.
| Therefore, reduction cannot advance to the remaining case
| trying to reduce M[B]
| failed since selector B
| does not match case A => Int
| and cannot be shown to be disjoint from it either.
| Therefore, reduction cannot advance to the remaining case
|
| case B => String
| case B => String
-- Error: tests/neg/i12049.scala:25:26 ---------------------------------------------------------------------------------
25 |val _ = summon[String =:= Last[Int *: Int *: Boolean *: String *: EmptyTuple]] // error
| ^
Expand Down
8 changes: 4 additions & 4 deletions tests/neg/i12232.check
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
-- Error: tests/neg/i12232.scala:17:15 ---------------------------------------------------------------------------------
17 | foo(min(3, 4)) // error: works in Scala 2, not in 3
| ^
| no implicit argument of type Op[Int, Int, V] was found for parameter op of method min in object Foo
| no given instance of type Op[Int, Int, V] was found for parameter op of method min in object Foo
|
| where: V is a type variable with constraint <: Double
| where: V is a type variable with constraint <: Double
-- Error: tests/neg/i12232.scala:19:16 ---------------------------------------------------------------------------------
19 | foo(minR(3, 4)) // error: works in Scala 2, not in 3
| ^
| no implicit argument of type Op[Int, Int, R] was found for parameter op of method minR in object Foo
| no given instance of type Op[Int, Int, R] was found for parameter op of method minR in object Foo
|
| where: R is a type variable with constraint <: Double
| where: R is a type variable with constraint <: Double
2 changes: 1 addition & 1 deletion tests/neg/i12591.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Error: tests/neg/i12591/Inner.scala:12:31 ---------------------------------------------------------------------------
12 |val badSummon = summon[TC[Bar]] // error here
| ^
|ambiguous implicit arguments: both outer.inner.Foo.ofFoo and outer.Foo.ofFoo match type outer.inner.Foo.TC[outer.Bar] of parameter x of method summon in object Predef
|ambiguous given instances: both outer.inner.Foo.ofFoo and outer.Foo.ofFoo match type outer.inner.Foo.TC[outer.Bar] of parameter x of method summon in object Predef
2 changes: 1 addition & 1 deletion tests/neg/i13991.check
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- Error: tests/neg/i13991.scala:5:7 -----------------------------------------------------------------------------------
5 | first[String] // error // before line 10 to test alignment of the error message `|`
| ^^^^^^^^^^^^^
| no implicit argument of type Foo[String] was found
| no given instance of type Foo[String] was found
|--------------------------------------------------------------------------------------------------------------------
|Inline stack trace
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i5498-postfixOps.check
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
-- Error: tests/neg/i5498-postfixOps.scala:6:0 -------------------------------------------------------------------------
6 | Seq(1, 2).filter(List(1,2) contains) // error: usage of postfix operator // error
|^
|no implicit argument of type scala.concurrent.duration.DurationConversions.Classifier[Null] was found for parameter ev of method second in trait DurationConversions
|no given instance of type scala.concurrent.duration.DurationConversions.Classifier[Null] was found for parameter ev of method second in trait DurationConversions
4 changes: 2 additions & 2 deletions tests/neg/i7613.check
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-- Error: tests/neg/i7613.scala:10:16 ----------------------------------------------------------------------------------
10 | new BazLaws[A] {} // error // error
| ^
| no implicit argument of type Baz[A] was found for parameter x$1 of constructor BazLaws in trait BazLaws
| no given instance of type Baz[A] was found for parameter x$1 of constructor BazLaws in trait BazLaws
-- Error: tests/neg/i7613.scala:10:2 -----------------------------------------------------------------------------------
10 | new BazLaws[A] {} // error // error
| ^
| no implicit argument of type Bar[A] was found for parameter x$1 of constructor BarLaws in trait BarLaws
| no given instance of type Bar[A] was found for parameter x$1 of constructor BarLaws in trait BarLaws
4 changes: 2 additions & 2 deletions tests/neg/i9185.check
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
| /* ambiguous: both object listMonad in object M and object optionMonad in object M match type M[F] */summon[M[F]]
| ) failed with
|
| ambiguous implicit arguments: both object listMonad in object M and object optionMonad in object M match type M[F] of parameter m of method pure in object M
| ambiguous given instances: both object listMonad in object M and object optionMonad in object M match type M[F] of parameter m of method pure in object M
-- Error: tests/neg/i9185.scala:8:28 -----------------------------------------------------------------------------------
8 | val value3 = M.pure("ola") // error
| ^
|ambiguous implicit arguments: both object listMonad in object M and object optionMonad in object M match type M[F] of parameter m of method pure in object M
|ambiguous given instances: both object listMonad in object M and object optionMonad in object M match type M[F] of parameter m of method pure in object M
-- [E008] Not Found Error: tests/neg/i9185.scala:11:16 -----------------------------------------------------------------
11 | val l = "abc".len // error
| ^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i9568.check
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- Error: tests/neg/i9568.scala:13:10 ----------------------------------------------------------------------------------
13 | blaMonad.foo(bla) // error: diverges
| ^
| no implicit argument of type => Monad[F] was found for parameter ev of method blaMonad in object Test
| no given instance of type => Monad[F] was found for parameter ev of method blaMonad in object Test
|
| where: F is a type variable with constraint <: [_] =>> Any
| .
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i9958.check
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- Error: tests/neg/i9958.scala:1:30 -----------------------------------------------------------------------------------
1 |val x = summon[[X] =>> (X, X)] // error
| ^
| no implicit argument of type [X] =>> (X, X) was found for parameter x of method summon in object Predef
| no given instance of type [X] =>> (X, X) was found for parameter x of method summon in object Predef
-- [E007] Type Mismatch Error: tests/neg/i9958.scala:8:10 --------------------------------------------------------------
8 |def b = f(a) // error
| ^
Expand Down
10 changes: 5 additions & 5 deletions tests/neg/implicitSearch.check
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
-- Error: tests/neg/implicitSearch.scala:13:12 -------------------------------------------------------------------------
13 | sort(xs) // error (with a partially constructed implicit argument shown)
| ^
| no implicit argument of type Test.Ord[List[List[T]]] was found for parameter o of method sort in object Test.
| I found:
| no given instance of type Test.Ord[List[List[T]]] was found for parameter o of method sort in object Test.
| I found:
|
| Test.listOrd[List[T]](Test.listOrd[T](/* missing */summon[Test.Ord[T]]))
| Test.listOrd[List[T]](Test.listOrd[T](/* missing */summon[Test.Ord[T]]))
|
| But no implicit values were found that match type Test.Ord[T].
| But no implicit values were found that match type Test.Ord[T].
-- Error: tests/neg/implicitSearch.scala:15:38 -------------------------------------------------------------------------
15 | listOrd(listOrd(implicitly[Ord[T]] /*not found*/)) // error
| ^
| no implicit argument of type Test.Ord[T] was found for parameter e of method implicitly in object Predef
| no given instance of type Test.Ord[T] was found for parameter e of method implicitly in object Predef
4 changes: 2 additions & 2 deletions tests/neg/missing-implicit1.check
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- Error: tests/neg/missing-implicit1.scala:17:4 -----------------------------------------------------------------------
17 | ff // error
| ^
|no implicit argument of type testObjectInstance.Zip[Option] was found for parameter xs of method ff in object testObjectInstance
|no given instance of type testObjectInstance.Zip[Option] was found for parameter xs of method ff in object testObjectInstance
|
|The following import might fix the problem:
|
Expand All @@ -19,7 +19,7 @@
-- Error: tests/neg/missing-implicit1.scala:23:42 ----------------------------------------------------------------------
23 | List(1, 2, 3).traverse(x => Option(x)) // error
| ^
|no implicit argument of type testObjectInstance.Zip[Option] was found for an implicit parameter of method traverse in trait Traverse
|no given instance of type testObjectInstance.Zip[Option] was found for an implicit parameter of method traverse in trait Traverse
|
|The following import might fix the problem:
|
Expand Down
4 changes: 2 additions & 2 deletions tests/neg/missing-implicit2.check
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-- Error: tests/neg/missing-implicit2.scala:10:18 ----------------------------------------------------------------------
10 | f(using xFromY) // error
| ^
| no implicit argument of type Y was found for parameter y of given instance xFromY
| no given instance of type Y was found for parameter y of given instance xFromY
|
| The following import might fix the problem:
|
Expand All @@ -10,7 +10,7 @@
-- Error: tests/neg/missing-implicit2.scala:16:5 -----------------------------------------------------------------------
16 | f // error
| ^
| no implicit argument of type X was found for parameter x of method f in object test
| no given instance of type X was found for parameter x of method f in object test
|
| The following import might make progress towards fixing the problem:
|
Expand Down
8 changes: 4 additions & 4 deletions tests/neg/missing-implicit3.check
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
-- Error: tests/neg/missing-implicit3.scala:13:36 ----------------------------------------------------------------------
13 |val sortedFoos = sort(List(new Foo)) // error
| ^
|no implicit argument of type ord.Ord[ord.Foo] was found for an implicit parameter of method sort in package ord.
|I found:
| no given instance of type ord.Ord[ord.Foo] was found for an implicit parameter of method sort in package ord.
| I found:
|
| ord.Ord.ordered[ord.Foo](/* missing */summon[ord.Foo => Comparable[? >: ord.Foo]])
| ord.Ord.ordered[ord.Foo](/* missing */summon[ord.Foo => Comparable[? >: ord.Foo]])
|
|But no implicit values were found that match type ord.Foo => Comparable[? >: ord.Foo].
| But no implicit values were found that match type ord.Foo => Comparable[? >: ord.Foo].
Loading