Skip to content

Commit 0e68c4d

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents 4a04596 + 667bec0 commit 0e68c4d

File tree

4 files changed

+29
-12
lines changed

4 files changed

+29
-12
lines changed

lib/Sema/CSDiagnostics.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3710,15 +3710,19 @@ bool AllowTypeOrInstanceMemberFailure::diagnoseAsError() {
37103710
}
37113711

37123712
// Fall back to a fix-it with a full type qualifier
3713-
if (auto *NTD = Member->getDeclContext()->getSelfNominalTypeDecl()) {
3714-
auto type = NTD->getSelfInterfaceType();
3715-
if (auto *SE = dyn_cast<SubscriptExpr>(getRawAnchor())) {
3716-
auto *baseExpr = SE->getBase();
3717-
Diag->fixItReplace(baseExpr->getSourceRange(), diag::replace_with_type,
3718-
type);
3719-
} else {
3720-
Diag->fixItInsert(loc, diag::insert_type_qualification, type);
3721-
}
3713+
const Expr *baseExpr = nullptr;
3714+
if (const auto SE = dyn_cast<SubscriptExpr>(getRawAnchor()))
3715+
baseExpr = SE->getBase();
3716+
else if (const auto UDE = dyn_cast<UnresolvedDotExpr>(getRawAnchor()))
3717+
baseExpr = UDE->getBase();
3718+
3719+
// An implicit 'self' reference base expression means we should
3720+
// prepend with qualification.
3721+
if (baseExpr && !baseExpr->isImplicit()) {
3722+
Diag->fixItReplace(baseExpr->getSourceRange(),
3723+
diag::replace_with_type, baseTy);
3724+
} else {
3725+
Diag->fixItInsert(loc, diag::insert_type_qualification, baseTy);
37223726
}
37233727

37243728
return true;

test/NameBinding/name_lookup.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,19 @@ class ThisDerived1 : ThisBase1 {
344344
}
345345
}
346346

347+
protocol Crawlable {}
348+
extension Crawlable {
349+
static func crawl() {}
350+
}
351+
struct GenericChameleon<U>: Crawlable {
352+
static func chameleon() {}
353+
354+
func testStaticOnInstance(arg: GenericChameleon<Never>) {
355+
arg.chameleon() // expected-error {{static member 'chameleon' cannot be used on instance of type 'GenericChameleon<Never>'}} {{5-8=GenericChameleon<Never>}}
356+
arg.crawl() // expected-error {{static member 'crawl' cannot be used on instance of type 'GenericChameleon<Never>'}} {{5-8=GenericChameleon<Never>}}
357+
}
358+
}
359+
347360
extension ThisBase1 {
348361
var baseExtProp : Int {
349362
get {

test/Parse/enum.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ enum SE0036 {
473473

474474
func staticReferenceInInstanceMethod() {
475475
_ = A // expected-error {{enum case 'A' cannot be used as an instance member}} {{9-9=SE0036.}}
476-
_ = self.A // expected-error {{enum case 'A' cannot be used as an instance member}} {{9-9=SE0036.}}
476+
_ = self.A // expected-error {{enum case 'A' cannot be used as an instance member}} {{9-13=SE0036}}
477477
_ = SE0036.A
478478
}
479479

test/TypeCoercion/overload_member.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func test_static_method_value_coerce(_ a: A) {
6969
func test_mixed_overload(_ a: A, x: X, y: Y) {
7070
var x1 = a.mixed(x: x)
7171
x1 = x
72-
var y1 = a.mixed(y: y) // expected-error {{static member 'mixed' cannot be used on instance of type 'A'}} {{12-12=A.}}
72+
var y1 = a.mixed(y: y) // expected-error {{static member 'mixed' cannot be used on instance of type 'A'}} {{12-13=A}}
7373

7474
A.mixed(x) // expected-error{{cannot convert value of type 'X' to expected argument type 'A'}}
7575
var x2 = A.mixed(a)(x: x)
@@ -89,7 +89,7 @@ func test_mixed_overload_coerce(_ a: A, x: inout X, y: Y, z: Z) {
8989
func test_mixed_method_value_coerce(_ a: A) {
9090
var _ : (X) -> X = a.mixed
9191
var _ : (Y) -> Y = A.mixed
92-
var _ : (Y) -> Y = a.mixed; // expected-error {{static member 'mixed' cannot be used on instance of type 'A'}} {{22-22=A.}}
92+
var _ : (Y) -> Y = a.mixed; // expected-error {{static member 'mixed' cannot be used on instance of type 'A'}} {{22-23=A}}
9393
var _ : (A) -> (X) -> X = A.mixed
9494
}
9595

0 commit comments

Comments
 (0)