Skip to content

Checker: fix stale type subsumption cache entries - #21026

Open
auduchinok wants to merge 1 commit into
dotnet:mainfrom
auduchinok:checker-subsumptionCacheOpenTypes
Open

auduchinok wants to merge 1 commit into
dotnet:mainfrom
auduchinok:checker-subsumptionCacheOpenTypes

Conversation

@auduchinok

Copy link
Copy Markdown
Member
type Overloaded =
    static member Pick(x: System.IEquatable<Item>) = 1
    static member Pick(x: obj) = "obj"

and Item =
    { Value: int }

    static member Inside() = Overloaded.Pick({ Value = 1 })

This fails with FS0363 (“The interface ‘System.IEquatable‘ is included in multiple explicitly implemented interface types”) at --langversion:10.0. A record gets its equality interfaces after the members of its recursive group are checked, so the call in Inside caches “Item is not an IEquatable” and the later interface check gets that answer back.

The type subsumption cache is now only used when the type whose supertypes are searched has been closed, which is when its supertypes and interfaces are final.

At the default language version the same source currently fails with FS0001 instead, from the overload resolution cache; that is fixed separately in checker-overloadCacheTyArgs.

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

✅ Release notes checked


✅ Found changes and release notes in following paths:

Change path Release notes path Description
`src/Compiler` docs/release-notes/.FSharp.Compiler.Service/11.0.200.md

The type subsumption cache remembered whether one type is a supertype of
another, but the supertypes and interfaces of a type are only final once the
file declaring it has been checked. A record, union or struct gets its
equality and comparison interfaces after the members of its recursive group
are checked, so a question asked inside the group cached "no" and later checks
got that answer back. Valid code then failed with FS0363, or an overload was
chosen as if the interface were missing.

The cache is now only used when the type whose supertypes are searched has
been closed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@auduchinok
auduchinok force-pushed the checker-subsumptionCacheOpenTypes branch from 629c3c5 to 4a6a3d0 Compare November 24, 2026 16:29
@github-project-automation github-project-automation Bot moved this from New to In Progress in F# Compiler and Tooling Nov 27, 2026
@dotnet dotnet deleted a comment from azure-pipelines Bot Nov 27, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants