Skip to content

Fix spurious unions of generics from fixpoint iteration #1732

@carljm

Description

@carljm

When we fixpoint-iterate a cycle, we union the resulting types at each iteration with the previous iteration, to ensure monotonicity.

This has an unfortunate side effect when the types involved are invariant generics or generics specialized with dynamic types; in those cases the unions don't simplify, and this can lead to undesired behavior. See for example the TODO unsupported-base errors in mdtest/generics/legacy/classes.md, or the TODOs for spurious unions with Divergent added in call/methods.md in astral-sh/ruff#21551. These can both occur in reasonably common cases and show up in the ecosystem.

(The latter TODOs might also be resolvable by fixing #1729 to eliminate the seemingly-unnecessary cycle.)

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions