Skip to content

Commit b90752d

Browse files
authored
Merge pull request #14718 from ckipp01/givenLanguage
refactor: align "given instance" language instead of implicit
2 parents e31856c + b8df6aa commit b90752d

24 files changed

+61
-63
lines changed

compiler/src/dotty/tools/dotc/typer/ErrorReporting.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -306,15 +306,13 @@ class ImplicitSearchError(
306306

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

309-
private def defaultAmbiguousImplicitMsg(ambi: AmbiguousImplicits) = {
310-
formatMsg(s"ambiguous implicit arguments: ${ambi.explanation}${location("of")}")(
311-
s"ambiguous implicit arguments of type ${pt.show} found${location("for")}"
309+
private def defaultAmbiguousImplicitMsg(ambi: AmbiguousImplicits) =
310+
formatMsg(s"ambiguous given instances: ${ambi.explanation}${location("of")}")(
311+
s"ambiguous given instances of type ${pt.show} found${location("for")}"
312312
)
313-
}
314313

315-
private def defaultImplicitNotFoundMessage = {
316-
ex"no implicit argument of type $pt was found${location("for")}"
317-
}
314+
private def defaultImplicitNotFoundMessage =
315+
ex"no given instance of type $pt was found${location("for")}"
318316

319317
/** Construct a custom error message given an ambiguous implicit
320318
* candidate `alt` and a user defined message `raw`.

tests/neg-custom-args/i13838.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/neg-custom-args/i13838.scala:10:5 ----------------------------------------------------------------------
22
10 | foo // error
33
| ^
4-
|no implicit argument of type Order[X] was found for parameter x$1 of method foo in object FooT
4+
|no given instance of type Order[X] was found for parameter x$1 of method foo in object FooT
55
|
66
|where: X is a type variable
77
|.

tests/neg-macros/i6436.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/neg-macros/i6436.scala:5:9 -----------------------------------------------------------------------------
22
5 | case '{ StringContext(${Varargs(parts)}*) } => // error
33
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4-
| no implicit argument of type scala.quoted.Quotes was found
4+
| no given instance of type scala.quoted.Quotes was found
55
-- [E006] Not Found Error: tests/neg-macros/i6436.scala:6:34 -----------------------------------------------------------
66
6 | val ps: Seq[Expr[String]] = parts // error
77
| ^^^^^

tests/neg-macros/i9014b.check

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
-- Error: tests/neg-macros/i9014b/Test_2.scala:1:23 --------------------------------------------------------------------
33
1 |val tests = summon[Bar] // error
44
| ^
5-
| no implicit argument of type Bar was found for parameter x of method summon in object Predef.
6-
| I found:
5+
| no given instance of type Bar was found for parameter x of method summon in object Predef.
6+
| I found:
77
|
8-
| given_Bar
8+
| given_Bar
99
|
10-
| But given instance given_Bar does not match type Bar.
10+
| But given instance given_Bar does not match type Bar.

tests/neg-scalajs/jsconstructortag-error-in-typer.check

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/neg-scalajs/jsconstructortag-error-in-typer.scala:9:39 -------------------------------------------------
22
9 | val a = js.constructorTag[ScalaClass] // error
33
| ^
4-
|no implicit argument of type scala.scalajs.js.ConstructorTag[ScalaClass] was found for parameter tag of method constructorTag in package scala.scalajs.js.
4+
|no given instance of type scala.scalajs.js.ConstructorTag[ScalaClass] was found for parameter tag of method constructorTag in package scala.scalajs.js.
55
|I found:
66
|
77
| scala.scalajs.js.ConstructorTag.materialize[T]
@@ -10,7 +10,7 @@
1010
-- Error: tests/neg-scalajs/jsconstructortag-error-in-typer.scala:10:39 ------------------------------------------------
1111
10 | val b = js.constructorTag[ScalaTrait] // error
1212
| ^
13-
|no implicit argument of type scala.scalajs.js.ConstructorTag[ScalaTrait] was found for parameter tag of method constructorTag in package scala.scalajs.js.
13+
|no given instance of type scala.scalajs.js.ConstructorTag[ScalaTrait] was found for parameter tag of method constructorTag in package scala.scalajs.js.
1414
|I found:
1515
|
1616
| scala.scalajs.js.ConstructorTag.materialize[T]
@@ -19,7 +19,7 @@
1919
-- Error: tests/neg-scalajs/jsconstructortag-error-in-typer.scala:11:45 ------------------------------------------------
2020
11 | val c = js.constructorTag[ScalaObject.type] // error
2121
| ^
22-
|no implicit argument of type scala.scalajs.js.ConstructorTag[ScalaObject.type] was found for parameter tag of method constructorTag in package scala.scalajs.js.
22+
|no given instance of type scala.scalajs.js.ConstructorTag[ScalaObject.type] was found for parameter tag of method constructorTag in package scala.scalajs.js.
2323
|I found:
2424
|
2525
| scala.scalajs.js.ConstructorTag.materialize[T]

tests/neg/i10603a.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
-- Error: tests/neg/i10603a.scala:2:35 ---------------------------------------------------------------------------------
22
2 | val x = implicitly[List[Boolean]] // error
33
| ^
4-
| no implicit argument of type List[Boolean] was found for parameter e of method implicitly in object Predef
4+
| no given instance of type List[Boolean] was found for parameter e of method implicitly in object Predef

tests/neg/i10901.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@
3838
|
3939
| Test.foo("abc")(/* missing */summon[C]) failed with
4040
|
41-
| no implicit argument of type C was found for parameter x$2 of method foo in object Test
41+
| no given instance of type C was found for parameter x$2 of method foo in object Test

tests/neg/i11066.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
-- Error: tests/neg/i11066.scala:15:37 ---------------------------------------------------------------------------------
22
15 |val x = Greeter.greet("Who's there?") // error
33
| ^
4-
|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
4+
|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

tests/neg/i11897.check

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@
2626
-- Error: tests/neg/i11897.scala:16:18 ---------------------------------------------------------------------------------
2727
16 | assert(summon[A] == A(23)) // error
2828
| ^
29-
| no implicit argument of type A was found for parameter x of method summon in object Predef
29+
| no given instance of type A was found for parameter x of method summon in object Predef
3030
-- Error: tests/neg/i11897.scala:17:18 ---------------------------------------------------------------------------------
3131
17 | assert(summon[B] == B(false)) // error
3232
| ^
33-
| no implicit argument of type B was found for parameter x of method summon in object Predef
33+
| no given instance of type B was found for parameter x of method summon in object Predef
3434
-- Error: tests/neg/i11897.scala:18:18 ---------------------------------------------------------------------------------
3535
18 | assert(summon[C] == C("c")) // error
3636
| ^
37-
| no implicit argument of type C was found for parameter x of method summon in object Predef
37+
| no given instance of type C was found for parameter x of method summon in object Predef
3838
-- Error: tests/neg/i11897.scala:19:18 ---------------------------------------------------------------------------------
3939
19 | assert(summon[E] == E(93)) // error
4040
| ^
41-
| no implicit argument of type E was found for parameter x of method summon in object Predef
41+
| no given instance of type E was found for parameter x of method summon in object Predef
4242
-- Error: tests/neg/i11897.scala:20:18 ---------------------------------------------------------------------------------
4343
20 | assert(summon[G] == G(101)) // error
4444
| ^
45-
| no implicit argument of type G was found for parameter x of method summon in object Predef
45+
| no given instance of type G was found for parameter x of method summon in object Predef

tests/neg/i12049.check

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@
3434
-- Error: tests/neg/i12049.scala:24:20 ---------------------------------------------------------------------------------
3535
24 |val _ = summon[M[B]] // error
3636
| ^
37-
| no implicit argument of type M[B] was found for parameter x of method summon in object Predef
37+
| no given instance of type M[B] was found for parameter x of method summon in object Predef
3838
|
39-
| Note: a match type could not be fully reduced:
39+
| Note: a match type could not be fully reduced:
4040
|
41-
| trying to reduce M[B]
42-
| failed since selector B
43-
| does not match case A => Int
44-
| and cannot be shown to be disjoint from it either.
45-
| Therefore, reduction cannot advance to the remaining case
41+
| trying to reduce M[B]
42+
| failed since selector B
43+
| does not match case A => Int
44+
| and cannot be shown to be disjoint from it either.
45+
| Therefore, reduction cannot advance to the remaining case
4646
|
47-
| case B => String
47+
| case B => String
4848
-- Error: tests/neg/i12049.scala:25:26 ---------------------------------------------------------------------------------
4949
25 |val _ = summon[String =:= Last[Int *: Int *: Boolean *: String *: EmptyTuple]] // error
5050
| ^

tests/neg/i12232.check

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
-- Error: tests/neg/i12232.scala:17:15 ---------------------------------------------------------------------------------
22
17 | foo(min(3, 4)) // error: works in Scala 2, not in 3
33
| ^
4-
| no implicit argument of type Op[Int, Int, V] was found for parameter op of method min in object Foo
4+
| no given instance of type Op[Int, Int, V] was found for parameter op of method min in object Foo
55
|
6-
| where: V is a type variable with constraint <: Double
6+
| where: V is a type variable with constraint <: Double
77
-- Error: tests/neg/i12232.scala:19:16 ---------------------------------------------------------------------------------
88
19 | foo(minR(3, 4)) // error: works in Scala 2, not in 3
99
| ^
10-
| no implicit argument of type Op[Int, Int, R] was found for parameter op of method minR in object Foo
10+
| no given instance of type Op[Int, Int, R] was found for parameter op of method minR in object Foo
1111
|
12-
| where: R is a type variable with constraint <: Double
12+
| where: R is a type variable with constraint <: Double

tests/neg/i12591.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
-- Error: tests/neg/i12591/Inner.scala:12:31 ---------------------------------------------------------------------------
22
12 |val badSummon = summon[TC[Bar]] // error here
33
| ^
4-
|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
4+
|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

tests/neg/i13991.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/neg/i13991.scala:5:7 -----------------------------------------------------------------------------------
22
5 | first[String] // error // before line 10 to test alignment of the error message `|`
33
| ^^^^^^^^^^^^^
4-
| no implicit argument of type Foo[String] was found
4+
| no given instance of type Foo[String] was found
55
|--------------------------------------------------------------------------------------------------------------------
66
|Inline stack trace
77
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

tests/neg/i5498-postfixOps.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
-- Error: tests/neg/i5498-postfixOps.scala:6:0 -------------------------------------------------------------------------
1414
6 | Seq(1, 2).filter(List(1,2) contains) // error: usage of postfix operator // error
1515
|^
16-
|no implicit argument of type scala.concurrent.duration.DurationConversions.Classifier[Null] was found for parameter ev of method second in trait DurationConversions
16+
|no given instance of type scala.concurrent.duration.DurationConversions.Classifier[Null] was found for parameter ev of method second in trait DurationConversions

tests/neg/i7613.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
-- Error: tests/neg/i7613.scala:10:16 ----------------------------------------------------------------------------------
22
10 | new BazLaws[A] {} // error // error
33
| ^
4-
| no implicit argument of type Baz[A] was found for parameter x$1 of constructor BazLaws in trait BazLaws
4+
| no given instance of type Baz[A] was found for parameter x$1 of constructor BazLaws in trait BazLaws
55
-- Error: tests/neg/i7613.scala:10:2 -----------------------------------------------------------------------------------
66
10 | new BazLaws[A] {} // error // error
77
| ^
8-
| no implicit argument of type Bar[A] was found for parameter x$1 of constructor BarLaws in trait BarLaws
8+
| no given instance of type Bar[A] was found for parameter x$1 of constructor BarLaws in trait BarLaws

tests/neg/i9185.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
| /* ambiguous: both object listMonad in object M and object optionMonad in object M match type M[F] */summon[M[F]]
99
| ) failed with
1010
|
11-
| 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
11+
| 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
1212
-- Error: tests/neg/i9185.scala:8:28 -----------------------------------------------------------------------------------
1313
8 | val value3 = M.pure("ola") // error
1414
| ^
15-
|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
15+
|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
1616
-- [E008] Not Found Error: tests/neg/i9185.scala:11:16 -----------------------------------------------------------------
1717
11 | val l = "abc".len // error
1818
| ^^^^^^^^^

