forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension-of-typealias.swift
47 lines (35 loc) · 1.22 KB
/
extension-of-typealias.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// RUN: rm -rf %t && mkdir -p %t
// RUN: %target-swift-frontend -emit-module -module-name Library -o %t -D LIBRARY %s
// RUN: %target-swift-ide-test -print-module -module-to-print=Library -I %t -source-filename=%s | %FileCheck %s
// RUN: %target-swift-frontend -typecheck -I %t %s -verify
// Check that base types of extensions are desugared. This isn't necessarily
// the behavior we want long-term, but it's the behavior we need right now.
#if LIBRARY
public typealias Zahl = Int
// CHECK-LABEL: extension Int {
extension Zahl {
// CHECK-NEXT: addedMember()
public func addedMember() {}
} // CHECK-NEXT: {{^}$}}
public typealias List<T> = Array<T>
// CHECK-LABEL: extension Array {
extension List {
// CHECK-NEXT: addedMember()
public func addedMember() {}
} // CHECK-NEXT: {{^}$}}
// CHECK-LABEL: extension Array where Element == Int {
extension List where Element == Int {
// CHECK-NEXT: addedMemberInt()
public func addedMemberInt() {}
} // CHECK-NEXT: {{^}$}}
// CHECK: typealias List
// CHECK: typealias Zahl
#else
import Library
func test(x: Int) {
x.addedMember()
[x].addedMember()
[x].addedMemberInt()
([] as [Bool]).addedMemberInt() // expected-error {{'[Bool]' is not convertible to 'Array<Int>'}}
}
#endif