File tree 4 files changed +54
-22
lines changed
4 files changed +54
-22
lines changed Original file line number Diff line number Diff line change
1
+ #ifndef IMPORT_AS_MEMBER_ERR_H
2
+ #define IMPORT_AS_MEMBER_ERR_H
3
+
4
+ struct __attribute__ ((swift_name(" ErrorStruct" ))) IAMStruct {
5
+ double x, y, z;
6
+ };
7
+
8
+ @import Foundation;
9
+
10
+ @protocol ImportedProtocolBase;
11
+ @protocol ImportedProtocolBase <NSObject >
12
+ @end
13
+ typedef NSObject <ImportedProtocolBase> *ImportedProtocolBase_t;
14
+
15
+ @protocol ErrorProto;
16
+ @protocol ErrorProto <ImportedProtocolBase>
17
+ @end
18
+
19
+ typedef NSObject <ErrorProto> *ErrorProto_t;
20
+
21
+ // Instance and static member onto protocol
22
+ void mutateSomeStaticState ()
23
+ __attribute__((swift_name(" ErrorProto.mutateSomeStaticState()" ))); // ok
24
+ void mutateSomeInstanceState (ErrorProto_t self) __attribute__((
25
+ swift_name (" ErrorProto.mutateSomeInstanceState(self:)" ))); // error
26
+
27
+ // Non-prototype declaration
28
+ extern void IAMErrorStructHasPrototype (void )
29
+ __attribute__((swift_name(" ErrorStruct.hasPrototype()" ))); // ok
30
+ extern void IAMErrorStructNonPrototype ()
31
+ __attribute__((swift_name(" ErrorStruct.nonPrototype()" ))); // error
32
+
33
+ #endif // IMPORT_AS_MEMBER_ERR_H
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -31,11 +31,12 @@ module ImportAsMember {
31
31
requires objc
32
32
header "ImportAsMemberProto.h"
33
33
}
34
+ }
34
35
35
- module ProtoErr {
36
- requires objc
37
- header "ImportAsMemberProto.h"
38
- }
36
+ module IAMError {
37
+ export *
38
+ requires objc
39
+ header "ImportAsMemberError.h"
39
40
}
40
41
41
42
module InferImportAsMember {
Original file line number Diff line number Diff line change 67
67
68
68
// REQUIRES: objc_interop
69
69
70
- import ImportAsMember
70
+ import Foundation
71
+ import ImportAsMember. A
71
72
import ImportAsMember. B
72
- import ImportAsMember. ProtoErr
73
+ import ImportAsMember. Proto
74
+ import IAMError
73
75
74
76
let iamStructFail = IAMStruct1CreateSimple ( )
75
77
// expected-error@-1{{use of unresolved identifier 'IAMStruct1CreateSimple'}}
@@ -96,19 +98,25 @@ iamStruct = Struct1.zero
96
98
// Global properties
97
99
currentStruct1. x += 1.5
98
100
101
+ ErrorStruct . hasPrototype ( ) ;
102
+ ErrorStruct . nonPrototype ( ) ;
103
+ // expected-error@-1{{type 'ErrorStruct' has no member 'nonPrototype'}}
104
+
99
105
// Protocols
100
- // class Foo : NSObject, IAMProto {}
106
+ @ objc class Foo : NSObject , IAMProto { }
101
107
102
108
struct Bar : IAMProto { }
103
109
// expected-error@-1{{non-class type 'Bar' cannot conform to class protocol 'IAMProto'}}
104
110
// expected-error@-2{{non-class type 'Bar' cannot conform to class protocol 'ImportedProtocolBase'}}
105
111
// expected-error@-3{{non-class type 'Bar' cannot conform to class protocol 'NSObjectProtocol'}}
106
112
113
+ @objc class FooErr : NSObject , ErrorProto { }
107
114
108
- // let foo = Foo()
109
- // foo.mutateSomeState()
110
- // Foo.mutateSomeStaticState()
111
- // expected-not-error@-1{{type 'Foo' has no member 'mutateSomeStaticState'}}
115
+ let foo = Foo ( )
116
+ foo. mutateSomeState ( )
112
117
113
- // TODO: error: "swift_name cannot be used to define static member on protocol"
118
+ let fooErr = FooErr ( )
119
+ fooErr. mutateSomeInstanceState ( )
120
+ FooErr . mutateSomeStaticState ( )
121
+ // expected-error@-1{{type 'FooErr' has no member 'mutateSomeStaticState'}}
114
122
You can’t perform that action at this time.
0 commit comments