Files
swift-mirror/test/SILOptimizer/inline_subclass_existential.swift
Slava Pestov ac7664357a SIL: Correctly substitute type parameters in opened existential types
This wasn't possible when the SIL cloner was first written, but subclass
existentials can involve generic classes, so you can have an opened
archetype type with a superclass constraint involving a type constraint.
2018-10-08 17:02:19 -07:00

22 lines
691 B
Swift

// RUN: %target-swift-frontend -emit-sil -primary-file %s | %FileCheck %s
class C<T> {}
protocol P {
func f()
}
// CHECK-LABEL: sil hidden [transparent] @$s27inline_subclass_existential3fooyyAA1P_AA1CCyxGXclF : $@convention(thin) <T> (@guaranteed C<T> & P) -> () {
// CHECK: open_existential_ref %0 : $C<T> & P to $@opened("{{.*}}") C<T> & P
// CHECK: return
@_transparent
func foo<T>(_ x: C<T> & P) {
x.f()
}
// CHECK-LABEL: sil hidden @$s27inline_subclass_existential3baryyAA1P_AA1CCySiGXcF : $@convention(thin) (@guaranteed C<Int> & P) -> () {
// CHECK: open_existential_ref %0 : $C<Int> & P to $@opened("{{.*}}") C<Int> & P
// CHECK: return
func bar(_ x: C<Int> & P) {
foo(x)
}