Skip to content

Conversation

@grynspan
Copy link
Contributor

@grynspan grynspan commented Jun 17, 2025

This PR refactors the (new) type inference logic for exit test capture lists to use a syntax visitor, which allows for the types of more complex expressions to be inferred.

For example, previously the type of this capture would not be inferred:

[x = try await f() as Int]

Even though the type (Int) is clearly present, because the AsExprSyntax is nested in an AwaitExprSyntax and then a TryExprSyntax.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

This PR refactors the (new) type inference logic for exit test capture lists to
use a syntax visitor, which allows for the types of more complex expressions to
be inferred.

For example, previously the type of this capture would not be inferred:

```swift
[x = try await f() as Int]
```

Even though the type (`Int`) is clearly present, because the `AsExprSyntax` is
nested in an `AwaitExprSyntax` and then a `TryExprSyntax`.
@grynspan grynspan added this to the Swift 6.x milestone Jun 17, 2025
@grynspan grynspan self-assigned this Jun 17, 2025
@grynspan grynspan added enhancement New feature or request exit-tests ☠️ Work related to exit tests labels Jun 17, 2025
@grynspan
Copy link
Contributor Author

@swift-ci test

@grynspan grynspan requested a review from suzannaratcliff June 18, 2025 17:54
@grynspan grynspan merged commit 66701fb into main Jun 18, 2025
3 checks passed
@grynspan grynspan deleted the jgrynspan/improved-capture-type-inference branch June 18, 2025 18:00
@grynspan grynspan added the exit-test-capture-lists 🥍 Work related to exit test capture lists label Jun 18, 2025
@stmontgomery stmontgomery modified the milestones: Swift 6.x, Swift 6.2 Jun 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request exit-test-capture-lists 🥍 Work related to exit test capture lists exit-tests ☠️ Work related to exit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants