Skip to content

Commit 4dcc3f1

Browse files
committed
[CodeCompletion] No crash on a terribly wrong code completion position. rdar://21796881
Swift SVN r30706
1 parent 4ed4497 commit 4dcc3f1

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

include/swift/Parse/PersistentParserState.h

+2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ class PersistentParserState {
128128
std::unique_ptr<FunctionBodyState>
129129
takeFunctionBodyState(AbstractFunctionDecl *AFD);
130130

131+
bool hasFunctionBodyState(AbstractFunctionDecl *AFD);
132+
131133
void delayAccessorBodyParsing(AbstractFunctionDecl *AFD,
132134
SourceRange BodyRange,
133135
SourceLoc PreviousLoc,

lib/Parse/Parser.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class ParseDelayedFunctionBodies : public ASTWalker {
8989
Parsed = true;
9090
}
9191
}
92-
if (!Parsed)
92+
if (!Parsed && ParserState.hasFunctionBodyState(AFD))
9393
TheParser.parseAbstractFunctionBodyDelayed(AFD);
9494
if (CodeCompletion)
9595
CodeCompletion->doneParsing();

lib/Parse/PersistentParserState.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ PersistentParserState::takeFunctionBodyState(AbstractFunctionDecl *AFD) {
4141
return State;
4242
}
4343

44+
bool PersistentParserState::hasFunctionBodyState(AbstractFunctionDecl *AFD) {
45+
return DelayedFunctionBodies.find(AFD) != DelayedFunctionBodies.end();
46+
}
47+
4448
void PersistentParserState::delayAccessorBodyParsing(AbstractFunctionDecl *AFD,
4549
SourceRange BodyRange,
4650
SourceLoc PreviousLoc,

test/IDE/complete_crashes.swift

+5
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,8 @@ struct CustomGenericCollection<Key> : DictionaryLiteralConvertible {
6767
var count: Int { #^GENERIC_PARAM_AND_ASSOC_TYPE^# }
6868
}
6969

70+
// rdar://problem/21796881
71+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=RDAR_21796881
72+
extension NilLiteralConvertible {
73+
var nil: Self { #^RDAR_21796881^#
74+
}

0 commit comments

Comments
 (0)