Skip to content

Commit f15e17a

Browse files
committed
[Sema] NFC: reword "only concrete types can conform to protocols" diagnostic
1 parent c60e517 commit f15e17a

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,8 +1508,8 @@ ERROR(use_of_equal_instead_of_equality,none,
15081508

15091509

15101510
ERROR(protocol_does_not_conform_objc,none,
1511-
"using %0 as a concrete type conforming to protocol %1 is not supported",
1512-
(Type, Type))
1511+
"protocol type %0 cannot conform to %1 because only concrete "
1512+
"types can conform to protocols", (Type, Type))
15131513
ERROR(protocol_does_not_conform_static,none,
15141514
"%0 cannot be used as a type conforming to protocol %1 because %1 "
15151515
"has static requirements",

lib/Sema/CSSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2779,7 +2779,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
27792779
auto typeRequirement = path.back();
27802780
std::pair<Expr *, unsigned> reqLoc = {anchor, typeRequirement.getValue()};
27812781
MissingConformances[reqLoc] = {type.getPointer(), protocol};
2782-
// Let's strip all of the uncessary information from locator,
2782+
// Let's strip all of the unnecessary information from locator,
27832783
// diagnostics only care about anchor - to lookup type,
27842784
// and what was the requirement# which is not satisfied.
27852785
ConstraintLocatorBuilder requirement(getConstraintLocator(anchor));

lib/Sema/ConstraintSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ class ConstraintSystem {
10091009
/// Argument labels fixed by the constraint solver.
10101010
SmallVector<std::vector<Identifier>, 4> FixedArgLabels;
10111011

1012-
/// Conformances which solver "fixed" to exist to help with
1012+
/// Conformances which solver "fixed" to help with
10131013
/// diagnosing problems related to generic requirements.
10141014
llvm::SmallDenseMap<std::pair<Expr *, unsigned>,
10151015
std::pair<TypeBase *, ProtocolDecl *>>

test/Constraints/generics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func r22459135() {
188188

189189
// <rdar://problem/19710848> QoI: Friendlier error message for "[] as Set"
190190
// <rdar://problem/22326930> QoI: "argument for generic parameter 'Element' could not be inferred" lacks context
191-
_ = [] as Set // expected-error {{using 'Any' as a concrete type conforming to protocol 'Hashable' is not supported}}
191+
_ = [] as Set // expected-error {{protocol type 'Any' cannot conform to 'Hashable' because only concrete types can conform to protocols}}
192192

193193

194194
//<rdar://problem/22509125> QoI: Error when unable to infer generic archetype lacks greatness

test/Generics/existential_restrictions.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func fAOE(_ t: AnyObject) { }
1717
func fT<T>(_ t: T) { }
1818

1919
func testPassExistential(_ p: P, op: OP, opp: OP & P, cp: CP, sp: SP, any: Any, ao: AnyObject) {
20-
fP(p) // expected-error{{using 'P' as a concrete type conforming to protocol 'P' is not supported}}
20+
fP(p) // expected-error{{protocol type 'P' cannot conform to 'P' because only concrete types can conform to protocols}}
2121
fAO(p) // expected-error{{cannot invoke 'fAO' with an argument list of type '(P)'}} // expected-note{{expected an argument list of type '(T)'}}
2222
fAOE(p) // expected-error{{argument type 'P' does not conform to expected type 'AnyObject'}}
2323
fT(p)
@@ -31,8 +31,8 @@ func testPassExistential(_ p: P, op: OP, opp: OP & P, cp: CP, sp: SP, any: Any,
3131
fAOE(cp)
3232
fT(cp)
3333

34-
fP(opp) // expected-error{{using 'OP & P' as a concrete type conforming to protocol 'P' is not supported}}
35-
fOP(opp) // expected-error{{using 'OP & P' as a concrete type conforming to protocol 'OP' is not supported}}
34+
fP(opp) // expected-error{{protocol type 'OP & P' cannot conform to 'P' because only concrete types can conform to protocols}}
35+
fOP(opp) // expected-error{{protocol type 'OP & P' cannot conform to 'OP' because only concrete types can conform to protocols}}
3636
fAO(opp) // expected-error{{cannot invoke 'fAO' with an argument list of type '(OP & P)'}} // expected-note{{expected an argument list of type '(T)'}}
3737
fAOE(opp)
3838
fT(opp)
@@ -58,9 +58,9 @@ class GAO<T : AnyObject> {} // expected-note 2{{requirement specified as 'T' : '
5858
func blackHole(_ t: Any) {}
5959

6060
func testBindExistential() {
61-
blackHole(GP<P>()) // expected-error{{using 'P' as a concrete type conforming to protocol 'P' is not supported}}
61+
blackHole(GP<P>()) // expected-error{{protocol type 'P' cannot conform to 'P' because only concrete types can conform to protocols}}
6262
blackHole(GOP<OP>())
63-
blackHole(GCP<CP>()) // expected-error{{using 'CP' as a concrete type conforming to protocol 'CP' is not supported}}
63+
blackHole(GCP<CP>()) // expected-error{{protocol type 'CP' cannot conform to 'CP' because only concrete types can conform to protocols}}
6464
blackHole(GAO<P>()) // expected-error{{'GAO' requires that 'P' be a class type}}
6565
blackHole(GAO<OP>())
6666
blackHole(GAO<CP>()) // expected-error{{'GAO' requires that 'CP' be a class type}}
@@ -85,5 +85,5 @@ func foo() {
8585
// generic no overloads error path. The error should actually talk
8686
// about the return type, and this can happen in other contexts as well;
8787
// <rdar://problem/21900971> tracks improving QoI here.
88-
allMine.takeAll() // expected-error{{using 'Mine' as a concrete type conforming to protocol 'Mine' is not supported}}
88+
allMine.takeAll() // expected-error{{protocol type 'Mine' cannot conform to 'Mine' because only concrete types can conform to protocols}}
8989
}

test/stmt/foreach.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func testOptionalSequence() {
176176

177177
// Crash with (invalid) for each over an existential
178178
func testExistentialSequence(s: Sequence) { // expected-error {{protocol 'Sequence' can only be used as a generic constraint because it has Self or associated type requirements}}
179-
for x in s { // expected-error {{using 'Sequence' as a concrete type conforming to protocol 'Sequence' is not supported}}
179+
for x in s { // expected-error {{protocol type 'Sequence' cannot conform to 'Sequence' because only concrete types can conform to protocols}}
180180
_ = x
181181
}
182182
}

test/type/subclass_composition.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ func conformsTo<T1 : P2, T2 : Base<Int> & P2>(
407407
// expected-note@-2 {{expected an argument list of type '(T)'}}
408408

409409
conformsToP1(p1)
410-
// expected-error@-1 {{using 'P1' as a concrete type conforming to protocol 'P1' is not supported}}
410+
// expected-error@-1 {{protocol type 'P1' cannot conform to 'P1' because only concrete types can conform to protocols}}
411411

412412
// FIXME: Following diagnostics are not great because when
413413
// `conformsTo*` methods are re-typechecked, they loose information

validation-test/compiler_crashers_fixed/00017-llvm-foldingset-llvm-attributesetnode-nodeequals.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ extension Bool : BooleanProtocol {
1919
}
2020
func f<T : BooleanProtocol>(_ b: T) {
2121
}
22-
f(true as BooleanProtocol) // expected-error {{using 'BooleanProtocol' as a concrete type conforming to protocol 'BooleanProtocol' is not supported}}
22+
f(true as BooleanProtocol) // expected-error {{protocol type 'BooleanProtocol' cannot conform to 'BooleanProtocol' because only concrete types can conform to protocols}}

0 commit comments

Comments
 (0)