Skip to content

Commit b31bd99

Browse files
authored
Merge pull request #18754 from rintaro/ide-rdar41593893
[IDE] Fix a crasher in SynthesizedExtensionAnalyzer
2 parents 32da3c3 + baa6903 commit b31bd99

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

lib/IDE/IDETypeChecking.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,10 @@ struct SynthesizedExtensionAnalyzer::Implementation {
263263
InfoMap(collectSynthesizedExtensionInfo(AllGroups)) {}
264264

265265
unsigned countInherits(ExtensionDecl *ED) {
266-
unsigned Count = 0;
267-
for (auto TL : ED->getInherited()) {
268-
auto *nominal = TL.getType()->getAnyNominal();
269-
if (nominal && Options.shouldPrint(nominal))
270-
Count ++;
271-
}
272-
return Count;
266+
SmallVector<TypeLoc, 4> Results;
267+
getInheritedForPrinting(
268+
ED, [&](const Decl *D) { return Options.shouldPrint(D); }, Results);
269+
return Results.size();
273270
}
274271

275272
std::pair<SynthesizedExtensionInfo, ExtensionMergeInfo>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %{python} %utils/split_file.py -o %t %s
3+
// RUN: %sourcekitd-test -req=cursor -pos=8:37 %t/first.swift -- %t/first.swift %t/second.swift | %FileCheck %s
4+
5+
// CHECK: source.lang.swift.ref.var.instance (6:9-6:12)
6+
7+
8+
// BEGIN first.swift
9+
protocol ChatDataSourceDelegateProtocol {
10+
func chatDataSourceDidUpdate()
11+
}
12+
13+
class BaseChatViewController {
14+
var foo = 1
15+
func bar() {
16+
print(self . /*cursor-info->*/foo)
17+
}
18+
}
19+
20+
// BEGIN second.swift
21+
extension BaseChatViewController: ChatDataSourceDelegateProtocol {
22+
func chatDataSourceDidUpdate() { fatalError() }
23+
}

0 commit comments

Comments
 (0)