Skip to content

Commit fd79acd

Browse files
committed
TypeCheckType: Do not fail after emitting a warning
Also remove the redundant diagnosis altogether. This case is already handled by the existential syntax checker just fine.
1 parent e056c63 commit fd79acd

File tree

2 files changed

+10
-23
lines changed

2 files changed

+10
-23
lines changed

lib/Sema/TypeCheckType.cpp

+1-16
Original file line numberDiff line numberDiff line change
@@ -915,22 +915,7 @@ static Type applyGenericArguments(Type type,
915915
argTys.push_back(argTy);
916916
}
917917

918-
auto parameterized =
919-
ParameterizedProtocolType::get(ctx, protoType, argTys);
920-
921-
// FIXME: Can this not be done in ExistentialTypeSyntaxChecker?
922-
if (resolution.getOptions().isConstraintImplicitExistential() &&
923-
!ctx.LangOpts.hasFeature(Feature::ImplicitSome)) {
924-
diags
925-
.diagnose(loc, diag::existential_requires_any, parameterized,
926-
ExistentialType::get(parameterized),
927-
/*isAlias=*/isa<TypeAliasType>(type.getPointer()))
928-
.warnUntilSwiftVersion(7);
929-
930-
return ErrorType::get(ctx);
931-
}
932-
933-
return parameterized;
918+
return ParameterizedProtocolType::get(ctx, protoType, argTys);
934919
}
935920

936921
// Builtins have special handling.

test/type/explicit_existential.swift

+9-7
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,13 @@ protocol Collection<T> {
173173
struct TestParameterizedProtocol<T> : Collection {
174174
typealias T = T
175175

176-
let x : Collection<T> // expected-warning {{use of protocol 'Collection<T>' as a type must be written 'any Collection<T>'}}
176+
let x : Collection<T> // expected-warning {{use of protocol 'Collection' as a type must be written 'any Collection'}}
177177
}
178178

179179
func acceptAny(_: Collection<Int>) {}
180-
// expected-warning@-1 {{use of protocol 'Collection<Int>' as a type must be written 'any Collection<Int>'}}
180+
// expected-warning@-1 {{use of protocol 'Collection' as a type must be written 'any Collection'}}
181181
func returnsAny() -> Collection<Int> {}
182-
// expected-warning@-1 {{use of protocol 'Collection<Int>' as a type must be written 'any Collection<Int>'}}
182+
// expected-warning@-1 {{use of protocol 'Collection' as a type must be written 'any Collection'}}
183183

184184
func testInvalidAny() {
185185
struct S: HasAssoc {
@@ -374,8 +374,8 @@ func testAnyFixIt() {
374374
let _: Optional<HasAssoc>
375375
// expected-warning@+1 {{constraint that suppresses conformance requires 'any'}}{{19-28=any ~Copyable}}
376376
let _: Optional<~Copyable>
377-
// FIXME: No fix-it + generic argument not diagnosed.
378-
// expected-warning@+1 {{use of protocol 'HasAssocGeneric<any HasAssoc>' as a type must be written 'any HasAssocGeneric<any HasAssoc>'}}{{none}}
377+
// expected-warning@+2:10 {{use of protocol 'HasAssocGeneric' as a type must be written 'any HasAssocGeneric'}}{{10-35=any HasAssocGeneric<HasAssoc>}}
378+
// expected-warning@+1:26 {{use of protocol 'HasAssoc' as a type must be written 'any HasAssoc'}}{{26-34=any HasAssoc}}
379379
let _: HasAssocGeneric<HasAssoc>
380380
// expected-warning@+1 {{use of protocol 'HasAssoc' as a type must be written 'any HasAssoc'}}{{14-22=any HasAssoc}}
381381
let _: S.G<HasAssoc>
@@ -407,8 +407,8 @@ func testAnyFixIt() {
407407
// expected-warning@+2 {{use of protocol 'HasAssoc' as a type must be written 'any HasAssoc'}}{{13-21=any HasAssoc}}
408408
// expected-warning@+1 {{constraint that suppresses conformance requires 'any'}}{{10-37=any ~G<HasAssoc>.Copyable_Alias}}
409409
let _: ~G<HasAssoc>.Copyable_Alias
410-
// FIXME: No fix-it + generic argument not diagnosed.
411-
// expected-warning@+1 {{use of 'HasAssocGeneric<any HasAssoc>' as a type must be written 'any HasAssocGeneric<any HasAssoc>}}{{none}}
410+
// 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<HasAssoc>}}
411+
// expected-warning@+1:34 {{use of protocol 'HasAssoc' as a type must be written 'any HasAssoc'}}{{34-42=any HasAssoc}}
412412
let _: S.HasAssocGeneric_Alias<HasAssoc>
413413
// FIXME: No diagnostic.
414414
let _: HasAssoc.Int_Alias
@@ -543,6 +543,8 @@ func testAnyFixIt() {
543543

544544
// expected-error@+1 {{optional 'any' type must be written '(any HasAssoc)?'}}{{10-23=(any HasAssoc)?}}
545545
let _: any HasAssoc?
546+
// expected-error@+1:10 {{optional 'any' type must be written '(any HasAssocGeneric<Int>)?'}}{{10-35=(any HasAssocGeneric<Int>)?}}
547+
let _: any HasAssocGeneric<Int>?
546548
// FIXME: Better recovery
547549
// expected-error@+1 {{type '(any Copyable)?' cannot be suppressed}}
548550
let _: any ~Copyable?

0 commit comments

Comments
 (0)