Skip to content

Commit ad21e5f

Browse files
authored
Merge pull request #6302 from CodaFi/pattern-ity
Walk into top level pattern binding decls to resolve conditions
2 parents dbc832b + a7957a1 commit ad21e5f

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lib/Parse/ConditionResolver.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,14 @@ namespace {
282282
for (auto condition : configsToResolve) {
283283
R.resolveClausesAndInsertMembers(IDC, condition);
284284
}
285+
} else if (auto *PBD = dyn_cast<PatternBindingDecl>(D)) {
286+
PBD->walk(R.NDF);
287+
for (unsigned i = 0, e = PBD->getNumPatternEntries(); i != e; ++i) {
288+
if (auto e = PBD->getInit(i)) {
289+
PBD->setInit(i,
290+
e->walk(const_cast<ASTWalker&>(R.getClosureFinder())));
291+
}
292+
}
285293
}
286294
return true;
287295
}

test/Parse/ConditionalCompilation/can_import.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,19 @@ func performPerOS() -> Int {
9494
return performFoo(withX: value, andY: value)
9595
}
9696
#endif
97+
98+
let osName: String = {
99+
#if os(iOS)
100+
return "iOS"
101+
#elseif os(watchOS)
102+
return "watchOS"
103+
#elseif os(tvOS)
104+
return "tvOS"
105+
#elseif os(OSX)
106+
return "OS X"
107+
#elseif os(Linux)
108+
return "Linux"
109+
#else
110+
return "Unknown"
111+
#endif
112+
}()

0 commit comments

Comments
 (0)