Skip to content

Commit 70f8c84

Browse files
committed
Diag: Correct message for protocols with multiple superclass requirements
1 parent 8ec0e39 commit 70f8c84

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,8 +2049,9 @@ NOTE(same_type_redundancy_here,none,
20492049
"inferred from type here}0",
20502050
(unsigned, Type, Type))
20512051
ERROR(requires_superclass_conflict,none,
2052-
"%select{generic parameter |protocol |}0%1 cannot be a subclass of both "
2053-
"%2 and %3", (unsigned, Type, Type, Type))
2052+
"%select{generic parameter %1 cannot|protocol %1 cannot require 'Self' to|"
2053+
"%1 cannot}0 be a subclass of both %2 and %3",
2054+
(unsigned, Type, Type, Type))
20542055
WARNING(redundant_superclass_constraint,none,
20552056
"redundant superclass constraint %0 : %1", (Type, Type))
20562057
NOTE(superclass_redundancy_here,none,

test/Generics/superclass_constraint.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ func superclassConformance3<T>(t: T) where T : C, T : P4, T : C2 {}
9494

9595
protocol P5: A { }
9696

97-
protocol P6: A, Other { } // expected-error {{protocol 'P6' cannot be a subclass of both 'Other' and 'A'}}
97+
protocol P6: A, Other { } // expected-error {{protocol 'P6' cannot require 'Self' to be a subclass of both 'Other' and 'A'}}
9898
// expected-error@-1{{multiple inheritance from classes 'A' and 'Other'}}
9999
// expected-note@-2 {{superclass constraint 'Self' : 'A' written here}}
100100

test/IDE/print_ast_tc_decls_errors.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ protocol ProtocolWithInheritance4 : FooClass, FooProtocol {}
155155
// NO-TYREPR: {{^}}protocol ProtocolWithInheritance4 : FooClass, FooProtocol {{{$}}
156156
// TYREPR: {{^}}protocol ProtocolWithInheritance4 : FooClass, FooProtocol {{{$}}
157157

158-
protocol ProtocolWithInheritance5 : FooClass, BarClass {} // expected-error{{multiple inheritance from classes 'FooClass' and 'BarClass'}} expected-error{{protocol 'ProtocolWithInheritance5' cannot be a subclass of both 'BarClass' and 'FooClass'}} // expected-note{{superclass constraint 'Self' : 'FooClass' written here}}
158+
protocol ProtocolWithInheritance5 : FooClass, BarClass {} // expected-error{{multiple inheritance from classes 'FooClass' and 'BarClass'}} expected-error{{protocol 'ProtocolWithInheritance5' cannot require 'Self' to be a subclass of both 'BarClass' and 'FooClass'}} // expected-note{{superclass constraint 'Self' : 'FooClass' written here}}
159159
// NO-TYREPR: {{^}}protocol ProtocolWithInheritance5 : <<error type>>, <<error type>> {{{$}}
160160
// TYREPR: {{^}}protocol ProtocolWithInheritance5 : FooClass, BarClass {{{$}}
161161

0 commit comments

Comments
 (0)