diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index 25917e4d7aa6..64cc0ff432ed 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -426,6 +426,8 @@ class PlainPrinter(_ctx: Context) extends Printer { else if (sym.isType) "type" else if (sym.isGetter) "getter" else if (sym.isSetter) "setter" + else if sym.is(Param) then "parameter" + else if sym.is(Given) then "given instance" else if (flags.is(Lazy)) "lazy value" else if (flags.is(Mutable)) "variable" else if (sym.isClassConstructor && sym.isPrimaryConstructor) "primary constructor" diff --git a/tests/neg-macros/i9014.check b/tests/neg-macros/i9014.check index 76f328f9ef4a..be338d620c60 100644 --- a/tests/neg-macros/i9014.check +++ b/tests/neg-macros/i9014.check @@ -7,4 +7,4 @@ | | given_Bar | - | But method given_Bar does not match type Bar. + | But given instance given_Bar does not match type Bar. diff --git a/tests/neg/abstract-givens.check b/tests/neg/abstract-givens.check index 88ed38f47ce0..cd504320383c 100644 --- a/tests/neg/abstract-givens.check +++ b/tests/neg/abstract-givens.check @@ -5,10 +5,10 @@ -- Error: tests/neg/abstract-givens.scala:8:8 -------------------------------------------------------------------------- 8 | given y(using Int): String = summon[Int].toString * 22 // error | ^ - | error overriding method y in trait T of type (using x$1: Int): String; - | method y of type (using x$1: Int): String cannot override final member method y in trait T + | error overriding given instance y in trait T of type (using x$1: Int): String; + | given instance y of type (using x$1: Int): String cannot override final member given instance y in trait T -- Error: tests/neg/abstract-givens.scala:9:8 -------------------------------------------------------------------------- 9 | given z[T](using T): Seq[T] = List(summon[T]) // error | ^ - | error overriding method z in trait T of type [T](using x$1: T): List[T]; - | method z of type [T](using x$1: T): Seq[T] has incompatible type + | error overriding given instance z in trait T of type [T](using x$1: T): List[T]; + | given instance z of type [T](using x$1: T): Seq[T] has incompatible type diff --git a/tests/neg/exports.check b/tests/neg/exports.check index 4d871161087f..8eeea9f5db8d 100644 --- a/tests/neg/exports.check +++ b/tests/neg/exports.check @@ -10,7 +10,7 @@ -- Error: tests/neg/exports.scala:25:21 -------------------------------------------------------------------------------- 25 | export printUnit.bitmap // error: no eligible member | ^ - | non-private method bitmap in class Copier refers to private value printUnit + | non-private given instance bitmap in class Copier refers to private value printUnit | in its type signature => Copier.this.printUnit.bitmap$ -- [E120] Naming Error: tests/neg/exports.scala:23:33 ------------------------------------------------------------------ 23 | export printUnit.{stat => _, _} // error: double definition diff --git a/tests/neg/i11066.check b/tests/neg/i11066.check new file mode 100644 index 000000000000..2b100005e809 --- /dev/null +++ b/tests/neg/i11066.check @@ -0,0 +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 diff --git a/tests/neg/i11066.scala b/tests/neg/i11066.scala new file mode 100644 index 000000000000..4b8e16e85e9d --- /dev/null +++ b/tests/neg/i11066.scala @@ -0,0 +1,15 @@ +class PreferredPrompt(val preference: String) +object Greeter: + def greet(name: String)(using prompt: PreferredPrompt) = + println(s"Welcome, $name. The system is ready.") + println(prompt.preference) +object JillsPrefs: + given jillsPrompt: PreferredPrompt = + PreferredPrompt("Your wish> ") +object JoesPrefs: + given joesPrompt: PreferredPrompt = + PreferredPrompt("relax> ") + +import JillsPrefs.jillsPrompt +import JoesPrefs.joesPrompt +val x = Greeter.greet("Who's there?") // error diff --git a/tests/neg/i9014.check b/tests/neg/i9014.check index b7a399f5cb75..629e81f6b6af 100644 --- a/tests/neg/i9014.check +++ b/tests/neg/i9014.check @@ -6,4 +6,4 @@ | | Bar.given_Bar | - | But method given_Bar in object Bar does not match type Bar. + | But given instance given_Bar in object Bar does not match type Bar. diff --git a/tests/neg/missing-implicit2.check b/tests/neg/missing-implicit2.check index 3b3661295d3a..834c8203780d 100644 --- a/tests/neg/missing-implicit2.check +++ b/tests/neg/missing-implicit2.check @@ -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 method xFromY + | no implicit argument of type Y was found for parameter y of given instance xFromY | | The following import might fix the problem: | diff --git a/tests/run-staging/i7142.scala b/tests/run-staging/i7142.scala index ff4bd6597703..295dd3376ce8 100644 --- a/tests/run-staging/i7142.scala +++ b/tests/run-staging/i7142.scala @@ -8,6 +8,6 @@ object Test { try run {returning('{ { (x: Int) => ${ throwReturn('x) }} apply 0 })} catch { case ex: dotty.tools.dotc.reporting.Diagnostic.Error => - assert(ex.getMessage == "While expanding a macro, a reference to value x was used outside the scope where it was defined", ex.getMessage) + assert(ex.getMessage == "While expanding a macro, a reference to parameter x was used outside the scope where it was defined", ex.getMessage) } }