Skip to content

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

1 participant