diff --git a/compiler/src/dotty/tools/repl/Rendering.scala b/compiler/src/dotty/tools/repl/Rendering.scala index 17c876661e18..f13e0616d1ec 100644 --- a/compiler/src/dotty/tools/repl/Rendering.scala +++ b/compiler/src/dotty/tools/repl/Rendering.scala @@ -33,7 +33,8 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None) { /** A `MessageRenderer` for the REPL without file positions */ private val messageRenderer = new MessageRendering { - override def posStr(pos: SourcePosition, diagnosticLevel: String, message: Message)(using Context): String = "" + override def posStr(pos: SourcePosition, diagnosticLevel: String, message: Message)(using Context): String = + hl(diagnosticLevel)(s"-- $diagnosticLevel:") } private var myClassLoader: ClassLoader = _ diff --git a/compiler/test-resources/repl/1379 b/compiler/test-resources/repl/1379 index 902d6251a62b..4814370995a0 100644 --- a/compiler/test-resources/repl/1379 +++ b/compiler/test-resources/repl/1379 @@ -1,4 +1,5 @@ scala> object Foo { val bar = new Object { def baz = 1 }; bar.baz } +-- Error: 1 | object Foo { val bar = new Object { def baz = 1 }; bar.baz } | ^^^^^^^ | value baz is not a member of Object \ No newline at end of file diff --git a/compiler/test-resources/repl/errmsgs b/compiler/test-resources/repl/errmsgs index e4cb6eca36d4..8e415ed41a88 100644 --- a/compiler/test-resources/repl/errmsgs +++ b/compiler/test-resources/repl/errmsgs @@ -1,35 +1,42 @@ scala> class Inv[T](x: T) // defined class Inv scala> val x: List[String] = List(1) +-- Error: 1 | val x: List[String] = List(1) | ^ | Found: (1 : Int) | Required: String scala> val y: List[List[String]] = List(List(1)) +-- Error: 1 | val y: List[List[String]] = List(List(1)) | ^ | Found: (1 : Int) | Required: String scala> val z: (List[String], List[Int]) = (List(1), List("a")) +-- Error: 1 | val z: (List[String], List[Int]) = (List(1), List("a")) | ^ | Found: (1 : Int) | Required: String +-- Error: 1 | val z: (List[String], List[Int]) = (List(1), List("a")) | ^^^ | Found: ("a" : String) | Required: Int scala> val a: Inv[String] = new Inv(new Inv(1)) +-- Error: 1 | val a: Inv[String] = new Inv(new Inv(1)) | ^^^^^^^^^^ | Found: Inv[Int] | Required: String scala> val b: Inv[String] = new Inv(1) +-- Error: 1 | val b: Inv[String] = new Inv(1) | ^ | Found: (1 : Int) | Required: String scala> abstract class C { type T; val x: T; val s: Unit = { type T = String; var y: T = x; locally { def f() = { type T = Int; val z: T = y }; f() } }; } +-- Error: 1 | abstract class C { type T; val x: T; val s: Unit = { type T = String; var y: T = x; locally { def f() = { type T = Int; val z: T = y }; f() } }; } | ^ |Found: (C.this.x : C.this.T) @@ -37,6 +44,7 @@ scala> abstract class C { type T; val x: T; val s: Unit = { type T = String; var | |where: T is a type in class C | T² is a type in the initializer of value s which is an alias of String +-- Error: 1 | abstract class C { type T; val x: T; val s: Unit = { type T = String; var y: T = x; locally { def f() = { type T = Int; val z: T = y }; f() } }; } | ^ |Found: (y : T) @@ -45,27 +53,33 @@ scala> abstract class C { type T; val x: T; val s: Unit = { type T = String; var |where: T is a type in the initializer of value s which is an alias of String | T² is a type in method f which is an alias of Int scala> class Foo() { def bar: Int = 1 }; val foo = new Foo(); foo.barr +-- Error: 1 | class Foo() { def bar: Int = 1 }; val foo = new Foo(); foo.barr | ^^^^^^^^ | value barr is not a member of Foo - did you mean foo.bar? scala> val x: List[Int] = "foo" :: List(1) +-- Error: 1 | val x: List[Int] = "foo" :: List(1) | ^^^^^ | Found: ("foo" : String) | Required: Int scala> while ((( foo ))) {} +-- Error: 1 | while ((( foo ))) {} | ^^^ | Not found: foo scala> val a: iDontExist = 1 +-- Error: 1 | val a: iDontExist = 1 | ^^^^^^^^^^ | Not found: type iDontExist scala> def foo1(x: => Int) = x _ +-- Error: 1 | def foo1(x: => Int) = x _ | ^^^ |Only function types can be followed by _ but the current expression has type Int scala> def foo2(x: => Int): () => Int = x _ +-- Error: 1 | def foo2(x: => Int): () => Int = x _ | ^^^ |Only function types can be followed by _ but the current expression has type Int diff --git a/compiler/test-resources/repl/errorThenValid b/compiler/test-resources/repl/errorThenValid index 3aea44b6392d..6f07caed9b0d 100644 --- a/compiler/test-resources/repl/errorThenValid +++ b/compiler/test-resources/repl/errorThenValid @@ -1,4 +1,5 @@ scala> val xs = scala.collection.mutable.ListBuffer[Int] +-- Error: 1 | val xs = scala.collection.mutable.ListBuffer[Int] | ^ | Missing parameter type diff --git a/compiler/test-resources/repl/i1370 b/compiler/test-resources/repl/i1370 index 21193692e355..9ecc6baf05b7 100644 --- a/compiler/test-resources/repl/i1370 +++ b/compiler/test-resources/repl/i1370 @@ -1,4 +1,5 @@ scala> object Lives { class Private { def foo1: Any = new Private.C1; def foo2: Any = new Private.C2 }; object Private { class C1 private {}; private class C2 {} } } +-- Error: 1 | object Lives { class Private { def foo1: Any = new Private.C1; def foo2: Any = new Private.C2 }; object Private { class C1 private {}; private class C2 {} } } | ^^^^^^^^^^ |constructor C1 cannot be accessed as a member of Lives.Private.C1 from class Private. diff --git a/compiler/test-resources/repl/i2063 b/compiler/test-resources/repl/i2063 index 2cee5d4fa735..e134c4eb9738 100644 --- a/compiler/test-resources/repl/i2063 +++ b/compiler/test-resources/repl/i2063 @@ -1,12 +1,15 @@ scala> class Foo extends Bar // with one tab +-- Error: 1 | class Foo extends Bar // with one tab | ^^^ | Not found: type Bar scala> class Foo extends Bar // with spaces +-- Error: 1 | class Foo extends Bar // with spaces | ^^^ | Not found: type Bar scala> class Foo extends Bar // with tabs +-- Error: 1 | class Foo extends Bar // with tabs | ^^^ | Not found: type Bar diff --git a/compiler/test-resources/repl/i2213 b/compiler/test-resources/repl/i2213 index 93638f03f504..2ff87954dd8f 100644 --- a/compiler/test-resources/repl/i2213 +++ b/compiler/test-resources/repl/i2213 @@ -1,9 +1,10 @@ scala> def x +-- Error: 1 | def x | ^ | Missing return type - scala> def x: Int +-- Error: 1 | def x: Int | ^ |Declaration of method x not allowed here: only classes can have declared but undefined members diff --git a/compiler/test-resources/repl/i2631 b/compiler/test-resources/repl/i2631 index f68b430d829d..a1cd56e372e0 100644 --- a/compiler/test-resources/repl/i2631 +++ b/compiler/test-resources/repl/i2631 @@ -1,4 +1,5 @@ scala> class Foo(x : Any) { val foo : Integer = 0; def this() = { this(foo) } } +-- Error: 1 | class Foo(x : Any) { val foo : Integer = 0; def this() = { this(foo) } } | ^^^ | foo is not accessible from constructor arguments \ No newline at end of file diff --git a/compiler/test-resources/repl/i4184 b/compiler/test-resources/repl/i4184 index 385e98014d11..ce407561354d 100644 --- a/compiler/test-resources/repl/i4184 +++ b/compiler/test-resources/repl/i4184 @@ -5,6 +5,7 @@ scala> object bar { class Foo } scala> implicit def eqFoo: CanEqual[foo.Foo, foo.Foo] = CanEqual.derived def eqFoo: CanEqual[foo.Foo, foo.Foo] scala> object Bar { new foo.Foo == new bar.Foo } +-- Error: 1 | object Bar { new foo.Foo == new bar.Foo } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | Values of types foo.Foo and bar.Foo cannot be compared with == or != diff --git a/compiler/test-resources/repl/i4217 b/compiler/test-resources/repl/i4217 index 22964adaf6a7..2015f0041431 100644 --- a/compiler/test-resources/repl/i4217 +++ b/compiler/test-resources/repl/i4217 @@ -1,4 +1,5 @@ scala> def foo(x: Option[Int]) = x match { case None => } +-- Warning: 1 | def foo(x: Option[Int]) = x match { case None => } | ^ | match may not be exhaustive. diff --git a/compiler/test-resources/repl/i4566 b/compiler/test-resources/repl/i4566 index dcc7262a0eaf..40e0d0610579 100644 --- a/compiler/test-resources/repl/i4566 +++ b/compiler/test-resources/repl/i4566 @@ -1,4 +1,5 @@ scala> object test { type ::[A, B]; def a: Int :: Int = ???; def b: Int = a } +-- Error: 1 | object test { type ::[A, B]; def a: Int :: Int = ???; def b: Int = a } | ^ | Found: Int :: Int diff --git a/compiler/test-resources/repl/i5733 b/compiler/test-resources/repl/i5733 index e9afea5e98ec..2a9ce5515467 100644 --- a/compiler/test-resources/repl/i5733 +++ b/compiler/test-resources/repl/i5733 @@ -1,7 +1,8 @@ scala> abstract class F { def f(arg: Any): Unit; override def toString = "F" } // defined class F scala> val f: F = println +-- Warning: 1 | val f: F = println | ^^^^^^^ |method println is eta-expanded even though F does not have the @FunctionalInterface annotation. -val f: F = F +val f: F = F \ No newline at end of file diff --git a/compiler/test-resources/repl/i6474 b/compiler/test-resources/repl/i6474 index 8b11b42859cf..b39fa1b91a75 100644 --- a/compiler/test-resources/repl/i6474 +++ b/compiler/test-resources/repl/i6474 @@ -9,6 +9,7 @@ val res0: (Any, Int) = (1,2) scala> ((1, 2): Foo2.T[Int][Int]): Foo2.T[Any][Int] val res1: (Any, Int) = (1,2) scala> (1, 2): Foo3.T[Int][Int] +-- Error: 1 | (1, 2): Foo3.T[Int][Int] | ^^^^^^^^^^^^^^^^ | Missing type parameter for Foo3.T[Int][Int] diff --git a/compiler/test-resources/repl/i6676 b/compiler/test-resources/repl/i6676 index 8e7f2c3d22ef..301dd50d1202 100644 --- a/compiler/test-resources/repl/i6676 +++ b/compiler/test-resources/repl/i6676 @@ -1,19 +1,24 @@ scala> xml" +-- Error: 1 | xml" | ^ | unclosed string literal scala> xml"" +-- Error: 1 | xml"" | ^^^^^ | value xml is not a member of StringContext scala> xml""" +-- Error: 1 | xml""" | ^ | unclosed multi-line string literal +-- Error: 1 | xml""" | ^ | unclosed multi-line string literal scala> s" +-- Error: 1 | s" | ^ | unclosed string literal diff --git a/compiler/test-resources/repl/i7644 b/compiler/test-resources/repl/i7644 index 780b3847bb4e..8ecab9be11f3 100644 --- a/compiler/test-resources/repl/i7644 +++ b/compiler/test-resources/repl/i7644 @@ -1,14 +1,18 @@ scala> class T extends CanEqual +-- Error: 1 | class T extends CanEqual | ^ | Cannot extend sealed trait CanEqual in a different source file +-- Error: 1 | class T extends CanEqual | ^^^^^^^^ | Missing type parameter for CanEqual scala> class T extends CanEqual +-- Error: 1 | class T extends CanEqual | ^ | Cannot extend sealed trait CanEqual in a different source file +-- Error: 1 | class T extends CanEqual | ^^^^^^^^ | Missing type parameter for CanEqual diff --git a/compiler/test-resources/repl/i9227 b/compiler/test-resources/repl/i9227 index 772325640ff7..c591fa9f1e0c 100644 --- a/compiler/test-resources/repl/i9227 +++ b/compiler/test-resources/repl/i9227 @@ -1,4 +1,5 @@ scala> import scala.quoted._; inline def myMacro[T]: Unit = ${ myMacroImpl[T] }; def myMacroImpl[T](using Quotes): Expr[Unit] = '{}; println(myMacro[Int]) +-- Error: 1 | import scala.quoted._; inline def myMacro[T]: Unit = ${ myMacroImpl[T] }; def myMacroImpl[T](using Quotes): Expr[Unit] = '{}; println(myMacro[Int]) | ^^^^^^^^^^^^ | Cannot call macro method myMacroImpl defined in the same source file diff --git a/compiler/test-resources/repl/importFromObj b/compiler/test-resources/repl/importFromObj index 144859891519..4b26e59196bd 100644 --- a/compiler/test-resources/repl/importFromObj +++ b/compiler/test-resources/repl/importFromObj @@ -5,6 +5,7 @@ scala> object o { val xs = List(1, 2, 3) } // defined object o scala> import o._ scala> buf += xs +-- Error: 1 | buf += xs | ^^ | Found: (o.xs : List[Int]) @@ -12,10 +13,12 @@ scala> buf += xs scala> buf ++= xs val res0: scala.collection.mutable.ListBuffer[Int] = ListBuffer(1, 2, 3) scala> import util.foobar +-- Error: 1 | import util.foobar | ^^^^^^ | value foobar is not a member of util scala> import util.foobar.bar +-- Error: 1 | import util.foobar.bar | ^^^^^^^^^^^ | value foobar is not a member of util diff --git a/compiler/test-resources/repl/notFound b/compiler/test-resources/repl/notFound index 99379a89660d..46c700f0412a 100644 --- a/compiler/test-resources/repl/notFound +++ b/compiler/test-resources/repl/notFound @@ -1,8 +1,10 @@ scala> Foo +-- Error: 1 | Foo | ^^^ | Not found: Foo scala> Bar +-- Error: 1 | Bar | ^^^ - | Not found: Bar + | Not found: Bar \ No newline at end of file diff --git a/compiler/test-resources/repl/overrides b/compiler/test-resources/repl/overrides index 05ddd3229deb..35dc779bf446 100644 --- a/compiler/test-resources/repl/overrides +++ b/compiler/test-resources/repl/overrides @@ -1,10 +1,12 @@ scala> class B { override def foo(i: Int): Unit = {}; } +-- Error: 1 | class B { override def foo(i: Int): Unit = {}; } | ^ | method foo overrides nothing scala> class A { def foo: Unit = {}; } // defined class A scala> class B extends A { override def foo(i: Int): Unit = {}; } +-- Error: 1 | class B extends A { override def foo(i: Int): Unit = {}; } | ^ | method foo has a different signature than the overridden declaration diff --git a/compiler/test-resources/repl/parsing b/compiler/test-resources/repl/parsing index 2b3da45aa537..9c8955f2effc 100644 --- a/compiler/test-resources/repl/parsing +++ b/compiler/test-resources/repl/parsing @@ -1,14 +1,15 @@ -scala> ; -scala> ;; -scala> 1; 2 +scala> ; +scala> ;; +scala> 1; 2 val res0: Int = 1 val res1: Int = 2 -scala> 1; +scala> 1; val res2: Int = 1 -scala> 1;; 2 +scala> 1;; 2 val res3: Int = 1 val res4: Int = 2 -scala> } +scala> } +-- Error: 1 | } | ^ | eof expected, but '}' found diff --git a/compiler/test-resources/type-printer/type-mismatch b/compiler/test-resources/type-printer/type-mismatch index 83a84d917113..30bbea0c7050 100644 --- a/compiler/test-resources/type-printer/type-mismatch +++ b/compiler/test-resources/type-printer/type-mismatch @@ -3,6 +3,7 @@ scala> case class Foo[A](a: A) scala> Foo(1) val res0: Foo[Int] = Foo(1) scala> val x: Foo[String] = res0 +-- Error: 1 | val x: Foo[String] = res0 | ^^^^ | Found: (res0 : Foo[Int]) diff --git a/compiler/test/dotty/tools/repl/ShadowingTests.scala b/compiler/test/dotty/tools/repl/ShadowingTests.scala index 037887602a44..3af6c02cf320 100644 --- a/compiler/test/dotty/tools/repl/ShadowingTests.scala +++ b/compiler/test/dotty/tools/repl/ShadowingTests.scala @@ -78,6 +78,7 @@ class ShadowingTests extends ReplTest(options = ShadowingTests.options): shadowed = "class C(val c: Int)", script = """|scala> new C().c + |-- Error: |1 | new C().c | | ^^^^^^^ | | missing argument for parameter c of constructor C in class C: (c: Int): C