Skip to content

Commit 0e6cf6d

Browse files
authored
Merge pull request #33481 from xymus/serialize-user-accessible
[Serialization] Serialize isUserAccessible on functions
2 parents f91fe9c + f523c88 commit 0e6cf6d

File tree

5 files changed

+28
-1
lines changed

5 files changed

+28
-1
lines changed

lib/Serialization/Deserialization.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2995,6 +2995,7 @@ class DeclDeserializer {
29952995
DeclID accessorStorageDeclID;
29962996
bool overriddenAffectsABI, needsNewVTableEntry, isTransparent;
29972997
DeclID opaqueReturnTypeID;
2998+
bool isUserAccessible;
29982999
ArrayRef<uint64_t> nameAndDependencyIDs;
29993000

30003001
if (!isAccessor) {
@@ -3012,6 +3013,7 @@ class DeclDeserializer {
30123013
rawAccessLevel,
30133014
needsNewVTableEntry,
30143015
opaqueReturnTypeID,
3016+
isUserAccessible,
30153017
nameAndDependencyIDs);
30163018
} else {
30173019
decls_block::AccessorLayout::readRecord(scratch, contextID, isImplicit,
@@ -3196,6 +3198,7 @@ class DeclDeserializer {
31963198
fn->setForcedStaticDispatch(hasForcedStaticDispatch);
31973199
ctx.evaluator.cacheOutput(NeedsNewVTableEntryRequest{fn},
31983200
std::move(needsNewVTableEntry));
3201+
fn->setUserAccessible(isUserAccessible);
31993202

32003203
if (opaqueReturnTypeID) {
32013204
ctx.evaluator.cacheOutput(

lib/Serialization/ModuleFormat.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5555
/// describe what change you made. The content of this comment isn't important;
5656
/// it just ensures a conflict if two people change the module format.
5757
/// Don't worry about adhering to the 80-column limit for this line.
58-
const uint16_t SWIFTMODULE_VERSION_MINOR = 569; // subclass scope
58+
const uint16_t SWIFTMODULE_VERSION_MINOR = 570; // isUserAccessible
5959

6060
/// A standard hash seed used for all string hashes in a serialized module.
6161
///
@@ -1307,6 +1307,7 @@ namespace decls_block {
13071307
AccessLevelField, // access level
13081308
BCFixed<1>, // requires a new vtable slot
13091309
DeclIDField, // opaque result type decl
1310+
BCFixed<1>, // isUserAccessible?
13101311
BCArray<IdentifierIDField> // name components,
13111312
// followed by TypeID dependencies
13121313
// The record is trailed by:

lib/Serialization/Serialization.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3437,6 +3437,7 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
34373437
rawAccessLevel,
34383438
fn->needsNewVTableEntry(),
34393439
S.addDeclRef(fn->getOpaqueResultTypeDecl()),
3440+
fn->isUserAccessible(),
34403441
nameComponentsAndDependencies);
34413442

34423443
writeGenericParams(fn->getGenericParams());
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public enum MyEnum {
2+
case foo, bar
3+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/// Check that serialized non user accessible functions are not autocompleted.
2+
/// rdar://problem/53891642
3+
/// SR-7460
4+
5+
// RUN: %empty-directory(%t)
6+
// RUN: %target-swift-frontend -emit-module %S/Inputs/complete_user_accessibility_helper.swift -module-name helper -emit-module-path %t/helper.swiftmodule
7+
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=USER-ACCESS -I %t | %FileCheck %s -check-prefix=USER-ACCESS
8+
9+
import helper
10+
11+
{
12+
_ = MyEnum.#^USER-ACCESS^#
13+
// USER-ACCESS: Begin completions
14+
// USER-ACCESS-DAG: Keyword[self]/CurrNominal: self[#MyEnum.Type#]; name=self
15+
// USER-ACCESS-DAG: Keyword/CurrNominal: Type[#MyEnum.Type#]; name=Type
16+
// USER-ACCESS-DAG: Decl[EnumElement]/CurrNominal: foo[#MyEnum#]; name=foo
17+
// USER-ACCESS-DAG: Decl[EnumElement]/CurrNominal: bar[#MyEnum#]; name=bar
18+
// USER-ACCESS-NOT: __derived_enum_equals
19+
}

0 commit comments

Comments
 (0)