-
Notifications
You must be signed in to change notification settings - Fork 285
fix: Incompleteness in the resolver when detecting support for equality #6231
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
base: master
Are you sure you want to change the base?
Conversation
| if (allowCommonSuperType) { | ||
| if (HaveCommonSuperPreType(aa, bb)) { | ||
| return true; | ||
| } | ||
| } else { | ||
| if (IsSuperPreTypeOf(aa, bb) || IsSuperPreTypeOf(bb, aa)) { | ||
| return true; | ||
| } |
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.
Another way to accomplish this is to leave the original comparison
if (IsSuperPreTypeOf(aa, bb) || IsSuperPreTypeOf(bb, aa)) {
return true;
}and then do
if (allowCommonSuperType && HaveCommonSuperPreType(aa, bb)) {
return true;
}where the initial comparison if (IsSuperPreTypeOf(t, u) || IsSuperPreTypeOf(u, t)) ... inside HaveCommonSuperPreType can be removed.
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.
Ah OK so now two types are comparable iff, additionally to the usual rules, they have a common supertype and allowCommonSuperType is true. And allowCommonSuperType is true everywhere except for conversions and type tests. But if I do a quick search through PreTypeResolve.Expressions.cs, I never see both allowConversion and allowCommonSuperType to be both true or false at the same time, so isn't one implied by the other? Or did I miss something?
|
You're right, we could do with just one boolean flag the way we use this method. I think of them as two independent relaxations of the basic rule, so I like exposing them as such, but I'm happy to merge the flags into one. |
Fixes #6181.