Skip to content

Commit 59fa22b

Browse files
authored
Merge pull request swiftlang#36197 from slavapestov/reasync-preparations
Refactor TypeCheckEffects.cpp in preparation for 'reasync' checking
2 parents 53069e2 + a4acf39 commit 59fa22b

File tree

4 files changed

+516
-332
lines changed

4 files changed

+516
-332
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4093,7 +4093,7 @@ NOTE(because_rethrows_argument_throws,none,
40934093
NOTE(because_rethrows_default_argument_throws,none,
40944094
"call is to 'rethrows' function, but a defaulted argument function"
40954095
" can throw", ())
4096-
NOTE(because_rethrows_default_conformance_throws,none,
4096+
NOTE(because_rethrows_conformance_throws,none,
40974097
"call is to 'rethrows' function, but a conformance has a throwing witness", ())
40984098

40994099
ERROR(throwing_call_in_nonthrowing_autoclosure,none,

include/swift/AST/Types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ class TypeAliasDecl;
7676
class TypeDecl;
7777
class NominalTypeDecl;
7878
class GenericTypeDecl;
79+
enum class EffectKind : uint8_t;
7980
class EnumDecl;
8081
class EnumElementDecl;
8182
class SILFunctionType;
@@ -3159,6 +3160,8 @@ class AnyFunctionType : public TypeBase {
31593160

31603161
bool isThrowing() const { return getExtInfo().isThrowing(); }
31613162

3163+
bool hasEffect(EffectKind kind) const;
3164+
31623165
bool isDifferentiable() const { return getExtInfo().isDifferentiable(); }
31633166
DifferentiabilityKind getDifferentiabilityKind() const {
31643167
return getExtInfo().getDifferentiabilityKind();

lib/AST/Effects.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,21 @@
2020
#include "swift/AST/Decl.h"
2121
#include "swift/AST/ProtocolConformanceRef.h"
2222
#include "swift/AST/Type.h"
23+
#include "swift/AST/Types.h"
2324
#include "swift/AST/TypeCheckRequests.h"
2425
#include "llvm/ADT/ArrayRef.h"
2526
#include "llvm/Support/raw_ostream.h"
2627

2728
using namespace swift;
2829

30+
bool AnyFunctionType::hasEffect(EffectKind kind) const {
31+
switch (kind) {
32+
case EffectKind::Throws: return getExtInfo().isThrowing();
33+
case EffectKind::Async: return getExtInfo().isAsync();
34+
}
35+
llvm_unreachable("Bad effect kind");
36+
}
37+
2938
void swift::simple_display(llvm::raw_ostream &out, const EffectKind kind) {
3039
switch (kind) {
3140
case EffectKind::Throws: out << "throws"; return;

0 commit comments

Comments
 (0)