Files
swift-mirror/include/swift/AST/KnownProtocols.def
Philippe Hausler 6e05240426 AsyncSequence and protocol conformance rethrows (#35224)
* Initial draft of async sequences

* Adjust AsyncSequence associated type requirements

* Add a draft implementation of AsyncSequence and associated functionality

* Correct merge damage and rename from GeneratorProtocol to AsyncIteratorProtocol

* Add AsyncSequence types to the cmake lists

* Add cancellation support

* [DRAFT] Implementation of protocol conformance rethrowing

* Account for ASTVerifier passes to ensure throwing and by conformance rethrowing verifies appropriately

* Remove commented out code

* OtherConstructorDeclRefExpr can also be a source of a rethrowing kind function

* Re-order the checkApply logic to account for existing throwing calculations better

* Extract rethrowing calculation into smaller functions

* Allow for closures and protocol conformances to contribute to throwing

* Add unit tests for conformance based rethrowing

* Restrict rethrowing requirements to only protocols marked with @rethrows

* Correct logic for gating of `@rethrows` and adjust the determinates to be based upon throws and not rethrows spelling

* Attempt to unify the async sequence features together

* Reorder try await to latest syntax

* revert back to the inout diagnosis

* House mutations in local scope

* Revert "House mutations in local scope"

This reverts commit d91f1b25b59fff8e4be107c808895ff3f293b394.

* Adjust for inout diagnostics and fall back to original mutation strategy

* Convert async flag to source locations and add initial try support to for await in syntax

* Fix case typo of MinMax.swift

* Adjust rethrowing tests to account for changes associated with @rethrows

* Allow parsing and diagnostics associated with try applied to for await in syntax

* Correct the code-completion for @rethrows

* Additional corrections for the code-completion for @rethrows this time for the last in the list

* Handle throwing cases of iteration of async sequences

* restore building XCTest

* First wave of feedback fixes

* Rework constraints checking for async sequence for-try-await-in checking

* Allow testing of for-await-in parsing and silgen testing and add unit tests for both

* Remove async sequence operators for now

* Back out cancellation of AsyncIteratorProtocols

* Restructure protocol conformance throws checking and cache results

* remove some stray whitespaces

* Correct some merge damage

* Ensure the throwing determinate for applying for-await-in always has a valid value and adjust the for-await-in silgen test to reflect the cancel changes

* Squelch the python linter for line length
2021-01-25 18:48:50 -08:00

126 lines
5.2 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
#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(IteratorProtocol)
PROTOCOL(RawRepresentable)
PROTOCOL(Equatable)
PROTOCOL(Hashable)
PROTOCOL(Comparable)
PROTOCOL(Error)
PROTOCOL_(ErrorCodeProtocol)
PROTOCOL(OptionSet)
PROTOCOL(CaseIterable)
PROTOCOL(SIMDScalar)
PROTOCOL(BinaryInteger)
PROTOCOL_(BridgedNSError)
PROTOCOL_(BridgedStoredNSError)
PROTOCOL_(CFObject)
PROTOCOL_(SwiftNewtypeWrapper)
PROTOCOL(CodingKey)
PROTOCOL(Encodable)
PROTOCOL(Decodable)
PROTOCOL_(ObjectiveCBridgeable)
PROTOCOL_(DestructorSafeContainer)
PROTOCOL(StringInterpolationProtocol)
PROTOCOL(AdditiveArithmetic)
PROTOCOL(Differentiable)
PROTOCOL(AsyncSequence)
PROTOCOL(AsyncIteratorProtocol)
PROTOCOL(FloatingPoint)
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 PROTOCOL
#undef PROTOCOL_
#undef PROTOCOL_WITH_NAME