mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
AST: Remove ParameterTypeFlags::Escaping
Escapingness is a property of the type of a value, not a property of a function parameter. Having it as a separate parameter flag just meant one more piece of state that could get out of sync and cause weird problems. Instead, always look at the noescape bit in a function type as the canonical source of truth. This does mean that '@escaping' is now printed in a few diagnostics where it was not printed before; we can investigate these as separate issues, but it is correct to print it there because the function types in question are, in fact, escaping. Fixes <https://bugs.swift.org/browse/SR-10256>, <rdar://problem/49522774>.
This commit is contained in:
@@ -1718,11 +1718,10 @@ class ParameterTypeFlags {
|
||||
None = 0,
|
||||
Variadic = 1 << 0,
|
||||
AutoClosure = 1 << 1,
|
||||
Escaping = 1 << 2,
|
||||
OwnershipShift = 3,
|
||||
OwnershipShift = 2,
|
||||
Ownership = 7 << OwnershipShift,
|
||||
|
||||
NumBits = 6
|
||||
NumBits = 5
|
||||
};
|
||||
OptionSet<ParameterFlags> value;
|
||||
static_assert(NumBits < 8*sizeof(OptionSet<ParameterFlags>), "overflowed");
|
||||
@@ -1735,10 +1734,9 @@ public:
|
||||
return ParameterTypeFlags(OptionSet<ParameterFlags>(raw));
|
||||
}
|
||||
|
||||
ParameterTypeFlags(bool variadic, bool autoclosure, bool escaping,
|
||||
ParameterTypeFlags(bool variadic, bool autoclosure,
|
||||
ValueOwnership ownership)
|
||||
: value((variadic ? Variadic : 0) | (autoclosure ? AutoClosure : 0) |
|
||||
(escaping ? Escaping : 0) |
|
||||
uint8_t(ownership) << OwnershipShift) {}
|
||||
|
||||
/// Create one from what's present in the parameter type
|
||||
@@ -1749,7 +1747,6 @@ public:
|
||||
bool isNone() const { return !value; }
|
||||
bool isVariadic() const { return value.contains(Variadic); }
|
||||
bool isAutoClosure() const { return value.contains(AutoClosure); }
|
||||
bool isEscaping() const { return value.contains(Escaping); }
|
||||
bool isInOut() const { return getValueOwnership() == ValueOwnership::InOut; }
|
||||
bool isShared() const { return getValueOwnership() == ValueOwnership::Shared;}
|
||||
bool isOwned() const { return getValueOwnership() == ValueOwnership::Owned; }
|
||||
@@ -1763,11 +1760,6 @@ public:
|
||||
: value - ParameterTypeFlags::Variadic);
|
||||
}
|
||||
|
||||
ParameterTypeFlags withEscaping(bool escaping) const {
|
||||
return ParameterTypeFlags(escaping ? value | ParameterTypeFlags::Escaping
|
||||
: value - ParameterTypeFlags::Escaping);
|
||||
}
|
||||
|
||||
ParameterTypeFlags withInOut(bool isInout) const {
|
||||
return withValueOwnership(isInout ? ValueOwnership::InOut
|
||||
: ValueOwnership::Default);
|
||||
@@ -1860,7 +1852,6 @@ public:
|
||||
ParameterTypeFlags asParamFlags() const {
|
||||
return ParameterTypeFlags(/*variadic*/ false,
|
||||
/*autoclosure*/ false,
|
||||
/*escaping*/ false,
|
||||
getValueOwnership());
|
||||
}
|
||||
|
||||
@@ -1931,9 +1922,6 @@ public:
|
||||
/// Determine whether this field is an autoclosure parameter closure.
|
||||
bool isAutoClosure() const { return Flags.isAutoClosure(); }
|
||||
|
||||
/// Determine whether this field is an escaping parameter closure.
|
||||
bool isEscaping() const { return Flags.isEscaping(); }
|
||||
|
||||
/// Determine whether this field is marked 'inout'.
|
||||
bool isInOut() const { return Flags.isInOut(); }
|
||||
|
||||
@@ -2724,9 +2712,6 @@ public:
|
||||
/// Whether the parameter is marked '@autoclosure'
|
||||
bool isAutoClosure() const { return Flags.isAutoClosure(); }
|
||||
|
||||
/// Whether the parameter is marked '@escaping'
|
||||
bool isEscaping() const { return Flags.isEscaping(); }
|
||||
|
||||
/// Whether the parameter is marked 'inout'
|
||||
bool isInOut() const { return Flags.isInOut(); }
|
||||
|
||||
@@ -5374,8 +5359,6 @@ inline ParameterTypeFlags
|
||||
ParameterTypeFlags::fromParameterType(Type paramTy, bool isVariadic,
|
||||
bool isAutoClosure,
|
||||
ValueOwnership ownership) {
|
||||
bool escaping = paramTy->is<AnyFunctionType>() &&
|
||||
!paramTy->castTo<AnyFunctionType>()->isNoEscape();
|
||||
// FIXME(Remove InOut): The last caller that needs this is argument
|
||||
// decomposition. Start by enabling the assertion there and fixing up those
|
||||
// callers, then remove this, then remove
|
||||
@@ -5385,7 +5368,7 @@ ParameterTypeFlags::fromParameterType(Type paramTy, bool isVariadic,
|
||||
ownership == ValueOwnership::InOut);
|
||||
ownership = ValueOwnership::InOut;
|
||||
}
|
||||
return {isVariadic, isAutoClosure, escaping, ownership};
|
||||
return {isVariadic, isAutoClosure, ownership};
|
||||
}
|
||||
|
||||
inline const Type *BoundGenericType::getTrailingObjectsPointer() const {
|
||||
|
||||
@@ -52,7 +52,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 = 484; // SDK-relative dependencies flag
|
||||
const uint16_t SWIFTMODULE_VERSION_MINOR = 485; // remove @escaping parameter flag
|
||||
|
||||
using DeclIDField = BCFixed<31>;
|
||||
|
||||
@@ -765,7 +765,6 @@ namespace decls_block {
|
||||
TypeIDField, // type
|
||||
BCFixed<1>, // vararg?
|
||||
BCFixed<1>, // autoclosure?
|
||||
BCFixed<1>, // escaping?
|
||||
ValueOwnershipField // inout, shared or owned?
|
||||
>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user