Skip to content

Commit d3b71ba

Browse files
committed
[cxx-interop] Fix static extensions on foreign reference types.
Foreign reference types don't have dynamic metadata like other Swift classes.
1 parent c6cea1e commit d3b71ba

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
@@ -659,6 +659,9 @@ bool SILFunction::hasDynamicSelfMetadata() const {
659659
selfTy = dynamicSelfTy.getSelfType();
660660
}
661661

662+
if (selfTy.isForeignReferenceType())
663+
return false;
664+
662665
return !!selfTy.getClassOrBoundGenericClass();
663666
}
664667

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)