Skip to content

Conversation

hamishknight
Copy link
Contributor

Move the logic from FailureDiagnostic::resolveType into Solution::simplifyType, which then allows us to re-use it in simplifyTypeForCodeCompletion.

@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight
Copy link
Contributor Author

@swift-ci please SourceKit stress test

func f(_: Int...) {}
let _ = [(1, 2, 3)].map(f) // expected-error {{no exact matches in call to instance method 'map'}}
// expected-note@-1 {{found candidate with type '(((Int, Int, Int)) -> _) -> Array<_>'}}
// expected-note@-1 2{{found candidate with type '(((Int, Int, Int)) -> T) -> [T]'}}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now get 2 notes here because T is a generic parameter from 2 different decls. We ought to be able to fix this by canonicalizing ErrorType's original type when computing the canonical type, I can look into that in a follow-up

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Make sure we do this after we transform the type as otherwise we could
skip resolving type variables and let them escape.
Move the logic from `FailureDiagnostic::resolveType` into
`Solution::simplifyType` to allow completion to use it too. While
here, also handle cases where the placeholder is from a different
member of the equivalence class to the generic parameter.
We ought to be able to just use `simplifyType` with an additional
parameter to tell it to produce archetypes.
@hamishknight
Copy link
Contributor Author

@swift-ci please smoke test

@hamishknight
Copy link
Contributor Author

@swift-ci please test Linux

@hamishknight
Copy link
Contributor Author

swiftlang/swift-testing#1353

@swift-ci please smoke test Linux

@hamishknight hamishknight enabled auto-merge October 4, 2025 18:47
@hamishknight hamishknight merged commit d06d126 into swiftlang:main Oct 4, 2025
3 of 4 checks passed
@hamishknight hamishknight deleted the can-opener branch October 4, 2025 22:14
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.

2 participants