Skip to content

[5.1] Opaque types require the next Swift runtime #24607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public struct Pair : P {
}
#endif

@available(iOS 9999, macOS 9999, tvOS 9999, watchOS 9999, *)
public func resilientFunction() -> some P {
#if BEFORE
return Int(5)
Expand All @@ -27,10 +28,12 @@ public func resilientFunction() -> some P {
#endif
}

@available(iOS 9999, macOS 9999, tvOS 9999, watchOS 9999, *)
public func expectedResult() -> Int {
return resilientFunction().getValue()
}

@available(iOS 9999, macOS 9999, tvOS 9999, watchOS 9999, *)
public func expectedSize() -> Int {
return MemoryLayout.size(ofValue: resilientFunction())
}
Expand All @@ -39,6 +42,7 @@ public func expectedSize() -> Int {
public struct Container {
public init() {}

@available(iOS 9999, macOS 9999, tvOS 9999, watchOS 9999, *)
public var property : some P {
get {
#if BEFORE
Expand All @@ -49,10 +53,12 @@ public struct Container {
}
}

@available(iOS 9999, macOS 9999, tvOS 9999, watchOS 9999, *)
public func expectedResult() -> Int {
return property.getValue()
}

@available(iOS 9999, macOS 9999, tvOS 9999, watchOS 9999, *)
public func expectedSize() -> Int {
return MemoryLayout.size(ofValue: property)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ import StdlibUnittest
var OpaqueArchetypes = TestSuite("OpaqueArchetypes")

OpaqueArchetypes.test("test1") {
let o = resilientFunction()
expectEqual(o.getValue(), expectedResult())
expectEqual(MemoryLayout.size(ofValue: o), expectedSize())
if #available(iOS 9999, macOS 9999, tvOS 9999, watchOS 9999, *) {
let o = resilientFunction()
expectEqual(o.getValue(), expectedResult())
expectEqual(MemoryLayout.size(ofValue: o), expectedSize())

let c = Container()
expectEqual(c.property.getValue(), c.expectedResult())
expectEqual(MemoryLayout.size(ofValue: c.property), c.expectedSize())
let c = Container()
expectEqual(c.property.getValue(), c.expectedResult())
expectEqual(MemoryLayout.size(ofValue: c.property), c.expectedSize())
}
}

runAllTests()