Skip to content

[Type checker] Allow extensions of typealiases naming generic specializations #21328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

DougGregor
Copy link
Member

@DougGregor DougGregor commented Dec 14, 2018

When a (non-generic) typealias refers to a specialization of a generic
type, e.g.

  typealias simd_float3 = SIMD3<Float>

treat an extension of the typealias as an extension of the underlying
type with same-type constraints between the generic parameters and the
specific arguments, e.g.,

  extension simd_float3 { }

is treated as

  extension SIMD3 where Scalar == Float { }

This addresses a source-compatibility problem with SE-0229, where
existing types such as simd3_float (which were separate structs)
became specializations of a generic SIMD type.

Fixes rdar://problem/46604664 and rdar://problem/46604370.

…izations.

When a (non-generic) typealias refers to a specialization of a generic
type, e.g.

```swift
  typealias simd_float3 = SIMD3<Float>
```

treat an extension of the typealias as an extension of the underlying
type with same-type constraints between the generic parameters and the
specific arguments, e.g.,

```swift
  extension simd_float3 { }
```

is treated as

```swift
  extension SIMD where Scalar == Float { }
```

This addresses a source-compatibility problem with SE-0229, where
existing types such as simd3_float (which were separate structs)
became specializations of a generic SIMD type.

Fixes rdar://problem/46604664 and rdar://problem/46604370.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

@swift-ci please test source compatibility

@stephentyrone
Copy link
Contributor

I assume that it's actually treated as extension SIMD3 where ... rather than extension SIMD where ....

@DougGregor
Copy link
Member Author

The source-compat issue is an unrelated UPASS:

/Users/dgregor/Projects/swift-internal/build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64

@DougGregor DougGregor merged commit d98b5d1 into swiftlang:master Dec 14, 2018
@DougGregor DougGregor deleted the ext-typealias-of-specialized branch December 14, 2018 23:05
Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

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

Awesome! Parametrized extensions are next?

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