Skip to content

Commit 113f11c

Browse files
authored
Merge pull request #77391 from swiftlang/gaborh/avoid-exporting-read-accessors
[cxx-interop] Fix crash trying to export read accesors
2 parents ccfbc38 + e00e285 commit 113f11c

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/PrintAsClang/DeclAndTypePrinter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,8 +1948,9 @@ class DeclAndTypePrinter::Implementation
19481948

19491949
if (outputLang == OutputLanguageMode::Cxx) {
19501950
// FIXME: Documentation.
1951-
auto *getter = VD->getOpaqueAccessor(AccessorKind::Get);
1952-
printAbstractFunctionAsMethod(getter, /*isStatic=*/VD->isStatic());
1951+
// TODO: support read/modify accessors.
1952+
if (auto *getter = VD->getOpaqueAccessor(AccessorKind::Get))
1953+
printAbstractFunctionAsMethod(getter, /*isStatic=*/VD->isStatic());
19531954
if (auto *setter = VD->getOpaqueAccessor(AccessorKind::Set))
19541955
printAbstractFunctionAsMethod(setter, /*isStatic=*/VD->isStatic());
19551956
return;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %empty-directory(%t)
2+
3+
// RUN: %target-swift-frontend -typecheck %s -typecheck -module-name UseSynchronization -enable-experimental-cxx-interop -clang-header-expose-decls=all-public -emit-clang-header-path %t/UseSynchronization.h
4+
// RUN: %FileCheck %s < %t/UseSynchronization.h
5+
6+
// REQUIRES: synchronization
7+
8+
import Synchronization
9+
10+
public class SomeClass { }
11+
12+
@available(macOS 15, iOS 18, tvOS 18, watchOS 11, visionOS 2, *)
13+
public class Thing {
14+
public static let rc = Mutex(SomeClass())
15+
}
16+
17+
// CHECK: class SWIFT_AVAILABILITY(visionos,introduced=2) SWIFT_AVAILABILITY(watchos,introduced=11) SWIFT_AVAILABILITY(tvos,introduced=18) SWIFT_AVAILABILITY(ios,introduced=18) SWIFT_AVAILABILITY(macos,introduced=15) SWIFT_SYMBOL("s:18UseSynchronization5ThingC") Thing;

0 commit comments

Comments
 (0)