diff --git a/lib/Sema/TypeCheckType.cpp b/lib/Sema/TypeCheckType.cpp index 653ba59db2f53..46442eac06d14 100644 --- a/lib/Sema/TypeCheckType.cpp +++ b/lib/Sema/TypeCheckType.cpp @@ -915,22 +915,7 @@ static Type applyGenericArguments(Type type, argTys.push_back(argTy); } - auto parameterized = - ParameterizedProtocolType::get(ctx, protoType, argTys); - - // FIXME: Can this not be done in ExistentialTypeSyntaxChecker? - if (resolution.getOptions().isConstraintImplicitExistential() && - !ctx.LangOpts.hasFeature(Feature::ImplicitSome)) { - diags - .diagnose(loc, diag::existential_requires_any, parameterized, - ExistentialType::get(parameterized), - /*isAlias=*/isa(type.getPointer())) - .warnUntilSwiftVersion(7); - - return ErrorType::get(ctx); - } - - return parameterized; + return ParameterizedProtocolType::get(ctx, protoType, argTys); } // Builtins have special handling. diff --git a/test/type/explicit_existential.swift b/test/type/explicit_existential.swift index a7684a18956d8..aa2fa65c3ce7a 100644 --- a/test/type/explicit_existential.swift +++ b/test/type/explicit_existential.swift @@ -173,13 +173,13 @@ protocol Collection { struct TestParameterizedProtocol : Collection { typealias T = T - let x : Collection // expected-warning {{use of protocol 'Collection' as a type must be written 'any Collection'}} + let x : Collection // expected-warning {{use of protocol 'Collection' as a type must be written 'any Collection'}} } func acceptAny(_: Collection) {} -// expected-warning@-1 {{use of protocol 'Collection' as a type must be written 'any Collection'}} +// expected-warning@-1 {{use of protocol 'Collection' as a type must be written 'any Collection'}} func returnsAny() -> Collection {} -// expected-warning@-1 {{use of protocol 'Collection' as a type must be written 'any Collection'}} +// expected-warning@-1 {{use of protocol 'Collection' as a type must be written 'any Collection'}} func testInvalidAny() { struct S: HasAssoc { @@ -374,8 +374,8 @@ func testAnyFixIt() { let _: Optional // expected-warning@+1 {{constraint that suppresses conformance requires 'any'}}{{19-28=any ~Copyable}} let _: Optional<~Copyable> - // FIXME: No fix-it + generic argument not diagnosed. - // expected-warning@+1 {{use of protocol 'HasAssocGeneric' as a type must be written 'any HasAssocGeneric'}}{{none}} + // expected-warning@+2:10 {{use of protocol 'HasAssocGeneric' as a type must be written 'any HasAssocGeneric'}}{{10-35=any HasAssocGeneric}} + // expected-warning@+1:26 {{use of protocol 'HasAssoc' as a type must be written 'any HasAssoc'}}{{26-34=any HasAssoc}} let _: HasAssocGeneric // expected-warning@+1 {{use of protocol 'HasAssoc' as a type must be written 'any HasAssoc'}}{{14-22=any HasAssoc}} let _: S.G @@ -407,8 +407,8 @@ func testAnyFixIt() { // expected-warning@+2 {{use of protocol 'HasAssoc' as a type must be written 'any HasAssoc'}}{{13-21=any HasAssoc}} // expected-warning@+1 {{constraint that suppresses conformance requires 'any'}}{{10-37=any ~G.Copyable_Alias}} let _: ~G.Copyable_Alias - // FIXME: No fix-it + generic argument not diagnosed. - // expected-warning@+1 {{use of 'HasAssocGeneric' as a type must be written 'any HasAssocGeneric}}{{none}} + // expected-warning@+2:12 {{use of 'S.HasAssocGeneric_Alias' (aka 'HasAssocGeneric') as a type must be written 'any S.HasAssocGeneric_Alias' (aka 'any HasAssocGeneric')}} {{10-43=any S.HasAssocGeneric_Alias}} + // expected-warning@+1:34 {{use of protocol 'HasAssoc' as a type must be written 'any HasAssoc'}}{{34-42=any HasAssoc}} let _: S.HasAssocGeneric_Alias // FIXME: No diagnostic. let _: HasAssoc.Int_Alias @@ -543,6 +543,8 @@ func testAnyFixIt() { // expected-error@+1 {{optional 'any' type must be written '(any HasAssoc)?'}}{{10-23=(any HasAssoc)?}} let _: any HasAssoc? + // expected-error@+1:10 {{optional 'any' type must be written '(any HasAssocGeneric)?'}}{{10-35=(any HasAssocGeneric)?}} + let _: any HasAssocGeneric? // FIXME: Better recovery // expected-error@+1 {{type '(any Copyable)?' cannot be suppressed}} let _: any ~Copyable? diff --git a/test/type/parameterized_existential.swift b/test/type/parameterized_existential.swift index bd1cd11ab1ed4..55032bcf3c60e 100644 --- a/test/type/parameterized_existential.swift +++ b/test/type/parameterized_existential.swift @@ -7,10 +7,10 @@ protocol Sequence { // expected-note {{'Sequence' declared here}} // 'any' is required here func takesSequenceOfInt1(_: Sequence) {} -// expected-warning@-1 {{use of protocol 'Sequence' as a type must be written 'any Sequence'}} +// expected-warning@-1 {{use of protocol 'Sequence' as a type must be written 'any Sequence'}} func returnsSequenceOfInt1() -> Sequence {} -// expected-warning@-1 {{use of protocol 'Sequence' as a type must be written 'any Sequence'}} +// expected-warning@-1 {{use of protocol 'Sequence' as a type must be written 'any Sequence'}} struct ConcreteSequence : Sequence {} @@ -74,7 +74,7 @@ func saturation(_ dry: any Sponge, _ wet: any Sponge) { func typeExpr() { _ = Sequence.self - // expected-warning@-1 {{use of protocol 'Sequence' as a type must be written 'any Sequence'}} + // expected-warning@-1 {{use of protocol 'Sequence' as a type must be written 'any Sequence'}} _ = any Sequence.self // expected-error@-1 {{'self' is not a member type of protocol 'parameterized_existential.Sequence'}}