mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
That does not work if there is a resilient class in the hiearchy from a different module than the testable imported one. Rather treat an internal but testable imported class as having resilient metadata. The scenario that does not work assuming we can build a fragile layout is the following. FrameworkA is resilient and defines a public class `Base` with a stored field. FrameworkB is resilient and defines an internal class `Sub` that inherits from the class `Base` in FrameworkA and adds some fields. FrameworkB is compiled with enable-testing. The test case testable imports FrameworkB and accesses a field in the internal class `Base` from FrameworkB. The test case only has access to FrameworkA's public swiftinterface file and therefore does not know `Base`'s layout. The layout computation for `Sub` cannot take the field from `Base` into account and things fail silently. rdar://103323275
32 lines
1.3 KiB
Swift
32 lines
1.3 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swift-frontend -enable-testing -enable-library-evolution -module-name=resilient %S/Inputs/resilient-class.swift -emit-module -emit-module-path %t/resilient.swiftmodule
|
|
// RUN: %target-swift-frontend -I %t -emit-ir %s | %FileCheck %s
|
|
|
|
// Check that linking succeeds.
|
|
// RUN: %empty-directory(%t)
|
|
// RUN: %target-build-swift-dylib(%t/%target-library-name(resilient)) %S/Inputs/resilient-class.swift -module-name resilient -emit-module -emit-module-path %t/resilient.swiftmodule -enable-library-evolution -enable-testing
|
|
// RUN: %target-build-swift -I %t -L %t -lresilient %s -o %t/main %target-rpath(%t)
|
|
// RUN: %target-build-swift -O -I %t -L %t -lresilient %s -o %t/main %target-rpath(%t)
|
|
// RUN: %target-codesign %t/main
|
|
// RUN: %target-codesign %t/%target-library-name(resilient)
|
|
// RUN: %target-run %t/main %t/%target-library-name(resilient) | %FileCheck --check-prefix=EXEC-CHECK %s
|
|
|
|
// REQUIRES: executable_test
|
|
|
|
@testable import resilient
|
|
|
|
// Use a resilient access pattern.
|
|
// CHECK: s9resilient8SubClassC1yAA13TypeContainerV8SomeEnumOvgTj
|
|
|
|
public func isEqual<T:Equatable>(_ l: T, _ r: T) -> Bool {
|
|
return l == r
|
|
}
|
|
|
|
public func testCase() {
|
|
let t = SubClass()
|
|
print(t.y) // EXEC-CHECK: FirstCase
|
|
print("isEqual \(isEqual(t.y, .FirstCase))") // EXEC-CHECK: isEqual true
|
|
}
|
|
|
|
testCase()
|