File tree 2 files changed +27
-1
lines changed
test/Interop/Cxx/foreign-reference
2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -1059,7 +1059,13 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
1059
1059
1060
1060
auto objectTy = value->getType ().unwrapOptionalType ();
1061
1061
1062
- require (objectTy.isReferenceCounted (F.getModule ()),
1062
+ // Immortal C++ foreign reference types are represented as trivially lowered
1063
+ // types since they do not require retain/release calls.
1064
+ bool isImmortalFRT = objectTy.isForeignReferenceType () &&
1065
+ objectTy.getASTType ()->getReferenceCounting () ==
1066
+ ReferenceCounting::None;
1067
+
1068
+ require (objectTy.isReferenceCounted (F.getModule ()) || isImmortalFRT,
1063
1069
valueDescription + " must have reference semantics" );
1064
1070
}
1065
1071
Original file line number Diff line number Diff line change
1
+ // RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=default -Xfrontend -disable-availability-checking) | %FileCheck %s
2
+
3
+ // REQUIRES: executable_test
4
+
5
+ import POD
6
+
7
+ extension Empty {
8
+ public static func == ( lhs: Empty , rhs: Empty ) -> Bool {
9
+ Unmanaged . passUnretained ( lhs) . toOpaque ( ) == Unmanaged . passUnretained ( rhs) . toOpaque ( )
10
+ }
11
+ }
12
+
13
+ let x = Empty . create ( )
14
+ let y = Empty . create ( )
15
+
16
+ print ( x == y)
17
+ // CHECK: false
18
+
19
+ print ( x == x)
20
+ // CHECK: true
You can’t perform that action at this time.
0 commit comments