// RUN: %target-swift-frontend -Xllvm -sil-print-types -emit-silgen %s | %FileCheck %s public class SelfCasts { // CHECK-LABEL: sil [ossa] @$s17dynamic_self_cast9SelfCastsC02toD0yACXDACFZ : $@convention(method) (@guaranteed SelfCasts, @thick SelfCasts.Type) -> @owned SelfCasts { // CHECK: unconditional_checked_cast {{.*}} : $SelfCasts to @dynamic_self SelfCasts // CHECK: } public static func toSelf(_ s: SelfCasts) -> Self { return s as! Self } // CHECK-LABEL: sil [ossa] @$s17dynamic_self_cast9SelfCastsC09genericToD0yACXDxlFZ : $@convention(method) (@in_guaranteed T, @thick SelfCasts.Type) -> @owned SelfCasts { // CHECK: unconditional_checked_cast_addr T in {{.*}} : $*T to @dynamic_self SelfCasts in {{.*}} : $*SelfCasts // CHECK: } public static func genericToSelf(_ s: T) -> Self { return s as! Self } // CHECK-LABEL: sil [ossa] @$s17dynamic_self_cast9SelfCastsC014classGenericToD0yACXDxRlzClFZ : $@convention(method) (@guaranteed T, @thick SelfCasts.Type) -> @owned SelfCasts { // CHECK: unconditional_checked_cast {{.*}} : $T to @dynamic_self SelfCasts // CHECK: } public static func classGenericToSelf(_ s: T) -> Self { return s as! Self } // CHECK-LABEL: sil [ossa] @$s17dynamic_self_cast9SelfCastsC011genericFromD0xylFZ : $@convention(method) (@thick SelfCasts.Type) -> @out T { // CHECK: unconditional_checked_cast_addr @dynamic_self SelfCasts in {{.*}} : $*SelfCasts to T in {{.*}} : $*T // CHECK: } public static func genericFromSelf() -> T { let s = Self() return s as! T } // CHECK-LABEL: sil [ossa] @$s17dynamic_self_cast9SelfCastsC016classGenericFromD0xyRlzClFZ : $@convention(method) (@thick SelfCasts.Type) -> @owned T // CHECK: unconditional_checked_cast_addr @dynamic_self SelfCasts in {{.*}} : $*SelfCasts to T in {{.*}} : $*T // CHECK: } public static func classGenericFromSelf() -> T { let s = Self() return s as! T } // CHECK-LABEL: sil [ossa] @$s17dynamic_self_cast9SelfCastsC02toD11ConditionalyACXDSgACFZ : $@convention(method) (@guaranteed SelfCasts, @thick SelfCasts.Type) -> @owned Optional { // CHECK: checked_cast_br SelfCasts in {{.*}} : $SelfCasts to @dynamic_self SelfCasts // CHECK: } public static func toSelfConditional(_ s: SelfCasts) -> Self? { return s as? Self } // CHECK-LABEL: sil [ossa] @$s17dynamic_self_cast9SelfCastsC09genericToD11ConditionalyACXDSgxlFZ : $@convention(method) (@in_guaranteed T, @thick SelfCasts.Type) -> @owned Optional { // CHECK: checked_cast_addr_br take_always T in {{.*}} : $*T to @dynamic_self SelfCasts in {{.*}} : $*SelfCasts // CHECK: } public static func genericToSelfConditional(_ s: T) -> Self? { return s as? Self } // CHECK-LABEL: sil [ossa] @$s17dynamic_self_cast9SelfCastsC014classGenericToD11ConditionalyACXDSgxRlzClFZ : $@convention(method) (@guaranteed T, @thick SelfCasts.Type) -> @owned Optional { // CHECK: checked_cast_br T in {{.*}} : $T to @dynamic_self SelfCasts // CHECK: } public static func classGenericToSelfConditional(_ s: T) -> Self? { return s as? Self } // CHECK-LABEL: sil [ossa] @$s17dynamic_self_cast9SelfCastsC011genericFromD11ConditionalxSgylFZ : $@convention(method) (@thick SelfCasts.Type) -> @out Optional { // CHECK: checked_cast_addr_br take_always @dynamic_self SelfCasts in {{.*}} : $*SelfCasts to T in {{.*}} : $*T // CHECK: } public static func genericFromSelfConditional() -> T? { let s = Self() return s as? T } // CHECK-LABEL: sil [ossa] @$s17dynamic_self_cast9SelfCastsC016classGenericFromD11ConditionalxSgyRlzClFZ : $@convention(method) (@thick SelfCasts.Type) -> @owned Optional { // CHECK: checked_cast_addr_br take_always @dynamic_self SelfCasts in {{.*}} : $*SelfCasts to T in {{.*}} : $*T // CHECK: } public static func classGenericFromSelfConditional() -> T? { let s = Self() return s as? T } public required init() {} }