Fix #7776: Detect missing implementations for C# 'abstract override' methods#19503
Draft
Fix #7776: Detect missing implementations for C# 'abstract override' methods#19503
Conversation
Member
|
@copilot : Try again |
Copilot stopped work on behalf of
T-Gro due to an error
March 27, 2026 08:41
Member
|
@copilot : Try again. |
Copilot stopped work on behalf of
T-Gro due to an error
March 27, 2026 11:54
Member
|
@copilot Try again |
…methods The IgnoreOverrides filter in InfoReader.fs incorrectly removed abstract override methods (e.g. C# 'abstract override string ToString()') because they were signature-equivalent to the base virtual method. This caused GetClassDispatchSlots to miss these as required dispatch slots. The fix adds an isAbstract check to the FilterOverrides function so that abstract methods from derived types are preserved even when they override an equivalent virtual in a supertype. This ensures the compiler correctly reports FS0365 when a non-abstract F# class inherits from a C# class with abstract override members without providing implementations. Agent-Logs-Url: https://github.com/dotnet/fsharp/sessions/1d6d6e17-b57c-435f-b144-0d3146d9cbd8 Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/fsharp/sessions/1d6d6e17-b57c-435f-b144-0d3146d9cbd8 Co-authored-by: abonie <20281641+abonie@users.noreply.github.com>
Contributor
Author
Implemented the fix in commit ab7b03c. Root cause: The Fix: Added an 6 regression tests added, all 2871 Conformance tests pass with 0 regressions. |
Copilot
AI
changed the title
[WIP] Copilot Request
Fix #7776: Detect missing implementations for C# 'abstract override' methods
Mar 31, 2026
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.
The F# compiler did not report an error when a non-abstract F# class inherited from a C# class with
abstract overridemembers (e.g.,public abstract override string ToString()) without providing implementations. This caused aTypeLoadExceptionat runtime with no compile-time warning.Root Cause
The
IgnoreOverridesfilter inInfoReader.FilterOverrideswas incorrectly removing C#abstract overridemethods from the method set. These methods have IL flagsAbstract=true, Virtual=true, NewSlot=false, and the filter treated them as equivalent to the base virtual method they re-abstract (e.g.,Object.ToString()), discarding them. This causedGetClassDispatchSlotsto only see the original non-abstract base method, which was marked as "optional" (already has an implementation), so no FS0365 error was reported.Fix
Added an
isAbstractparameter to theFilterOverridesfunction inInfoReader.fs. In theIgnoreOverridespath, abstract methods from derived types are now preserved even when they're signature-equivalent to virtual methods in supertypes. This ensuresGetClassDispatchSlotscorrectly identifies abstract override methods as required (non-optional) dispatch slots.Changes
src/Compiler/Checking/InfoReader.fs: AddedisAbstracttoFilterOverridesparameter tuple and theIgnoreOverrideskeepTest condition so abstract re-declarations are not filtered out.tests/.../AbstractMembers/AbstractMembers.fs: Added 6 regression tests covering: missing implementation error forabstract override ToString(), missing implementation for custom abstract override method, successful compilation when implementation is provided, abstract F# subclass allowed without implementation, and object expression with implementation.docs/release-notes/.FSharp.Compiler.Service/11.0.100.md: Added release note.Testing
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.