File tree Expand file tree Collapse file tree 4 files changed +41
-0
lines changed
Inputs/ObjCEvilClassInitialization Expand file tree Collapse file tree 4 files changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ #import < Foundation/Foundation.h>
2
+
3
+ // A class that overrides +class and +self to return nil.
4
+ @interface EvilClass : NSObject
5
+ @end
Original file line number Diff line number Diff line change
1
+ #import " EvilClass.h"
2
+
3
+ @implementation EvilClass
4
+
5
+ + (Class )class { return nil ; }
6
+ + (id )self { return nil ; }
7
+
8
+ @end
Original file line number Diff line number Diff line change
1
+ module EvilClass {
2
+ header "EvilClass.h"
3
+ }
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %target-clang -fobjc-arc %S/Inputs/ObjCEvilClassInitialization/EvilClass.m -c -o %t/EvilClass.o
3
+ // RUN: %target-build-swift -I %S/Inputs/ObjCEvilClassInitialization/ %t/EvilClass.o %s -o %t/a.out
4
+ // RUN: %target-codesign %t/a.out
5
+ // RUN: %target-run %t/a.out
6
+
7
+ // REQUIRES: executable_test
8
+ // REQUIRES: objc_interop
9
+
10
+ import EvilClass
11
+
12
+ import StdlibUnittest
13
+
14
+ let tests = TestSuite ( " ObjCEvilClassInitialization " )
15
+
16
+ tests. test ( " GenericOnEvilClass " ) {
17
+ struct Generic < T> {
18
+ var type : T . Type { return T . self }
19
+ }
20
+ let g = Generic < EvilClass > ( )
21
+ expectEqual ( " \( type ( of: g) ) " , " Generic<EvilClass> " )
22
+ expectEqual ( g. type, EvilClass . self)
23
+ }
24
+
25
+ runAllTests ( )
You can’t perform that action at this time.
0 commit comments