Skip to content

Commit fedaf52

Browse files
authored
Merge pull request swiftlang#63478 from bnbarham/index-use-accesslevel-instead
[Index] Use access level to check decls to include
2 parents 2d91316 + 1808a39 commit fedaf52

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

lib/AST/Module.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3470,14 +3470,14 @@ bool FileUnit::walk(ASTWalker &walker) {
34703470
if (SkipInternal) {
34713471
// Ignore if the decl isn't visible
34723472
if (auto *VD = dyn_cast<ValueDecl>(D)) {
3473-
if (!VD->isAccessibleFrom(nullptr))
3473+
if (VD->getFormalAccess() < AccessLevel::Public)
34743474
continue;
34753475
}
34763476

34773477
// Also ignore if the extended nominal isn't visible
34783478
if (auto *ED = dyn_cast<ExtensionDecl>(D)) {
34793479
auto *ND = ED->getExtendedNominal();
3480-
if (ND && !ND->isAccessibleFrom(nullptr))
3480+
if (ND && ND->getFormalAccess() < AccessLevel::Public)
34813481
continue;
34823482
}
34833483
}

lib/Index/Index.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
10081008
return false;
10091009

10101010
// Do not handle non-public imported decls.
1011-
if (IsModuleFile && !D->isAccessibleFrom(nullptr))
1011+
if (IsModuleFile && D->getFormalAccess() < AccessLevel::Public)
10121012
return false;
10131013

10141014
if (!IdxConsumer.indexLocals() && isLocalSymbol(D))

test/Index/index_objc_impl.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// REQUIRES: objc_interop
2+
3+
// RUN: %empty-directory(%t)
4+
// RUN: %empty-directory(%t/mods)
5+
// RUN: split-file %s %t
6+
7+
// RUN: %target-swift-frontend -emit-module -o %t/mods %t/ObjcImpl.swift -import-objc-header %t/objc_impl.h -disable-objc-attr-requires-foundation-module
8+
// RUN: %target-swift-ide-test -print-indexed-symbols -module-to-print ObjcImpl -source-filename none -I %t/mods | %FileCheck %s
9+
10+
//--- objc_impl.h
11+
@interface NSObject
12+
@end
13+
14+
@interface ObjCClass : NSObject
15+
@property int someObjCDeclaredVar;
16+
@end
17+
18+
//--- ObjcImpl.swift
19+
// CHECK: extension/ext-class/Swift | ObjCClass | s:e:c:@CM@ObjcImpl@@objc(cs)ObjCClass(py)someObjCDeclaredVar | Def
20+
// CHECK: class/Swift | ObjCClass | c:objc(cs)ObjCClass | Ref
21+
@_objcImplementation public extension ObjCClass {
22+
// CHECK: instance-property/Swift | someObjCDeclaredVar | c:@CM@ObjcImpl@@objc(cs)ObjCClass(py)someObjCDeclaredVar | Def
23+
@objc var someObjCDeclaredVar: CInt
24+
}

0 commit comments

Comments
 (0)