Skip to content

Commit 77aa564

Browse files
committed
[Diagnostics] Expand test coverage of existing edu notes
1 parent 1ac3709 commit 77aa564

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

test/Constraints/diagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public func myMap<T, U>(_ x: T?, _ f: (T) -> U) -> U? {
161161

162162
// <rdar://problem/20142523>
163163
func rdar20142523() {
164-
myMap(0..<10, { x in // expected-error{{unable to infer complex closure return type; add explicit type to disambiguate}} {{21-21=-> <#Result#> }}
164+
myMap(0..<10, { x in // expected-error{{unable to infer complex closure return type; add explicit type to disambiguate}} {{21-21=-> <#Result#> }} {{educational-notes=complex-closure-inference}}
165165
()
166166
return x
167167
})

test/attr/attr_dynamic_callable.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func testFunction(a: CallableReturningFunction) {
9898
//===----------------------------------------------------------------------===//
9999

100100
// Arguments' type may not be variadic.
101-
// expected-error @+1 {{@dynamicCallable attribute requires 'Invalid1' to have either a valid 'dynamicallyCall(withArguments:)' method or 'dynamicallyCall(withKeywordArguments:)' method}}
101+
// expected-error @+1 {{@dynamicCallable attribute requires 'Invalid1' to have either a valid 'dynamicallyCall(withArguments:)' method or 'dynamicallyCall(withKeywordArguments:)' method}} {{educational-notes=dynamic-callable-requirements}}
102102
@dynamicCallable
103103
struct Invalid1 {
104104
func dynamicallyCall(withArguments arguments: [Int]...) -> Int {
@@ -107,7 +107,7 @@ struct Invalid1 {
107107
}
108108

109109
// Keyword arguments' key type must be ExpressibleByStringLiteral.
110-
// expected-error @+1 {{@dynamicCallable attribute requires 'Invalid2' to have either a valid 'dynamicallyCall(withArguments:)' method or 'dynamicallyCall(withKeywordArguments:)' method}}
110+
// expected-error @+1 {{@dynamicCallable attribute requires 'Invalid2' to have either a valid 'dynamicallyCall(withArguments:)' method or 'dynamicallyCall(withKeywordArguments:)' method}} {{educational-notes=dynamic-callable-requirements}}
111111
@dynamicCallable
112112
struct Invalid2 {
113113
func dynamicallyCall(
@@ -128,8 +128,8 @@ protocol NoKeywordProtocol {
128128
}
129129

130130
func testInvalidKeywordCall(x: NoKeyword, y: NoKeywordProtocol & AnyObject) {
131-
x(a: 1, b: 2) // expected-error {{@dynamicCallable type 'NoKeyword' cannot be applied with keyword arguments; missing 'dynamicCall(withKeywordArguments:)' method}}
132-
y(a: 1, b: 2) // expected-error {{@dynamicCallable type 'NoKeywordProtocol & AnyObject' cannot be applied with keyword arguments; missing 'dynamicCall(withKeywordArguments:)' method}}
131+
x(a: 1, b: 2) // expected-error {{@dynamicCallable type 'NoKeyword' cannot be applied with keyword arguments; missing 'dynamicCall(withKeywordArguments:)' method}} {{educational-notes=dynamic-callable-requirements}}
132+
y(a: 1, b: 2) // expected-error {{@dynamicCallable type 'NoKeywordProtocol & AnyObject' cannot be applied with keyword arguments; missing 'dynamicCall(withKeywordArguments:)' method}} {{educational-notes=dynamic-callable-requirements}}
133133
}
134134

135135
// expected-error @+1 {{'@dynamicCallable' attribute cannot be applied to this declaration}}

test/decl/ext/extensions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ protocol P1 {}
8181

8282
protocol P2 {}
8383

84-
extension () {} // expected-error {{non-nominal type '()' cannot be extended}}
84+
extension () {} // expected-error {{non-nominal type '()' cannot be extended}} {{educational-notes=nominal-types}}
8585

8686
typealias TupleAlias = (x: Int, y: Int)
87-
extension TupleAlias {} // expected-error{{non-nominal type 'TupleAlias' (aka '(x: Int, y: Int)') cannot be extended}}
87+
extension TupleAlias {} // expected-error{{non-nominal type 'TupleAlias' (aka '(x: Int, y: Int)') cannot be extended}} {{educational-notes=nominal-types}}
8888

8989
// Test property accessors in extended types
9090
class C {}

test/decl/var/property_wrappers.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ struct WrapperAcceptingAutoclosure<T> {
5858

5959
@propertyWrapper
6060
struct MissingValue<T> { }
61-
// expected-error@-1{{property wrapper type 'MissingValue' does not contain a non-static property named 'wrappedValue'}}
61+
// expected-error@-1{{property wrapper type 'MissingValue' does not contain a non-static property named 'wrappedValue'}} {{educational-notes=property-wrapper-requirements}}
6262

6363
@propertyWrapper
6464
struct StaticValue {
@@ -76,7 +76,7 @@ protocol CannotBeAWrapper {
7676

7777
@propertyWrapper
7878
struct NonVisibleValueWrapper<Value> {
79-
private var wrappedValue: Value // expected-error{{private property 'wrappedValue' cannot have more restrictive access than its enclosing property wrapper type 'NonVisibleValueWrapper' (which is internal)}}
79+
private var wrappedValue: Value // expected-error{{private property 'wrappedValue' cannot have more restrictive access than its enclosing property wrapper type 'NonVisibleValueWrapper' (which is internal)}} {{educational-notes=property-wrapper-requirements}}
8080
}
8181

8282
@propertyWrapper
@@ -92,7 +92,7 @@ struct NonVisibleInitWrapper<Value> {
9292
struct InitialValueTypeMismatch<Value> {
9393
var wrappedValue: Value // expected-note{{'wrappedValue' declared here}}
9494

95-
init(wrappedValue initialValue: Value?) { // expected-error{{'init(wrappedValue:)' parameter type ('Value?') must be the same as its 'wrappedValue' property type ('Value') or an @autoclosure thereof}}
95+
init(wrappedValue initialValue: Value?) { // expected-error{{'init(wrappedValue:)' parameter type ('Value?') must be the same as its 'wrappedValue' property type ('Value') or an @autoclosure thereof}} {{educational-notes=property-wrapper-requirements}}
9696
self.wrappedValue = initialValue!
9797
}
9898
}
@@ -112,7 +112,7 @@ struct MultipleInitialValues<Value> {
112112
struct InitialValueFailable<Value> {
113113
var wrappedValue: Value
114114

115-
init?(wrappedValue initialValue: Value) { // expected-error{{property wrapper initializer 'init(wrappedValue:)' cannot be failable}}
115+
init?(wrappedValue initialValue: Value) { // expected-error{{property wrapper initializer 'init(wrappedValue:)' cannot be failable}} {{educational-notes=property-wrapper-requirements}}
116116
return nil
117117
}
118118
}

test/type/protocol_types.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
protocol HasSelfRequirements {
44
func foo(_ x: Self)
55

6-
func returnsOwnProtocol() -> HasSelfRequirements // expected-error{{protocol 'HasSelfRequirements' can only be used as a generic constraint because it has Self or associated type requirements}}
6+
func returnsOwnProtocol() -> HasSelfRequirements // expected-error{{protocol 'HasSelfRequirements' can only be used as a generic constraint because it has Self or associated type requirements}} {{educational-notes=associated-type-requirements}}
77
}
88
protocol Bar {
99
// init() methods should not prevent use as an existential.
@@ -68,7 +68,7 @@ protocol HasAssoc {
6868
}
6969

7070
func testHasAssoc(_ x: Any) {
71-
if let p = x as? HasAssoc { // expected-error {{protocol 'HasAssoc' can only be used as a generic constraint}}
71+
if let p = x as? HasAssoc { // expected-error {{protocol 'HasAssoc' can only be used as a generic constraint}} {{educational-notes=associated-type-requirements}}
7272
p.foo() // don't crash here.
7373
}
7474
}

0 commit comments

Comments
 (0)