Skip to content

Commit 634ba4f

Browse files
authored
Merge pull request #61425 from hyp/eng/init-class-bug
[interop][SwiftToCxx] Fix a bug with bridging class initializer in ve…
2 parents 1a86d92 + 8710c26 commit 634ba4f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/PrintAsClang/PrintClangFunction.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,13 @@ class CFunctionSignatureTypePrinter
465465
return ClangRepresentation::representable;
466466
}
467467

468+
ClangRepresentation
469+
visitDynamicSelfType(DynamicSelfType *ds,
470+
Optional<OptionalTypeKind> optionalKind,
471+
bool isInOutParam) {
472+
return visitPart(ds->getSelfType(), optionalKind, isInOutParam);
473+
}
474+
468475
ClangRepresentation visitPart(Type Ty,
469476
Optional<OptionalTypeKind> optionalKind,
470477
bool isInOutParam) {

test/Interop/SwiftToCxx/initializers/init-in-cxx.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44

55
// RUN: %check-interop-cxx-header-in-clang(%t/inits.h -Wno-unused-function)
66

7+
// RUN: %target-swift-frontend %s -typecheck -module-name Init -clang-header-expose-decls=all-public -swift-version 5 -emit-clang-header-path %t/inits2.h
8+
// RUN: %FileCheck %s < %t/inits2.h
9+
710

811
// CHECK: SWIFT_EXTERN void * _Nonnull $s4Init9BaseClassCyACSi_SitcfC(ptrdiff_t x, ptrdiff_t y, SWIFT_CONTEXT void * _Nonnull _self) SWIFT_NOEXCEPT SWIFT_CALL; // init(_:_:)
12+
// CHECK-NEXT: SWIFT_EXTERN void * _Nonnull $s4Init9BaseClassCyACSicfC(ptrdiff_t x, SWIFT_CONTEXT void * _Nonnull _self) SWIFT_NOEXCEPT SWIFT_CALL; // init(_:)
913
// CHECK-NEXT: SWIFT_EXTERN void * _Nonnull $s4Init12DerivedClassCyACSi_SitcfC(ptrdiff_t x, ptrdiff_t y, SWIFT_CONTEXT void * _Nonnull _self) SWIFT_NOEXCEPT SWIFT_CALL; // init(_:_:)
1014

1115
// CHECK: SWIFT_EXTERN struct swift_interop_returnStub_Init_uint32_t_0_4 $s4Init16FirstSmallStructVACycfC(void) SWIFT_NOEXCEPT SWIFT_CALL; // init()
@@ -107,6 +111,10 @@ public class BaseClass {
107111
public var x: Int
108112

109113
public init(_ x: Int, _ y: Int) { self.x = x + y }
114+
115+
public convenience init(_ x: Int) {
116+
self.init(x, x * 2)
117+
}
110118
}
111119

112120
public class DerivedClass: BaseClass {

0 commit comments

Comments
 (0)