|
637 | 637 | let exist: any InvalidTypeParameters
|
638 | 638 |
|
639 | 639 | exist.method1() // expected-error {{instance method 'method1()' requires that 'Self.A' conform to 'InvalidTypeParameters'}}
|
| 640 | + // expected-error@-1 {{inferred result type '(any InvalidTypeParameters).A.A' requires explicit coercion due to loss of generic requirements}}{{16-16=as (any InvalidTypeParameters).A.A}} |
640 | 641 | exist.method2(false) // expected-error {{instance method 'method2' requires that 'Self.A' conform to 'InvalidTypeParameters'}}
|
641 | 642 | exist.method3(false, false) // expected-error {{instance method 'method3' requires that 'Self.A' conform to 'InvalidTypeParameters'}}
|
642 | 643 | // expected-error@-1 {{member 'method3' cannot be used on value of type 'any InvalidTypeParameters'; consider using a generic constraint instead}}
|
@@ -794,14 +795,14 @@ do {
|
794 | 795 |
|
795 | 796 | let _: (
|
796 | 797 | Struct<Bool>, (any ConcreteAssocTypes).Type, () -> Bool
|
797 |
| - ) -> any Class<Struct<Bool>.Inner> & ConcreteAssocTypes = arg.method4 |
| 798 | + ) -> any Class<Struct<Bool>.Inner> & ConcreteAssocTypes = arg.method4 // expected-error {{inferred result type 'any Class<Struct<(any ConcreteAssocTypes).A7>.Inner> & ConcreteAssocTypes' requires explicit coercion due to loss of generic requirements}}{{74-74=as any Class<Struct<(any ConcreteAssocTypes).A7>.Inner> & ConcreteAssocTypes}} |
798 | 799 |
|
799 | 800 | let _: (
|
800 | 801 | Struct<Bool>, (any ConcreteAssocTypes).Type, () -> Bool
|
801 | 802 | ) -> any Class<Struct<Bool>.Inner> & ConcreteAssocTypes = arg.property4
|
802 | 803 |
|
803 | 804 | let _: any Class<Struct<Bool>.Inner> & ConcreteAssocTypes =
|
804 |
| - arg[ |
| 805 | + arg[ // expected-error {{inferred result type 'any Class<Struct<(any ConcreteAssocTypes).A7>.Inner> & ConcreteAssocTypes' requires explicit coercion due to loss of generic requirements}}{{7-7=(}} {{807:8-8=as any Class<Struct<(any ConcreteAssocTypes).A7>.Inner> & ConcreteAssocTypes)}} |
805 | 806 | subscript4: Struct<Bool>(), (any ConcreteAssocTypes).self, { true }
|
806 | 807 | ]
|
807 | 808 | }
|
@@ -914,31 +915,45 @@ do {
|
914 | 915 | let _: Any = exist.method1()
|
915 | 916 | let _: AnyObject = exist.method2()
|
916 | 917 | let _: any CovariantAssocTypeErasure = exist.method3()
|
917 |
| - let _: Class2Base = exist.method4() // expected-error {{inferred result type 'Class2Base' requires explicit coercion due to loss of generic requirements}} |
918 |
| - let _: Class2Base = exist.method5() // expected-error {{inferred result type 'Class2Derived<any CovariantAssocTypeErasure>' requires explicit coercion due to loss of generic requirements}} |
| 918 | + let _: Class2Base = exist.method4() |
| 919 | + let _: Class2Base = exist.method5() |
919 | 920 | let _: any Class2Base & CovariantAssocTypeErasure = exist.method6()
|
920 | 921 | let _: any Class2Base & CovariantAssocTypeErasure = exist.method7()
|
921 |
| - |
922 |
| - let _: Any? = exist.method8() // expected-error {{inferred result type 'Optional<Any>' requires explicit coercion due to loss of generic requirements}} |
| 922 | + let _: Any? = exist.method8() |
923 | 923 | let _: (AnyObject, Bool) = exist.method9()
|
924 | 924 | let _: any CovariantAssocTypeErasure.Type = exist.method10()
|
925 |
| - let _: Array<Class2Base> = exist.method11() // expected-error {{inferred result type 'Array<Class2Base>' requires explicit coercion due to loss of generic requirements}} |
926 |
| - let _: Dictionary<String, Class2Base> = exist.method12() //expected-error {{inferred result type 'Dictionary<String, Class2Derived<any CovariantAssocTypeErasure>>' requires explicit coercion due to loss of generic requirements}} |
| 925 | + let _: Array<Class2Base> = exist.method11() |
| 926 | + let _: Dictionary<String, Class2Base> = exist.method12() |
| 927 | + |
| 928 | + let _ = exist.method1() |
| 929 | + let _ = exist.method2() |
| 930 | + let _ = exist.method3() |
| 931 | + let _ = exist.method4() |
| 932 | + let _ = exist.method5() // expected-error {{inferred result type 'Class2Base' requires explicit coercion due to loss of generic requirements}}{{24-24=as Class2Base}} |
| 933 | + let _ = exist.method6() |
| 934 | + let _ = exist.method7() // expected-error {{inferred result type 'any Class2Base & CovariantAssocTypeErasure' requires explicit coercion due to loss of generic requirements}}{{24-24=as any Class2Base & CovariantAssocTypeErasure}} |
| 935 | + let _ = exist.method8() |
| 936 | + let _ = exist.method9() |
| 937 | + let _ = exist.method10() |
| 938 | + let _ = exist.method11() |
| 939 | + let _ = exist.method12() // expected-error {{inferred result type 'Dictionary<String, Class2Base>' requires explicit coercion due to loss of generic requirements}}{{25-25=as Dictionary<String, Class2Base>}} |
| 940 | + |
| 941 | + |
927 | 942 | }
|
928 | 943 | do {
|
929 | 944 | let exist: any CovariantAssocTypeErasureDerived
|
930 | 945 |
|
931 | 946 | let _: any CovariantAssocTypeErasureDerived = exist.method1()
|
932 |
| - let _: Class2Base = exist.method2() //expected-error {{inferred result type 'Class2Base' requires explicit coercion due to loss of generic requirements}} |
| 947 | + let _: Class2Base = exist.method2() |
933 | 948 | let _: any CovariantAssocTypeErasureDerived = exist.method3()
|
934 | 949 | let _: any Class2Base & CovariantAssocTypeErasureDerived = exist.method4()
|
935 | 950 | let _: any Class2Base & CovariantAssocTypeErasureDerived = exist.method5()
|
936 | 951 | let _: any Class2Base & CovariantAssocTypeErasureDerived = exist.method6()
|
937 | 952 | let _: any Class2Base & CovariantAssocTypeErasure & Sequence = exist.method7()
|
938 | 953 |
|
939 |
| - let _: (any CovariantAssocTypeErasureDerived)? = exist.method8() //expected-error {{inferred result type 'Optional<any CovariantAssocTypeErasureDerived>' requires explicit coercion due to loss of generic requirements}} |
| 954 | + let _: (any CovariantAssocTypeErasureDerived)? = exist.method8() |
940 | 955 | let _: (Class2Base, Bool) = exist.method9()
|
941 | 956 | let _: any CovariantAssocTypeErasureDerived.Type = exist.method10()
|
942 |
| - let _: Array<any Class2Base & CovariantAssocTypeErasureDerived> = exist.method11() //expected-error {{inferred result type 'Array<any Class2Base & CovariantAssocTypeErasureDerived>' requires explicit coercion due to loss of generic requirements}} |
943 |
| - let _: Dictionary<String, any Class2Base & CovariantAssocTypeErasureDerived> = exist.method12() //expected-error {{inferred result type 'Dictionary<String, any Class2Derived<any CovariantAssocTypeErasureDerived> & CovariantAssocTypeErasureDerived>' requires explicit coercion due to loss of generic requirements}} |
| 957 | + let _: Array<any Class2Base & CovariantAssocTypeErasureDerived> = exist.method11() |
| 958 | + let _: Dictionary<String, any Class2Base & CovariantAssocTypeErasureDerived> = exist.method12() |
944 | 959 | }
|
0 commit comments