-
Notifications
You must be signed in to change notification settings - Fork 814
Type inference breaks when class is not sealed #4171
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
Labels
Area-Compiler-SRTP
bugs in SRTP inference, resolution, witness passing, code gen
Bug
Impact-Medium
(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone
Comments
Closing as the PR that removes this error was accepted and merged. |
The above script is working now. However there are other cases where type inference is not working for non-sealed types and at the moment I don't have a fix for that, but trying to get closer on #7458 Here's a new repro that still fails:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Area-Compiler-SRTP
bugs in SRTP inference, resolution, witness passing, code gen
Bug
Impact-Medium
(Internal MS Team use only) Describes an issue with moderate impact on existing code.
There are cases when using SRTP with overloads where a class that is not sealed is not resolved, when in fact the compiler has a good candidate.
Repro steps
Try this script
Expected behavior
Compile fine, inferring
test1
,test2
,test3
Actual behavior
Only
test1
is inferred, since it's anoption
type (sealed).Then we get this error:
Which doesn't add any useful information.
Known workarounds
Uncomment the first line and
test2
will be inferred.However for
test3
there's no workaround without fixing the compiler.Related information
I submitted a very easy fix for this issue
Basically we don't fail, because:
obj
was used and it doesn't match this (very useful to debug) list of candidate methods.Another option would be to check if the candidate was inferred using a default type, but again, that error message is more useful than just 'Could not resolve the ambiguity'.
The text was updated successfully, but these errors were encountered: