Skip to content

[Serialization] Serialize isUserAccessible on functions #33481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/Serialization/Deserialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2995,6 +2995,7 @@ class DeclDeserializer {
DeclID accessorStorageDeclID;
bool overriddenAffectsABI, needsNewVTableEntry, isTransparent;
DeclID opaqueReturnTypeID;
bool isUserAccessible;
ArrayRef<uint64_t> nameAndDependencyIDs;

if (!isAccessor) {
Expand All @@ -3012,6 +3013,7 @@ class DeclDeserializer {
rawAccessLevel,
needsNewVTableEntry,
opaqueReturnTypeID,
isUserAccessible,
nameAndDependencyIDs);
} else {
decls_block::AccessorLayout::readRecord(scratch, contextID, isImplicit,
Expand Down Expand Up @@ -3196,6 +3198,7 @@ class DeclDeserializer {
fn->setForcedStaticDispatch(hasForcedStaticDispatch);
ctx.evaluator.cacheOutput(NeedsNewVTableEntryRequest{fn},
std::move(needsNewVTableEntry));
fn->setUserAccessible(isUserAccessible);

if (opaqueReturnTypeID) {
ctx.evaluator.cacheOutput(
Expand Down
3 changes: 2 additions & 1 deletion lib/Serialization/ModuleFormat.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
/// describe what change you made. The content of this comment isn't important;
/// it just ensures a conflict if two people change the module format.
/// Don't worry about adhering to the 80-column limit for this line.
const uint16_t SWIFTMODULE_VERSION_MINOR = 569; // subclass scope
const uint16_t SWIFTMODULE_VERSION_MINOR = 570; // isUserAccessible

/// A standard hash seed used for all string hashes in a serialized module.
///
Expand Down Expand Up @@ -1307,6 +1307,7 @@ namespace decls_block {
AccessLevelField, // access level
BCFixed<1>, // requires a new vtable slot
DeclIDField, // opaque result type decl
BCFixed<1>, // isUserAccessible?
BCArray<IdentifierIDField> // name components,
// followed by TypeID dependencies
// The record is trailed by:
Expand Down
1 change: 1 addition & 0 deletions lib/Serialization/Serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3437,6 +3437,7 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
rawAccessLevel,
fn->needsNewVTableEntry(),
S.addDeclRef(fn->getOpaqueResultTypeDecl()),
fn->isUserAccessible(),
nameComponentsAndDependencies);

writeGenericParams(fn->getGenericParams());
Expand Down
3 changes: 3 additions & 0 deletions test/IDE/Inputs/complete_user_accessibility_helper.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public enum MyEnum {
case foo, bar
}
19 changes: 19 additions & 0 deletions test/IDE/complete_user_accessible.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/// Check that serialized non user accessible functions are not autocompleted.
/// rdar://problem/53891642
/// SR-7460

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module %S/Inputs/complete_user_accessibility_helper.swift -module-name helper -emit-module-path %t/helper.swiftmodule
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=USER-ACCESS -I %t | %FileCheck %s -check-prefix=USER-ACCESS

import helper

{
_ = MyEnum.#^USER-ACCESS^#
// USER-ACCESS: Begin completions
// USER-ACCESS-DAG: Keyword[self]/CurrNominal: self[#MyEnum.Type#]; name=self
// USER-ACCESS-DAG: Keyword/CurrNominal: Type[#MyEnum.Type#]; name=Type
// USER-ACCESS-DAG: Decl[EnumElement]/CurrNominal: foo[#MyEnum#]; name=foo
// USER-ACCESS-DAG: Decl[EnumElement]/CurrNominal: bar[#MyEnum#]; name=bar
// USER-ACCESS-NOT: __derived_enum_equals
}