improvement: Simplify match types when possible#23146
Merged
tgodzik merged 1 commit intoscala:mainfrom May 13, 2025
Merged
Conversation
tgodzik
commented
May 13, 2025
| s"""|toString(): String | ||
| |toArray: Array[Object] | ||
| |toIArray: IArray[Object] | ||
| |toList: List[Int] |
Contributor
Author
There was a problem hiding this comment.
PReviously this was shown as a full match type
kasiaMarek
reviewed
May 13, 2025
| val returnType = tpe(gtpe.finalResultType) | ||
| val retType = gtpe.finalResultType | ||
| val simplified = if (retType.typeSymbol.isAliasType) retType else retType.deepDealiasAndSimplify | ||
| val returnType = tpe(simplified) |
Member
There was a problem hiding this comment.
Won't simplified negatively impact union types?
def f(): Int | String = ???
Contributor
Author
There was a problem hiding this comment.
Added a test, it seems to work. I don't think it will simplify something it's unable to simplify more. Do you have another example that might highlight the issue?
Member
There was a problem hiding this comment.
It's fine then, I think it works as we'd like it to. 😄 I saw it does lub on OrType but it seems to still return an unchanged OrType, maybe it only collapses same cases.
kasiaMarek
approved these changes
May 13, 2025
tgodzik
added a commit
to scala/scala3-lts
that referenced
this pull request
May 19, 2025
tgodzik
added a commit
to scala/scala3-lts
that referenced
this pull request
May 19, 2025
Fixes scalameta/metals#7004 [Cherry-picked e5a9355][modified]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes scalameta/metals#7004