Skip to content

Conversation

DougGregor
Copy link
Member

Now that associated types can have availability, make sure that we infer availability attributes for any inferred type witnesses of said associated types based on both the enclosing context and the associated type itself. This eliminates failures in the emitted Swift interfaces.

Fixes rdar://122596219.

Now that associated types can have availability, make sure that we
infer availability attributes for any inferred type witnesses of said
associated types based on both the enclosing context and the associated
type itself. This eliminates failures in the emitted Swift interfaces.

Fixes rdar://122596219.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test


// Construct the availability of the type witnesses based on the
// availability of the enclosing type and the associated type.
const Decl * availabilitySources[2] = {dc->getAsDecl(), assocType };
Copy link
Contributor

Choose a reason for hiding this comment

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

Whitespace is a bit wonky here

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed. Fixed up in #71512

@DougGregor DougGregor merged commit 0ab7f56 into swiftlang:main Feb 9, 2024
@DougGregor DougGregor deleted the infer-assoc-type-witness-availability branch February 9, 2024 07:59
tshortli added a commit to tshortli/swift that referenced this pull request Aug 23, 2024
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 added a commit to tshortli/swift that referenced this pull request Aug 23, 2024
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 added a commit to tshortli/swift that referenced this pull request Aug 23, 2024
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 added a commit to tshortli/swift that referenced this pull request Sep 3, 2024
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
andrurogerz pushed a commit to andrurogerz/swift that referenced this pull request Sep 3, 2024
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
andrurogerz pushed a commit to andrurogerz/swift that referenced this pull request Sep 3, 2024
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 added a commit to tshortli/swift that referenced this pull request Sep 4, 2024
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
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.

3 participants