File tree Expand file tree Collapse file tree 5 files changed +69
-0
lines changed Expand file tree Collapse file tree 5 files changed +69
-0
lines changed Original file line number Diff line number Diff line change
1
+ #ifndef TEST_INTEROP_CXX_CLASS_INPUTS_EXTENSIONS_H
2
+ #define TEST_INTEROP_CXX_CLASS_INPUTS_EXTENSIONS_H
3
+
4
+ namespace Outer {
5
+ namespace Space {
6
+
7
+ struct Foo {
8
+ int a;
9
+ };
10
+
11
+ }
12
+ }
13
+
14
+ #endif // TEST_INTEROP_CXX_CLASS_INPUTS_EXTENSIONS_H
Original file line number Diff line number Diff line change @@ -23,6 +23,11 @@ module Destructors {
23
23
requires cplusplus
24
24
}
25
25
26
+ module Extensions {
27
+ header "extensions.h"
28
+ requires cplusplus
29
+ }
30
+
26
31
module LoadableTypes {
27
32
header "loadable-types.h"
28
33
requires cplusplus
Original file line number Diff line number Diff line change
1
+ // RUN: %target-run-simple-swift(-I %S/Inputs/ -Xfrontend -enable-cxx-interop)
2
+ // REQUIRES: executable_test
3
+
4
+ import StdlibUnittest
5
+ import Extensions
6
+
7
+ var CxxClassExtensionsTestSuite = TestSuite ( " CxxClassExtensions " )
8
+
9
+ extension Outer . Space . Foo {
10
+ func bar( ) -> Int32 { return a + 1 }
11
+ }
12
+
13
+ CxxClassExtensionsTestSuite . test ( " calling extension method " ) {
14
+ var foo = Outer . Space. Foo ( a: 123 )
15
+ expectEqual ( 124 , foo. bar ( ) )
16
+ }
17
+
18
+ runAllTests ( )
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-emit-ir %s -I %S/Inputs -enable-cxx-interop | %FileCheck %s
2
+ //
3
+ // We can't yet call member functions correctly on Windows (SR-13129).
4
+ // XFAIL: OS=windows-msvc
5
+
6
+ import Extensions
7
+
8
+ extension Outer . Space . Foo {
9
+ func foo( ) { }
10
+ }
11
+
12
+ Outer . Space. Foo ( ) . foo ( )
13
+
14
+ // CHECK: call swiftcc void @"$sSo5OuterO5SpaceO10ExtensionsE3FooV4mainE3fooyyF"
15
+
16
+ // CHECK: define hidden swiftcc void @"$sSo5OuterO5SpaceO10ExtensionsE3FooV4mainE3fooyyF"
Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift -I %S/Inputs -enable-cxx-interop
2
+
3
+ import Extensions
4
+
5
+ extension Outer . Space . Foo {
6
+ func bar( ) -> Int32 { return a }
7
+ }
8
+
9
+ extension Outer . Space . Foo : ExpressibleByIntegerLiteral {
10
+ public init ( integerLiteral value: IntegerLiteralType ) {
11
+ self . init ( a: Int32 ( value) )
12
+ }
13
+ }
14
+
15
+ var it : Outer . Space . Foo = 123
16
+ let res = it. bar ( )
You can’t perform that action at this time.
0 commit comments