Skip to content

Conversation

tshortli
Copy link
Contributor

Only constrain the availability of the synthesized typealias for an inferred type witness by the availability of the associated type if the associated type is less available than its protocol. Without this, source compatibility is broken for some conformances. For example:

struct IdentifiableValue: Identifiable {
  let id = 42
}

extension IdentifiableValue {
  // error: 'ID' is only available in macOS 10.15 or newer
  var nextID: ID {
    return id + 1
  }
}

Fixes a regression introduced by #71496.

Resolves rdar://134584323

@tshortli tshortli requested a review from DougGregor August 23, 2024 21:17
@tshortli tshortli force-pushed the associated-type-inference-availability branch from 65ff6ac to e57bf14 Compare August 23, 2024 21:17
@tshortli
Copy link
Contributor Author

@swift-ci please smoke test

Only constrain the availability of the synthesized typealias for an inferred
type witness by the availability of the associated type if the associated type
is less available than its protocol. Without this, source compatibility is
broken for some conformances. For example:

```
struct IdentifiableValue: Identifiable {
  let id = 42
}

extension IdentifiableValue {
  // error: 'ID' is only available in macOS 10.15 or newer
  var nextID: ID {
    return id + 1
  }
}

```

Fixes a regression introduced by swiftlang#71496.

Resolves rdar://134584323
@tshortli tshortli force-pushed the associated-type-inference-availability branch from e57bf14 to 1c9b6eb Compare August 23, 2024 22:50
@tshortli
Copy link
Contributor Author

@swift-ci please smoke test

@tshortli
Copy link
Contributor Author

@swift-ci please smoke test Linux

@tshortli
Copy link
Contributor Author

@swift-ci please smoke test Windows

Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

Good catch, thank you!

@tshortli tshortli merged commit d8db750 into swiftlang:main Aug 26, 2024
3 checks passed
@tshortli tshortli deleted the associated-type-inference-availability branch August 26, 2024 16:49
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