@@ -657,6 +657,112 @@ func test_as_pattern(_ y : BaseClass) -> DerivedClass {
657
657
// CHECK-NEXT: return [[RESULT]] : $DerivedClass
658
658
return result
659
659
}
660
+
661
+ // CHECK-LABEL: sil hidden [ossa] @$s10statements35test_as_pattern_collection_downcastyySayAA9BaseClassCGF : $@convention(thin) (@guaranteed Array<BaseClass>) -> () {
662
+ func test_as_pattern_collection_downcast( _ arr: [ BaseClass ] ) {
663
+ // CHECK: [[ARR_CAST_FN:%[0-9]+]] = function_ref @$ss21_arrayConditionalCastySayq_GSgSayxGr0_lF : $@convention(thin) <τ_0_0, τ_0_1> (@guaranteed Array<τ_0_0>) -> @owned Optional<Array<τ_0_1>>
664
+ // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[ARR_CAST_FN]]<BaseClass, DerivedClass>
665
+ // CHECK-NEXT: switch_enum [[RESULT]]
666
+ if case _ as [ DerivedClass ] = arr { }
667
+ // CHECK: [[ARR_CAST_FN:%[0-9]+]] = function_ref @$ss21_arrayConditionalCastySayq_GSgSayxGr0_lF : $@convention(thin) <τ_0_0, τ_0_1> (@guaranteed Array<τ_0_0>) -> @owned Optional<Array<τ_0_1>>
668
+ // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[ARR_CAST_FN]]<BaseClass, DerivedClass>
669
+ // CHECK-NEXT: switch_enum [[RESULT]]
670
+ guard case _ as [ DerivedClass ] = arr else { }
671
+ // CHECK: [[ARR_CAST_FN:%[0-9]+]] = function_ref @$ss21_arrayConditionalCastySayq_GSgSayxGr0_lF : $@convention(thin) <τ_0_0, τ_0_1> (@guaranteed Array<τ_0_0>) -> @owned Optional<Array<τ_0_1>>
672
+ // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[ARR_CAST_FN]]<BaseClass, DerivedClass>
673
+ // CHECK-NEXT: switch_enum [[RESULT]]
674
+ while case _ as [ DerivedClass ] = arr { }
675
+ }
676
+ // CHECK: } // end sil function '$s10statements35test_as_pattern_collection_downcastyySayAA9BaseClassCGF'
677
+
678
+ // CHECK-LABEL: sil hidden [ossa] @$s10statements35test_as_pattern_dictionary_downcastyySDySSAA9BaseClassCGF : $@convention(thin) (@guaranteed Dictionary<String, BaseClass>) -> () {
679
+ func test_as_pattern_dictionary_downcast( _ dict: Dictionary < String , BaseClass > ) {
680
+ // CHECK: [[DICT_CAST_FN:%[0-9]+]] = function_ref @$ss30_dictionaryDownCastConditionalySDyq0_q1_GSgSDyxq_GSHRzSHR0_r2_lF : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2, τ_0_3 where τ_0_0 : Hashable, τ_0_2 : Hashable> (@guaranteed Dictionary<τ_0_0, τ_0_1>) -> @owned Optional<Dictionary<τ_0_2, τ_0_3>>
681
+ // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[DICT_CAST_FN]]<String, BaseClass, String, DerivedClass>
682
+ // CHECK-NEXT: switch_enum [[RESULT]]
683
+ if case _ as [ String : DerivedClass ] = dict { }
684
+ // CHECK: [[DICT_CAST_FN:%[0-9]+]] = function_ref @$ss30_dictionaryDownCastConditionalySDyq0_q1_GSgSDyxq_GSHRzSHR0_r2_lF : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2, τ_0_3 where τ_0_0 : Hashable, τ_0_2 : Hashable> (@guaranteed Dictionary<τ_0_0, τ_0_1>) -> @owned Optional<Dictionary<τ_0_2, τ_0_3>>
685
+ // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[DICT_CAST_FN]]<String, BaseClass, String, DerivedClass>
686
+ // CHECK-NEXT: switch_enum [[RESULT]]
687
+ guard case _ as [ String : DerivedClass ] = dict else { }
688
+ // CHECK: [[DICT_CAST_FN:%[0-9]+]] = function_ref @$ss30_dictionaryDownCastConditionalySDyq0_q1_GSgSDyxq_GSHRzSHR0_r2_lF : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2, τ_0_3 where τ_0_0 : Hashable, τ_0_2 : Hashable> (@guaranteed Dictionary<τ_0_0, τ_0_1>) -> @owned Optional<Dictionary<τ_0_2, τ_0_3>>
689
+ // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[DICT_CAST_FN]]<String, BaseClass, String, DerivedClass>
690
+ // CHECK-NEXT: switch_enum [[RESULT]]
691
+ while case _ as [ String : DerivedClass ] = dict { }
692
+ }
693
+ // CHECK: } // end sil function '$s10statements35test_as_pattern_dictionary_downcastyySDySSAA9BaseClassCGF'
694
+
695
+ // CHECK-LABEL: sil hidden [ossa] @$s10statements28test_as_pattern_set_downcastyyShyxGSHRzlF : $@convention(thin) <T where T : Hashable> (@guaranteed Set<T>) -> () {
696
+ func test_as_pattern_set_downcast< T: Hashable > ( _ set: Set < T > ) {
697
+ // CHECK: [[SET_CAST_FN:%[0-9]+]] = function_ref @$ss23_setDownCastConditionalyShyq_GSgShyxGSHRzSHR_r0_lF : $@convention(thin) <τ_0_0, τ_0_1 where τ_0_0 : Hashable, τ_0_1 : Hashable> (@guaranteed Set<τ_0_0>) -> @owned Optional<Set<τ_0_1>>
698
+ // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[SET_CAST_FN]]<T, Bool>
699
+ // CHECK-NEXT: switch_enum [[RESULT]]
700
+ if case let t as Set < Bool > = set { }
701
+ // expected-warning@-1 {{immutable value 't' was never used; consider replacing with '_' or removing it}}
702
+ // CHECK: [[SET_CAST_FN:%[0-9]+]] = function_ref @$ss23_setDownCastConditionalyShyq_GSgShyxGSHRzSHR_r0_lF : $@convention(thin) <τ_0_0, τ_0_1 where τ_0_0 : Hashable, τ_0_1 : Hashable> (@guaranteed Set<τ_0_0>) -> @owned Optional<Set<τ_0_1>>
703
+ // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[SET_CAST_FN]]<T, Bool>
704
+ // CHECK-NEXT: switch_enum [[RESULT]]
705
+ guard case let t as Set < Bool > = set else { }
706
+ // expected-warning@-1 {{immutable value 't' was never used; consider replacing with '_' or removing it}}
707
+ // CHECK: [[SET_CAST_FN:%[0-9]+]] = function_ref @$ss23_setDownCastConditionalyShyq_GSgShyxGSHRzSHR_r0_lF : $@convention(thin) <τ_0_0, τ_0_1 where τ_0_0 : Hashable, τ_0_1 : Hashable> (@guaranteed Set<τ_0_0>) -> @owned Optional<Set<τ_0_1>>
708
+ // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[SET_CAST_FN]]<T, Bool>
709
+ // CHECK-NEXT: switch_enum [[RESULT]]
710
+ while case let t as Set < Bool > = set { }
711
+ // expected-warning@-1 {{immutable value 't' was never used; consider replacing with '_' or removing it}}
712
+ }
713
+ // CHECK: } // end sil function '$s10statements28test_as_pattern_set_downcastyyShyxGSHRzlF'
714
+
715
+ // CHECK-LABEL: sil hidden [ossa] @$s10statements35test_is_pattern_collection_downcastyySayAA9BaseClassCGF : $@convention(thin) (@guaranteed Array<BaseClass>) -> () {
716
+ func test_is_pattern_collection_downcast( _ arr: [ BaseClass ] ) {
717
+ // CHECK: [[ARR_CAST_FN:%[0-9]+]] = function_ref @$ss21_arrayConditionalCastySayq_GSgSayxGr0_lF : $@convention(thin) <τ_0_0, τ_0_1> (@guaranteed Array<τ_0_0>) -> @owned Optional<Array<τ_0_1>>
718
+ // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[ARR_CAST_FN]]<BaseClass, DerivedClass>
719
+ // CHECK-NEXT: switch_enum [[RESULT]]
720
+ if case is [ DerivedClass ] = arr { }
721
+ // CHECK: [[ARR_CAST_FN:%[0-9]+]] = function_ref @$ss21_arrayConditionalCastySayq_GSgSayxGr0_lF : $@convention(thin) <τ_0_0, τ_0_1> (@guaranteed Array<τ_0_0>) -> @owned Optional<Array<τ_0_1>>
722
+ // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[ARR_CAST_FN]]<BaseClass, DerivedClass>
723
+ // CHECK-NEXT: switch_enum [[RESULT]]
724
+ guard case is [ DerivedClass ] = arr else { }
725
+ // CHECK: [[ARR_CAST_FN:%[0-9]+]] = function_ref @$ss21_arrayConditionalCastySayq_GSgSayxGr0_lF : $@convention(thin) <τ_0_0, τ_0_1> (@guaranteed Array<τ_0_0>) -> @owned Optional<Array<τ_0_1>>
726
+ // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[ARR_CAST_FN]]<BaseClass, DerivedClass>
727
+ // CHECK-NEXT: switch_enum [[RESULT]]
728
+ while case is [ DerivedClass ] = arr { }
729
+ }
730
+ // CHECK: } // end sil function '$s10statements35test_is_pattern_collection_downcastyySayAA9BaseClassCGF'
731
+
732
+ // CHECK-LABEL: sil hidden [ossa] @$s10statements35test_is_pattern_dictionary_downcastyySDySSAA9BaseClassCGF : $@convention(thin) (@guaranteed Dictionary<String, BaseClass>) -> () {
733
+ func test_is_pattern_dictionary_downcast( _ dict: Dictionary < String , BaseClass > ) {
734
+ // CHECK: [[DICT_CAST_FN:%[0-9]+]] = function_ref @$ss30_dictionaryDownCastConditionalySDyq0_q1_GSgSDyxq_GSHRzSHR0_r2_lF : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2, τ_0_3 where τ_0_0 : Hashable, τ_0_2 : Hashable> (@guaranteed Dictionary<τ_0_0, τ_0_1>) -> @owned Optional<Dictionary<τ_0_2, τ_0_3>>
735
+ // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[DICT_CAST_FN]]<String, BaseClass, String, DerivedClass>
736
+ // CHECK-NEXT: switch_enum [[RESULT]]
737
+ if case is [ String : DerivedClass ] = dict { }
738
+ // CHECK: [[DICT_CAST_FN:%[0-9]+]] = function_ref @$ss30_dictionaryDownCastConditionalySDyq0_q1_GSgSDyxq_GSHRzSHR0_r2_lF : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2, τ_0_3 where τ_0_0 : Hashable, τ_0_2 : Hashable> (@guaranteed Dictionary<τ_0_0, τ_0_1>) -> @owned Optional<Dictionary<τ_0_2, τ_0_3>>
739
+ // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[DICT_CAST_FN]]<String, BaseClass, String, DerivedClass>
740
+ // CHECK-NEXT: switch_enum [[RESULT]]
741
+ guard case is [ String : DerivedClass ] = dict else { }
742
+ // CHECK: [[DICT_CAST_FN:%[0-9]+]] = function_ref @$ss30_dictionaryDownCastConditionalySDyq0_q1_GSgSDyxq_GSHRzSHR0_r2_lF : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2, τ_0_3 where τ_0_0 : Hashable, τ_0_2 : Hashable> (@guaranteed Dictionary<τ_0_0, τ_0_1>) -> @owned Optional<Dictionary<τ_0_2, τ_0_3>>
743
+ // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[DICT_CAST_FN]]<String, BaseClass, String, DerivedClass>
744
+ // CHECK-NEXT: switch_enum [[RESULT]]
745
+ while case is [ String : DerivedClass ] = dict { }
746
+ }
747
+ // CHECK: } // end sil function '$s10statements35test_is_pattern_dictionary_downcastyySDySSAA9BaseClassCGF'
748
+
749
+ // CHECK-LABEL: sil hidden [ossa] @$s10statements28test_is_pattern_set_downcastyyShyxGSHRzlF : $@convention(thin) <T where T : Hashable> (@guaranteed Set<T>) -> () {
750
+ func test_is_pattern_set_downcast< T: Hashable > ( _ set: Set < T > ) {
751
+ // CHECK: [[SET_CAST_FN:%[0-9]+]] = function_ref @$ss23_setDownCastConditionalyShyq_GSgShyxGSHRzSHR_r0_lF : $@convention(thin) <τ_0_0, τ_0_1 where τ_0_0 : Hashable, τ_0_1 : Hashable> (@guaranteed Set<τ_0_0>) -> @owned Optional<Set<τ_0_1>>
752
+ // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[SET_CAST_FN]]<T, Int>
753
+ // CHECK-NEXT: switch_enum [[RESULT]]
754
+ if case is Set < Int > = set { }
755
+ // CHECK: [[SET_CAST_FN:%[0-9]+]] = function_ref @$ss23_setDownCastConditionalyShyq_GSgShyxGSHRzSHR_r0_lF : $@convention(thin) <τ_0_0, τ_0_1 where τ_0_0 : Hashable, τ_0_1 : Hashable> (@guaranteed Set<τ_0_0>) -> @owned Optional<Set<τ_0_1>>
756
+ // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[SET_CAST_FN]]<T, Int>
757
+ // CHECK-NEXT: switch_enum [[RESULT]]
758
+ guard case is Set < Int > = set else { }
759
+ // CHECK: [[SET_CAST_FN:%[0-9]+]] = function_ref @$ss23_setDownCastConditionalyShyq_GSgShyxGSHRzSHR_r0_lF : $@convention(thin) <τ_0_0, τ_0_1 where τ_0_0 : Hashable, τ_0_1 : Hashable> (@guaranteed Set<τ_0_0>) -> @owned Optional<Set<τ_0_1>>
760
+ // CHECK-NEXT: [[RESULT:%[0-9]+]] = apply [[SET_CAST_FN]]<T, Int>
761
+ // CHECK-NEXT: switch_enum [[RESULT]]
762
+ while case is Set < Int > = set { }
763
+ }
764
+ // CHECK: } // end sil function '$s10statements28test_is_pattern_set_downcastyyShyxGSHRzlF'
765
+
660
766
// CHECK-LABEL: sil hidden [ossa] @$s10statements22let_else_tuple_bindingyS2i_SitSgF
661
767
func let_else_tuple_binding( _ a : ( Int , Int ) ? ) -> Int {
662
768
0 commit comments