Skip to content

Commit bdfbba3

Browse files
committed
Revert "[Type Checker] Check subpattern storage instead of whole pattern."
1 parent 1c7fa7e commit bdfbba3

File tree

5 files changed

+8
-20
lines changed

5 files changed

+8
-20
lines changed

include/swift/AST/Pattern.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,6 @@ class alignas(8) Pattern {
163163
});
164164
}
165165

166-
/// Does this binding declare something that requires storage?
167-
bool hasStorage() const;
168-
169166
static bool classof(const Pattern *P) { return true; }
170167

171168
//*** Allocation Routines ************************************************/

lib/AST/Decl.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,10 +1132,14 @@ StaticSpellingKind PatternBindingDecl::getCorrectStaticSpelling() const {
11321132
bool PatternBindingDecl::hasStorage() const {
11331133
// Walk the pattern, to check to see if any of the VarDecls included in it
11341134
// have storage.
1135+
bool HasStorage = false;
11351136
for (auto entry : getPatternList())
1136-
if (entry.getPattern()->hasStorage())
1137-
return true;
1138-
return false;
1137+
entry.getPattern()->forEachVariable([&](VarDecl *VD) {
1138+
if (VD->hasStorage())
1139+
HasStorage = true;
1140+
});
1141+
1142+
return HasStorage;
11391143
}
11401144

11411145
void PatternBindingDecl::setPattern(unsigned i, Pattern *P) {

lib/AST/Pattern.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,16 +237,6 @@ void Pattern::forEachNode(const std::function<void(Pattern*)> &f) {
237237
}
238238
}
239239

240-
bool Pattern::hasStorage() const {
241-
bool HasStorage = false;
242-
forEachVariable([&](VarDecl *VD) {
243-
if (VD->hasStorage())
244-
HasStorage = true;
245-
});
246-
247-
return HasStorage;
248-
}
249-
250240
/// Return true if this is a non-resolved ExprPattern which is syntactically
251241
/// irrefutable.
252242
static bool isIrrefutableExprPattern(const ExprPattern *EP) {

lib/Sema/TypeCheckDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2866,7 +2866,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
28662866
// default-initializable. If so, do it.
28672867
if (PBD->getPattern(i)->hasType() &&
28682868
!PBD->getInit(i) &&
2869-
PBD->getPattern(i)->hasStorage() &&
2869+
PBD->hasStorage() &&
28702870
!PBD->getPattern(i)->getType()->is<ErrorType>()) {
28712871

28722872
// If we have a type-adjusting attribute (like ownership), apply it now.

test/decl/var/NSManaged_properties.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ class SwiftGizmo : A {
5050
@NSManaged func mutableArrayValueForB() {} // expected-error {{NSManaged method cannot have a body; it must be provided at runtime}}
5151
@NSManaged class func mutableArrayValueForA() {} // expected-error {{@NSManaged only allowed on an instance property or method}}
5252

53-
// SR-1050: don't assert
54-
@NSManaged var multiA, multiB, multiC : NSNumber?
55-
5653
override init() {}
5754
}
5855

0 commit comments

Comments
 (0)