tests/neg/i9568.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/neg/i9568.scala:13:10 ----------------------------------------------------------------------------------
22
13 | blaMonad.foo(bla) // error: diverges
33
| ^
4-
| no implicit argument of type => Monad[F] was found for parameter ev of method blaMonad in object Test
4+
| no given instance of type => Monad[F] was found for parameter ev of method blaMonad in object Test
55
|
66
| where: F is a type variable with constraint <: [_] =>> Any
77
| .

tests/neg/i9958.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/neg/i9958.scala:1:30 -----------------------------------------------------------------------------------
22
1 |val x = summon[[X] =>> (X, X)] // error
33
| ^
4-
| no implicit argument of type [X] =>> (X, X) was found for parameter x of method summon in object Predef
4+
| no given instance of type [X] =>> (X, X) was found for parameter x of method summon in object Predef
55
-- [E007] Type Mismatch Error: tests/neg/i9958.scala:8:10 --------------------------------------------------------------
66
8 |def b = f(a) // error
77
| ^

tests/neg/implicitSearch.check

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
-- Error: tests/neg/implicitSearch.scala:13:12 -------------------------------------------------------------------------
22
13 | sort(xs) // error (with a partially constructed implicit argument shown)
33
| ^
4-
| no implicit argument of type Test.Ord[List[List[T]]] was found for parameter o of method sort in object Test.
5-
| I found:
4+
| no given instance of type Test.Ord[List[List[T]]] was found for parameter o of method sort in object Test.
5+
| I found:
66
|
7-
| Test.listOrd[List[T]](Test.listOrd[T](/* missing */summon[Test.Ord[T]]))
7+
| Test.listOrd[List[T]](Test.listOrd[T](/* missing */summon[Test.Ord[T]]))
88
|
9-
| But no implicit values were found that match type Test.Ord[T].
9+
| But no implicit values were found that match type Test.Ord[T].
1010
-- Error: tests/neg/implicitSearch.scala:15:38 -------------------------------------------------------------------------
1111
15 | listOrd(listOrd(implicitly[Ord[T]] /*not found*/)) // error
1212
| ^
13-
| no implicit argument of type Test.Ord[T] was found for parameter e of method implicitly in object Predef
13+
| no given instance of type Test.Ord[T] was found for parameter e of method implicitly in object Predef

