-
Notifications
You must be signed in to change notification settings - Fork 1.1k
improvement: Simplify match types when possible #23146
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
s"""|toString(): String | ||
|toArray: Array[Object] | ||
|toIArray: IArray[Object] | ||
|toList: List[Int] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PReviously this was shown as a full match type
val returnType = tpe(gtpe.finalResultType) | ||
val retType = gtpe.finalResultType | ||
val simplified = if (retType.typeSymbol.isAliasType) retType else retType.deepDealiasAndSimplify | ||
val returnType = tpe(simplified) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't simplified
negatively impact union types?
def f(): Int | String = ???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes scalameta/metals#7004