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

improvement: print better bracket suffix in label, Scala 3 completions #5497

Merged
merged 3 commits into from
Aug 10, 2023

Conversation

kasiaMarek
Copy link
Contributor

This PR contains the following changes:

  1. better printing of type params when there is a bracket suffix. We also print the bounds now and keep the original type param names.
  2. we don't print the type params coming from bracket suffix in some situations, e.g. for types, where it is printed anyway
  3. add completion suffix to Scope completions

@kasiaMarek kasiaMarek requested review from tgodzik and jkciesluk July 31, 2023 15:33
|""".stripMargin,
"TTT[A] = O.TTT",
compat = Map(
"3" -> "TTT[A <: scala.Int] >: List[A] <: List[A]"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"3" -> "TTT[A <: scala.Int] >: List[A] <: List[A]"
"3" -> "TTT[A <: Int]"

doesn't look like we need the other bounds 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other bounds are on the result. Do we not want it? I guess we could instead of >: List[A] <: List[A] write = List[A] if the upper and lower bounds are the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this might already be handled in Scala 2, which we could maybe reuse, but we don't want to show bounds if they are exactly the same, that brings no additional information to the user

@kasiaMarek kasiaMarek force-pushed the type-completions branch 2 times, most recently from c0166f1 to 31f1812 Compare August 2, 2023 08:58
@kasiaMarek kasiaMarek requested a review from tgodzik August 2, 2023 11:00
Copy link
Member

@jkciesluk jkciesluk left a comment

Choose a reason for hiding this comment

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

LGTM

check(
"type-with-params",
s"""|object O {
| type TTT[A <: Int] = List[A]
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if this would be an issue with match types, whether we would not show too much for the user if we show the right hand side

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2023-08-02 at 13 42 11
Or do we want just the result type in the description?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm... since it's in the detail maybe that's a boon? Let's leave it as is

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The question was if you want the detail to be

[type params] = rhs

as currently, or

rhs

or possibly

= rsh

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe = rhs?

Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

LGTM!

@kasiaMarek kasiaMarek added Scala 3 Generic ticket relating to Scala 3 presentation-compiler Something relating to the presentation compiler labels Aug 8, 2023
This PR contains the following changes:
1. better printing of type params when there is a bracket suffix. We also print the bounds now and keep the original type param names.
2. we don't print the type params coming from bracket suffix in some situations, e.g. for types, where it is printed anyway
3. add completion suffix to `Scope` completions
@kasiaMarek kasiaMarek force-pushed the type-completions branch 2 times, most recently from 6940edc to 544b51c Compare August 9, 2023 14:23
@kasiaMarek
Copy link
Contributor Author

I ignored all the new/changed tests for dotty pc. Can I merge it like this, @tgodzik?

@tgodzik
Copy link
Contributor

tgodzik commented Aug 10, 2023

I ignored all the new/changed tests for dotty pc. Can I merge it like this, @tgodzik?

Sure! We can also backport things to the compiler later on and update the tests afterwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
presentation-compiler Something relating to the presentation compiler Scala 3 Generic ticket relating to Scala 3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants