Skip to content

Revert "AsyncSequence and protocol conformance rethrows" #35597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions include/swift/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,6 @@ class ASTContext final {
/// Get Sequence.makeIterator().
FuncDecl *getSequenceMakeIterator() const;

/// Get AsyncSequence.makeAsyncIterator().
FuncDecl *getAsyncSequenceMakeAsyncIterator() const;

/// Check whether the standard library provides all the correct
/// intrinsic support for Optional<T>.
///
Expand Down
2 changes: 0 additions & 2 deletions include/swift/AST/ASTTypeIDZone.def
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ SWIFT_TYPEID(PropertyWrapperTypeInfo)
SWIFT_TYPEID(Requirement)
SWIFT_TYPEID(ResilienceExpansion)
SWIFT_TYPEID(FragileFunctionKind)
SWIFT_TYPEID(FunctionRethrowingKind)
SWIFT_TYPEID(ProtocolRethrowsRequirementList)
SWIFT_TYPEID(TangentPropertyInfo)
SWIFT_TYPEID(SymbolSourceMap)
SWIFT_TYPEID(Type)
Expand Down
2 changes: 0 additions & 2 deletions include/swift/AST/ASTTypeIDs.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ class ProtocolDecl;
class Requirement;
enum class ResilienceExpansion : unsigned;
struct FragileFunctionKind;
enum class FunctionRethrowingKind : uint8_t;
class ProtocolRethrowsRequirementList;
class SourceFile;
class SymbolSourceMap;
struct TangentPropertyInfo;
Expand Down
4 changes: 0 additions & 4 deletions include/swift/AST/Attr.def
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,6 @@ SIMPLE_DECL_ATTR(rethrows, Rethrows,
RejectByParser |
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,
57)
SIMPLE_DECL_ATTR(rethrows, AtRethrows,
OnProtocol |
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,
58)
DECL_ATTR(_swift_native_objc_runtime_base, SwiftNativeObjCRuntimeBase,
OnClass |
UserInaccessible |
Expand Down
82 changes: 0 additions & 82 deletions include/swift/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3879,66 +3879,6 @@ enum class KnownDerivableProtocolKind : uint8_t {
Actor,
};

class ProtocolRethrowsRequirementList {
public:
typedef std::pair<Type, ValueDecl *> Entry;

private:
ArrayRef<Entry> entries;

public:
ProtocolRethrowsRequirementList(ArrayRef<Entry> entries) : entries(entries) {}
ProtocolRethrowsRequirementList() : entries() {}

typedef const Entry *const_iterator;
typedef const_iterator iterator;

const_iterator begin() const { return entries.begin(); }
const_iterator end() const { return entries.end(); }

size_t size() const { return entries.size(); }

void print(raw_ostream &OS) const;

SWIFT_DEBUG_DUMP;

friend bool operator==(const ProtocolRethrowsRequirementList &lhs,
const ProtocolRethrowsRequirementList &rhs) {
if (lhs.size() != rhs.size()) {
return false;
}
auto lhsIter = lhs.begin();
auto rhsIter = rhs.begin();
while (lhsIter != lhs.end() && rhsIter != rhs.end()) {
if (lhsIter->first->isEqual(rhsIter->first)) {
return false;
}
if (lhsIter->second != rhsIter->second) {
return false;
}
}
return true;
}

friend bool operator!=(const ProtocolRethrowsRequirementList &lhs,
const ProtocolRethrowsRequirementList &rhs) {
return !(lhs == rhs);
}

friend llvm::hash_code hash_value(
const ProtocolRethrowsRequirementList &list) {
return llvm::hash_combine(list.size()); // it is good enought for
// llvm::hash_code hash;
// for (auto entry : list) {
// hash = llvm::hash_combine(hash, entry.first->getCanonicalType());
// hash = llvm::hash_combine(hash, entry.second);
// }
// return hash;
}
};

void simple_display(raw_ostream &out, const ProtocolRethrowsRequirementList reqs);

/// ProtocolDecl - A declaration of a protocol, for example:
///
/// protocol Drawable {
Expand Down Expand Up @@ -4120,9 +4060,6 @@ class ProtocolDecl final : public NominalTypeDecl {
/// contain 'Self' in 'parameter' or 'other' position.
bool existentialTypeSupported() const;

ProtocolRethrowsRequirementList getRethrowingRequirements() const;
bool isRethrowingProtocol() const;

private:
void computeKnownProtocolKind() const;

Expand Down Expand Up @@ -5532,23 +5469,6 @@ class ImportAsMemberStatus {
}
};

enum class FunctionRethrowingKind : uint8_t {
/// The function is not throwing
None,

/// The function rethrows by closure
ByClosure,

/// The function rethrows by conformance
ByConformance,

/// The function throws
Throws,

/// The function throwing determinate is invalid
Invalid
};

/// Base class for function-like declarations.
class AbstractFunctionDecl : public GenericContext, public ValueDecl {
friend class NeedsNewVTableEntryRequest;
Expand Down Expand Up @@ -5751,8 +5671,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
/// Returns true if the function body throws.
bool hasThrows() const { return Bits.AbstractFunctionDecl.Throws; }

FunctionRethrowingKind getRethrowingKind() const;

// FIXME: Hack that provides names with keyword arguments for accessors.
DeclName getEffectiveFullName() const;

Expand Down
4 changes: 0 additions & 4 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -2983,8 +2983,6 @@ ERROR(override_rethrows_with_non_rethrows,none,
"be 'rethrows'", (bool))
ERROR(rethrows_without_throwing_parameter,none,
"'rethrows' function must take a throwing function argument", ())
ERROR(rethrows_attr_on_non_protocol,none,
"@rethrows may only be used on 'protocol' declarations", ())

ERROR(autoclosure_function_type,none,
"@autoclosure attribute only applies to function types",
Expand Down Expand Up @@ -4061,8 +4059,6 @@ NOTE(because_rethrows_argument_throws,none,
NOTE(because_rethrows_default_argument_throws,none,
"call is to 'rethrows' function, but a defaulted argument function"
" can throw", ())
NOTE(because_rethrows_default_conformance_throws,none,
"call is to 'rethrows' function, but a conformance has a throwing witness", ())

ERROR(throwing_call_in_nonthrowing_autoclosure,none,
"call can throw, but it is executed in a non-throwing "
Expand Down
2 changes: 0 additions & 2 deletions include/swift/AST/KnownIdentifiers.def
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ IDENTIFIER(KeyedEncodingContainer)
IDENTIFIER(keyedBy)
IDENTIFIER(keyPath)
IDENTIFIER(makeIterator)
IDENTIFIER(makeAsyncIterator)
IDENTIFIER(Iterator)
IDENTIFIER(AsyncIterator)
IDENTIFIER(load)
IDENTIFIER(main)
IDENTIFIER_WITH_NAME(MainEntryPoint, "$main")
Expand Down
3 changes: 0 additions & 3 deletions include/swift/AST/KnownProtocols.def
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ PROTOCOL(StringInterpolationProtocol)
PROTOCOL(AdditiveArithmetic)
PROTOCOL(Differentiable)

PROTOCOL(AsyncSequence)
PROTOCOL(AsyncIteratorProtocol)

PROTOCOL(FloatingPoint)

EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByArrayLiteral, "Array", false)
Expand Down
5 changes: 0 additions & 5 deletions include/swift/AST/ProtocolConformanceRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,8 @@ class ProtocolConformanceRef {
/// Get any additional requirements that are required for this conformance to
/// be satisfied.
ArrayRef<Requirement> getConditionalRequirements() const;

bool classifyAsThrows() const;
};

void simple_display(llvm::raw_ostream &out, ProtocolConformanceRef conformanceRef);
SourceLoc extractNearestSourceLoc(const ProtocolConformanceRef conformanceRef);

} // end namespace swift

#endif // LLVM_SWIFT_AST_PROTOCOLCONFORMANCEREF_H
11 changes: 3 additions & 8 deletions include/swift/AST/Stmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,6 @@ class RepeatWhileStmt : public LabeledStmt {
/// \endcode
class ForEachStmt : public LabeledStmt {
SourceLoc ForLoc;
SourceLoc TryLoc;
SourceLoc AwaitLoc;
Pattern *Pat;
SourceLoc InLoc;
Expr *Sequence;
Expand All @@ -743,12 +741,12 @@ class ForEachStmt : public LabeledStmt {
Expr *convertElementExpr = nullptr;

public:
ForEachStmt(LabeledStmtInfo LabelInfo, SourceLoc ForLoc, SourceLoc TryLoc, SourceLoc AwaitLoc,
Pattern *Pat, SourceLoc InLoc, Expr *Sequence, SourceLoc WhereLoc,
ForEachStmt(LabeledStmtInfo LabelInfo, SourceLoc ForLoc, Pattern *Pat,
SourceLoc InLoc, Expr *Sequence, SourceLoc WhereLoc,
Expr *WhereExpr, BraceStmt *Body, Optional<bool> implicit = None)
: LabeledStmt(StmtKind::ForEach, getDefaultImplicitFlag(implicit, ForLoc),
LabelInfo),
ForLoc(ForLoc), TryLoc(TryLoc), AwaitLoc(AwaitLoc), Pat(nullptr), InLoc(InLoc), Sequence(Sequence),
ForLoc(ForLoc), Pat(nullptr), InLoc(InLoc), Sequence(Sequence),
WhereLoc(WhereLoc), WhereExpr(WhereExpr), Body(Body) {
setPattern(Pat);
}
Expand Down Expand Up @@ -780,9 +778,6 @@ class ForEachStmt : public LabeledStmt {

/// getWhereLoc - Retrieve the location of the 'where' keyword.
SourceLoc getWhereLoc() const { return WhereLoc; }

SourceLoc getAwaitLoc() const { return AwaitLoc; }
SourceLoc getTryLoc() const { return TryLoc; }

/// getPattern - Retrieve the pattern describing the iteration variables.
/// These variables will only be visible within the body of the loop.
Expand Down
58 changes: 0 additions & 58 deletions include/swift/AST/TypeCheckRequests.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,44 +311,6 @@ class ExistentialTypeSupportedRequest :
void cacheResult(bool value) const;
};

class ProtocolRethrowsRequirementsRequest :
public SimpleRequest<ProtocolRethrowsRequirementsRequest,
ProtocolRethrowsRequirementList(ProtocolDecl *),
RequestFlags::Cached> {
public:
using SimpleRequest::SimpleRequest;

private:
friend SimpleRequest;

// Evaluation.
ProtocolRethrowsRequirementList
evaluate(Evaluator &evaluator, ProtocolDecl *decl) const;

public:
// Caching.
bool isCached() const { return true; }
};

class ProtocolConformanceRefClassifyAsThrowsRequest :
public SimpleRequest<ProtocolConformanceRefClassifyAsThrowsRequest,
bool(ProtocolConformanceRef),
RequestFlags::Cached> {
public:
using SimpleRequest::SimpleRequest;

private:
friend SimpleRequest;

// Evaluation.
bool
evaluate(Evaluator &evaluator, ProtocolConformanceRef conformanceRef) const;

public:
// Caching.
bool isCached() const { return true; }
};

/// Determine whether the given declaration is 'final'.
class IsFinalRequest :
public SimpleRequest<IsFinalRequest,
Expand Down Expand Up @@ -772,26 +734,6 @@ void simple_display(llvm::raw_ostream &out, FragileFunctionKind value);

void simple_display(llvm::raw_ostream &out, ResilienceExpansion value);

class FunctionRethrowingKindRequest :
public SimpleRequest<FunctionRethrowingKindRequest,
FunctionRethrowingKind(AbstractFunctionDecl*),
RequestFlags::Cached> {
public:
using SimpleRequest::SimpleRequest;

private:
friend SimpleRequest;

// Evaluation.
FunctionRethrowingKind evaluate(Evaluator &evaluator, AbstractFunctionDecl *decl) const;

public:
// Caching.
bool isCached() const { return true; }
};

void simple_display(llvm::raw_ostream &out, FunctionRethrowingKind value);

/// Request the custom attribute which attaches a result builder to the
/// given declaration.
class AttachedResultBuilderRequest :
Expand Down
8 changes: 0 additions & 8 deletions include/swift/AST/TypeCheckerTypeIDZone.def
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ SWIFT_REQUEST(TypeChecker, RequiresOpaqueModifyCoroutineRequest,
bool(AbstractStorageDecl *), SeparatelyCached, NoLocationInfo)
SWIFT_REQUEST(TypeChecker, FragileFunctionKindRequest,
FragileFunctionKind(DeclContext *), Cached, NoLocationInfo)
SWIFT_REQUEST(TypeChecker, FunctionRethrowingKindRequest,
FunctionRethrowingKind(AbstractFunctionDecl *), Cached, NoLocationInfo)
SWIFT_REQUEST(TypeChecker, SelfAccessKindRequest, SelfAccessKind(FuncDecl *),
SeparatelyCached, NoLocationInfo)
SWIFT_REQUEST(TypeChecker, StorageImplInfoRequest,
Expand Down Expand Up @@ -267,12 +265,6 @@ SWIFT_REQUEST(TypeChecker, ResolveImplicitMemberRequest,
SWIFT_REQUEST(TypeChecker, ResolveTypeEraserTypeRequest,
Type(ProtocolDecl *, TypeEraserAttr *),
SeparatelyCached, NoLocationInfo)
SWIFT_REQUEST(TypeChecker, ProtocolRethrowsRequirementsRequest,
ProtocolRethrowsRequirementList(ProtocolDecl *),
Cached, NoLocationInfo)
SWIFT_REQUEST(TypeChecker, ProtocolConformanceRefClassifyAsThrowsRequest,
bool(ProtocolConformanceRef),
Cached, NoLocationInfo)
SWIFT_REQUEST(TypeChecker, ResolveTypeRequest,
Type (const TypeResolution *, TypeRepr *, GenericParamList *),
Uncached, NoLocationInfo)
Expand Down
30 changes: 0 additions & 30 deletions lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,6 @@ struct ASTContext::Implementation {
/// The declaration of 'Sequence.makeIterator()'.
FuncDecl *MakeIterator = nullptr;

/// The declaration of 'AsyncSequence.makeAsyncIterator()'.
FuncDecl *MakeAsyncIterator = nullptr;

/// The declaration of Swift.Optional<T>.Some.
EnumElementDecl *OptionalSomeDecl = nullptr;

Expand Down Expand Up @@ -775,31 +772,6 @@ FuncDecl *ASTContext::getSequenceMakeIterator() const {
return nullptr;
}

FuncDecl *ASTContext::getAsyncSequenceMakeAsyncIterator() const {
if (getImpl().MakeAsyncIterator) {
return getImpl().MakeAsyncIterator;
}

auto proto = getProtocol(KnownProtocolKind::AsyncSequence);
if (!proto)
return nullptr;

for (auto result : proto->lookupDirect(Id_makeAsyncIterator)) {
if (result->getDeclContext() != proto)
continue;

if (auto func = dyn_cast<FuncDecl>(result)) {
if (func->getParameters()->size() != 0)
continue;

getImpl().MakeAsyncIterator = func;
return func;
}
}

return nullptr;
}

#define KNOWN_STDLIB_TYPE_DECL(NAME, DECL_CLASS, NUM_GENERIC_PARAMS) \
DECL_CLASS *ASTContext::get##NAME##Decl() const { \
if (getImpl().NAME##Decl) \
Expand Down Expand Up @@ -971,8 +943,6 @@ ProtocolDecl *ASTContext::getProtocol(KnownProtocolKind kind) const {
M = getLoadedModule(Id_Differentiation);
break;
case KnownProtocolKind::Actor:
case KnownProtocolKind::AsyncSequence:
case KnownProtocolKind::AsyncIteratorProtocol:
M = getLoadedModule(Id_Concurrency);
break;
default:
Expand Down
Loading