Skip to content

Commit 93c386d

Browse files
committed
Parse: Skip function bodies when delayed member parsing mode is on
Fixes <rdar://problem/47305142>.
1 parent 83472bc commit 93c386d

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

include/swift/Parse/Parser.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ class Parser {
165165

166166
DelayedParsingCallbacks *DelayedParseCB = nullptr;
167167

168-
bool isDelayedParsingEnabled() const { return DelayedParseCB != nullptr; }
168+
bool isDelayedParsingEnabled() const {
169+
return DelayBodyParsing || DelayedParseCB != nullptr;
170+
}
169171

170172
void setDelayedParsingCallbacks(DelayedParsingCallbacks *DelayedParseCB) {
171173
this->DelayedParseCB = DelayedParseCB;

lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5401,7 +5401,8 @@ void Parser::consumeAbstractFunctionBody(AbstractFunctionDecl *AFD,
54015401

54025402
BodyRange.End = PreviousLoc;
54035403

5404-
if (DelayedParseCB->shouldDelayFunctionBodyParsing(*this, AFD, Attrs,
5404+
if (DelayedParseCB &&
5405+
DelayedParseCB->shouldDelayFunctionBodyParsing(*this, AFD, Attrs,
54055406
BodyRange)) {
54065407
State->delayFunctionBodyParsing(AFD, BodyRange,
54075408
BeginParserPosition.PreviousLoc);

validation-test/compiler_scale/function_bodies.gyb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,35 @@
33
// REQUIRES: asserts
44

55
func method${N}() {}
6+
7+
class C${N} {
8+
func method${N}() {}
9+
}
10+
11+
extension C${N} {
12+
func otherMethod${N}() {}
13+
}
14+
15+
struct S${N} {
16+
func method${N}() {}
17+
}
18+
19+
extension S${N} {
20+
func otherMethod${N}() {}
21+
}
22+
23+
enum E${N} {
24+
func method${N}() {}
25+
}
26+
27+
extension E${N} {
28+
func otherMethod${N}() {}
29+
}
30+
31+
protocol P${N} {
32+
func method${N}()
33+
}
34+
35+
extension P${N} {
36+
func otherMethod${N}() {}
37+
}

0 commit comments

Comments
 (0)