Skip to content

Fix and reinstate repl/errmsgs #13459

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

Merged
merged 3 commits into from
Sep 4, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/repl/ReplDriver.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package dotty.tools.repl

import java.io.{File => JFile, PrintStream, PrintWriter}
import java.io.{BufferedWriter, File => JFile, OutputStreamWriter, PrintStream, PrintWriter}
import java.nio.charset.StandardCharsets

import dotty.tools.dotc.ast.Trees._
Expand Down Expand Up @@ -428,7 +428,7 @@ class ReplDriver(settings: Array[String],
/** Like ConsoleReporter, but without file paths or real -Xprompt'ing */
private object ReplConsoleReporter extends ConsoleReporter(
reader = null, // this short-circuits the -Xprompt display from waiting for an input
writer = new PrintWriter(out, /* autoFlush = */ true), // write to out, not Console.err
writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(out, StandardCharsets.UTF_8)), /* autoFlush = */ true), // write to out, not Console.err
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the BufferedWriter useful for something here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering the same, but it already took me n hours today to figure out what was actually different (need to toInt chars to get real differences) and how it possibly broke, that I'm done. This combination comes from what the constructor in PrintWriter does when it's given a PrintStream (out).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it doesn't matter since there's autoFlush=true, but I'll note that the repl reporter in scala 2 doesn't use BufferedWriter.

) {
override def posFileStr(pos: SourcePosition) = "" // omit file paths
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ scala> abstract class C { type T; val x: T; val s: Unit = { type T = String; var
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)
|Required: T?
|Required: T²
|
|where: T is a type in class C
| T? is a type in the initializer of value s which is an alias of String
| T² is a type in the initializer of value s which is an alias of String
longer explanation available when compiling with `-explain`
-- [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() } }; }
| ^
|Found: (y : T)
|Required: T?
|Required: T²
|
|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
| 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
Expand Down