Skip to content

Commit 7a21e46

Browse files
committed
embedded: don't try to specialize vtables of C++ imported reference-counted classes
Fixes a false compiler error rdar://165209061
1 parent ba1b8f8 commit 7a21e46

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/GenericSpecialization.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ private struct VTableSpecializer {
4848
}
4949

5050
let classDecl = classType.nominal! as! ClassDecl
51+
if classDecl.isForeign {
52+
return
53+
}
5154
guard let origVTable = context.lookupVTable(for: classDecl) else {
5255
if context.enableWMORequiredDiagnostics {
5356
context.diagnosticEngine.diagnose(.cannot_specialize_class, classType, at: errorLocation)

test/embedded/cxx-import-reference.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,12 @@ public func test()
4040
let c = C.create()
4141
c.foo()
4242
}
43+
44+
public func cast<S,D>(_ s:S, to type:D.Type) -> D {
45+
return unsafeBitCast(s, to: type.self)
46+
}
47+
48+
public func testcast(_ provider: AnyObject) -> C {
49+
return cast (provider, to: C.self)
50+
}
51+

0 commit comments

Comments
 (0)