Skip to content

Commit ee65f20

Browse files
authored
Revert "AsyncSequence and protocol conformance rethrows (#35224)"
This reverts commit 6e05240.
1 parent f55f290 commit ee65f20

Some content is hidden

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

42 files changed

+84
-1413
lines changed

include/swift/AST/ASTContext.h

-3
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,6 @@ class ASTContext final {
522522
/// Get Sequence.makeIterator().
523523
FuncDecl *getSequenceMakeIterator() const;
524524

525-
/// Get AsyncSequence.makeAsyncIterator().
526-
FuncDecl *getAsyncSequenceMakeAsyncIterator() const;
527-
528525
/// Check whether the standard library provides all the correct
529526
/// intrinsic support for Optional<T>.
530527
///

include/swift/AST/ASTTypeIDZone.def

-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ SWIFT_TYPEID(PropertyWrapperTypeInfo)
3131
SWIFT_TYPEID(Requirement)
3232
SWIFT_TYPEID(ResilienceExpansion)
3333
SWIFT_TYPEID(FragileFunctionKind)
34-
SWIFT_TYPEID(FunctionRethrowingKind)
35-
SWIFT_TYPEID(ProtocolRethrowsRequirementList)
3634
SWIFT_TYPEID(TangentPropertyInfo)
3735
SWIFT_TYPEID(SymbolSourceMap)
3836
SWIFT_TYPEID(Type)

include/swift/AST/ASTTypeIDs.h

-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ class ProtocolDecl;
6464
class Requirement;
6565
enum class ResilienceExpansion : unsigned;
6666
struct FragileFunctionKind;
67-
enum class FunctionRethrowingKind : uint8_t;
68-
class ProtocolRethrowsRequirementList;
6967
class SourceFile;
7068
class SymbolSourceMap;
7169
struct TangentPropertyInfo;

include/swift/AST/Attr.def

-4
Original file line numberDiff line numberDiff line change
@@ -359,10 +359,6 @@ SIMPLE_DECL_ATTR(rethrows, Rethrows,
359359
RejectByParser |
360360
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,
361361
57)
362-
SIMPLE_DECL_ATTR(rethrows, AtRethrows,
363-
OnProtocol |
364-
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,
365-
58)
366362
DECL_ATTR(_swift_native_objc_runtime_base, SwiftNativeObjCRuntimeBase,
367363
OnClass |
368364
UserInaccessible |

include/swift/AST/Decl.h

-82
Original file line numberDiff line numberDiff line change
@@ -3879,66 +3879,6 @@ enum class KnownDerivableProtocolKind : uint8_t {
38793879
Actor,
38803880
};
38813881

3882-
class ProtocolRethrowsRequirementList {
3883-
public:
3884-
typedef std::pair<Type, ValueDecl *> Entry;
3885-
3886-
private:
3887-
ArrayRef<Entry> entries;
3888-
3889-
public:
3890-
ProtocolRethrowsRequirementList(ArrayRef<Entry> entries) : entries(entries) {}
3891-
ProtocolRethrowsRequirementList() : entries() {}
3892-
3893-
typedef const Entry *const_iterator;
3894-
typedef const_iterator iterator;
3895-
3896-
const_iterator begin() const { return entries.begin(); }
3897-
const_iterator end() const { return entries.end(); }
3898-
3899-
size_t size() const { return entries.size(); }
3900-
3901-
void print(raw_ostream &OS) const;
3902-
3903-
SWIFT_DEBUG_DUMP;
3904-
3905-
friend bool operator==(const ProtocolRethrowsRequirementList &lhs,
3906-
const ProtocolRethrowsRequirementList &rhs) {
3907-
if (lhs.size() != rhs.size()) {
3908-
return false;
3909-
}
3910-
auto lhsIter = lhs.begin();
3911-
auto rhsIter = rhs.begin();
3912-
while (lhsIter != lhs.end() && rhsIter != rhs.end()) {
3913-
if (lhsIter->first->isEqual(rhsIter->first)) {
3914-
return false;
3915-
}
3916-
if (lhsIter->second != rhsIter->second) {
3917-
return false;
3918-
}
3919-
}
3920-
return true;
3921-
}
3922-
3923-
friend bool operator!=(const ProtocolRethrowsRequirementList &lhs,
3924-
const ProtocolRethrowsRequirementList &rhs) {
3925-
return !(lhs == rhs);
3926-
}
3927-
3928-
friend llvm::hash_code hash_value(
3929-
const ProtocolRethrowsRequirementList &list) {
3930-
return llvm::hash_combine(list.size()); // it is good enought for
3931-
// llvm::hash_code hash;
3932-
// for (auto entry : list) {
3933-
// hash = llvm::hash_combine(hash, entry.first->getCanonicalType());
3934-
// hash = llvm::hash_combine(hash, entry.second);
3935-
// }
3936-
// return hash;
3937-
}
3938-
};
3939-
3940-
void simple_display(raw_ostream &out, const ProtocolRethrowsRequirementList reqs);
3941-
39423882
/// ProtocolDecl - A declaration of a protocol, for example:
39433883
///
39443884
/// protocol Drawable {
@@ -4120,9 +4060,6 @@ class ProtocolDecl final : public NominalTypeDecl {
41204060
/// contain 'Self' in 'parameter' or 'other' position.
41214061
bool existentialTypeSupported() const;
41224062

4123-
ProtocolRethrowsRequirementList getRethrowingRequirements() const;
4124-
bool isRethrowingProtocol() const;
4125-
41264063
private:
41274064
void computeKnownProtocolKind() const;
41284065

@@ -5532,23 +5469,6 @@ class ImportAsMemberStatus {
55325469
}
55335470
};
55345471

5535-
enum class FunctionRethrowingKind : uint8_t {
5536-
/// The function is not throwing
5537-
None,
5538-
5539-
/// The function rethrows by closure
5540-
ByClosure,
5541-
5542-
/// The function rethrows by conformance
5543-
ByConformance,
5544-
5545-
/// The function throws
5546-
Throws,
5547-
5548-
/// The function throwing determinate is invalid
5549-
Invalid
5550-
};
5551-
55525472
/// Base class for function-like declarations.
55535473
class AbstractFunctionDecl : public GenericContext, public ValueDecl {
55545474
friend class NeedsNewVTableEntryRequest;
@@ -5751,8 +5671,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
57515671
/// Returns true if the function body throws.
57525672
bool hasThrows() const { return Bits.AbstractFunctionDecl.Throws; }
57535673

5754-
FunctionRethrowingKind getRethrowingKind() const;
5755-
57565674
// FIXME: Hack that provides names with keyword arguments for accessors.
57575675
DeclName getEffectiveFullName() const;
57585676

include/swift/AST/DiagnosticsSema.def

-4
Original file line numberDiff line numberDiff line change
@@ -2983,8 +2983,6 @@ ERROR(override_rethrows_with_non_rethrows,none,
29832983
"be 'rethrows'", (bool))
29842984
ERROR(rethrows_without_throwing_parameter,none,
29852985
"'rethrows' function must take a throwing function argument", ())
2986-
ERROR(rethrows_attr_on_non_protocol,none,
2987-
"@rethrows may only be used on 'protocol' declarations", ())
29882986

29892987
ERROR(autoclosure_function_type,none,
29902988
"@autoclosure attribute only applies to function types",
@@ -4061,8 +4059,6 @@ NOTE(because_rethrows_argument_throws,none,
40614059
NOTE(because_rethrows_default_argument_throws,none,
40624060
"call is to 'rethrows' function, but a defaulted argument function"
40634061
" can throw", ())
4064-
NOTE(because_rethrows_default_conformance_throws,none,
4065-
"call is to 'rethrows' function, but a conformance has a throwing witness", ())
40664062

40674063
ERROR(throwing_call_in_nonthrowing_autoclosure,none,
40684064
"call can throw, but it is executed in a non-throwing "

include/swift/AST/KnownIdentifiers.def

-2
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ IDENTIFIER(KeyedEncodingContainer)
9393
IDENTIFIER(keyedBy)
9494
IDENTIFIER(keyPath)
9595
IDENTIFIER(makeIterator)
96-
IDENTIFIER(makeAsyncIterator)
9796
IDENTIFIER(Iterator)
98-
IDENTIFIER(AsyncIterator)
9997
IDENTIFIER(load)
10098
IDENTIFIER(main)
10199
IDENTIFIER_WITH_NAME(MainEntryPoint, "$main")

include/swift/AST/KnownProtocols.def

-3
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,6 @@ PROTOCOL(StringInterpolationProtocol)
8888
PROTOCOL(AdditiveArithmetic)
8989
PROTOCOL(Differentiable)
9090

91-
PROTOCOL(AsyncSequence)
92-
PROTOCOL(AsyncIteratorProtocol)
93-
9491
PROTOCOL(FloatingPoint)
9592

9693
EXPRESSIBLE_BY_LITERAL_PROTOCOL(ExpressibleByArrayLiteral, "Array", false)

include/swift/AST/ProtocolConformanceRef.h

-5
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,8 @@ class ProtocolConformanceRef {
170170
/// Get any additional requirements that are required for this conformance to
171171
/// be satisfied.
172172
ArrayRef<Requirement> getConditionalRequirements() const;
173-
174-
bool classifyAsThrows() const;
175173
};
176174

177-
void simple_display(llvm::raw_ostream &out, ProtocolConformanceRef conformanceRef);
178-
SourceLoc extractNearestSourceLoc(const ProtocolConformanceRef conformanceRef);
179-
180175
} // end namespace swift
181176

182177
#endif // LLVM_SWIFT_AST_PROTOCOLCONFORMANCEREF_H

include/swift/AST/Stmt.h

+3-8
Original file line numberDiff line numberDiff line change
@@ -726,8 +726,6 @@ class RepeatWhileStmt : public LabeledStmt {
726726
/// \endcode
727727
class ForEachStmt : public LabeledStmt {
728728
SourceLoc ForLoc;
729-
SourceLoc TryLoc;
730-
SourceLoc AwaitLoc;
731729
Pattern *Pat;
732730
SourceLoc InLoc;
733731
Expr *Sequence;
@@ -743,12 +741,12 @@ class ForEachStmt : public LabeledStmt {
743741
Expr *convertElementExpr = nullptr;
744742

745743
public:
746-
ForEachStmt(LabeledStmtInfo LabelInfo, SourceLoc ForLoc, SourceLoc TryLoc, SourceLoc AwaitLoc,
747-
Pattern *Pat, SourceLoc InLoc, Expr *Sequence, SourceLoc WhereLoc,
744+
ForEachStmt(LabeledStmtInfo LabelInfo, SourceLoc ForLoc, Pattern *Pat,
745+
SourceLoc InLoc, Expr *Sequence, SourceLoc WhereLoc,
748746
Expr *WhereExpr, BraceStmt *Body, Optional<bool> implicit = None)
749747
: LabeledStmt(StmtKind::ForEach, getDefaultImplicitFlag(implicit, ForLoc),
750748
LabelInfo),
751-
ForLoc(ForLoc), TryLoc(TryLoc), AwaitLoc(AwaitLoc), Pat(nullptr), InLoc(InLoc), Sequence(Sequence),
749+
ForLoc(ForLoc), Pat(nullptr), InLoc(InLoc), Sequence(Sequence),
752750
WhereLoc(WhereLoc), WhereExpr(WhereExpr), Body(Body) {
753751
setPattern(Pat);
754752
}
@@ -780,9 +778,6 @@ class ForEachStmt : public LabeledStmt {
780778

781779
/// getWhereLoc - Retrieve the location of the 'where' keyword.
782780
SourceLoc getWhereLoc() const { return WhereLoc; }
783-
784-
SourceLoc getAwaitLoc() const { return AwaitLoc; }
785-
SourceLoc getTryLoc() const { return TryLoc; }
786781

787782
/// getPattern - Retrieve the pattern describing the iteration variables.
788783
/// These variables will only be visible within the body of the loop.

include/swift/AST/TypeCheckRequests.h

-58
Original file line numberDiff line numberDiff line change
@@ -311,44 +311,6 @@ class ExistentialTypeSupportedRequest :
311311
void cacheResult(bool value) const;
312312
};
313313

314-
class ProtocolRethrowsRequirementsRequest :
315-
public SimpleRequest<ProtocolRethrowsRequirementsRequest,
316-
ProtocolRethrowsRequirementList(ProtocolDecl *),
317-
RequestFlags::Cached> {
318-
public:
319-
using SimpleRequest::SimpleRequest;
320-
321-
private:
322-
friend SimpleRequest;
323-
324-
// Evaluation.
325-
ProtocolRethrowsRequirementList
326-
evaluate(Evaluator &evaluator, ProtocolDecl *decl) const;
327-
328-
public:
329-
// Caching.
330-
bool isCached() const { return true; }
331-
};
332-
333-
class ProtocolConformanceRefClassifyAsThrowsRequest :
334-
public SimpleRequest<ProtocolConformanceRefClassifyAsThrowsRequest,
335-
bool(ProtocolConformanceRef),
336-
RequestFlags::Cached> {
337-
public:
338-
using SimpleRequest::SimpleRequest;
339-
340-
private:
341-
friend SimpleRequest;
342-
343-
// Evaluation.
344-
bool
345-
evaluate(Evaluator &evaluator, ProtocolConformanceRef conformanceRef) const;
346-
347-
public:
348-
// Caching.
349-
bool isCached() const { return true; }
350-
};
351-
352314
/// Determine whether the given declaration is 'final'.
353315
class IsFinalRequest :
354316
public SimpleRequest<IsFinalRequest,
@@ -772,26 +734,6 @@ void simple_display(llvm::raw_ostream &out, FragileFunctionKind value);
772734

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

775-
class FunctionRethrowingKindRequest :
776-
public SimpleRequest<FunctionRethrowingKindRequest,
777-
FunctionRethrowingKind(AbstractFunctionDecl*),
778-
RequestFlags::Cached> {
779-
public:
780-
using SimpleRequest::SimpleRequest;
781-
782-
private:
783-
friend SimpleRequest;
784-
785-
// Evaluation.
786-
FunctionRethrowingKind evaluate(Evaluator &evaluator, AbstractFunctionDecl *decl) const;
787-
788-
public:
789-
// Caching.
790-
bool isCached() const { return true; }
791-
};
792-
793-
void simple_display(llvm::raw_ostream &out, FunctionRethrowingKind value);
794-
795737
/// Request the custom attribute which attaches a result builder to the
796738
/// given declaration.
797739
class AttachedResultBuilderRequest :

include/swift/AST/TypeCheckerTypeIDZone.def

-8
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,6 @@ SWIFT_REQUEST(TypeChecker, RequiresOpaqueModifyCoroutineRequest,
211211
bool(AbstractStorageDecl *), SeparatelyCached, NoLocationInfo)
212212
SWIFT_REQUEST(TypeChecker, FragileFunctionKindRequest,
213213
FragileFunctionKind(DeclContext *), Cached, NoLocationInfo)
214-
SWIFT_REQUEST(TypeChecker, FunctionRethrowingKindRequest,
215-
FunctionRethrowingKind(AbstractFunctionDecl *), Cached, NoLocationInfo)
216214
SWIFT_REQUEST(TypeChecker, SelfAccessKindRequest, SelfAccessKind(FuncDecl *),
217215
SeparatelyCached, NoLocationInfo)
218216
SWIFT_REQUEST(TypeChecker, StorageImplInfoRequest,
@@ -267,12 +265,6 @@ SWIFT_REQUEST(TypeChecker, ResolveImplicitMemberRequest,
267265
SWIFT_REQUEST(TypeChecker, ResolveTypeEraserTypeRequest,
268266
Type(ProtocolDecl *, TypeEraserAttr *),
269267
SeparatelyCached, NoLocationInfo)
270-
SWIFT_REQUEST(TypeChecker, ProtocolRethrowsRequirementsRequest,
271-
ProtocolRethrowsRequirementList(ProtocolDecl *),
272-
Cached, NoLocationInfo)
273-
SWIFT_REQUEST(TypeChecker, ProtocolConformanceRefClassifyAsThrowsRequest,
274-
bool(ProtocolConformanceRef),
275-
Cached, NoLocationInfo)
276268
SWIFT_REQUEST(TypeChecker, ResolveTypeRequest,
277269
Type (const TypeResolution *, TypeRepr *, GenericParamList *),
278270
Uncached, NoLocationInfo)

lib/AST/ASTContext.cpp

-30
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,6 @@ struct ASTContext::Implementation {
206206
/// The declaration of 'Sequence.makeIterator()'.
207207
FuncDecl *MakeIterator = nullptr;
208208

209-
/// The declaration of 'AsyncSequence.makeAsyncIterator()'.
210-
FuncDecl *MakeAsyncIterator = nullptr;
211-
212209
/// The declaration of Swift.Optional<T>.Some.
213210
EnumElementDecl *OptionalSomeDecl = nullptr;
214211

@@ -775,31 +772,6 @@ FuncDecl *ASTContext::getSequenceMakeIterator() const {
775772
return nullptr;
776773
}
777774

778-
FuncDecl *ASTContext::getAsyncSequenceMakeAsyncIterator() const {
779-
if (getImpl().MakeAsyncIterator) {
780-
return getImpl().MakeAsyncIterator;
781-
}
782-
783-
auto proto = getProtocol(KnownProtocolKind::AsyncSequence);
784-
if (!proto)
785-
return nullptr;
786-
787-
for (auto result : proto->lookupDirect(Id_makeAsyncIterator)) {
788-
if (result->getDeclContext() != proto)
789-
continue;
790-
791-
if (auto func = dyn_cast<FuncDecl>(result)) {
792-
if (func->getParameters()->size() != 0)
793-
continue;
794-
795-
getImpl().MakeAsyncIterator = func;
796-
return func;
797-
}
798-
}
799-
800-
return nullptr;
801-
}
802-
803775
#define KNOWN_STDLIB_TYPE_DECL(NAME, DECL_CLASS, NUM_GENERIC_PARAMS) \
804776
DECL_CLASS *ASTContext::get##NAME##Decl() const { \
805777
if (getImpl().NAME##Decl) \
@@ -971,8 +943,6 @@ ProtocolDecl *ASTContext::getProtocol(KnownProtocolKind kind) const {
971943
M = getLoadedModule(Id_Differentiation);
972944
break;
973945
case KnownProtocolKind::Actor:
974-
case KnownProtocolKind::AsyncSequence:
975-
case KnownProtocolKind::AsyncIteratorProtocol:
976946
M = getLoadedModule(Id_Concurrency);
977947
break;
978948
default:

0 commit comments

Comments
 (0)