mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Introduce a new Type node, BoundNameAliasType, which describes a reference to a typealias that requires substitutions to produce the underlying type. This new type node is used both for references to generic typealiases and for references to (non-generic) typealiases that occur within generic contexts, e.g., Array<Int>.Element. At present, the new type node is mainly useful in preserving type sugar for diagnostics purposes, as well as being reflected in other tools (indexing, code completion, etc.). The intent is to completely replace NameAliasType in the future.
17 lines
451 B
Swift
17 lines
451 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
typealias Not<A> = (A) -> Never
|
|
typealias And<A, B> = (left: A, right: B)
|
|
indirect enum Or<A, B> {
|
|
case inl(A)
|
|
case inr(B)
|
|
}
|
|
|
|
func deMorgan<A, B>(_ ne: Not<Or<A, B>>) -> And<Not<A>, Not<B>> {
|
|
return And<Not<A>, Not<B>>(
|
|
Not<A> { a in ne(.left(a)) }, // expected-error {{non-nominal type 'Not<A>' (aka '(A) -> Never') does not support explicit initialization}}
|
|
Not<B> { a in ne(.right(a)) }
|
|
)
|
|
}
|
|
|