forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmixed-target-using-header.swift
59 lines (45 loc) · 1.38 KB
/
mixed-target-using-header.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
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/../Inputs/custom-modules -import-objc-header %S/Inputs/mixed-target/header.h -parse %s -disable-objc-attr-requires-foundation-module -verify
// REQUIRES: objc_interop
func test(foo : FooProto) {
_ = foo.bar as CInt
_ = ExternIntX.x as CInt
}
@objc class ForwardClass : NSObject {
}
@objc protocol ForwardProto : NSObjectProtocol {
}
@objc class ForwardProtoAdopter : NSObject, ForwardProto {
}
@objc class PartialBaseClass {
}
@objc class PartialSubClass : NSObject {
}
func testCFunction() {
doSomething(ForwardClass())
doSomethingProto(ForwardProtoAdopter())
doSomethingPartialBase(PartialBaseClass())
doSomethingPartialSub(PartialSubClass())
}
class ProtoConformer : ForwardClassUser {
@objc func consumeForwardClass(arg: ForwardClass) {}
@objc var forward = ForwardClass()
}
func testProtocolWrapper(conformer: ForwardClassUser) {
conformer.consumeForwardClass(conformer.forward)
}
testProtocolWrapper(ProtoConformer())
func testStruct(p: Point) -> Point {
var result = p
result.y += 5
return result
}
func testSuppressed() {
let _: __int128_t? = nil // expected-error{{use of undeclared type '__int128_t'}}
}
func testMacro() {
_ = CONSTANT as CInt
}
func testFoundationOverlay() {
_ = NSUTF8StringEncoding // no ambiguity
_ = NSUTF8StringEncoding as UInt // and we should get the overlay version
}