Skip to content

Order explicit type args by constraint dependencies before unifying - #20342

Open
T-Gro wants to merge 5 commits into
mainfrom
t-gro-issue-20103-cannot-call-method-with-a-generic-interf-d02fa6
Open

Order explicit type args by constraint dependencies before unifying#20342
T-Gro wants to merge 5 commits into
mainfrom
t-gro-issue-20103-cannot-call-method-with-a-generic-interf-d02fa6

Conversation

@T-Gro

@T-Gro T-Gro commented Aug 25, 2026

Copy link
Copy Markdown
Member

Fixes #20103

A generic value or method whose subtype constraint references a later type parameter (Register<'a, 'b when 'a :> I<'b>>) failed with FS0001 when the supplied argument implemented the interface at more than one instantiation (I<int> and I<string>): the explicit type arguments were unified left-to-right, so 'a := Foo re-solved 'a :> I<'b> while 'b was still unknown and greedily committed it to the wrong instantiation. Explicit type arguments are now unified in constraint-dependency order, so a parameter referenced by another's constraint is solved first. Behind a language-version 11.0 flag; a genuine dependency cycle degrades to the previous left-to-right order.

@github-actions

github-actions Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

❗ Release notes required

You can open this PR in browser to add release notes: open in github.dev


✅ Found changes and release notes in following paths:

Change path Release notes path Description
`src/Compiler` docs/release-notes/.FSharp.Compiler.Service/11.0.100.md
`src/Compiler/Facilities/LanguageFeatures.fsi` docs/release-notes/.Language/preview.md

A generic value/method with a subtype constraint that references a later
type parameter (Register<'a,'b when 'a :> I<'b>>) failed with FS0001 when
the argument implements the interface at several instantiations. The
explicit type arguments are now unified in dependency order so a parameter
referenced by another's constraint is solved first.

Fixes #20103

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8ce30fb9-238f-4bb2-8f31-71e8d173c2ca
@T-Gro
T-Gro force-pushed the t-gro-issue-20103-cannot-call-method-with-a-generic-interf-d02fa6 branch from a443f4d to 3ff71f4 Compare August 25, 2026 08:57
@T-Gro
T-Gro marked this pull request as ready for review August 25, 2026 11:48
@T-Gro
T-Gro requested a review from a team as a code owner August 25, 2026 11:48
@T-Gro
T-Gro enabled auto-merge (squash) August 25, 2026 11:48
@github-actions github-actions Bot added the AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed label Aug 25, 2026
@T-Gro
T-Gro requested a review from abonie August 25, 2026 13:01
Copilot and others added 2 commits September 3, 2026 15:36
…not-call-method-with-a-generic-interf-d02fa6

# Conflicts:
#	src/Compiler/Facilities/LanguageFeatures.fs
#	src/Compiler/Facilities/LanguageFeatures.fsi
@github-project-automation github-project-automation Bot moved this from New to In Progress in F# Compiler and Tooling Sep 11, 2026
Copilot added 2 commits September 11, 2026 17:43
Add equal-arity competing overloads with explicit selection assertions and explicit/inferred type arguments. Verify dependency ordering and rollback through red-green and a failed-candidate undo mutation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 137c3de0-8937-4b62-aff3-13ce91c4cdcb
…not-call-method-with-a-generic-interf-d02fa6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI-Tooling-Check-Bypassed Tooling check: non-fork PR, not diff-analyzed

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Cannot call method with a generic interface constraint, when concrete type implements the interface with multiple generic instantiations

2 participants