Skip to content

Commit ae0936f

Browse files
Merge pull request #79934 from AnthonyLatsis/no-карри
TypeCheckType: Do not fail after emitting a warning
2 parents 42ad91e + 89f5066 commit ae0936f

File tree

3 files changed

+13
-26
lines changed

3 files changed

+13
-26
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 1 addition & 16 deletions
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

Lines changed: 9 additions & 7 deletions
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?

test/type/parameterized_existential.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ protocol Sequence<Element> { // expected-note {{'Sequence' declared here}}
77
// 'any' is required here
88

99
func takesSequenceOfInt1(_: Sequence<Int>) {}
10-
// expected-warning@-1 {{use of protocol 'Sequence<Int>' as a type must be written 'any Sequence<Int>'}}
10+
// expected-warning@-1 {{use of protocol 'Sequence' as a type must be written 'any Sequence'}}
1111

1212
func returnsSequenceOfInt1() -> Sequence<Int> {}
13-
// expected-warning@-1 {{use of protocol 'Sequence<Int>' as a type must be written 'any Sequence<Int>'}}
13+
// expected-warning@-1 {{use of protocol 'Sequence' as a type must be written 'any Sequence'}}
1414

1515
struct ConcreteSequence<Element> : Sequence {}
1616

@@ -74,7 +74,7 @@ func saturation(_ dry: any Sponge, _ wet: any Sponge<Int, Int>) {
7474

7575
func typeExpr() {
7676
_ = Sequence<Int>.self
77-
// expected-warning@-1 {{use of protocol 'Sequence<Int>' as a type must be written 'any Sequence<Int>'}}
77+
// expected-warning@-1 {{use of protocol 'Sequence' as a type must be written 'any Sequence'}}
7878

7979
_ = any Sequence<Int>.self
8080
// expected-error@-1 {{'self' is not a member type of protocol 'parameterized_existential.Sequence<Swift.Int>'}}

0 commit comments

Comments
 (0)