Skip to content

Provide fixit for inferred property of opaque type (#69241) #74811

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Androp0v
Copy link

@Androp0v Androp0v commented Jun 28, 2024

When a pattern binding at top level attempts to pick up another declaration's opaque result type as its type by type inference, provide a fixit to explicitly declare the type. This is done to prevent opaque result types from propagating nontrivially into other declarations' types, see 6db0540

(First PR in this repo 🙏)

Added fix-it that annotates a top level declaration property declaration of inferred opaque type to be explicitly typed. Reasoning for this requirement in 6db0540.

Resolves #69241

Tests

Reused the 3 existing cases covered in test/type/opaque.swift:

Test case 1

let inferredOpaque = bar()

Is fixed to:

let inferredOpaque: some P = bar()

Test case 2

let inferredOpaqueStructural = Optional(bar())

Is fixed to:

let inferredOpaqueStructural: Optional<some P> = Optional(bar())

Test case 3

let inferredOpaqueStructural2 = (bar(), bas())

Is fixed to

let inferredOpaqueStructural2: (some P, some P & Q) = (bar(), bas())

When a pattern binding at top level attempts to pick up another declaration's opaque result type as its type by type inference, provide a fixit to explicitly declare the type. This is done to prevent opaque result types from propagating nontrivially into other declarations' types, see 6db0540
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing fix-it when opaque property type is inferred
1 participant