Skip to content

Commit 5b8a2e2

Browse files
[SwiftToCxx] Fixing as signature
1 parent 5af07a4 commit 5b8a2e2

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lib/PrintAsClang/_SwiftCxxInteroperability.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class Error {
255255
opaqueValue = other.opaqueValue;
256256
}
257257

258-
template<class T, class U>
258+
template<class T>
259259
std::optional<T> as() {
260260
char *ptr = (char*)malloc(100);
261261
const void *em = testErrorCall();
@@ -264,12 +264,15 @@ class Error {
264264

265265
// Dynamic cast will release the error, so we need to retain it.
266266
swift::swift_errorRetain(ep);
267-
bool dynamicCast = swift::swift_dynamicCast(ptr, &ep, em, metadata,/*take on success destroy on failure*/ 6);
267+
bool dynamicCast =
268+
swift::swift_dynamicCast(ptr, &ep, em, metadata,
269+
/*take on success destroy on failure*/ 6);
268270

269271
if (dynamicCast) {
270-
//swift::_impl::implClassFor<T>::initializeWithTake
271272
auto result =
272-
U::returnNewValue([&](char *dest) { U::initializeWithTake(dest, ptr); });
273+
swift::_impl::implClassFor<T>::type::returnNewValue([&](char *dest) {
274+
swift::_impl::implClassFor<T>::type::initializeWithTake(dest, ptr);
275+
});
273276
return std::optional(result);
274277
}
275278
return std::nullopt;

test/Interop/SwiftToCxx/functions/swift-functions-errors-execution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ int main() {
2727
try {
2828
Functions::throwFunction();
2929
} catch (swift::Error& e) {
30-
auto errorVal = e.as<Functions::NaiveErrors, Functions::_impl::_impl_NaiveErrors>();
30+
auto errorVal = e.as<Functions::NaiveErrors>();
3131
if (errorVal) {
3232
assert(errorVal == Functions::NaiveErrors::throwError);
3333
errorVal->getMessage();

0 commit comments

Comments
 (0)