Skip to content

Commit 84b359e

Browse files
authored
Merge pull request #60283 from zoecarver/frt-static-extension
[cxx-interop] Fix static extensions on foreign reference types.
2 parents 379d5d8 + d3b71ba commit 84b359e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/SIL/IR/SILFunction.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,9 @@ bool SILFunction::hasDynamicSelfMetadata() const {
752752
selfTy = dynamicSelfTy.getSelfType();
753753
}
754754

755+
if (selfTy.isForeignReferenceType())
756+
return false;
757+
755758
return !!selfTy.getClassOrBoundGenericClass();
756759
}
757760

test/Interop/Cxx/foreign-reference/pod.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ import StdlibUnittest
77
import CxxShim
88
import POD
99

10+
extension IntPair {
11+
static public func swiftMake() -> IntPair { IntPair.create() }
12+
}
13+
1014
struct StructHoldingPair {
1115
var pair: IntPair
1216
};
@@ -49,6 +53,12 @@ PODTestSuite.test("var IntPair") {
4953
expectEqual(x.test(), 1)
5054
}
5155

56+
PODTestSuite.test("static extension") {
57+
var x = IntPair.swiftMake()
58+
expectEqual(x.test(), 1)
59+
expectEqual(x.testMutable(), 1)
60+
}
61+
5262
PODTestSuite.test("let IntPair") {
5363
let x = IntPair.create()
5464
expectEqual(x.test(), 1)

0 commit comments

Comments
 (0)