tests/neg/missing-implicit1.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/neg/missing-implicit1.scala:17:4 -----------------------------------------------------------------------
22
17 | ff // error
33
| ^
4-
|no implicit argument of type testObjectInstance.Zip[Option] was found for parameter xs of method ff in object testObjectInstance
4+
|no given instance of type testObjectInstance.Zip[Option] was found for parameter xs of method ff in object testObjectInstance
55
|
66
|The following import might fix the problem:
77
|
@@ -19,7 +19,7 @@
1919
-- Error: tests/neg/missing-implicit1.scala:23:42 ----------------------------------------------------------------------
2020
23 | List(1, 2, 3).traverse(x => Option(x)) // error
2121
| ^
22-
|no implicit argument of type testObjectInstance.Zip[Option] was found for an implicit parameter of method traverse in trait Traverse
22+
|no given instance of type testObjectInstance.Zip[Option] was found for an implicit parameter of method traverse in trait Traverse
2323
|
2424
|The following import might fix the problem:
2525
|

tests/neg/missing-implicit2.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Error: tests/neg/missing-implicit2.scala:10:18 ----------------------------------------------------------------------
22
10 | f(using xFromY) // error
33
| ^
4-
| no implicit argument of type Y was found for parameter y of given instance xFromY
4+
| no given instance of type Y was found for parameter y of given instance xFromY
55
|
66
| The following import might fix the problem:
77
|
@@ -10,7 +10,7 @@
1010
-- Error: tests/neg/missing-implicit2.scala:16:5 -----------------------------------------------------------------------
1111
16 | f // error
1212
| ^
13-
| no implicit argument of type X was found for parameter x of method f in object test
13+
| no given instance of type X was found for parameter x of method f in object test
1414
|
1515
| The following import might make progress towards fixing the problem:
1616
|

tests/neg/missing-implicit3.check

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
-- Error: tests/neg/missing-implicit3.scala:13:36 ----------------------------------------------------------------------
22
13 |val sortedFoos = sort(List(new Foo)) // error
33
| ^
4-
|no implicit argument of type ord.Ord[ord.Foo] was found for an implicit parameter of method sort in package ord.
5-
|I found:
4+
| no given instance of type ord.Ord[ord.Foo] was found for an implicit parameter of method sort in package ord.
5+
| I found:
66
|
7-
| ord.Ord.ordered[ord.Foo](/* missing */summon[ord.Foo => Comparable[? >: ord.Foo]])
7+
| ord.Ord.ordered[ord.Foo](/* missing */summon[ord.Foo => Comparable[? >: ord.Foo]])
88
|
9-
|But no implicit values were found that match type ord.Foo => Comparable[? >: ord.Foo].
9+
| But no implicit values were found that match type ord.Foo => Comparable[? >: ord.Foo].

0 commit comments

Comments
 (0)