-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add colon after method type in printer #1705
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
Conversation
Hi and thanks for the PR! If I may comment as an outsider, I think the type syntax itself is intended, and is even described in the language spec (http://scala-lang.org/files/archive/spec/2.12/03-types.html#method-types); maybe the highlighting should be changed. Your example doesn't work in Scala 2, but a variant does and gives a colon-less output in both REPLs. I can confirm that the scala> def id(x: Int): Int = x
id: (x: Int)Int |
I think we should just print it like this: scala> def id(x: Int): Int = x
def id(x: Int): Int Anything else is confusing for users. |
...which is exactly what scala/scala#5498 is about |
@Blaisorblade thanks for reference to the spec and your comments. That would mean we're simply missing the space. I just tested that and if there is a space, then the higlighting works correctly (the colon is not necessary for that). @smarter consequently, should the same thing apply for |
Yes. |
d892fc0
to
9c6fe7d
Compare
bd7a059
to
dc71872
Compare
I have updated the code to print the following: scala> def id(x: Int): Int = 10
def id: (x: Int): Int
scala> def idi(x: Int)(implicit y: Int): Int = x + y
def idi: (x: Int)(implicit y: Int): Int
scala> val a: Int = 10
val a: Int = 10
scala> var b: Int = 10
var b: Int = 10 @smarter What do you think? |
Looks nice! I think I would go further and print |
@smarter sorry I missed that in your example above. Fixed now! |
As the test failures indicate, you need to update the check files in https://github.com/lampepfl/dotty/tree/master/tests/repl to the new format (you can run just these tests locally using |
Fix #1707: Survive non-existing positions in parser
Changes
to
Contrary to the github markdown, the REPL would not highlight the method type w/o this change.