mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
64 lines
1.2 KiB
Swift
64 lines
1.2 KiB
Swift
// RUN: %target-run-simple-swift(-Xfrontend -disable-availability-checking) | %FileCheck %s
|
|
|
|
// UNSUPPORTED: use_os_stdlib
|
|
// UNSUPPORTED: back_deployment_runtime
|
|
|
|
// REQUIRES: executable_test
|
|
|
|
struct A<let N: Int, let M: Int> {
|
|
func foo() {
|
|
print("Lower: \(N), Upper: \(M)")
|
|
}
|
|
}
|
|
|
|
extension A where N == 2 {
|
|
struct B {}
|
|
}
|
|
|
|
extension A where M == 5 {
|
|
struct C {}
|
|
}
|
|
|
|
extension A where N == M {
|
|
struct D {}
|
|
}
|
|
|
|
func getA<let N: Int>() -> A<N, N> {
|
|
A()
|
|
}
|
|
|
|
// CHECK: main.A<123, 321>
|
|
print(_typeName(A<123, 321>.self, qualified: true))
|
|
|
|
// CHECK: (extension in main):main.A<2, 9582>.B
|
|
print(_typeName(A<2, 9582>.B.self, qualified: true))
|
|
|
|
// CHECK: (extension in main):main.A<942735, 5>.C
|
|
print(_typeName(A<942735, 5>.C.self, qualified: true))
|
|
|
|
let x: A<-5, -5> = getA()
|
|
|
|
// CHECK: main.A<-5, -5>
|
|
print(_typeName(type(of: x), qualified: true))
|
|
|
|
// CHECK: Lower: 1, Upper: 8
|
|
A<1, 8>().foo()
|
|
|
|
// CHECK: Lower: 0, Upper: 8
|
|
A<0, 8>().foo()
|
|
|
|
// CHECK: Lower: -1, Upper: 8
|
|
A< -1, 8>().foo()
|
|
|
|
// CHECK: Lower: -2, Upper: 8
|
|
A< -2, 8>().foo()
|
|
|
|
// CHECK: Lower: -3, Upper: 8
|
|
A< -3, 8>().foo()
|
|
|
|
// CHECK: Lower: -4, Upper: 8
|
|
A< -4, 8>().foo()
|
|
|
|
// CHECK: Lower: -5, Upper: 8
|
|
A< -5, 8>().foo()
|