From 8fd820a99eea796d7688a25a36110a67fe509bc8 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Sat, 7 Aug 2021 21:42:57 +0100 Subject: [PATCH] REPL: Make sure to call printSummary For example: scala> @deprecated("no", "nah") class C; new C there were 1 deprecation warning(s); re-run with -deprecation for details // defined class C val res0: C = C@4273cda6 --- compiler/src/dotty/tools/repl/ReplCompiler.scala | 1 + compiler/test-resources/repl/1379 | 1 + compiler/test-resources/repl/errmsgs | 12 ++++++++++++ compiler/test-resources/repl/errorThenValid | 1 + compiler/test-resources/repl/i13208.default.scala | 1 + compiler/test-resources/repl/i1370 | 1 + compiler/test-resources/repl/i2063 | 3 +++ compiler/test-resources/repl/i2213 | 1 + compiler/test-resources/repl/i2631 | 1 + compiler/test-resources/repl/i4184 | 1 + compiler/test-resources/repl/i4217 | 1 + compiler/test-resources/repl/i4566 | 1 + compiler/test-resources/repl/i5733 | 1 + compiler/test-resources/repl/i6474 | 1 + compiler/test-resources/repl/i6676 | 1 + compiler/test-resources/repl/i7644 | 2 ++ compiler/test-resources/repl/i9227 | 1 + compiler/test-resources/repl/importFromObj | 3 +++ compiler/test-resources/repl/notFound | 2 ++ compiler/test-resources/repl/overrides | 2 ++ compiler/test-resources/type-printer/type-mismatch | 1 + compiler/test/dotty/tools/repl/ShadowingTests.scala | 1 + 22 files changed, 40 insertions(+) diff --git a/compiler/src/dotty/tools/repl/ReplCompiler.scala b/compiler/src/dotty/tools/repl/ReplCompiler.scala index 5d0d5ae99d95..545c9d60ebf0 100644 --- a/compiler/src/dotty/tools/repl/ReplCompiler.scala +++ b/compiler/src/dotty/tools/repl/ReplCompiler.scala @@ -153,6 +153,7 @@ class ReplCompiler extends Compiler { private def runCompilationUnit(unit: CompilationUnit, state: State): Result[(CompilationUnit, State)] = { val ctx = state.context ctx.run.compileUnits(unit :: Nil) + ctx.run.printSummary() if (!ctx.reporter.hasErrors) (unit, state).result else ctx.reporter.removeBufferedMessages(using ctx).errors diff --git a/compiler/test-resources/repl/1379 b/compiler/test-resources/repl/1379 index 40017f1ef2e0..978aab344204 100644 --- a/compiler/test-resources/repl/1379 +++ b/compiler/test-resources/repl/1379 @@ -3,3 +3,4 @@ scala> object Foo { val bar = new Object { def baz = 1 }; bar.baz } 1 | object Foo { val bar = new Object { def baz = 1 }; bar.baz } | ^^^^^^^ | value baz is not a member of Object +1 error found diff --git a/compiler/test-resources/repl/errmsgs b/compiler/test-resources/repl/errmsgs index 71d82268f0b6..14e9d44fa0b8 100644 --- a/compiler/test-resources/repl/errmsgs +++ b/compiler/test-resources/repl/errmsgs @@ -7,6 +7,7 @@ scala> val x: List[String] = List(1) | Found: (1 : Int) | Required: String longer explanation available when compiling with `-explain` +1 error found scala> val y: List[List[String]] = List(List(1)) -- [E007] Type Mismatch Error: ------------------------------------------------- 1 | val y: List[List[String]] = List(List(1)) @@ -14,6 +15,7 @@ scala> val y: List[List[String]] = List(List(1)) | Found: (1 : Int) | Required: String longer explanation available when compiling with `-explain` +1 error found scala> val z: (List[String], List[Int]) = (List(1), List("a")) -- [E007] Type Mismatch Error: ------------------------------------------------- 1 | val z: (List[String], List[Int]) = (List(1), List("a")) @@ -27,6 +29,7 @@ longer explanation available when compiling with `-explain` | Found: ("a" : String) | Required: Int longer explanation available when compiling with `-explain` +2 errors found scala> val a: Inv[String] = new Inv(new Inv(1)) -- [E007] Type Mismatch Error: ------------------------------------------------- 1 | val a: Inv[String] = new Inv(new Inv(1)) @@ -34,6 +37,7 @@ scala> val a: Inv[String] = new Inv(new Inv(1)) | Found: Inv[Int] | Required: String longer explanation available when compiling with `-explain` +1 error found scala> val b: Inv[String] = new Inv(1) -- [E007] Type Mismatch Error: ------------------------------------------------- 1 | val b: Inv[String] = new Inv(1) @@ -41,6 +45,7 @@ scala> val b: Inv[String] = new Inv(1) | Found: (1 : Int) | Required: String longer explanation available when compiling with `-explain` +1 error found 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() } }; } -- [E007] Type Mismatch 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() } }; } @@ -60,11 +65,13 @@ longer explanation available when compiling with `-explain` |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 longer explanation available when compiling with `-explain` +2 errors found scala> class Foo() { def bar: Int = 1 }; val foo = new Foo(); foo.barr -- [E008] Not Found 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? +1 error found scala> val x: List[Int] = "foo" :: List(1) -- [E007] Type Mismatch Error: ------------------------------------------------- 1 | val x: List[Int] = "foo" :: List(1) @@ -72,27 +79,32 @@ scala> val x: List[Int] = "foo" :: List(1) | Found: ("foo" : String) | Required: Int longer explanation available when compiling with `-explain` +1 error found scala> while ((( foo ))) {} -- [E006] Not Found Error: ----------------------------------------------------- 1 | while ((( foo ))) {} | ^^^ | Not found: foo longer explanation available when compiling with `-explain` +1 error found scala> val a: iDontExist = 1 -- [E006] Not Found Error: ----------------------------------------------------- 1 | val a: iDontExist = 1 | ^^^^^^^^^^ | Not found: type iDontExist longer explanation available when compiling with `-explain` +1 error found scala> def foo1(x: => Int) = x _ -- [E099] Syntax Error: -------------------------------------------------------- 1 | def foo1(x: => Int) = x _ | ^^^ |Only function types can be followed by _ but the current expression has type Int longer explanation available when compiling with `-explain` +1 error found scala> def foo2(x: => Int): () => Int = x _ -- [E099] Syntax Error: -------------------------------------------------------- 1 | def foo2(x: => Int): () => Int = x _ | ^^^ |Only function types can be followed by _ but the current expression has type Int longer explanation available when compiling with `-explain` +1 error found diff --git a/compiler/test-resources/repl/errorThenValid b/compiler/test-resources/repl/errorThenValid index 8a67161a102a..bfe97c5a7400 100644 --- a/compiler/test-resources/repl/errorThenValid +++ b/compiler/test-resources/repl/errorThenValid @@ -5,5 +5,6 @@ scala> val xs = scala.collection.mutable.ListBuffer[Int] | Missing parameter type | | I could not infer the type of the parameter elems. +1 error found scala> val xs = scala.collection.mutable.ListBuffer[Int]() val xs: scala.collection.mutable.ListBuffer[Int] = ListBuffer() diff --git a/compiler/test-resources/repl/i13208.default.scala b/compiler/test-resources/repl/i13208.default.scala index b33941069abb..586b5862a67f 100644 --- a/compiler/test-resources/repl/i13208.default.scala +++ b/compiler/test-resources/repl/i13208.default.scala @@ -1,4 +1,5 @@ scala> try 1 +1 warning found -- [E000] Syntax Warning: ------------------------------------------------------ 1 | try 1 | ^^^^^ diff --git a/compiler/test-resources/repl/i1370 b/compiler/test-resources/repl/i1370 index 0cc56a4a185c..6582e03b6539 100644 --- a/compiler/test-resources/repl/i1370 +++ b/compiler/test-resources/repl/i1370 @@ -3,3 +3,4 @@ scala> object Lives { class Private { def foo1: Any = new Private.C1; def foo2: 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. +1 error found diff --git a/compiler/test-resources/repl/i2063 b/compiler/test-resources/repl/i2063 index a8d320be86eb..e1da25588cdf 100644 --- a/compiler/test-resources/repl/i2063 +++ b/compiler/test-resources/repl/i2063 @@ -4,15 +4,18 @@ scala> class Foo extends Bar // with one tab | ^^^ | Not found: type Bar longer explanation available when compiling with `-explain` +1 error found scala> class Foo extends Bar // with spaces -- [E006] Not Found Error: ----------------------------------------------------- 1 | class Foo extends Bar // with spaces | ^^^ | Not found: type Bar longer explanation available when compiling with `-explain` +1 error found scala> class Foo extends Bar // with tabs -- [E006] Not Found Error: ----------------------------------------------------- 1 | class Foo extends Bar // with tabs | ^^^ | Not found: type Bar longer explanation available when compiling with `-explain` +1 error found diff --git a/compiler/test-resources/repl/i2213 b/compiler/test-resources/repl/i2213 index a2d8fae57caf..b4f703b42167 100644 --- a/compiler/test-resources/repl/i2213 +++ b/compiler/test-resources/repl/i2213 @@ -9,3 +9,4 @@ scala> def x: Int 1 | def x: Int | ^ |Declaration of method x not allowed here: only classes can have declared but undefined members +1 error found diff --git a/compiler/test-resources/repl/i2631 b/compiler/test-resources/repl/i2631 index 72d2b6efacbe..a04e2cb15bc6 100644 --- a/compiler/test-resources/repl/i2631 +++ b/compiler/test-resources/repl/i2631 @@ -3,3 +3,4 @@ scala> class Foo(x : Any) { val foo : Integer = 0; def this() = { this(foo) } } 1 | class Foo(x : Any) { val foo : Integer = 0; def this() = { this(foo) } } | ^^^ | foo is not accessible from constructor arguments +1 error found diff --git a/compiler/test-resources/repl/i4184 b/compiler/test-resources/repl/i4184 index a7129f393e54..2c4eb7d12a6f 100644 --- a/compiler/test-resources/repl/i4184 +++ b/compiler/test-resources/repl/i4184 @@ -9,3 +9,4 @@ scala> object Bar { new foo.Foo == new bar.Foo } 1 | object Bar { new foo.Foo == new bar.Foo } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | Values of types foo.Foo and bar.Foo cannot be compared with == or != +1 error found diff --git a/compiler/test-resources/repl/i4217 b/compiler/test-resources/repl/i4217 index 7452332d06dd..61dfcdc3a955 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 => } +1 warning found -- [E029] Pattern Match Exhaustivity Warning: ---------------------------------- 1 | def foo(x: Option[Int]) = x match { case None => } | ^ diff --git a/compiler/test-resources/repl/i4566 b/compiler/test-resources/repl/i4566 index 2fa2cb6b2d54..27516a98b0c1 100644 --- a/compiler/test-resources/repl/i4566 +++ b/compiler/test-resources/repl/i4566 @@ -5,3 +5,4 @@ scala> object test { type ::[A, B]; def a: Int :: Int = ???; def b: Int = a } | Found: Int :: Int | Required: Int longer explanation available when compiling with `-explain` +1 error found diff --git a/compiler/test-resources/repl/i5733 b/compiler/test-resources/repl/i5733 index ef6e9be31cb3..ef578f24522f 100644 --- a/compiler/test-resources/repl/i5733 +++ b/compiler/test-resources/repl/i5733 @@ -1,6 +1,7 @@ scala> abstract class F { def f(arg: Any): Unit; override def toString = "F" } // defined class F scala> val f: F = println +1 warning found -- Warning: -------------------------------------------------------------------- 1 | val f: F = println | ^^^^^^^ diff --git a/compiler/test-resources/repl/i6474 b/compiler/test-resources/repl/i6474 index 13badfb96f04..0957bbbe2761 100644 --- a/compiler/test-resources/repl/i6474 +++ b/compiler/test-resources/repl/i6474 @@ -13,6 +13,7 @@ scala> (1, 2): Foo3.T[Int][Int] 1 | (1, 2): Foo3.T[Int][Int] | ^^^^^^^^^^^^^^^^ | Missing type parameter for Foo3.T[Int][Int] +1 error found scala> ((1, 2): Foo3.T[Int][Int][Int]): Foo3.T[Any][Int][Int] val res2: (Any, Int) = (1,2) scala> object Foo3 { type T[A] = [B] =>> [C] =>> (A, B) } diff --git a/compiler/test-resources/repl/i6676 b/compiler/test-resources/repl/i6676 index bcc64d13bb03..e60023000b1d 100644 --- a/compiler/test-resources/repl/i6676 +++ b/compiler/test-resources/repl/i6676 @@ -8,6 +8,7 @@ scala> xml"" 1 | xml"" | ^^^^^ | value xml is not a member of StringContext +1 error found scala> xml""" -- Error: ---------------------------------------------------------------------- 1 | xml""" diff --git a/compiler/test-resources/repl/i7644 b/compiler/test-resources/repl/i7644 index e2eb4fb911b9..4b6fd33acefa 100644 --- a/compiler/test-resources/repl/i7644 +++ b/compiler/test-resources/repl/i7644 @@ -8,6 +8,7 @@ longer explanation available when compiling with `-explain` 1 | class T extends CanEqual | ^^^^^^^^ | Missing type parameter for CanEqual +2 errors found scala> class T extends CanEqual -- [E112] Syntax Error: -------------------------------------------------------- 1 | class T extends CanEqual @@ -18,3 +19,4 @@ longer explanation available when compiling with `-explain` 1 | class T extends CanEqual | ^^^^^^^^ | Missing type parameter for CanEqual +2 errors found diff --git a/compiler/test-resources/repl/i9227 b/compiler/test-resources/repl/i9227 index 79064429de9b..45d1731dae39 100644 --- a/compiler/test-resources/repl/i9227 +++ b/compiler/test-resources/repl/i9227 @@ -4,3 +4,4 @@ scala> import scala.quoted._; inline def myMacro[T]: Unit = ${ myMacroImpl[T] }; | ^^^^^^^^^^^^ | Cannot call macro method myMacroImpl defined in the same source file | This location contains code that was inlined from rs$line$1:1 +1 error found diff --git a/compiler/test-resources/repl/importFromObj b/compiler/test-resources/repl/importFromObj index 4c575c3550d7..58e8c5370f72 100644 --- a/compiler/test-resources/repl/importFromObj +++ b/compiler/test-resources/repl/importFromObj @@ -11,6 +11,7 @@ scala> buf += xs | Found: (o.xs : List[Int]) | Required: Int longer explanation available when compiling with `-explain` +1 error found scala> buf ++= xs val res0: scala.collection.mutable.ListBuffer[Int] = ListBuffer(1, 2, 3) scala> import util.foobar @@ -18,8 +19,10 @@ scala> import util.foobar 1 | import util.foobar | ^^^^^^ | value foobar is not a member of util +1 error found scala> import util.foobar.bar -- [E008] Not Found Error: ----------------------------------------------------- 1 | import util.foobar.bar | ^^^^^^^^^^^ | value foobar is not a member of util +1 error found diff --git a/compiler/test-resources/repl/notFound b/compiler/test-resources/repl/notFound index 984c5716f90a..e6b251d8b723 100644 --- a/compiler/test-resources/repl/notFound +++ b/compiler/test-resources/repl/notFound @@ -4,9 +4,11 @@ scala> Foo | ^^^ | Not found: Foo longer explanation available when compiling with `-explain` +1 error found scala> Bar -- [E006] Not Found Error: ----------------------------------------------------- 1 | Bar | ^^^ | Not found: Bar longer explanation available when compiling with `-explain` +1 error found diff --git a/compiler/test-resources/repl/overrides b/compiler/test-resources/repl/overrides index fefe49f3e607..a32d4b18d404 100644 --- a/compiler/test-resources/repl/overrides +++ b/compiler/test-resources/repl/overrides @@ -4,6 +4,7 @@ scala> class B { override def foo(i: Int): Unit = {}; } | ^ | method foo overrides nothing longer explanation available when compiling with `-explain` +1 error found scala> class A { def foo: Unit = {}; } // defined class A scala> class B extends A { override def foo(i: Int): Unit = {}; } @@ -12,3 +13,4 @@ scala> class B extends A { override def foo(i: Int): Unit = {}; } | ^ | method foo has a different signature than the overridden declaration longer explanation available when compiling with `-explain` +1 error found diff --git a/compiler/test-resources/type-printer/type-mismatch b/compiler/test-resources/type-printer/type-mismatch index ca434c6e05aa..363065320b9d 100644 --- a/compiler/test-resources/type-printer/type-mismatch +++ b/compiler/test-resources/type-printer/type-mismatch @@ -9,3 +9,4 @@ scala> val x: Foo[String] = res0 | Found: (res0 : Foo[Int]) | Required: Foo[String] longer explanation available when compiling with `-explain` +1 error found diff --git a/compiler/test/dotty/tools/repl/ShadowingTests.scala b/compiler/test/dotty/tools/repl/ShadowingTests.scala index 07eb9169dbe4..4284c44c58de 100644 --- a/compiler/test/dotty/tools/repl/ShadowingTests.scala +++ b/compiler/test/dotty/tools/repl/ShadowingTests.scala @@ -82,6 +82,7 @@ class ShadowingTests extends ReplTest(options = ShadowingTests.options): |1 | new C().c | | ^^^^^^^ | | missing argument for parameter c of constructor C in class C: (c: Int): C + |1 error found | |scala> new C(13).c |val res0: Int = 13