Skip to content

Commit 96be6cf

Browse files
committed
DiagnosticEngine: Do not describe an accessor's storage for %kindonly
This is the desired behavior is most cases. In the future, we should consider adding format specifiers for short/detailed descriptions.
1 parent 08d46d2 commit 96be6cf

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

lib/AST/DiagnosticEngine.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -874,11 +874,13 @@ static void formatDiagnosticArgument(StringRef Modifier,
874874
assert(Modifier.empty() && "Improper modifier for ValueDecl argument");
875875
}
876876

877-
// If it's an accessor, describe that and then switch to discussing its
878-
// storage.
879-
if (auto accessor = dyn_cast<AccessorDecl>(D)) {
880-
Out << Decl::getDescriptiveKindName(D->getDescriptiveKind()) << " for ";
881-
D = accessor->getStorage();
877+
if (includeName) {
878+
// If it's an accessor, describe that and then switch to discussing its
879+
// storage.
880+
if (auto accessor = dyn_cast<AccessorDecl>(D)) {
881+
Out << Decl::getDescriptiveKindName(D->getDescriptiveKind()) << " for ";
882+
D = accessor->getStorage();
883+
}
882884
}
883885

884886
// If it's an extension, describe that and then switch to discussing its

test/Sema/availability_accessors.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -555,18 +555,18 @@ struct TestPatternBindingInitExprs {
555555

556556
struct BadAccessorAvailability<T> {
557557
var alwaysUnavailableObservers: T {
558-
@available(*, unavailable) // expected-error {{willSet observer for property cannot be marked unavailable with '@available'}}
558+
@available(*, unavailable) // expected-error {{willSet observer cannot be marked unavailable with '@available'}}
559559
willSet { }
560560

561-
@available(*, unavailable) // expected-error {{didSet observer for property cannot be marked unavailable with '@available'}}
561+
@available(*, unavailable) // expected-error {{didSet observer cannot be marked unavailable with '@available'}}
562562
didSet { }
563563
}
564564

565565
var observersUnavailableBeforeSwift99: T {
566-
@available(swift, introduced: 99) // expected-error {{willSet observer for property cannot be marked unavailable with '@available'}}
566+
@available(swift, introduced: 99) // expected-error {{willSet observer cannot be marked unavailable with '@available'}}
567567
willSet { }
568568

569-
@available(swift, introduced: 99) // expected-error {{didSet observer for property cannot be marked unavailable with '@available'}}
569+
@available(swift, introduced: 99) // expected-error {{didSet observer cannot be marked unavailable with '@available'}}
570570
didSet { }
571571
}
572572
}

test/Sema/availability_versions.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,26 +1920,26 @@ class StoredPropertiesWithAvailabilityInClosures {
19201920

19211921
struct PropertyObservers {
19221922
var hasPotentiallyUnavailableObservers: Int {
1923-
@available(macOS 51, *) // expected-error {{willSet observer for property cannot be marked potentially unavailable with '@available'}}
1923+
@available(macOS 51, *) // expected-error {{willSet observer cannot be marked potentially unavailable with '@available'}}
19241924
willSet { }
19251925

1926-
@available(macOS 51, *) // expected-error {{didSet observer for property cannot be marked potentially unavailable with '@available'}}
1926+
@available(macOS 51, *) // expected-error {{didSet observer cannot be marked potentially unavailable with '@available'}}
19271927
didSet { }
19281928
}
19291929

19301930
var hasObsoletedObservers: Int {
1931-
@available(macOS, obsoleted: 10.9) // expected-error {{willSet observer for property cannot be marked unavailable with '@available'}}
1931+
@available(macOS, obsoleted: 10.9) // expected-error {{willSet observer cannot be marked unavailable with '@available'}}
19321932
willSet { }
19331933

1934-
@available(macOS, obsoleted: 10.9) // expected-error {{didSet observer for property cannot be marked unavailable with '@available'}}
1934+
@available(macOS, obsoleted: 10.9) // expected-error {{didSet observer cannot be marked unavailable with '@available'}}
19351935
didSet { }
19361936
}
19371937

19381938
var hasSPIAvailableObservers: Int {
1939-
@_spi_available(macOS, introduced: 10.9) // expected-error {{willSet observer for property cannot be marked unavailable with '@available'}}
1939+
@_spi_available(macOS, introduced: 10.9) // expected-error {{willSet observer cannot be marked unavailable with '@available'}}
19401940
willSet { }
19411941

1942-
@_spi_available(macOS, introduced: 10.9) // expected-error {{didSet observer for property cannot be marked unavailable with '@available'}}
1942+
@_spi_available(macOS, introduced: 10.9) // expected-error {{didSet observer cannot be marked unavailable with '@available'}}
19431943
didSet { }
19441944
}
19451945

0 commit comments

Comments
 (0)