forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathreference-dependencies-dynamic-lookup.swift
65 lines (48 loc) · 1.56 KB
/
reference-dependencies-dynamic-lookup.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// RUN: rm -rf %t && mkdir %t
// RUN: cp %s %t/main.swift
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -parse -primary-file %t/main.swift -emit-reference-dependencies-path - > %t.swiftdeps
// RUN: FileCheck %s < %t.swiftdeps
// RUN: FileCheck -check-prefix=NEGATIVE %s < %t.swiftdeps
// REQUIRES: objc_interop
import Foundation
// CHECK-LABEL: provides-dynamic-lookup:
@objc class Base : NSObject {
// CHECK-DAG: - "foo"
func foo() {}
// CHECK-DAG: - "bar"
func bar(_ x: Int, y: Int) {}
// FIXME: We don't really need this twice, but de-duplicating is effort.
// CHECK-DAG: - "bar"
func bar(_ str: String) {}
// CHECK-DAG: - "prop"
var prop: String?
// CHECK-DAG: - "unusedProp"
var unusedProp: Int = 0
// CHECK-DAG: - "classFunc"
class func classFunc() {}
}
func getAnyObject() -> AnyObject? { return nil }
// CHECK-LABEL: depends-dynamic-lookup:
func testDynamicLookup(_ obj: AnyObject) {
// CHECK-DAG: - !private "foo"
obj.foo()
// CHECK-DAG: - !private "bar"
obj.bar(1, y: 2)
obj.bar("abc")
// CHECK-DAG: - !private "classFunc"
obj.dynamicType.classFunc()
// CHECK-DAG: - !private "prop"
_ = obj.prop
// CHECK-DAG: - !private "description"
_ = obj.description
// CHECK-DAG: - !private "method"
_ = obj.method(5, with: 5.0 as Double)
// CHECK-DAG: - !private "subscript"
_ = obj[2] as AnyObject
_ = obj[2] as AnyObject!
}
// CHECK-DAG: - "counter"
let globalUse = getAnyObject()?.counter
// NEGATIVE-LABEL: depends-dynamic-lookup:
// NEGATIVE-NOT: "cat1Method"
// NEGATIVE-NOT: "unusedProp"