Skip to content

Conversation

@allevato
Copy link
Member

@allevato allevato commented Dec 4, 2025

It's useful to know where a conformance is coming from when doing semantic analysis. The main motivating use case is this: imagine a module that declares a type:

// SomeTypeModule
struct SomeType {}

Then a second module that adds a conformance:

// SomeTypeConformanceModule
extension SomeType: @retroactive Codable {
  // implementation of requirements
}

Then a third module that uses that conformance:

import SomeTypeModule
import SomeTypeConformanceModule

func f() {
  _ = try? JSONEncoder().encode(SomeType())
}

There's currently nothing in the printed AST that indicates that the import of SomeTypeConformanceModule is required. Printing the declaring context for conformances lets us get that signal from the substitution map at the call site in f().

Also removed a place where we redundantly output retroactive.

…ext.

It's useful to know where a conformance is coming from when doing semantic
analysis. The main motivating use case is this: imagine a module that
declares a type:

```swift
// SomeTypeModule
struct SomeType {}
```

Then a second module that adds a conformance:

```swift
// SomeTypeConformanceModule
extension SomeType: @retroactive Codable {
  // implementation of requirements
}
```

Then a third module that uses that conformance:

```swift
import SomeTypeModule
import SomeTypeConformanceModule

func f() {
  _ = try? JSONEncoder().encode(SomeType())
}
```

There's currently nothing in the printed AST that indicates that the import
of `SomeTypeConformanceModule` is required. Printing the declaring context
for conformances lets us get that signal from the substitution map at the
call site in `f()`.

Also removed a place where we redundantly output `retroactive`.
@allevato
Copy link
Member Author

allevato commented Dec 4, 2025

@swift-ci please smoke test

@allevato
Copy link
Member Author

allevato commented Dec 5, 2025

@slavapestov Does this seem like a reasonable way to represent this? (Hoping to get this into 6.3 🤞🏻 )

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.

1 participant