Skip to content

Commit 8eebb5b

Browse files
authored
Merge pull request swiftlang#63522 from xedin/revert-type-wrappers
[AST/Sema/SIL] Revert TypeWrappers feature functionality
2 parents 8546e43 + 5dded3d commit 8eebb5b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+82
-5812
lines changed

include/swift/AST/Decl.h

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#include "swift/AST/StorageImpl.h"
3636
#include "swift/AST/TypeAlignments.h"
3737
#include "swift/AST/TypeWalker.h"
38-
#include "swift/AST/TypeWrappers.h"
3938
#include "swift/AST/Types.h"
4039
#include "swift/Basic/ArrayRefView.h"
4140
#include "swift/Basic/Compiler.h"
@@ -3978,35 +3977,6 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
39783977
return getGlobalActorInstance() != nullptr;
39793978
}
39803979

3981-
/// Returns true if this type has a type wrapper custom attribute.
3982-
bool hasTypeWrapper() const { return bool(getTypeWrapper()); }
3983-
3984-
/// Return a type wrapper (if any) associated with this type.
3985-
Optional<TypeWrapperInfo> getTypeWrapper() const;
3986-
3987-
/// If this declaration has a type wrapper return a property that
3988-
/// is used for all type wrapper related operations (mainly for
3989-
/// applicable property access routing).
3990-
VarDecl *getTypeWrapperProperty() const;
3991-
3992-
/// If this declaration has a type wrapper, return `$Storage`
3993-
/// declaration that contains all the stored properties managed
3994-
/// by the wrapper. Note that if this type is a protocol them
3995-
/// this method returns an associated type for $Storage.
3996-
TypeDecl *getTypeWrapperStorageDecl() const;
3997-
3998-
/// If this declaration is a type wrapper, retrieve
3999-
/// its required initializer - `init(storageWrapper:)`.
4000-
ConstructorDecl *getTypeWrapperInitializer() const;
4001-
4002-
/// Get an initializer that accepts a type wrapper instance to
4003-
/// initialize the wrapped type.
4004-
ConstructorDecl *getTypeWrappedTypeStorageInitializer() const;
4005-
4006-
/// Get a memberwise initializer that could be used to instantiate a
4007-
/// type wrapped type.
4008-
ConstructorDecl *getTypeWrappedTypeMemberwiseInitializer() const;
4009-
40103980
// Implement isa/cast/dyncast/etc.
40113981
static bool classof(const Decl *D) {
40123982
return D->getKind() >= DeclKind::First_NominalTypeDecl &&
@@ -5872,17 +5842,6 @@ class VarDecl : public AbstractStorageDecl {
58725842
/// wrapper that has storage.
58735843
bool hasStorageOrWrapsStorage() const;
58745844

5875-
/// Whether this property belongs to a type wrapped type and has
5876-
/// all access to it routed through a type wrapper.
5877-
bool isAccessedViaTypeWrapper() const;
5878-
5879-
/// For type wrapped properties (see \c isAccessedViaTypeWrapper)
5880-
/// all access is routed through a type wrapper.
5881-
///
5882-
/// \returns an underlying type wrapper property which is a
5883-
/// storage endpoint for all access to this property.
5884-
VarDecl *getUnderlyingTypeWrapperStorage() const;
5885-
58865845
/// Visit all auxiliary declarations to this VarDecl.
58875846
///
58885847
/// An auxiliary declaration is a declaration synthesized by the compiler to support
@@ -5960,11 +5919,6 @@ class VarDecl : public AbstractStorageDecl {
59605919
/// backing property will be treated as the member-initialized property.
59615920
bool isMemberwiseInitialized(bool preferDeclaredProperties) const;
59625921

5963-
/// Check whether this variable presents a local storage synthesized
5964-
/// by the compiler in a user-defined designated initializer to
5965-
/// support initialization of type wrapper managed properties.
5966-
bool isTypeWrapperLocalStorageForInitializer() const;
5967-
59685922
/// Return the range of semantics attributes attached to this VarDecl.
59695923
auto getSemanticsAttrs() const
59705924
-> decltype(getAttrs().getAttributes<SemanticsAttr>()) {
@@ -7910,12 +7864,6 @@ class ConstructorDecl : public AbstractFunctionDecl {
79107864
/// \endcode
79117865
bool isObjCZeroParameterWithLongSelector() const;
79127866

7913-
/// If this is a user-defined constructor that belongs to
7914-
/// a type wrapped type return a local `_storage` variable
7915-
/// injected by the compiler for aid with type wrapper
7916-
/// initialization.
7917-
VarDecl *getLocalTypeWrapperStorageVar() const;
7918-
79197867
static bool classof(const Decl *D) {
79207868
return D->getKind() == DeclKind::Constructor;
79217869
}

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -6748,85 +6748,6 @@ ERROR(move_expression_not_passed_lvalue,none,
67486748
ERROR(borrow_expression_not_passed_lvalue,none,
67496749
"'borrow' can only be applied to lvalues", ())
67506750

6751-
//------------------------------------------------------------------------------
6752-
// MARK: Type Wrappers
6753-
//------------------------------------------------------------------------------
6754-
6755-
ERROR(type_wrappers_are_experimental,none,
6756-
"type wrappers are an experimental feature", ())
6757-
6758-
ERROR(type_wrapper_attribute_not_allowed_here,none,
6759-
"type wrapper attribute %0 can only be applied to a class, struct, or protocol",
6760-
(Identifier))
6761-
6762-
ERROR(type_wrapper_requires_two_generic_params,none,
6763-
"type wrapper has to declare two generic parameters: "
6764-
"wrapped and storage types", ())
6765-
6766-
ERROR(cannot_use_multiple_type_wrappers,none,
6767-
"%0 %1 cannot use more than one type wrapper",
6768-
(DescriptiveDeclKind, DeclName))
6769-
6770-
NOTE(type_wrapper_inferred_from,none,
6771-
"type wrapper %0 inferred from %1 %2",
6772-
(DeclName, DescriptiveDeclKind, DeclName))
6773-
6774-
ERROR(type_wrapper_requires_memberwise_init,none,
6775-
"type wrapper type %0 does not contain a required initializer"
6776-
" - init(for:storage:)",
6777-
(DeclName))
6778-
6779-
ERROR(cannot_overload_type_wrapper_initializer,none,
6780-
"cannot overload type wrapper initializer 'init(for:storage:)'", ())
6781-
6782-
ERROR(cannot_declare_type_wrapper_init_with_invalid_first_param,none,
6783-
"first parameter of type wrapper initializer should be wrapped type - %0", (Type))
6784-
6785-
ERROR(cannot_declare_type_wrapper_init_with_invalid_second_param,none,
6786-
"second parameter of type wrapper initializer should be storage type - %0", (Type))
6787-
6788-
ERROR(type_wrapper_requires_subscript,none,
6789-
"type wrapper type %0 does not contain a required subscript"
6790-
" - subscript(propertyKeyPath:storageKeyPath:)",
6791-
(DeclName))
6792-
6793-
ERROR(type_wrapper_requires_readonly_subscript,none,
6794-
"type wrapper type %0 does not contain a required ready-only subscript",
6795-
(DeclName))
6796-
6797-
ERROR(type_wrapper_requires_writable_subscript,none,
6798-
"type wrapper type %0 does not contain a required writable subscript",
6799-
(DeclName))
6800-
6801-
NOTE(add_type_wrapper_subscript_stub_note,none,
6802-
"do you want to add a stub?", ())
6803-
6804-
ERROR(type_wrapper_failable_init,none,
6805-
"type wrapper initializer %0 cannot be failable", (DeclName))
6806-
6807-
ERROR(type_wrapper_subscript_invalid_parameter_type,none,
6808-
"type wrapper subscript parameter %0 expects type %1 (got: %2)",
6809-
(Identifier, Type, Type))
6810-
6811-
ERROR(type_wrapper_subscript_invalid_keypath_parameter,none,
6812-
"type wrapper subscript parameter %0 expects a key path (got: %1)",
6813-
(Identifier, Type))
6814-
6815-
ERROR(type_wrapper_type_requirement_not_accessible,none,
6816-
"%select{private|fileprivate|internal|package|public|open}0 %1 %2 cannot have "
6817-
"more restrictive access than its enclosing type wrapper type %3 "
6818-
"(which is %select{private|fileprivate|internal|package|public|open}4)",
6819-
(AccessLevel, DescriptiveDeclKind, DeclName, Type, AccessLevel))
6820-
6821-
ERROR(type_wrapper_ignored_on_local_properties,none,
6822-
"%0 must not be used on local properties", (DeclAttribute))
6823-
ERROR(type_wrapper_ignored_on_computed_properties,none,
6824-
"%0 must not be used on computed properties", (DeclAttribute))
6825-
ERROR(type_wrapper_ignored_on_static_properties,none,
6826-
"%0 must not be used on static properties", (DeclAttribute))
6827-
ERROR(type_wrapper_ignored_on_lazy_properties,none,
6828-
"%0 must not be used on lazy properties", (DeclAttribute))
6829-
68306751
//------------------------------------------------------------------------------
68316752
// MARK: #_hasSymbol
68326753
//------------------------------------------------------------------------------

include/swift/AST/KnownIdentifiers.def

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,6 @@ IDENTIFIER(decodeNextArgument)
309309
IDENTIFIER(SerializationRequirement)
310310
IDENTIFIER_WITH_NAME(builderSelf, "$builderSelf")
311311

312-
// Type wrappers
313-
IDENTIFIER_WITH_NAME(TypeWrapperStorage, "$Storage")
314-
IDENTIFIER_WITH_NAME(TypeWrapperProperty, "$storage")
315-
IDENTIFIER(storageKeyPath)
316-
IDENTIFIER(propertyKeyPath)
317-
IDENTIFIER(wrappedSelf)
318-
IDENTIFIER(storageWrapper)
319-
IDENTIFIER_WITH_NAME(localStorageVar, "_storage")
320-
321312
// Attribute options
322313
IDENTIFIER_(_always)
323314
IDENTIFIER_(assumed)

0 commit comments

Comments
 (0)