Skip to content

Fix #4217: display warnings in repl #4269

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
Apr 7, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/repl/ReplDriver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ class ReplDriver(settings: Array[String],
val newImports = newState.imports ++ extractImports(parsed.trees)
val newStateWithImports = newState.copy(imports = newImports)

implicit val ctx: Context = newState.run.runContext
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this implicit context is needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, an implicit State is required.

displayErrors(newState.run.runContext.flushBufferedMessages())
Copy link
Contributor

@allanrenucci allanrenucci Apr 6, 2018

Choose a reason for hiding this comment

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

Can you add a comment saying that this code displays warnings. Otherwise it confusing (the name of the function is misleading).

Copy link
Contributor

Choose a reason for hiding this comment

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

Can that function get renamed a bit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, it's for another PR :)


displayDefinitions(unit.tpdTree, newestWrapper)(newStateWithImports)
}
}
Expand Down
7 changes: 7 additions & 0 deletions compiler/test-resources/repl/i4217
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
scala> def foo(x: Option[Int]) = x match { case None => }
1 | def foo(x: Option[Int]) = x match { case None => }
| ^
| match may not be exhaustive.
|
| It would fail on pattern case: Some(_)
def foo(x: Option[Int]): Unit