-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Static virtual reabstraction doesn't seem to work #71414
Comments
Thanks Michal for reporting this issue. Just to make sure I understand you correctly, are you only concerned about the insufficiently descriptive error message or do you believe that the actual runtime behavior is incorrect? |
I don't know what the runtime is doing that we hit a |
The Roslyn issue is already fixed. Somehow I switched to a globally installed Preview 5 SDK mid-experimenting with this. The MissingMethodException still reproes with the latest daily build of the SDK. |
I am not sure if there was a Roslyn issue around the |
Is this something we need to fix in 7? |
I'm going to try to give it a shot next week; in general I think it's a somewhat corner case, at the very least static virtual method functionality in the .NET 7 runtime libraries hasn't hit this yet. |
It's in the same bucket as the diamond case. Properly authored apps will never hit it at runtime because Roslyn would never emit it. Mismatched dependencies and incorrectly composed apps can hit it. It's more likely the customers would hit it than us. |
moving to 8 at this point. |
- Add a new helper for the re-abstraction case when the JIT detects an issue - In the late bound case, instead of producing an error directly, produce an IL stub and have it make the virtual stub dispatch call itself, this will fall back to the JIT implementation for re-abstraction - Tweak the late bound case to also actively detect the AmbiguousMatchException case as well and use the same helper there as well. Fixes #71414
I'm working on implementing this with NativeAOT and was looking at how it works in the VM.
Reproed with
7.0.100-preview.5.22307.18 SDK7.0.100-preview.7.22328.2:Compile following program:
This will throw at runtime:Sure, looks like a Roslyn bug, but it's not what I'm after. (@AlekseyTs is this known?)Fix the problem by ildasm-ing the assembly, adding the missingfinal
and ILAsm-ing it back. Now the program works as expected.Now, go back to the IL and change BarClass to implement IBaz instead of the IBar (Roslyn wouldn't allow compiling that because the method was reabstracted). Rebuild the IL.
This doesn't look like the experience we would want for reabstraction. For reference, the exception with instance default interface methods is (you have to go back to the IL this generates and replace IBar with IBaz in BarClass interface list, same as for the static virtual case because Roslyn doesn't allow compiling with the reabstraction):
This will print a more descriptive message:
Cc @trylek @davidwrighton
The text was updated successfully, but these errors were encountered: