Skip to content
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

Prefer focus for missing arg position #15644

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3581,7 +3581,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
case failure: SearchFailureType =>
report.error(
missingArgMsg(arg, formal, implicitParamString(paramName, methodStr, tree), paramSymWithMethodTree(paramName)),
tree.srcPos.endPos
tree.srcPos.focus
)
case _ =>
}
Expand Down
4 changes: 2 additions & 2 deletions tests/neg-custom-args/i13838.check
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Error: tests/neg-custom-args/i13838.scala:10:5 ----------------------------------------------------------------------
-- Error: tests/neg-custom-args/i13838.scala:10:2 ----------------------------------------------------------------------
10 | foo // error
| ^
| ^
|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
12 changes: 6 additions & 6 deletions tests/neg-macros/i9014b.check
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

-- Error: tests/neg-macros/i9014b/Test_2.scala:1:23 --------------------------------------------------------------------
-- Error: tests/neg-macros/i9014b/Test_2.scala:1:18 --------------------------------------------------------------------
1 |val tests = summon[Bar] // error
| ^
| No given instance 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.
12 changes: 6 additions & 6 deletions tests/neg-scalajs/jsconstructortag-error-in-typer.check
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
-- Error: tests/neg-scalajs/jsconstructortag-error-in-typer.scala:9:39 -------------------------------------------------
-- Error: tests/neg-scalajs/jsconstructortag-error-in-typer.scala:9:27 -------------------------------------------------
9 | val a = js.constructorTag[ScalaClass] // error
| ^
| ^
|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]
|
|But method materialize in object ConstructorTag does not match type scala.scalajs.js.ConstructorTag[ScalaClass].
-- Error: tests/neg-scalajs/jsconstructortag-error-in-typer.scala:10:39 ------------------------------------------------
-- Error: tests/neg-scalajs/jsconstructortag-error-in-typer.scala:10:27 ------------------------------------------------
10 | val b = js.constructorTag[ScalaTrait] // error
| ^
| ^
|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]
|
|But method materialize in object ConstructorTag does not match type scala.scalajs.js.ConstructorTag[ScalaTrait].
-- Error: tests/neg-scalajs/jsconstructortag-error-in-typer.scala:11:45 ------------------------------------------------
-- Error: tests/neg-scalajs/jsconstructortag-error-in-typer.scala:11:27 ------------------------------------------------
11 | val c = js.constructorTag[ScalaObject.type] // error
| ^
| ^
|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:
|
Expand Down
8 changes: 4 additions & 4 deletions tests/neg/9107.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ trait M[F[_]]
trait Inv[T]

