mirror of
https://github.com/apple/swift.git
synced 2026-10-22 19:15:50 +02:00
35 lines
921 B
Swift
35 lines
921 B
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-build-swift %s -target %module-target-future -o %t/anyobject-cast-crash
|
|
// RUN: %target-codesign %t/anyobject-cast-crash
|
|
// RUN: %target-run %t/anyobject-cast-crash
|
|
// RUN: %target-build-swift %s -target %module-target-future -O -o %t/anyobject-cast-crash-opt
|
|
// RUN: %target-codesign %t/anyobject-cast-crash-opt
|
|
// RUN: %target-run %t/anyobject-cast-crash-opt
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: objc_interop
|
|
// UNSUPPORTED: use_os_stdlib
|
|
// UNSUPPORTED: back_deployment_runtime
|
|
|
|
// Test that it doesn't crash
|
|
|
|
import Foundation
|
|
|
|
enum Unconstrained<P> {
|
|
static var `protocol`: Protocol? {
|
|
P.self as AnyObject as? Protocol
|
|
}
|
|
}
|
|
|
|
enum Constrained<P: AnyObject> {
|
|
static var `protocol`: Protocol? {
|
|
P.self as AnyObject as? Protocol
|
|
}
|
|
}
|
|
|
|
@objc protocol TestProtocol {
|
|
|
|
}
|
|
|
|
print(Unconstrained<TestProtocol>.protocol)
|
|
print(Constrained<TestProtocol>.protocol)
|