Skip to content

Commit daf87c0

Browse files
committed
Serialization: Serialize the IsForEmbedded bit on @available attributes.
1 parent 53413dd commit daf87c0

File tree

4 files changed

+27
-3
lines changed

4 files changed

+27
-3
lines changed

lib/Serialization/Deserialization.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5602,6 +5602,7 @@ DeclDeserializer::readAvailable_DECL_ATTR(SmallVectorImpl<uint64_t> &scratch,
56025602
bool isNoAsync;
56035603
bool isPackageDescriptionVersionSpecific;
56045604
bool isSPI;
5605+
bool isForEmbedded;
56055606
DEF_VER_TUPLE_PIECES(Introduced);
56065607
DEF_VER_TUPLE_PIECES(Deprecated);
56075608
DEF_VER_TUPLE_PIECES(Obsoleted);
@@ -5611,7 +5612,7 @@ DeclDeserializer::readAvailable_DECL_ATTR(SmallVectorImpl<uint64_t> &scratch,
56115612
// Decode the record, pulling the version tuple information.
56125613
serialization::decls_block::AvailableDeclAttrLayout::readRecord(
56135614
scratch, isImplicit, isUnavailable, isDeprecated, isNoAsync,
5614-
isPackageDescriptionVersionSpecific, isSPI,
5615+
isPackageDescriptionVersionSpecific, isSPI, isForEmbedded,
56155616
LIST_VER_TUPLE_PIECES(Introduced), LIST_VER_TUPLE_PIECES(Deprecated),
56165617
LIST_VER_TUPLE_PIECES(Obsoleted), rawPlatform, renameDeclID, messageSize,
56175618
renameSize);
@@ -5655,7 +5656,7 @@ DeclDeserializer::readAvailable_DECL_ATTR(SmallVectorImpl<uint64_t> &scratch,
56555656
auto attr = new (ctx) AvailableAttr(
56565657
SourceLoc(), SourceRange(), platform, message, rename, renameDecl,
56575658
Introduced, SourceRange(), Deprecated, SourceRange(), Obsoleted,
5658-
SourceRange(), platformAgnostic, isImplicit, isSPI);
5659+
SourceRange(), platformAgnostic, isImplicit, isSPI, isForEmbedded);
56595660
return attr;
56605661
}
56615662

lib/Serialization/ModuleFormat.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5858
/// describe what change you made. The content of this comment isn't important;
5959
/// it just ensures a conflict if two people change the module format.
6060
/// Don't worry about adhering to the 80-column limit for this line.
61-
const uint16_t SWIFTMODULE_VERSION_MINOR = 899; // Builtin.FixedArray serialize
61+
const uint16_t SWIFTMODULE_VERSION_MINOR = 900; // @_unavailableInEmbedded
6262

6363
/// A standard hash seed used for all string hashes in a serialized module.
6464
///
@@ -2351,6 +2351,7 @@ namespace decls_block {
23512351
BCFixed<1>, // is unavailable from async?
23522352
BCFixed<1>, // is this PackageDescription version-specific kind?
23532353
BCFixed<1>, // is SPI?
2354+
BCFixed<1>, // is for Embedded
23542355
BC_AVAIL_TUPLE, // Introduced
23552356
BC_AVAIL_TUPLE, // Deprecated
23562357
BC_AVAIL_TUPLE, // Obsoleted

lib/Serialization/Serialization.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,6 +3032,7 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
30323032
theAttr->isNoAsync(),
30333033
theAttr->isPackageDescriptionVersionSpecific(),
30343034
theAttr->isSPI(),
3035+
theAttr->isForEmbedded(),
30353036
LIST_VER_TUPLE_PIECES(Introduced),
30363037
LIST_VER_TUPLE_PIECES(Deprecated),
30373038
LIST_VER_TUPLE_PIECES(Obsoleted),
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %{python} %utils/split_file.py -o %t %s
3+
4+
// RUN: %target-swift-frontend -emit-module -o %t/MyModule.swiftmodule %t/MyModule.swift -enable-experimental-feature Embedded -parse-as-library
5+
// RUN: %target-swift-frontend -typecheck -verify -I %t %t/Main.swift -enable-experimental-feature Embedded
6+
7+
// REQUIRES: swift_in_compiler
8+
9+
// BEGIN MyModule.swift
10+
11+
@_unavailableInEmbedded
12+
public func unavailable() { }
13+
14+
// BEGIN Main.swift
15+
16+
import MyModule
17+
18+
func available() {
19+
unavailable() // expected-error {{'unavailable()' is unavailable: unavailable in embedded Swift}}
20+
}
21+

0 commit comments

Comments
 (0)