Skip to content
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

make refined type printing more source compatible #12939

Closed
bishabosha opened this issue Jun 25, 2021 · 6 comments · Fixed by #16303
Closed

make refined type printing more source compatible #12939

bishabosha opened this issue Jun 25, 2021 · 6 comments · Fixed by #16303
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc exp:novice good first issue Perfect for someone who wants to get started contributing itype:enhancement Spree Suitable for a future Spree
Milestone

Comments

@bishabosha
Copy link
Member

bishabosha commented Jun 25, 2021

Compiler version

3.0.1-RC1

Minimized example

class Bag extends reflect.Selectable

val m = new Bag { val f = 23; def g = 47; def h(i: Int): Int = i }

Output

in the repl the type printed has a type that is not source compatible

scala> val m = new Bag { val f = 23; def g = 47; def h(i: Int): Int = i; var i = 101; type N = Int }
val m: Bag{f: Int; g: => Int; h(i: Int): Int; i: Int; i_=(x$1: Int): Unit; N = Int} = anon$1@403364e9

Expectation

we annotate each refinement with if it is a type, def or val

scala> val m = new Bag { val f = 23; def g = 47; def h(i: Int): Int = i; var i = 101; type N = Int }
val m: Bag{val f: Int; def g: Int; def h(i: Int): Int; def i: Int; def i_=(x$1: Int): Unit; type N = Int} = anon$1@403364e9
@bishabosha bishabosha added itype:enhancement area:reporting Error reporting including formatting, implicit suggestions, etc help wanted good first issue Perfect for someone who wants to get started contributing and removed help wanted labels Jun 25, 2021
@yasuomaidana
Copy link

Hi, let me try it.

@yasuomaidana
Copy link

I have a question, how do you make this test?.
It is my first time trying to use and contribute with this project. I already downloaded the repo and if I'm doing well, I'm running scala3 with this repo.
I run tests/pos/HelloWorld.scala, but I'm not sure how to run this example
😞

@bishabosha
Copy link
Member Author

bishabosha commented Jun 26, 2021

I think the best option would be to add a file to compiler/test-resources/type-printer, these get executed by compiler/test/dotty/tools/repl/ScriptedTests.scala, and its essentially replaying a repl session and asserting that the output matches the file in the type-printer dir

@anatoliykmetyuk
Copy link
Contributor

This issue was picked for the Issue Spree No. 23 of 08 November 2022 which takes place in a week from now. @SethTisue, @jan-pieter will be working on it. If you have any insight into the issue or guidance on how to fix it, please leave it here.

@SethTisue
Copy link
Member

SethTisue commented Nov 7, 2022

note that there is an abandoned draft PR at #13698 that already got some review feedback, so presumably we just need to pick that back up again and get it across the finish line

@SethTisue
Copy link
Member

var isn't allowed in refined types, so it's expected that the var shows up as a getter/setter pair

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc exp:novice good first issue Perfect for someone who wants to get started contributing itype:enhancement Spree Suitable for a future Spree
Projects
None yet
5 participants