Why does `import typealias` work on types?

It works with actual type aliases:

import typealias Swift.Void

But also, types. Either spelling seems to work the same.

import typealias Foundation.Data
import struct Foundation.Data

Is this a bug, a result of preparing for some future feature, or something useful I don't know about yet?

Convenience, really. You might not know or care if a particular type is implemented as a struct, class, or enum, depending on its API. (And once upon a time, we wondered whether converting a struct to an enum should be considered an ABI-compatible change, not just API-compatible, but decided not to bother ensuring that.)

3 Likes