embedded: don't try to specialize vtables of C++ imported reference-counted classes

Fixes a false compiler error

rdar://165209061
This commit is contained in:
Erik Eckstein
2025-11-21 16:33:49 +01:00
parent a371aecb95
commit fa3bfa3b10
2 changed files with 12 additions and 0 deletions

View File

@@ -48,6 +48,9 @@ private struct VTableSpecializer {
}
let classDecl = classType.nominal! as! ClassDecl
if classDecl.isForeign {
return
}
guard let origVTable = context.lookupVTable(for: classDecl) else {
if context.enableWMORequiredDiagnostics {
context.diagnosticEngine.diagnose(.cannot_specialize_class, classType, at: errorLocation)

View File

@@ -40,3 +40,12 @@ public func test()
let c = C.create()
c.foo()
}
public func cast<S,D>(_ s:S, to type:D.Type) -> D {
return unsafeBitCast(s, to: type.self)
}
public func testcast(_ provider: AnyObject) -> C {
return cast (provider, to: C.self)
}