From 2fb5afb755bde0627a1d9a7582376cc95d3927b8 Mon Sep 17 00:00:00 2001 From: Robert Widmann Date: Thu, 5 Jul 2018 11:53:15 -0700 Subject: [PATCH] Remove the @_downgrade_exhaustivity_check hack This hack was only needed for Swift 3 mode in a narrow case. Flush it out of the compiler so we can simplify the space engine. --- include/swift/AST/Attr.def | 7 +- include/swift/Serialization/ModuleFormat.h | 2 +- lib/AST/ASTDumper.cpp | 2 - lib/SILGen/SILGenPattern.cpp | 3 +- lib/Sema/TypeCheckAttr.cpp | 2 - lib/Sema/TypeCheckDeclOverride.cpp | 1 - lib/Sema/TypeCheckSwitchStmt.cpp | 123 +++++------------- stdlib/public/SDK/Dispatch/Time.swift | 1 - test/Compatibility/exhaustive_switch.swift | 30 +---- test/FixCode/fixits-switch-nonfrozen.swift | 2 - .../fixits-switch-nonfrozen.swift.result | 2 - test/Sema/exhaustive_switch.swift | 37 +----- test/Sema/exhaustive_switch_debugger.swift | 39 +----- .../nonexhaustive_switch_stmt_editor.swift | 28 ---- .../lib/SwiftLang/SwiftLangSupport.cpp | 1 - 15 files changed, 40 insertions(+), 240 deletions(-) diff --git a/include/swift/AST/Attr.def b/include/swift/AST/Attr.def index 2e82f55bd31ec..e9fb85525a300 100644 --- a/include/swift/AST/Attr.def +++ b/include/swift/AST/Attr.def @@ -345,12 +345,7 @@ DECL_ATTR(_restatedObjCConformance, RestatedObjCConformance, OnProtocol | LongAttribute | RejectByParser | NotSerialized, 70) -// HACK: Attribute needed to preserve source compatibility by downgrading errors -// due to an SDK change in Dispatch -SIMPLE_DECL_ATTR(_downgrade_exhaustivity_check, DowngradeExhaustivityCheck, - OnEnumElement | - LongAttribute | UserInaccessible, - 71) +// NOTE: 71 is unused SIMPLE_DECL_ATTR(_implicitly_unwrapped_optional, ImplicitlyUnwrappedOptional, OnFunc | OnAccessor | OnVar | OnParam | OnSubscript | OnConstructor | RejectByParser, diff --git a/include/swift/Serialization/ModuleFormat.h b/include/swift/Serialization/ModuleFormat.h index b7e475b6594f3..f416b5f48c8c8 100644 --- a/include/swift/Serialization/ModuleFormat.h +++ b/include/swift/Serialization/ModuleFormat.h @@ -55,7 +55,7 @@ const uint16_t VERSION_MAJOR = 0; /// describe what change you made. The content of this comment isn't important; /// it just ensures a conflict if two people change the module format. /// Don't worry about adhering to the 80-column limit for this line. -const uint16_t VERSION_MINOR = 438; // Last change: add isbitwisetakable +const uint16_t VERSION_MINOR = 439; // Last change: remove @_downgrade_exhaustivity_check attribute using DeclIDField = BCFixed<31>; diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp index cf27feb6119f5..e24543e07d5be 100644 --- a/lib/AST/ASTDumper.cpp +++ b/lib/AST/ASTDumper.cpp @@ -862,8 +862,6 @@ namespace { void visitEnumElementDecl(EnumElementDecl *EED) { printCommon(EED, "enum_element_decl"); - if (EED->getAttrs().hasAttribute()) - OS << "@_downgrade_exhaustivity_check"; PrintWithColorRAII(OS, ParenthesisColor) << ')'; } diff --git a/lib/SILGen/SILGenPattern.cpp b/lib/SILGen/SILGenPattern.cpp index 28f20d2ab61db..01b0e31668040 100644 --- a/lib/SILGen/SILGenPattern.cpp +++ b/lib/SILGen/SILGenPattern.cpp @@ -1806,8 +1806,7 @@ CaseBlocks::CaseBlocks( enumDecl->isEffectivelyExhaustive(SGF.getModule().getSwiftModule(), SGF.F.getResilienceExpansion()); if (canAssumeExhaustive) { - // Check that Sema didn't let any cases slip through. (This can happen - // with @_downgrade_exhaustivity_check.) + // Check that Sema didn't let any cases slip through. canAssumeExhaustive = llvm::all_of(enumDecl->getAllElements(), [&](const EnumElementDecl *elt) { return caseToIndex.count(elt); diff --git a/lib/Sema/TypeCheckAttr.cpp b/lib/Sema/TypeCheckAttr.cpp index fc07197e97a6e..69323d0b83cb7 100644 --- a/lib/Sema/TypeCheckAttr.cpp +++ b/lib/Sema/TypeCheckAttr.cpp @@ -78,7 +78,6 @@ class AttributeEarlyChecker : public AttributeVisitor { IGNORED_ATTR(ClangImporterSynthesizedType) IGNORED_ATTR(Convenience) IGNORED_ATTR(DiscardableResult) - IGNORED_ATTR(DowngradeExhaustivityCheck) IGNORED_ATTR(DynamicMemberLookup) IGNORED_ATTR(Effects) IGNORED_ATTR(Exported) @@ -777,7 +776,6 @@ class AttributeChecker : public AttributeVisitor { IGNORED_ATTR(ClangImporterSynthesizedType) IGNORED_ATTR(Consuming) IGNORED_ATTR(Convenience) - IGNORED_ATTR(DowngradeExhaustivityCheck) IGNORED_ATTR(Dynamic) IGNORED_ATTR(Effects) IGNORED_ATTR(Exported) diff --git a/lib/Sema/TypeCheckDeclOverride.cpp b/lib/Sema/TypeCheckDeclOverride.cpp index 3c20efabb1cae..13c0de225e779 100644 --- a/lib/Sema/TypeCheckDeclOverride.cpp +++ b/lib/Sema/TypeCheckDeclOverride.cpp @@ -1159,7 +1159,6 @@ namespace { UNINTERESTING_ATTR(RestatedObjCConformance) UNINTERESTING_ATTR(Implements) UNINTERESTING_ATTR(StaticInitializeObjCMetadata) - UNINTERESTING_ATTR(DowngradeExhaustivityCheck) UNINTERESTING_ATTR(ImplicitlyUnwrappedOptional) UNINTERESTING_ATTR(ClangImporterSynthesizedType) UNINTERESTING_ATTR(WeakLinked) diff --git a/lib/Sema/TypeCheckSwitchStmt.cpp b/lib/Sema/TypeCheckSwitchStmt.cpp index 07b466392bb42..da1c652474982 100644 --- a/lib/Sema/TypeCheckSwitchStmt.cpp +++ b/lib/Sema/TypeCheckSwitchStmt.cpp @@ -87,9 +87,8 @@ namespace { enum class DowngradeToWarning { No, ForUnknownCase, - ForSwift3Case, - LAST = ForSwift3Case + LAST = ForUnknownCase }; enum UnknownCase_t { @@ -194,13 +193,11 @@ namespace { : Kind(SpaceKind::UnknownCase), TypeAndVal(Type(), allowedButNotRequired), Head(Identifier()), Spaces({}) {} - explicit Space(Type T, Identifier H, bool downgrade, - ArrayRef SP) - : Kind(SpaceKind::Constructor), TypeAndVal(T, downgrade), Head(H), + explicit Space(Type T, Identifier H, ArrayRef SP) + : Kind(SpaceKind::Constructor), TypeAndVal(T), Head(H), Spaces(SP.begin(), SP.end()) {} - explicit Space(Type T, Identifier H, bool downgrade, - std::forward_list SP) - : Kind(SpaceKind::Constructor), TypeAndVal(T, downgrade), Head(H), + explicit Space(Type T, Identifier H, std::forward_list SP) + : Kind(SpaceKind::Constructor), TypeAndVal(T), Head(H), Spaces(SP) {} explicit Space(ArrayRef SP) : Kind(SpaceKind::Disjunct), TypeAndVal(Type()), @@ -221,20 +218,19 @@ namespace { static Space forUnknown(bool allowedButNotRequired) { return Space(UnknownCase, allowedButNotRequired); } - static Space forConstructor(Type T, Identifier H, bool downgrade, - ArrayRef SP) { + static Space forConstructor(Type T, Identifier H, ArrayRef SP) { if (llvm::any_of(SP, std::mem_fn(&Space::isEmpty))) { // A constructor with an unconstructible parameter can never actually // be used. return Space(); } - return Space(T, H, downgrade, SP); + return Space(T, H, SP); } - static Space forConstructor(Type T, Identifier H, bool downgrade, + static Space forConstructor(Type T, Identifier H, std::forward_list SP) { // No need to filter SP here; this is only used to copy other // Constructor spaces. - return Space(T, H, downgrade, SP); + return Space(T, H, SP); } static Space forBool(bool C) { return Space(C); @@ -273,13 +269,6 @@ namespace { } bool isEmpty() const { return getKind() == SpaceKind::Empty; } - - bool canDowngradeToWarning() const { - assert((getKind() == SpaceKind::Type - || getKind() == SpaceKind::Constructor) - && "Wrong kind of space tried to access downgrade"); - return TypeAndVal.getInt(); - } bool isAllowedButNotRequired() const { assert(getKind() == SpaceKind::UnknownCase @@ -560,7 +549,6 @@ namespace { newSubSpaces.push_back(nextSpace.getValue()); } return Space::forConstructor(this->getType(), this->getHead(), - this->canDowngradeToWarning(), newSubSpaces); } @@ -619,7 +607,6 @@ namespace { copyParams[idx] = reducedSpace; Space CS = Space::forConstructor(this->getType(), this->getHead(), - this->canDowngradeToWarning(), copyParams); constrSpaces.push_back(CS); } @@ -757,13 +744,6 @@ namespace { } } - static bool isSwift3DowngradeExhaustivityCase(TypeChecker &TC, - const EnumElementDecl *eed){ - if (TC.getLangOpts().isSwiftVersionAtLeast(4)) - return false; - return eed->getAttrs().hasAttribute(); - } - // Decompose a type into its component spaces. static void decompose(TypeChecker &TC, const DeclContext *DC, Type tp, SmallVectorImpl &arr) { @@ -813,8 +793,7 @@ namespace { Space::forType(TTy->getUnderlyingType(), Identifier())); } } - bool canDowngrade = isSwift3DowngradeExhaustivityCase(TC, eed); - return Space::forConstructor(tp, eed->getName(), canDowngrade, + return Space::forConstructor(tp, eed->getName(), constElemSpaces); }); @@ -834,7 +813,6 @@ namespace { }); // Create an empty constructor head for the tuple space. arr.push_back(Space::forConstructor(tp, Identifier(), - /*canDowngrade*/false, constElemSpaces)); } else { llvm_unreachable("Can't decompose type?"); @@ -853,8 +831,8 @@ namespace { tp->getEnumOrBoundGenericEnum(); } - // HACK: Search the space for any remaining cases that were labelled - // @_downgrade_exhaustivity_check, or 'exhaustive' enums in Swift 4 mode. + // Search the space for a reason to downgrade exhaustiveness errors to + // a warning e.g. 'unknown case' statements. DowngradeToWarning checkDowngradeToWarning() const { switch (getKind()) { case SpaceKind::Type: @@ -865,8 +843,6 @@ namespace { return DowngradeToWarning::ForUnknownCase; case SpaceKind::Constructor: { auto result = DowngradeToWarning::No; - if (canDowngradeToWarning()) - result = DowngradeToWarning::ForSwift3Case; // Traverse the constructor and its subspaces. for (const Space &space : getSpaces()) result = std::max(result, space.checkDowngradeToWarning()); @@ -1058,7 +1034,6 @@ namespace { return; } - bool sawDowngradablePattern = false; bool sawRedundantPattern = false; const CaseStmt *unknownCase = nullptr; SmallVector spaces; @@ -1079,8 +1054,7 @@ namespace { if (caseItem.isDefault()) return; - Space projection = projectPattern(TC, caseItem.getPattern(), - sawDowngradablePattern); + Space projection = projectPattern(TC, caseItem.getPattern()); if (!projection.isEmpty() && projection.isSubspace(Space::forDisjunct(spaces), TC, DC)) { @@ -1148,19 +1122,17 @@ namespace { SmallVector spaces; Space::decompose(TC, DC, uncovered.getType(), spaces); diagnoseMissingCases(RequiresDefault::No, Space::forDisjunct(spaces), - unknownCase, /*sawDowngradablePattern*/false); + unknownCase); } else { diagnoseMissingCases(Switch->getCases().empty() ? RequiresDefault::EmptySwitchBody : RequiresDefault::UncoveredSwitch, - uncovered, unknownCase, - /*sawDowngradablePattern*/false); + uncovered, unknownCase); } return; } - diagnoseMissingCases(RequiresDefault::No, uncovered, unknownCase, - sawDowngradablePattern); + diagnoseMissingCases(RequiresDefault::No, uncovered, unknownCase); } enum class RequiresDefault { @@ -1190,8 +1162,7 @@ namespace { } void diagnoseMissingCases(RequiresDefault defaultReason, Space uncovered, - const CaseStmt *unknownCase = nullptr, - bool sawDowngradablePattern = false) { + const CaseStmt *unknownCase = nullptr) { SourceLoc startLoc = Switch->getStartLoc(); SourceLoc insertLoc; if (unknownCase) @@ -1232,12 +1203,6 @@ namespace { switch (uncovered.checkDowngradeToWarning()) { case DowngradeToWarning::No: break; - case DowngradeToWarning::ForSwift3Case: - // If someone's used one of the cases introduced in the Swift 4 - // timeframe, force them to handle all of them. - if (!sawDowngradablePattern) - mainDiagType = diag::non_exhaustive_switch_warn; - break; case DowngradeToWarning::ForUnknownCase: if (TC.Context.LangOpts.DebuggerSupport || TC.Context.LangOpts.Playground || @@ -1475,7 +1440,6 @@ namespace { for (auto &row : matrix) { flats.push_back(Space::forConstructor(space.getType(), space.getHead(), - space.canDowngradeToWarning(), row)); } } @@ -1495,13 +1459,7 @@ namespace { } /// Recursively project a pattern into a Space. - /// - /// The resulting Space does not mark any subspaces as downgradable. - /// Instead, whether or not a Swift 3 downgradable pattern was seen is - /// recorded in \p sawDowngradablePattern. (This does not include - /// downgradable warnings for exhaustive enums in Swift 4.) - static Space projectPattern(TypeChecker &TC, const Pattern *item, - bool &sawDowngradablePattern) { + static Space projectPattern(TypeChecker &TC, const Pattern *item) { switch (item->getKind()) { case PatternKind::Any: return Space::forType(item->getType(), Identifier()); @@ -1517,8 +1475,7 @@ namespace { case CheckedCastKind::BridgingCoercion: { if (auto *subPattern = IP->getSubPattern()) { // Project the cast target's subpattern. - Space castSubSpace = projectPattern(TC, subPattern, - sawDowngradablePattern); + Space castSubSpace = projectPattern(TC, subPattern); // If we recieved a type space from a named pattern or a wildcard // we have to re-project with the cast's target type to maintain // consistency with the scrutinee's type. @@ -1548,45 +1505,35 @@ namespace { return Space(); case PatternKind::Var: { auto *VP = cast(item); - return projectPattern(TC, VP->getSubPattern(), sawDowngradablePattern); + return projectPattern(TC, VP->getSubPattern()); } case PatternKind::Paren: { auto *PP = cast(item); - return projectPattern(TC, PP->getSubPattern(), sawDowngradablePattern); + return projectPattern(TC, PP->getSubPattern()); } case PatternKind::OptionalSome: { auto *OSP = cast(item); Identifier name = TC.Context.getOptionalSomeDecl()->getName(); - auto subSpace = projectPattern(TC, OSP->getSubPattern(), - sawDowngradablePattern); + auto subSpace = projectPattern(TC, OSP->getSubPattern()); // To match patterns like (_, _, ...)?, we must rewrite the underlying // tuple pattern to .some(_, _, ...) first. if (subSpace.getKind() == SpaceKind::Constructor && subSpace.getHead().empty()) { return Space::forConstructor(item->getType(), name, - /*canDowngrade*/false, std::move(subSpace.getSpaces())); } - return Space::forConstructor(item->getType(), name, - /*canDowngrade*/false, subSpace); + return Space::forConstructor(item->getType(), name, subSpace); } case PatternKind::EnumElement: { auto *VP = cast(item); TC.validateDecl(item->getType()->getEnumOrBoundGenericEnum()); - if (auto *eed = VP->getElementDecl()) { - if (Space::isSwift3DowngradeExhaustivityCase(TC, eed)) { - sawDowngradablePattern |= true; - } - } - auto *SP = VP->getSubPattern(); if (!SP) { // If there's no sub-pattern then there's no further recursive // structure here. Yield the constructor space. - return Space::forConstructor(item->getType(), VP->getName(), - /*canDowngrade*/false, None); + return Space::forConstructor(item->getType(), VP->getName(), None); } SmallVector conArgSpace; @@ -1596,11 +1543,10 @@ namespace { std::transform(TP->getElements().begin(), TP->getElements().end(), std::back_inserter(conArgSpace), [&](TuplePatternElt pate) { - return projectPattern(TC, pate.getPattern(), - sawDowngradablePattern); + return projectPattern(TC, pate.getPattern()); }); return Space::forConstructor(item->getType(), VP->getName(), - /*canDowngrade*/false, conArgSpace); + conArgSpace); } case PatternKind::Paren: { auto *PP = dyn_cast(SP); @@ -1619,25 +1565,22 @@ namespace { ty.getName())); } } else { - conArgSpace.push_back(projectPattern(TC, SP, - sawDowngradablePattern)); + conArgSpace.push_back(projectPattern(TC, SP)); } } else if (SP->getKind() == PatternKind::Tuple) { - Space argTupleSpace = projectPattern(TC, SP, - sawDowngradablePattern); + Space argTupleSpace = projectPattern(TC, SP); assert(argTupleSpace.getKind() == SpaceKind::Constructor); conArgSpace.insert(conArgSpace.end(), argTupleSpace.getSpaces().begin(), argTupleSpace.getSpaces().end()); } else { - conArgSpace.push_back(projectPattern(TC, SP, - sawDowngradablePattern)); + conArgSpace.push_back(projectPattern(TC, SP)); } return Space::forConstructor(item->getType(), VP->getName(), - /*canDowngrade*/false, conArgSpace); + conArgSpace); } default: - return projectPattern(TC, SP, sawDowngradablePattern); + return projectPattern(TC, SP); } } case PatternKind::Tuple: { @@ -1646,10 +1589,10 @@ namespace { std::transform(TP->getElements().begin(), TP->getElements().end(), std::back_inserter(conArgSpace), [&](TuplePatternElt pate) { - return projectPattern(TC, pate.getPattern(), sawDowngradablePattern); + return projectPattern(TC, pate.getPattern()); }); return Space::forConstructor(item->getType(), Identifier(), - /*canDowngrade*/false, conArgSpace); + conArgSpace); } } } diff --git a/stdlib/public/SDK/Dispatch/Time.swift b/stdlib/public/SDK/Dispatch/Time.swift index 4b068542f5d56..5f127c898da69 100644 --- a/stdlib/public/SDK/Dispatch/Time.swift +++ b/stdlib/public/SDK/Dispatch/Time.swift @@ -163,7 +163,6 @@ public enum DispatchTimeInterval : Equatable { case milliseconds(Int) case microseconds(Int) case nanoseconds(Int) - @_downgrade_exhaustivity_check case never internal var rawValue: Int64 { diff --git a/test/Compatibility/exhaustive_switch.swift b/test/Compatibility/exhaustive_switch.swift index f75a0dd8c9871..dd987e2a32a2c 100644 --- a/test/Compatibility/exhaustive_switch.swift +++ b/test/Compatibility/exhaustive_switch.swift @@ -831,7 +831,6 @@ public enum NonExhaustivePayload { case milliseconds(Int) case microseconds(Int) case nanoseconds(Int) - @_downgrade_exhaustivity_check case never } @@ -930,20 +929,6 @@ public func testNonExhaustive(_ value: NonExhaustive, _ payload: NonExhaustivePa @unknown case _: break } // no-warning - // Test interaction with @_downgrade_exhaustivity_check. - switch (value, interval) { // no-warning - case (_, .seconds): break - case (.a, _): break - case (.b, _): break - } - - switch (value, interval) { // no-warning - case (_, .never): break - case (.a, _): break - case (.b, _): break - } - - // Test payloaded enums. switch payload { // expected-error {{switch must be exhaustive}} {{none}} expected-note {{add missing case: '.b(_)'}} {{none}} case .a: break @@ -1008,7 +993,7 @@ public func testNonExhaustive(_ value: NonExhaustive, _ payload: NonExhaustivePa } } -public func testNonExhaustiveWithinModule(_ value: NonExhaustive, _ payload: NonExhaustivePayload, for interval: TemporalProxy, flag: Bool) { +public func testNonExhaustiveWithinModule(_ value: NonExhaustive, _ payload: NonExhaustivePayload, flag: Bool) { switch value { // expected-error {{switch must be exhaustive}} {{none}} expected-note {{add missing case: '.b'}} case .a: break } @@ -1083,19 +1068,6 @@ public func testNonExhaustiveWithinModule(_ value: NonExhaustive, _ payload: Non @unknown case _: break } - // Test interaction with @_downgrade_exhaustivity_check. - switch (value, interval) { // no-warning - case (_, .seconds): break - case (.a, _): break - case (.b, _): break - } - - switch (value, interval) { // no-warning - case (_, .never): break - case (.a, _): break - case (.b, _): break - } - // Test payloaded enums. switch payload { // expected-error {{switch must be exhaustive}} {{none}} expected-note {{add missing case: '.b(_)'}} {{none}} case .a: break diff --git a/test/FixCode/fixits-switch-nonfrozen.swift b/test/FixCode/fixits-switch-nonfrozen.swift index eb3c082c3594a..813c572e4839a 100644 --- a/test/FixCode/fixits-switch-nonfrozen.swift +++ b/test/FixCode/fixits-switch-nonfrozen.swift @@ -146,7 +146,6 @@ public enum NonExhaustivePayload { case milliseconds(Int) case microseconds(Int) case nanoseconds(Int) - @_downgrade_exhaustivity_check case never } @@ -240,7 +239,6 @@ public func testNonExhaustive(_ value: NonExhaustive, _ payload: NonExhaustivePa @unknown case _: break } // no-warning - // Test interaction with @_downgrade_exhaustivity_check. switch (value, interval) { case (_, .seconds): break case (.a, _): break diff --git a/test/FixCode/fixits-switch-nonfrozen.swift.result b/test/FixCode/fixits-switch-nonfrozen.swift.result index 07cee6e0cdfca..7ff674825220f 100644 --- a/test/FixCode/fixits-switch-nonfrozen.swift.result +++ b/test/FixCode/fixits-switch-nonfrozen.swift.result @@ -416,7 +416,6 @@ public enum NonExhaustivePayload { case milliseconds(Int) case microseconds(Int) case nanoseconds(Int) - @_downgrade_exhaustivity_check case never } @@ -530,7 +529,6 @@ case .b: @unknown case _: break } // no-warning - // Test interaction with @_downgrade_exhaustivity_check. switch (value, interval) { case (_, .seconds): break case (.a, _): break diff --git a/test/Sema/exhaustive_switch.swift b/test/Sema/exhaustive_switch.swift index a230307a2fe45..f9629dd091946 100644 --- a/test/Sema/exhaustive_switch.swift +++ b/test/Sema/exhaustive_switch.swift @@ -864,7 +864,6 @@ public enum NonExhaustivePayload { case milliseconds(Int) case microseconds(Int) case nanoseconds(Int) - @_downgrade_exhaustivity_check case never } @@ -963,27 +962,6 @@ public func testNonExhaustive(_ value: NonExhaustive, _ payload: NonExhaustivePa @unknown case _: break } // no-warning - // Test interaction with @_downgrade_exhaustivity_check. - switch (value, interval) { // expected-warning {{switch must be exhaustive}} {{none}} - // expected-note@-1 {{add missing case: '(_, .milliseconds(_))'}} - // expected-note@-2 {{add missing case: '(_, .microseconds(_))'}} - // expected-note@-3 {{add missing case: '(_, .nanoseconds(_))'}} - // expected-note@-4 {{add missing case: '(_, .never)'}} - case (_, .seconds): break - case (.a, _): break - case (.b, _): break - } - - switch (value, interval) { // expected-warning {{switch must be exhaustive}} {{none}} - // expected-note@-1 {{add missing case: '(_, .seconds(_))'}} - // expected-note@-2 {{add missing case: '(_, .milliseconds(_))'}} - // expected-note@-3 {{add missing case: '(_, .microseconds(_))'}} - // expected-note@-4 {{add missing case: '(_, .nanoseconds(_))'}} - case (_, .never): break - case (.a, _): break - case (.b, _): break - } - // Test payloaded enums. switch payload { // expected-error {{switch must be exhaustive}} {{none}} expected-note {{add missing case: '.b(_)'}} {{none}} expected-note {{handle unknown values using "@unknown default"}} {{none}} case .a: break @@ -1048,7 +1026,7 @@ public func testNonExhaustive(_ value: NonExhaustive, _ payload: NonExhaustivePa } } -public func testNonExhaustiveWithinModule(_ value: NonExhaustive, _ payload: NonExhaustivePayload, for interval: TemporalProxy, flag: Bool) { +public func testNonExhaustiveWithinModule(_ value: NonExhaustive, _ payload: NonExhaustivePayload, flag: Bool) { switch value { // expected-error {{switch must be exhaustive}} {{none}} expected-note {{add missing case: '.b'}} case .a: break } @@ -1123,19 +1101,6 @@ public func testNonExhaustiveWithinModule(_ value: NonExhaustive, _ payload: Non @unknown case _: break } - // Test interaction with @_downgrade_exhaustivity_check. - switch (value, interval) { // no-warning - case (_, .seconds): break - case (.a, _): break - case (.b, _): break - } - - switch (value, interval) { // no-warning - case (_, .never): break - case (.a, _): break - case (.b, _): break - } - // Test payloaded enums. switch payload { // expected-error {{switch must be exhaustive}} {{none}} expected-note {{add missing case: '.b(_)'}} {{none}} case .a: break diff --git a/test/Sema/exhaustive_switch_debugger.swift b/test/Sema/exhaustive_switch_debugger.swift index 4f69726ff09d7..e7fc903b40db5 100644 --- a/test/Sema/exhaustive_switch_debugger.swift +++ b/test/Sema/exhaustive_switch_debugger.swift @@ -9,19 +9,10 @@ public enum NonExhaustivePayload { case a(Int), b(Bool) } -@_frozen public enum TemporalProxy { - case seconds(Int) - case milliseconds(Int) - case microseconds(Int) - case nanoseconds(Int) - @_downgrade_exhaustivity_check - case never -} - // Inlineable code is considered "outside" the module and must include a default // case. @inlinable -public func testNonExhaustive(_ value: NonExhaustive, _ payload: NonExhaustivePayload, for interval: TemporalProxy, flag: Bool) { +public func testNonExhaustive(_ value: NonExhaustive, _ payload: NonExhaustivePayload, flag: Bool) { switch value { // expected-error {{switch must be exhaustive}} {{none}} expected-note {{add missing case: '.b'}} {{none}} expected-note {{handle unknown values using "@unknown default"}} {{none}} case .a: break } @@ -81,19 +72,6 @@ public func testNonExhaustive(_ value: NonExhaustive, _ payload: NonExhaustivePa case (true, _): break } - // Test interaction with @_downgrade_exhaustivity_check. - switch (value, interval) { // no-warning - case (_, .seconds): break - case (.a, _): break - case (.b, _): break - } - - switch (value, interval) { // no-warning - case (_, .never): break - case (.a, _): break - case (.b, _): break - } - // Test payloaded enums. switch payload { // expected-error {{switch must be exhaustive}} {{none}} expected-note {{add missing case: '.b(_)'}} {{none}} expected-note {{handle unknown values using "@unknown default"}} {{none}} case .a: break @@ -133,7 +111,7 @@ public func testNonExhaustive(_ value: NonExhaustive, _ payload: NonExhaustivePa } } -public func testNonExhaustiveWithinModule(_ value: NonExhaustive, _ payload: NonExhaustivePayload, for interval: TemporalProxy, flag: Bool) { +public func testNonExhaustiveWithinModule(_ value: NonExhaustive, _ payload: NonExhaustivePayload, flag: Bool) { switch value { // expected-error {{switch must be exhaustive}} {{none}} expected-note {{add missing case: '.b'}} case .a: break } @@ -193,19 +171,6 @@ public func testNonExhaustiveWithinModule(_ value: NonExhaustive, _ payload: Non case (true, _): break } - // Test interaction with @_downgrade_exhaustivity_check. - switch (value, interval) { // no-warning - case (_, .seconds): break - case (.a, _): break - case (.b, _): break - } - - switch (value, interval) { // no-warning - case (_, .never): break - case (.a, _): break - case (.b, _): break - } - // Test payloaded enums. switch payload { // expected-error {{switch must be exhaustive}} {{none}} expected-note {{add missing case: '.b(_)'}} {{none}} case .a: break diff --git a/test/stmt/nonexhaustive_switch_stmt_editor.swift b/test/stmt/nonexhaustive_switch_stmt_editor.swift index 0d22147443136..77da11575792d 100644 --- a/test/stmt/nonexhaustive_switch_stmt_editor.swift +++ b/test/stmt/nonexhaustive_switch_stmt_editor.swift @@ -1,33 +1,5 @@ // RUN: %target-typecheck-verify-swift -diagnostics-editor-mode -enable-resilience -enable-nonfrozen-enum-exhaustivity-diagnostics -typealias TimeInterval = Double - -let NSEC_PER_USEC : UInt64 = 1000 -let NSEC_PER_SEC : UInt64 = 1000000000 - -@_frozen public enum TemporalProxy { - case seconds(Int) - case milliseconds(Int) - case microseconds(Int) - case nanoseconds(Int) - @_downgrade_exhaustivity_check - case never -} - -func unproxify(t : TemporalProxy) -> TimeInterval { - switch t { // expected-error {{switch must be exhaustive}} - // expected-note@-1 {{do you want to add missing cases?}} - case let .seconds(s): - return TimeInterval(s) - case let .milliseconds(ms): - return TimeInterval(TimeInterval(ms) / 1000.0) - case let .microseconds(us): - return TimeInterval( UInt64(us) * NSEC_PER_USEC ) / TimeInterval(NSEC_PER_SEC) - case let .nanoseconds(ns): - return TimeInterval(ns) / TimeInterval(NSEC_PER_SEC) - } -} - public enum NonExhaustive { case a, b } diff --git a/tools/SourceKit/lib/SwiftLang/SwiftLangSupport.cpp b/tools/SourceKit/lib/SwiftLang/SwiftLangSupport.cpp index f06554fd78512..b696a9ce4d10e 100644 --- a/tools/SourceKit/lib/SwiftLang/SwiftLangSupport.cpp +++ b/tools/SourceKit/lib/SwiftLang/SwiftLangSupport.cpp @@ -682,7 +682,6 @@ Optional SwiftLangSupport::getUIDForDeclAttribute(const swift::DeclAttri // Ignore these. case DAK_ShowInInterface: case DAK_RawDocComment: - case DAK_DowngradeExhaustivityCheck: case DAK_HasInitialValue: return None; default: