Skip to content

Correct availability for opaque type execution test. #24301

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
Merged
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
16 changes: 14 additions & 2 deletions test/Interpreter/opaque_return_type_protocol_ext.swift
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
// RUN: %target-run-simple-swift | %FileCheck %s
// REQUIRES: executable_test

@available(iOS 9999, macOS 9999, tvOS 9999, watchOS 9999, *)
protocol P {
associatedtype AT
func foo() -> AT
}

@available(iOS 9999, macOS 9999, tvOS 9999, watchOS 9999, *)
struct Adapter<T: P>: P {
var inner: T

@available(iOS 9999, macOS 9999, tvOS 9999, watchOS 9999, *)
func foo() -> some P {
return inner
}
}

@available(iOS 9999, macOS 9999, tvOS 9999, watchOS 9999, *)
extension P {
@available(iOS 9999, macOS 9999, tvOS 9999, watchOS 9999, *)
func foo() -> some P {
return Adapter(inner: self)
}
}

@available(iOS 9999, macOS 9999, tvOS 9999, watchOS 9999, *)
func getPAT<T: P>(_: T.Type) -> Any.Type {
return T.AT.self
}

@available(iOS 9999, macOS 9999, tvOS 9999, watchOS 9999, *)
extension Int: P { }

// CHECK: Adapter<Int>
print(getPAT(Int.self))
// CHECK: {{Adapter<Int>|too old}}
if #available(iOS 9999, macOS 9999, tvOS 9999, watchOS 9999, *) {
print(getPAT(Int.self))
} else {
print("i'm getting too old for this sh")
}