diff --git a/lib/Sema/TypeCheckSwitchStmt.cpp b/lib/Sema/TypeCheckSwitchStmt.cpp index 7e24182b48257..dd5e04c6a590d 100644 --- a/lib/Sema/TypeCheckSwitchStmt.cpp +++ b/lib/Sema/TypeCheckSwitchStmt.cpp @@ -212,12 +212,6 @@ namespace { } return Space(T, H, SP); } - static Space forConstructor(Type T, DeclName H, - std::forward_list SP) { - // No need to filter SP here; this is only used to copy other - // Constructor spaces. - return Space(T, H, SP); - } static Space forBool(bool C) { return Space(C); } @@ -1441,7 +1435,7 @@ namespace { if (subSpace.getKind() == SpaceKind::Constructor && subSpace.getHead().getBaseIdentifier().empty()) { return Space::forConstructor(item->getType(), name, - std::move(subSpace.getSpaces())); + {subSpace}); } return Space::forConstructor(item->getType(), name, subSpace); } diff --git a/test/Sema/exhaustive_switch.swift b/test/Sema/exhaustive_switch.swift index c2ed81f5eee95..a3933f3cfe4f6 100644 --- a/test/Sema/exhaustive_switch.swift +++ b/test/Sema/exhaustive_switch.swift @@ -1438,3 +1438,15 @@ enum SR11212Tests { } } // end SR11212Tests + +func sr12412() { + enum E { + case x + case y + } + switch (E.x, true) as Optional<(e: E, b: Bool)> { + case nil, (e: .x, b: _)?: break + case (e: .y, b: false)?: break + case (e: .y, b: true)?: break + } +}