Files
swift-mirror/include/swift/AST/KnownProtocols.def
Pavel Yaskevich 389c240a2a [AST] Mark Sendable as a repressible protocol
This allows to spell `~Sendable` to suppress the conformance
inference on types when `TildeSendable` flag is enabled.
2025-10-09 10:41:27 -07:00

196 lines
7.4 KiB
C++

//===--- KnownProtocols.def - Compiler protocol metaprogramming -*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines macros used for macro-metaprogramming with compiler-known
// protocols. Note that this mechanism does not look through an overlay into its
// underlying module, so it typically cannot find Objective-C protocols.
//
//===----------------------------------------------------------------------===//
/// \def PROTOCOL_WITH_NAME(Id, Name)
///
/// The enumerator value is \c KnownProtocolKind::Id. The protocol represented
/// is simply named \p Name.
#ifndef PROTOCOL_WITH_NAME
#define PROTOCOL_WITH_NAME(Id, Name)
#endif
/// \def EXPRESSIBLE_BY_LITERAL_PROTOCOL_WITH_NAME(Id, Name, typeName, performLocalLookup)
/// \param typeName supplies the name used for type lookup,
/// \param performLocalLookup specifies whether to first look in the local context.
#ifndef EXPRESSIBLE_BY_LITERAL_PROTOCOL_WITH_NAME
#define EXPRESSIBLE_BY_LITERAL_PROTOCOL_WITH_NAME(Id, Name, typeName, performLocalLookup) \
PROTOCOL_WITH_NAME(Id, Name)
#endif
/// \def BUILTIN_EXPRESSIBLE_BY_LITERAL_PROTOCOL_WITH_NAME(Id, Name)
///
/// Note that this is not a special form of EXPRESSIBLE_BY_LITERAL_PROTOCOL.
#ifndef BUILTIN_EXPRESSIBLE_BY_LITERAL_PROTOCOL_WITH_NAME
#define BUILTIN_EXPRESSIBLE_BY_LITERAL_PROTOCOL_WITH_NAME(Id, Name) \
PROTOCOL_WITH_NAME(Id, Name)
#endif
/// \def INVERTIBLE_PROTOCOL_WITH_NAME(id, name)
/// \param Name a string literal with the external name of this protocol
/// \param Id the internal "enum name" of this protocol.
#ifndef INVERTIBLE_PROTOCOL_WITH_NAME
#define INVERTIBLE_PROTOCOL_WITH_NAME(Id, Name) \
PROTOCOL_WITH_NAME(Id, Name)
#endif
/// \def REPRESSIBLE_PROTOCOL_WITH_NAME(id, name)
/// \param id the internal "enum name" of this protocol
/// \param name a string literal with the external name of this protocol
#ifndef REPRESSIBLE_PROTOCOL_WITH_NAME
#define REPRESSIBLE_PROTOCOL_WITH_NAME(Id, Name) \
PROTOCOL_WITH_NAME(Id, Name)
#endif
#define REPRESSIBLE_PROTOCOL(name) REPRESSIBLE_PROTOCOL_WITH_NAME(name, #name)
#define REPRESSIBLE_PROTOCOL_(name) REPRESSIBLE_PROTOCOL_WITH_NAME(name, "_" #name)
#define PROTOCOL(name) PROTOCOL_WITH_NAME(name, #name)
#define PROTOCOL_(name) PROTOCOL_WITH_NAME(name, "_" #name)
/// \param typeName supplies the name used for type lookup,
/// \param performLocalLookup specifies whether to first look in the local context.
#define EXPRESSIBLE_BY_LITERAL_PROTOCOL(name, typeName, performLocalLookup) \
EXPRESSIBLE_BY_LITERAL_PROTOCOL_WITH_NAME(name, #name, typeName, performLocalLookup)
/// \param typeName supplies the name used for type lookup,
/// \param performLocalLookup specifies whether to first look in the local context.
#define EXPRESSIBLE_BY_LITERAL_PROTOCOL_(name, typeName, performLocalLookup) \
EXPRESSIBLE_BY_LITERAL_PROTOCOL_WITH_NAME(name, "_" #name, typeName, performLocalLookup)
#define BUILTIN_EXPRESSIBLE_BY_LITERAL_PROTOCOL_(name) \
BUILTIN_EXPRESSIBLE_BY_LITERAL_PROTOCOL_WITH_NAME(name, "_" #name)
PROTOCOL(Actor)
PROTOCOL(Sequence)
PROTOCOL(Identifiable)
PROTOCOL(IteratorProtocol)
PROTOCOL(RawRepresentable)
PROTOCOL(Equatable)
PROTOCOL(Hashable)
PROTOCOL(Comparable)
PROTOCOL(Error)
PROTOCOL_(ErrorCodeProtocol)
PROTOCOL(OptionSet)
PROTOCOL(CaseIterable)
PROTOCOL(SIMD)
PROTOCOL(SIMDScalar)
PROTOCOL(BinaryInteger)
PROTOCOL(FixedWidthInteger)
PROTOCOL(RangeReplaceableCollection)
PROTOCOL(Executor)
PROTOCOL(SerialExecutor)
PROTOCOL(TaskExecutor)
PROTOCOL(GlobalActor)
PROTOCOL(ExecutorFactory)
PROTOCOL_(BridgedNSError)
PROTOCOL_(BridgedStoredNSError)
PROTOCOL_(CFObject)
PROTOCOL_(SwiftNewtypeWrapper)
PROTOCOL(CodingKey)
PROTOCOL(Encodable)
PROTOCOL(Decodable)
REPRESSIBLE_PROTOCOL(Sendable)
PROTOCOL(SendableMetatype)
PROTOCOL(UnsafeSendable)
PROTOCOL_(ObjectiveCBridgeable)
PROTOCOL_(DestructorSafeContainer)
PROTOCOL(StringInterpolationProtocol)
PROTOCOL(AdditiveArithmetic)
PROTOCOL(Differentiable)
// Distributed Actors
PROTOCOL(DistributedActor)
PROTOCOL_(DistributedActorStub)
PROTOCOL(DistributedActorSystem)
PROTOCOL(DistributedTargetInvocationEncoder)
PROTOCOL(DistributedTargetInvocationDecoder)
PROTOCOL(DistributedTargetInvocationResultHandler)
// C++ Standard Library Overlay:
PROTOCOL(CxxConvertibleToBool)
PROTOCOL(CxxConvertibleToCollection)
PROTOCOL(CxxDictionary)
PROTOCOL(CxxOptional)
PROTOCOL(CxxPair)
PROTOCOL(CxxSet)
PROTOCOL(CxxRandomAccessCollection)
PROTOCOL(CxxMutableRandomAccessCollection)
PROTOCOL(CxxSequence)
PROTOCOL(CxxUniqueSet)
PROTOCOL(CxxVector)
PROTOCOL(CxxSpan)
PROTOCOL(CxxMutableSpan)
PROTOCOL(UnsafeCxxInputIterator)
PROTOCOL(UnsafeCxxMutableInputIterator)
PROTOCOL(UnsafeCxxRandomAccessIterator)
PROTOCOL(UnsafeCxxMutableRandomAccessIterator)
PROTOCOL(UnsafeCxxContiguousIterator)
PROTOCOL(UnsafeCxxMutableContiguousIterator)
PROTOCOL(AsyncSequence)
PROTOCOL(AsyncIteratorProtocol)
PROTOCOL(FloatingPoint)
#define INVERTIBLE_PROTOCOL(Name, Bit) \
INVERTIBLE_PROTOCOL_WITH_NAME(Name, #Name)
#include "swift/ABI/InvertibleProtocols.def"
REPRESSIBLE_PROTOCOL(BitwiseCopyable)
EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByArrayLiteral, "Array", false)
EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByBooleanLiteral, "BooleanLiteralType", true)
EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByDictionaryLiteral, "Dictionary", false)
EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByExtendedGraphemeClusterLiteral, "ExtendedGraphemeClusterType", true)
EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByFloatLiteral, "FloatLiteralType", true)
EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByIntegerLiteral, "IntegerLiteralType", true)
EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByStringInterpolation, "StringLiteralType", true)
EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByStringLiteral, "StringLiteralType", true)
EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByNilLiteral, nullptr, false)
EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByUnicodeScalarLiteral, "UnicodeScalarType", true)
EXPRESSIBLE_BY_LITERAL_PROTOCOL_(ExpressibleByColorLiteral, "_ColorLiteralType", true)
EXPRESSIBLE_BY_LITERAL_PROTOCOL_(ExpressibleByImageLiteral, "_ImageLiteralType", true)
EXPRESSIBLE_BY_LITERAL_PROTOCOL_(ExpressibleByFileReferenceLiteral, "_FileReferenceLiteralType", true)
BUILTIN_EXPRESSIBLE_BY_LITERAL_PROTOCOL_(ExpressibleByBuiltinBooleanLiteral)
BUILTIN_EXPRESSIBLE_BY_LITERAL_PROTOCOL_(ExpressibleByBuiltinExtendedGraphemeClusterLiteral)
BUILTIN_EXPRESSIBLE_BY_LITERAL_PROTOCOL_(ExpressibleByBuiltinFloatLiteral)
BUILTIN_EXPRESSIBLE_BY_LITERAL_PROTOCOL_(ExpressibleByBuiltinIntegerLiteral)
BUILTIN_EXPRESSIBLE_BY_LITERAL_PROTOCOL_(ExpressibleByBuiltinStringLiteral)
BUILTIN_EXPRESSIBLE_BY_LITERAL_PROTOCOL_(ExpressibleByBuiltinUnicodeScalarLiteral)
#undef EXPRESSIBLE_BY_LITERAL_PROTOCOL
#undef EXPRESSIBLE_BY_LITERAL_PROTOCOL_
#undef EXPRESSIBLE_BY_LITERAL_PROTOCOL_WITH_NAME
#undef BUILTIN_EXPRESSIBLE_BY_LITERAL_PROTOCOL_
#undef BUILTIN_EXPRESSIBLE_BY_LITERAL_PROTOCOL_WITH_NAME
#undef REPRESSIBLE_PROTOCOL_WITH_NAME
#undef REPRESSIBLE_PROTOCOL
#undef REPRESSIBLE_PROTOCOL_
#undef INVERTIBLE_PROTOCOL_WITH_NAME
#undef PROTOCOL
#undef PROTOCOL_
#undef PROTOCOL_WITH_NAME