mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Simply mangling the derived method is no longer sufficient. Now also
mangle the base method, so that eventually we handle this sort of
scenario:
class Base {
// introduces: Base.method
func method(_: Int, _: Int) {}
}
class First : Base {
// overrides: Base.method
// introduces: First.method
override func method(_: Int?, _: Int) {}
}
class Second : First {
// overrides: Base.method, First.method
// introduces: Second.method
override func method(_: Int?, _: Int?) {}
}
Here, the override of Base.method by Second.method and the
override of First.method by Second.method require distinct
manglings even though the derived method (Second.method) is
the same in both cases.
Note that while the new mangling is longer, vtable thunks are
always emitted with private linkage, so with the exception of
the standard library which is built with -sil-serialize-all
they will not affect the size of dylibs.
The standard library itself has very few classes so it doesn't
matter there either.
This patch doesn't actually add any support to introduce new
vtable entries for methods that override; this is coming up
next.
20 lines
725 B
Swift
20 lines
725 B
Swift
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-sil -assert-config Release %s | %FileCheck %s
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
import Foundation
|
|
|
|
class C : Hive {}
|
|
|
|
// CHECK-LABEL: sil private @_T034objc_implicitly_unwrapped_optional1DCACSo7NSCoderC5coder_tcfcAA1CCSQyAHGSQyAEGAF_tcfcTV
|
|
// CHECK: bb0(%0 : $Optional<NSCoder>, %1 : $D):
|
|
// CHECK: [[THUNK:%.*]] = function_ref @_T034objc_implicitly_unwrapped_optional1DCACSo7NSCoderC5coder_tcfc
|
|
// CHECK: [[REF:%.*]] = apply [[THUNK]]
|
|
// CHECK: [[RESULT:%.*]] = enum $Optional<D>, #Optional.some!enumelt.1, [[REF]] : $D
|
|
// CHECK: return [[RESULT]] : $Optional<D>
|
|
class D : C {
|
|
override init(coder aCoder: NSCoder) {
|
|
super.init(coder: aCoder)
|
|
}
|
|
}
|