Skip to content

Commit 2604cbe

Browse files
committed
[Omit needless words] Don't split subscript accessors.
1 parent 90af7e6 commit 2604cbe

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2319,7 +2319,7 @@ auto ClangImporter::Implementation::importFullName(
23192319

23202320
// Omit needless words.
23212321
StringScratchSpace omitNeedlessWordsScratch;
2322-
if (OmitNeedlessWords) {
2322+
if (OmitNeedlessWords && !result.IsSubscriptAccessor) {
23232323
// Check whether the module in which the declaration resides has a
23242324
// module prefix. If so, strip that prefix off when present.
23252325
if (D->getDeclContext()->getRedeclContext()->isFileContext() &&

test/IDE/Inputs/custom-modules/OmitNeedlessWords.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@
1515
-(nullable Class)typeOfNamedString:(nonnull NSString *)string;
1616
-(nullable Class)typeOfTypeNamed:(nonnull NSString *)string;
1717
-(void)appendWithContentsOfString:(nonnull NSString *)string;
18+
-(nonnull id)objectAtIndexedSubscript:(NSUInteger)idx;
1819
@end

test/IDE/print_omit_needless_words.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,5 +287,9 @@
287287
// Look for preposition prior to "of".
288288
// CHECK-OMIT-NEEDLESS-WORDS: func append(contentsOf _: String)
289289

290+
// Leave subscripts alone
291+
// CHECK-OMIT-NEEDLESS-WORDS: subscript (_: UInt) -> AnyObject { get }
292+
// CHECK-OMIT-NEEDLESS-WORDS: func objectAtIndexedSubscript(_: UInt) -> AnyObject
293+
290294
// Don't drop the 'error'.
291295
// CHECK-ERRORS: func tryAndReturnError(_: ()) throws

0 commit comments

Comments
 (0)