Skip to content

Commit 2924be7

Browse files
authored
Merge pull request #23192 from rintaro/ide-completion-infix-rdar48648877
[CodeCompletion] Fixed a crasher regarding malformed operator decl
2 parents a2322b4 + 19e54fe commit 2924be7

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

lib/Sema/TypeCheckExpr.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ TypeChecker::lookupPrecedenceGroupForInfixOperator(DeclContext *DC, Expr *E) {
217217
/// 'findLHS(DC, expr, '==')' returns nullptr.
218218
Expr *TypeChecker::findLHS(DeclContext *DC, Expr *E, Identifier name) {
219219
auto right = lookupPrecedenceGroupForOperator(*this, DC, name, E->getEndLoc());
220+
if (!right)
221+
return nullptr;
222+
220223
while (true) {
221224

222225
// Look through implicit conversions.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %{python} %utils/split_file.py -o %t %s
3+
// RUN: %target-swift-ide-test -code-completion -code-completion-token=COMPLETE -source-filename=%t/main.swift %t/a.swift %t/b.swift %t/c.swift %t/d.swift
4+
5+
// BEGIN main.swift
6+
func foo(x: Int, y: Int) {
7+
x + y #^COMPLETE^#
8+
}
9+
10+
// BEGIN a.swift
11+
12+
infix operator ***
13+
14+
// BEGIN b.swift
15+
16+
infix operator ***
17+
18+
// BEGIN c.swift
19+
20+
precedencegroup FooPrecedenceGroup {
21+
higherThan: MultiplicationPrecedence
22+
}
23+
infix operator **** : FooPrecedenceGroup
24+
25+
// BEGIN d.swift
26+
27+
precedencegroup FooPrecedenceGroup {
28+
higherThan: MultiplicationPrecedence
29+
}
30+
infix operator **** : FooPrecedenceGroup

0 commit comments

Comments
 (0)