Files
swift-mirror/test/IRGen/anyobject-cast-crash.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)