object Test {
def ev[X] = implicitly[
def ev[X] = implicitly[ // error
(X match { case Inv[t] => Int }) =:=
(X match { case Inv[t] => t })
] // error
]

def ev2[X] = implicitly[
def ev2[X] = implicitly[ // error
(M[[t] =>> runtime.MatchCase[Inv[t], Int]]) =:=
(M[[t] =>> runtime.MatchCase[Inv[t], t]])
] // error
]
}
24 changes: 12 additions & 12 deletions tests/neg/i10098.check
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
-- Error: tests/neg/i10098.scala:20:32 ---------------------------------------------------------------------------------
-- Error: tests/neg/i10098.scala:20:12 ---------------------------------------------------------------------------------
20 | implicitly[Bar12[Int, String]] // error
| ^
| There's no Foo2[String, Int]
-- Error: tests/neg/i10098.scala:21:32 ---------------------------------------------------------------------------------
| ^
| There's no Foo2[String, Int]
-- Error: tests/neg/i10098.scala:21:12 ---------------------------------------------------------------------------------
21 | implicitly[Bar21[Int, String]] // error
| ^
| There's no Foo1[String, Int]
-- Error: tests/neg/i10098.scala:22:32 ---------------------------------------------------------------------------------
| ^
| There's no Foo1[String, Int]
-- Error: tests/neg/i10098.scala:22:12 ---------------------------------------------------------------------------------
22 | implicitly[Baz12[Int, String]] // error
| ^
| There's no Baz12[Int, String]
-- Error: tests/neg/i10098.scala:23:32 ---------------------------------------------------------------------------------
| ^
| There's no Baz12[Int, String]
-- Error: tests/neg/i10098.scala:23:12 ---------------------------------------------------------------------------------
23 | implicitly[Baz21[Int, String]] // error
| ^
| There's no Baz21[Int, String]
| ^
| There's no Baz21[Int, String]
4 changes: 2 additions & 2 deletions 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 ---------------------------------------------------------------------------------
-- Error: tests/neg/i10603a.scala:2:20 ---------------------------------------------------------------------------------
2 | val x = implicitly[List[Boolean]] // error
| ^
| ^
| No given instance of type List[Boolean] was found for parameter e of method implicitly in object Predef
6 changes: 3 additions & 3 deletions tests/neg/i10603b.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Error: tests/neg/i10603b.scala:4:35 ---------------------------------------------------------------------------------
-- Error: tests/neg/i10603b.scala:4:20 ---------------------------------------------------------------------------------
4 | val x = implicitly[List[Boolean]] // error
| ^
| No implicit view available from Int => Boolean.
| ^
| No implicit view available from Int => Boolean.
4 changes: 2 additions & 2 deletions 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 ---------------------------------------------------------------------------------
-- Error: tests/neg/i11066.scala:15:21 ---------------------------------------------------------------------------------
15 |val x = Greeter.greet("Who's there?") // error
| ^
| ^
|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
6 changes: 3 additions & 3 deletions tests/neg/i11797.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Error: tests/neg/i11797.scala:6:17 ----------------------------------------------------------------------------------
-- Error: tests/neg/i11797.scala:6:8 -----------------------------------------------------------------------------------
6 | summon[Foo.Bar] // error
| ^
| Oops
| ^
| Oops
30 changes: 15 additions & 15 deletions tests/neg/i11897.check
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@
| ^^^^^^^^^^^
| given patterns are not allowed in a val definition,
| please bind to an identifier and use an alias given.
-- Error: tests/neg/i11897.scala:16:18 ---------------------------------------------------------------------------------
-- Error: tests/neg/i11897.scala:16:15 ---------------------------------------------------------------------------------
16 | assert(summon[A] == A(23)) // error
| ^
| No given instance of type A was found for parameter x of method summon in object Predef
-- Error: tests/neg/i11897.scala:17:18 ---------------------------------------------------------------------------------
| ^
| No given instance of type A was found for parameter x of method summon in object Predef
-- Error: tests/neg/i11897.scala:17:15 ---------------------------------------------------------------------------------
17 | assert(summon[B] == B(false)) // error
| ^
| No given instance of type B was found for parameter x of method summon in object Predef
-- Error: tests/neg/i11897.scala:18:18 ---------------------------------------------------------------------------------
| ^
| No given instance of type B was found for parameter x of method summon in object Predef
-- Error: tests/neg/i11897.scala:18:15 ---------------------------------------------------------------------------------
18 | assert(summon[C] == C("c")) // error
| ^
| No given instance of type C was found for parameter x of method summon in object Predef
-- Error: tests/neg/i11897.scala:19:18 ---------------------------------------------------------------------------------
| ^
| No given instance of type C was found for parameter x of method summon in object Predef
-- Error: tests/neg/i11897.scala:19:15 ---------------------------------------------------------------------------------
19 | assert(summon[E] == E(93)) // error
| ^
| No given instance of type E was found for parameter x of method summon in object Predef
-- Error: tests/neg/i11897.scala:20:18 ---------------------------------------------------------------------------------
| ^
| No given instance of type E was found for parameter x of method summon in object Predef
-- Error: tests/neg/i11897.scala:20:15 ---------------------------------------------------------------------------------
20 | assert(summon[G] == G(101)) // error
| ^
| No given instance 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
6 changes: 3 additions & 3 deletions tests/neg/i11982.check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-- Error: tests/neg/i11982.scala:22:38 ---------------------------------------------------------------------------------
-- Error: tests/neg/i11982.scala:22:30 ---------------------------------------------------------------------------------
22 | val p1: ("msg", 42) = unpair[Tshape] // error: no singleton value for Any
| ^
| No singleton value available for Any.
| ^
| No singleton value available for Any.
20 changes: 10 additions & 10 deletions tests/neg/i12049.check
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@
|
| case t1 *: t2 *: ts => Tuple.Concat[Reverse[ts], (t2, t1)]
| case EmptyTuple => EmptyTuple
-- Error: tests/neg/i12049.scala:24:20 ---------------------------------------------------------------------------------
-- Error: tests/neg/i12049.scala:24:14 ---------------------------------------------------------------------------------
24 |val _ = summon[M[B]] // error
| ^
| No given instance 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
16 changes: 8 additions & 8 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 ---------------------------------------------------------------------------------
-- Error: tests/neg/i12232.scala:17:9 ----------------------------------------------------------------------------------
17 | foo(min(3, 4)) // error: works in Scala 2, not in 3
| ^
| No given instance 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
-- Error: tests/neg/i12232.scala:19:16 ---------------------------------------------------------------------------------
| where: V is a type variable with constraint <: Double
-- Error: tests/neg/i12232.scala:19:10 ---------------------------------------------------------------------------------
19 | foo(minR(3, 4)) // error: works in Scala 2, not in 3
| ^
| No given instance 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
4 changes: 2 additions & 2 deletions 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 ---------------------------------------------------------------------------
-- Error: tests/neg/i12591/Inner.scala:12:22 ---------------------------------------------------------------------------
12 |val badSummon = summon[TC[Bar]] // error here
| ^
| ^
|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
18 changes: 9 additions & 9 deletions tests/neg/i13846.check
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
3 |def foo(): Int throws ArithmeticException = 1 / 0 // error
| ^^^^^^^^^^^^^^^^^^^
| throws clause cannot be defined for RuntimeException
-- Error: tests/neg/i13846.scala:7:9 -----------------------------------------------------------------------------------
-- Error: tests/neg/i13846.scala:7:4 -----------------------------------------------------------------------------------
7 | foo() // error
| ^
| The capability to throw exception ArithmeticException is missing.
| The capability can be provided by one of the following:
| - Adding a using clause `(using CanThrow[ArithmeticException])` to the definition of the enclosing method
| - Adding `throws ArithmeticException` clause after the result type of the enclosing method
| - Wrapping this piece of code with a `try` block that catches ArithmeticException
| ^
| The capability to throw exception ArithmeticException is missing.
| The capability can be provided by one of the following:
| - Adding a using clause `(using CanThrow[ArithmeticException])` to the definition of the enclosing method
| - Adding `throws ArithmeticException` clause after the result type of the enclosing method
| - Wrapping this piece of code with a `try` block that catches ArithmeticException
|
| The following import might fix the problem:
| The following import might fix the problem:
|
| import unsafeExceptions.canThrowAny
| import unsafeExceptions.canThrowAny
|
18 changes: 9 additions & 9 deletions tests/neg/i13864.check
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
| ^^^^^^^^^^
| Implementation restriction: cannot generate CanThrow capability for this kind of catch.
| CanThrow capabilities can only be generated for cases of the form `ex: T` where `T` is fully defined.
-- Error: tests/neg/i13864.scala:9:10 ----------------------------------------------------------------------------------
-- Error: tests/neg/i13864.scala:9:4 -----------------------------------------------------------------------------------
9 | foo(1) // error
| ^
| The capability to throw exception Ex[Int] is missing.
| The capability can be provided by one of the following:
| - Adding a using clause `(using CanThrow[Ex[Int]])` to the definition of the enclosing method
| - Adding `throws Ex[Int]` clause after the result type of the enclosing method
| - Wrapping this piece of code with a `try` block that catches Ex[Int]
| ^
| The capability to throw exception Ex[Int] is missing.
| The capability can be provided by one of the following:
| - Adding a using clause `(using CanThrow[Ex[Int]])` to the definition of the enclosing method
| - Adding `throws Ex[Int]` clause after the result type of the enclosing method
| - Wrapping this piece of code with a `try` block that catches Ex[Int]
|
| The following import might fix the problem:
| The following import might fix the problem:
|
| import unsafeExceptions.canThrowAny
| import unsafeExceptions.canThrowAny
|
8 changes: 4 additions & 4 deletions tests/neg/i14025.check
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
-- Error: tests/neg/i14025.scala:1:88 ----------------------------------------------------------------------------------
-- Error: tests/neg/i14025.scala:1:16 ----------------------------------------------------------------------------------
1 |val foo = summon[deriving.Mirror.Product { type MirroredType = [X] =>> [Y] =>> (X, Y) }] // error
| ^
| ^
|No given instance of type deriving.Mirror.Product{MirroredType[X] = [Y] =>> (X, Y)} was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.Product{MirroredType[X] = [Y] =>> (X, Y)}: type `[X] =>> [Y] =>> (X, Y)` is not a generic product because its subpart `[X] =>> [Y] =>> (X, Y)` is not a supported kind (either `*` or `* -> *`)
-- Error: tests/neg/i14025.scala:2:90 ----------------------------------------------------------------------------------
-- Error: tests/neg/i14025.scala:2:16 ----------------------------------------------------------------------------------
2 |val bar = summon[deriving.Mirror.Sum { type MirroredType = [X] =>> [Y] =>> List[(X, Y)] }] // error
| ^
| ^
|No given instance of type deriving.Mirror.Sum{MirroredType[X] = [Y] =>> List[(X, Y)]} was found for parameter x of method summon in object Predef. Failed to synthesize an instance of type deriving.Mirror.Sum{MirroredType[X] = [Y] =>> List[(X, Y)]}: type `[X] =>> [Y] =>> List[(X, Y)]` is not a generic sum because its subpart `[X] =>> [Y] =>> List[(X, Y)]` is not a supported kind (either `*` or `* -> *`)
Loading