Skip to content

Commit 505b6f4

Browse files
authored
Merge pull request #6190 from robinkunde/SR-3373
[SR-3373] clarify error message when trying to use instance member statically
2 parents 62e93a6 + f04d50e commit 505b6f4

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,8 +839,8 @@ ERROR(member_shadows_global_function,none,
839839
DescriptiveDeclKind, DeclName))
840840

841841
ERROR(instance_member_use_on_type,none,
842-
"use of instance member %1 on type %0; "
843-
"did you mean to use a value of type %0 instead?", (Type, DeclName))
842+
"instance member %1 cannot be used on type %0; "
843+
"did you mean to use a value of this type instead?", (Type, DeclName))
844844
ERROR(instance_member_in_initializer,none,
845845
"cannot use instance member %0 within property initializer; "
846846
"property initializers run before 'self' is available", (DeclName))

test/Constraints/diagnostics.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func validateSaveButton(_ text: String) {
204204
// <rdar://problem/20201968> QoI: poor diagnostic when calling a class method via a metatype
205205
class r20201968C {
206206
func blah() {
207-
r20201968C.blah() // expected-error {{use of instance member 'blah' on type 'r20201968C'; did you mean to use a value of type 'r20201968C' instead?}}
207+
r20201968C.blah() // expected-error {{instance member 'blah' cannot be used on type 'r20201968C'; did you mean to use a value of this type instead?}}
208208
}
209209
}
210210

@@ -363,12 +363,12 @@ c.method2(1.0)(2.0) // expected-error {{cannot convert value of type 'Double' to
363363
CurriedClass.method1(c)()
364364
_ = CurriedClass.method1(c)
365365
CurriedClass.method1(c)(1) // expected-error {{argument passed to call that takes no arguments}}
366-
CurriedClass.method1(2.0)(1) // expected-error {{use of instance member 'method1' on type 'CurriedClass'; did you mean to use a value of type 'CurriedClass' instead?}}
366+
CurriedClass.method1(2.0)(1) // expected-error {{instance member 'method1' cannot be used on type 'CurriedClass'; did you mean to use a value of this type instead?}}
367367

368368
CurriedClass.method2(c)(32)(b: 1) // expected-error{{extraneous argument label 'b:' in call}}
369369
_ = CurriedClass.method2(c)
370370
_ = CurriedClass.method2(c)(32)
371-
_ = CurriedClass.method2(1,2) // expected-error {{use of instance member 'method2' on type 'CurriedClass'; did you mean to use a value of type 'CurriedClass' instead?}}
371+
_ = CurriedClass.method2(1,2) // expected-error {{instance member 'method2' cannot be used on type 'CurriedClass'; did you mean to use a value of this type instead?}}
372372
CurriedClass.method2(c)(1.0)(b: 1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
373373
CurriedClass.method2(c)(1)(1.0) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
374374
CurriedClass.method2(c)(2)(c: 1.0) // expected-error {{extraneous argument label 'c:'}}
@@ -377,7 +377,7 @@ CurriedClass.method3(c)(32, b: 1)
377377
_ = CurriedClass.method3(c)
378378
_ = CurriedClass.method3(c)(1, 2) // expected-error {{missing argument label 'b:' in call}} {{32-32=b: }}
379379
_ = CurriedClass.method3(c)(1, b: 2)(32) // expected-error {{cannot call value of non-function type '()'}}
380-
_ = CurriedClass.method3(1, 2) // expected-error {{use of instance member 'method3' on type 'CurriedClass'; did you mean to use a value of type 'CurriedClass' instead?}}
380+
_ = CurriedClass.method3(1, 2) // expected-error {{instance member 'method3' cannot be used on type 'CurriedClass'; did you mean to use a value of this type instead?}}
381381
CurriedClass.method3(c)(1.0, b: 1) // expected-error {{cannot convert value of type 'Double' to expected argument type 'Int'}}
382382
CurriedClass.method3(c)(1) // expected-error {{missing argument for parameter 'b' in call}}
383383

@@ -400,11 +400,11 @@ extension CurriedClass {
400400
}
401401

402402
// <rdar://problem/23718816> QoI: "Extra argument" error when accidentally currying a method
403-
CurriedClass.m1(2, b: 42) // expected-error {{use of instance member 'm1' on type 'CurriedClass'; did you mean to use a value of type 'CurriedClass' instead?}}
403+
CurriedClass.m1(2, b: 42) // expected-error {{instance member 'm1' cannot be used on type 'CurriedClass'; did you mean to use a value of this type instead?}}
404404

405405

406406
// <rdar://problem/22108559> QoI: Confusing error message when calling an instance method as a class method
407-
CurriedClass.m2(12) // expected-error {{use of instance member 'm2' on type 'CurriedClass'; did you mean to use a value of type 'CurriedClass' instead?}}
407+
CurriedClass.m2(12) // expected-error {{instance member 'm2' cannot be used on type 'CurriedClass'; did you mean to use a value of this type instead?}}
408408

409409

410410

0 commit comments

Comments
 (0)