Skip to content

Commit 6d41524

Browse files
committed
[SE-0289] Finish renaming source code, tests to "result builders"
1 parent 0d568a9 commit 6d41524

Some content is hidden

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

49 files changed

+314
-315
lines changed

include/swift/AST/ASTTypeIDZone.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ SWIFT_TYPEID(AncestryFlags)
2020
SWIFT_TYPEID(BodyInitKind)
2121
SWIFT_TYPEID(BodyInitKindAndExpr)
2222
SWIFT_TYPEID(CtorInitializerKind)
23-
SWIFT_TYPEID(FunctionBuilderBodyPreCheck)
23+
SWIFT_TYPEID(ResultBuilderBodyPreCheck)
2424
SWIFT_TYPEID(GenericSignature)
2525
SWIFT_TYPEID(ImplicitImportList)
2626
SWIFT_TYPEID(ImplicitMemberAction)

include/swift/AST/ASTTypeIDs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class CustomAttr;
3535
class Decl;
3636
class EnumDecl;
3737
class FuncDecl;
38-
enum class FunctionBuilderBodyPreCheck : uint8_t;
38+
enum class ResultBuilderBodyPreCheck : uint8_t;
3939
class GenericParamList;
4040
class GenericSignature;
4141
class GenericTypeParamType;

include/swift/AST/Decl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2403,11 +2403,11 @@ class ValueDecl : public Decl {
24032403

24042404
/// Retrieve the attribute associating this declaration with a
24052405
/// result builder, if there is one.
2406-
CustomAttr *getAttachedFunctionBuilder() const;
2406+
CustomAttr *getAttachedResultBuilder() const;
24072407

2408-
/// Retrieve the @functionBuilder type attached to this declaration,
2408+
/// Retrieve the @resultBuilder type attached to this declaration,
24092409
/// if there is one.
2410-
Type getFunctionBuilderType() const;
2410+
Type getResultBuilderType() const;
24112411

24122412
/// If this value or its backing storage is annotated
24132413
/// @_dynamicReplacement(for: ...), compute the original declaration

include/swift/AST/EducationalNotes.def

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ EDUCATIONAL_NOTES(unlabeled_trailing_closure_deprecated,
8282
"trailing-closure-matching.md")
8383

8484
EDUCATIONAL_NOTES(result_builder_static_buildblock,
85-
"function-builder-methods.md")
85+
"result-builder-methods.md")
8686
EDUCATIONAL_NOTES(result_builder_missing_limited_availability,
87-
"function-builder-methods.md")
87+
"result-builder-methods.md")
8888
EDUCATIONAL_NOTES(result_builder_missing_build_optional,
89-
"function-builder-methods.md")
89+
"result-builder-methods.md")
9090
EDUCATIONAL_NOTES(result_builder_missing_build_either,
91-
"function-builder-methods.md")
91+
"result-builder-methods.md")
9292
EDUCATIONAL_NOTES(result_builder_missing_build_array,
93-
"function-builder-methods.md")
93+
"result-builder-methods.md")
9494

9595
#undef EDUCATIONAL_NOTES

include/swift/AST/TypeCheckRequests.h

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -737,8 +737,8 @@ void simple_display(llvm::raw_ostream &out, ResilienceExpansion value);
737737

738738
/// Request the custom attribute which attaches a result builder to the
739739
/// given declaration.
740-
class AttachedFunctionBuilderRequest :
741-
public SimpleRequest<AttachedFunctionBuilderRequest,
740+
class AttachedResultBuilderRequest :
741+
public SimpleRequest<AttachedResultBuilderRequest,
742742
CustomAttr *(ValueDecl *),
743743
RequestFlags::Cached> {
744744
public:
@@ -758,8 +758,8 @@ class AttachedFunctionBuilderRequest :
758758

759759
/// Request the result builder type attached to the given declaration,
760760
/// if any.
761-
class FunctionBuilderTypeRequest :
762-
public SimpleRequest<FunctionBuilderTypeRequest,
761+
class ResultBuilderTypeRequest :
762+
public SimpleRequest<ResultBuilderTypeRequest,
763763
Type(ValueDecl *),
764764
RequestFlags::Cached> {
765765
public:
@@ -1960,7 +1960,7 @@ class ValueWitnessRequest
19601960
void cacheResult(Witness value) const;
19611961
};
19621962

1963-
struct PreCheckFunctionBuilderDescriptor {
1963+
struct PreCheckResultBuilderDescriptor {
19641964
AnyFunctionRef Fn;
19651965
bool SuppressDiagnostics;
19661966

@@ -1972,35 +1972,35 @@ struct PreCheckFunctionBuilderDescriptor {
19721972
BraceStmt *Body;
19731973

19741974
public:
1975-
PreCheckFunctionBuilderDescriptor(AnyFunctionRef Fn, bool suppressDiagnostics)
1975+
PreCheckResultBuilderDescriptor(AnyFunctionRef Fn, bool suppressDiagnostics)
19761976
: Fn(Fn), SuppressDiagnostics(suppressDiagnostics), Body(Fn.getBody()) {}
19771977

19781978
friend llvm::hash_code
1979-
hash_value(const PreCheckFunctionBuilderDescriptor &owner) {
1979+
hash_value(const PreCheckResultBuilderDescriptor &owner) {
19801980
return llvm::hash_combine(owner.Fn, owner.Body);
19811981
}
19821982

1983-
friend bool operator==(const PreCheckFunctionBuilderDescriptor &lhs,
1984-
const PreCheckFunctionBuilderDescriptor &rhs) {
1983+
friend bool operator==(const PreCheckResultBuilderDescriptor &lhs,
1984+
const PreCheckResultBuilderDescriptor &rhs) {
19851985
return lhs.Fn == rhs.Fn && lhs.Body == rhs.Body;
19861986
}
19871987

1988-
friend bool operator!=(const PreCheckFunctionBuilderDescriptor &lhs,
1989-
const PreCheckFunctionBuilderDescriptor &rhs) {
1988+
friend bool operator!=(const PreCheckResultBuilderDescriptor &lhs,
1989+
const PreCheckResultBuilderDescriptor &rhs) {
19901990
return !(lhs == rhs);
19911991
}
19921992

1993-
friend SourceLoc extractNearestSourceLoc(PreCheckFunctionBuilderDescriptor d) {
1993+
friend SourceLoc extractNearestSourceLoc(PreCheckResultBuilderDescriptor d) {
19941994
return extractNearestSourceLoc(d.Fn);
19951995
}
19961996

19971997
friend void simple_display(llvm::raw_ostream &out,
1998-
const PreCheckFunctionBuilderDescriptor &d) {
1998+
const PreCheckResultBuilderDescriptor &d) {
19991999
simple_display(out, d.Fn);
20002000
}
20012001
};
20022002

2003-
enum class FunctionBuilderBodyPreCheck : uint8_t {
2003+
enum class ResultBuilderBodyPreCheck : uint8_t {
20042004
/// There were no problems pre-checking the closure.
20052005
Okay,
20062006

@@ -2011,10 +2011,10 @@ enum class FunctionBuilderBodyPreCheck : uint8_t {
20112011
HasReturnStmt,
20122012
};
20132013

2014-
class PreCheckFunctionBuilderRequest
2015-
: public SimpleRequest<PreCheckFunctionBuilderRequest,
2016-
FunctionBuilderBodyPreCheck(
2017-
PreCheckFunctionBuilderDescriptor),
2014+
class PreCheckResultBuilderRequest
2015+
: public SimpleRequest<PreCheckResultBuilderRequest,
2016+
ResultBuilderBodyPreCheck(
2017+
PreCheckResultBuilderDescriptor),
20182018
RequestFlags::Cached> {
20192019
public:
20202020
using SimpleRequest::SimpleRequest;
@@ -2023,8 +2023,8 @@ class PreCheckFunctionBuilderRequest
20232023
friend SimpleRequest;
20242024

20252025
// Evaluation.
2026-
FunctionBuilderBodyPreCheck
2027-
evaluate(Evaluator &evaluator, PreCheckFunctionBuilderDescriptor owner) const;
2026+
ResultBuilderBodyPreCheck
2027+
evaluate(Evaluator &evaluator, PreCheckResultBuilderDescriptor owner) const;
20282028

20292029
public:
20302030
// Separate caching.
@@ -2759,7 +2759,7 @@ AnyValue::Holder<GenericSignature>::equals(const HolderBase &other) const {
27592759
void simple_display(llvm::raw_ostream &out, Type value);
27602760
void simple_display(llvm::raw_ostream &out, const TypeRepr *TyR);
27612761
void simple_display(llvm::raw_ostream &out, ImplicitMemberAction action);
2762-
void simple_display(llvm::raw_ostream &out, FunctionBuilderBodyPreCheck pck);
2762+
void simple_display(llvm::raw_ostream &out, ResultBuilderBodyPreCheck pck);
27632763

27642764
#define SWIFT_TYPEID_ZONE TypeChecker
27652765
#define SWIFT_TYPEID_HEADER "swift/AST/TypeCheckerTypeIDZone.def"

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ SWIFT_REQUEST(TypeChecker, AbstractGenericSignatureRequest,
2020
SmallVector<GenericTypeParamType *, 2>,
2121
SmallVector<Requirement, 2>),
2222
Cached, NoLocationInfo)
23-
SWIFT_REQUEST(TypeChecker, AttachedFunctionBuilderRequest,
23+
SWIFT_REQUEST(TypeChecker, AttachedResultBuilderRequest,
2424
CustomAttr *(ValueDecl *), Cached, NoLocationInfo)
2525
SWIFT_REQUEST(TypeChecker, AttachedPropertyWrapperTypeRequest,
2626
Type(VarDecl *, unsigned), Cached, NoLocationInfo)
@@ -81,7 +81,7 @@ SWIFT_REQUEST(TypeChecker, ExistentialTypeSupportedRequest,
8181
bool(ProtocolDecl *), SeparatelyCached, NoLocationInfo)
8282
SWIFT_REQUEST(TypeChecker, ExtendedTypeRequest, Type(ExtensionDecl *), Cached,
8383
NoLocationInfo)
84-
SWIFT_REQUEST(TypeChecker, FunctionBuilderTypeRequest, Type(ValueDecl *),
84+
SWIFT_REQUEST(TypeChecker, ResultBuilderTypeRequest, Type(ValueDecl *),
8585
Cached, NoLocationInfo)
8686
SWIFT_REQUEST(TypeChecker, IsAsyncHandlerRequest, bool(FuncDecl *),
8787
Cached, NoLocationInfo)
@@ -249,8 +249,8 @@ SWIFT_REQUEST(TypeChecker, HasUserDefinedDesignatedInitRequest,
249249
bool(NominalTypeDecl *), Cached, NoLocationInfo)
250250
SWIFT_REQUEST(TypeChecker, HasMemberwiseInitRequest,
251251
bool(StructDecl *), Cached, NoLocationInfo)
252-
SWIFT_REQUEST(TypeChecker, PreCheckFunctionBuilderRequest,
253-
FunctionBuilderClosurePreCheck(PreCheckFunctionBuilderDescriptor),
252+
SWIFT_REQUEST(TypeChecker, PreCheckResultBuilderRequest,
253+
ResultBuilderBodyPreCheck(PreCheckResultBuilderDescriptor),
254254
Cached, NoLocationInfo)
255255
SWIFT_REQUEST(TypeChecker, ResolveImplicitMemberRequest,
256256
evaluator::SideEffect(NominalTypeDecl *, ImplicitMemberAction),

include/swift/Sema/CSFix.h

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,8 @@ enum class FixKind : uint8_t {
193193
DefaultGenericArgument,
194194

195195
/// Skip any unhandled constructs that occur within a closure argument that
196-
/// matches up with a
197-
/// parameter that has a result builder.
198-
SkipUnhandledConstructInFunctionBuilder,
196+
/// matches up with a parameter that has a result builder.
197+
SkipUnhandledConstructInResultBuilder,
199198

200199
/// Allow invalid reference to a member declared as `mutating`
201200
/// when base is an r-value type.
@@ -278,7 +277,7 @@ enum class FixKind : uint8_t {
278277
AllowKeyPathWithoutComponents,
279278

280279
/// Ignore result builder body which fails `pre-check` call.
281-
IgnoreInvalidFunctionBuilderBody,
280+
IgnoreInvalidResultBuilderBody,
282281

283282
/// Resolve type of `nil` by providing a contextual type.
284283
SpecifyContextualTypeForNil,
@@ -1500,19 +1499,19 @@ class DefaultGenericArgument final : public ConstraintFix {
15001499
ConstraintLocator *locator);
15011500
};
15021501

1503-
class SkipUnhandledConstructInFunctionBuilder final : public ConstraintFix {
1502+
class SkipUnhandledConstructInResultBuilder final : public ConstraintFix {
15041503
public:
15051504
using UnhandledNode = llvm::PointerUnion<Stmt *, Decl *>;
15061505

15071506
private:
15081507
UnhandledNode unhandled;
15091508
NominalTypeDecl *builder;
15101509

1511-
SkipUnhandledConstructInFunctionBuilder(ConstraintSystem &cs,
1510+
SkipUnhandledConstructInResultBuilder(ConstraintSystem &cs,
15121511
UnhandledNode unhandled,
15131512
NominalTypeDecl *builder,
15141513
ConstraintLocator *locator)
1515-
: ConstraintFix(cs, FixKind::SkipUnhandledConstructInFunctionBuilder,
1514+
: ConstraintFix(cs, FixKind::SkipUnhandledConstructInResultBuilder,
15161515
locator),
15171516
unhandled(unhandled), builder(builder) { }
15181517

@@ -1523,7 +1522,7 @@ class SkipUnhandledConstructInFunctionBuilder final : public ConstraintFix {
15231522

15241523
bool diagnose(const Solution &solution, bool asNote = false) const override;
15251524

1526-
static SkipUnhandledConstructInFunctionBuilder *
1525+
static SkipUnhandledConstructInResultBuilder *
15271526
create(ConstraintSystem &cs, UnhandledNode unhandledNode,
15281527
NominalTypeDecl *builder, ConstraintLocator *locator);
15291528
};
@@ -1997,17 +1996,17 @@ class AllowKeyPathWithoutComponents final : public ConstraintFix {
19971996
ConstraintLocator *locator);
19981997
};
19991998

2000-
class IgnoreInvalidFunctionBuilderBody final : public ConstraintFix {
1999+
class IgnoreInvalidResultBuilderBody final : public ConstraintFix {
20012000
enum class ErrorInPhase {
20022001
PreCheck,
20032002
ConstraintGeneration,
20042003
};
20052004

20062005
ErrorInPhase Phase;
20072006

2008-
IgnoreInvalidFunctionBuilderBody(ConstraintSystem &cs, ErrorInPhase phase,
2007+
IgnoreInvalidResultBuilderBody(ConstraintSystem &cs, ErrorInPhase phase,
20092008
ConstraintLocator *locator)
2010-
: ConstraintFix(cs, FixKind::IgnoreInvalidFunctionBuilderBody, locator),
2009+
: ConstraintFix(cs, FixKind::IgnoreInvalidResultBuilderBody, locator),
20112010
Phase(phase) {}
20122011

20132012
public:
@@ -2021,18 +2020,18 @@ class IgnoreInvalidFunctionBuilderBody final : public ConstraintFix {
20212020
return diagnose(*commonFixes.front().first);
20222021
}
20232022

2024-
static IgnoreInvalidFunctionBuilderBody *
2023+
static IgnoreInvalidResultBuilderBody *
20252024
duringPreCheck(ConstraintSystem &cs, ConstraintLocator *locator) {
20262025
return create(cs, ErrorInPhase::PreCheck, locator);
20272026
}
20282027

2029-
static IgnoreInvalidFunctionBuilderBody *
2028+
static IgnoreInvalidResultBuilderBody *
20302029
duringConstraintGeneration(ConstraintSystem &cs, ConstraintLocator *locator) {
20312030
return create(cs, ErrorInPhase::ConstraintGeneration, locator);
20322031
}
20332032

20342033
private:
2035-
static IgnoreInvalidFunctionBuilderBody *
2034+
static IgnoreInvalidResultBuilderBody *
20362035
create(ConstraintSystem &cs, ErrorInPhase phase, ConstraintLocator *locator);
20372036
};
20382037

include/swift/Sema/ConstraintLocator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class ConstraintLocator : public llvm::FoldingSetNode {
223223
bool isForOptionalTry() const;
224224

225225
/// Determine whether this locator is for a result builder body result type.
226-
bool isForFunctionBuilderBodyResult() const;
226+
bool isForResultBuilderBodyResult() const;
227227

228228
/// Determine whether this locator points directly to a given expression.
229229
template <typename E> bool directlyAt() const {

include/swift/Sema/ConstraintLocatorPathElts.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ SIMPLE_LOCATOR_PATH_ELT(FunctionArgument)
7676
SIMPLE_LOCATOR_PATH_ELT(FunctionResult)
7777

7878
/// The result type of a result builder body.
79-
SIMPLE_LOCATOR_PATH_ELT(FunctionBuilderBodyResult)
79+
SIMPLE_LOCATOR_PATH_ELT(ResultBuilderBodyResult)
8080

8181
/// A generic argument.
8282
/// FIXME: Add support for named generic arguments?

include/swift/Sema/ConstraintSystem.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class SemaTest;
7676
// so they could be made friends of ConstraintSystem.
7777
namespace TypeChecker {
7878

79-
Optional<BraceStmt *> applyFunctionBuilderBodyTransform(FuncDecl *func,
79+
Optional<BraceStmt *> applyResultBuilderBodyTransform(FuncDecl *func,
8080
Type builderType);
8181

8282
Optional<constraints::SolutionApplicationTarget>
@@ -1186,7 +1186,7 @@ class Solution {
11861186

11871187
/// The set of functions that have been transformed by a result builder.
11881188
llvm::MapVector<AnyFunctionRef, AppliedBuilderTransform>
1189-
functionBuilderTransformed;
1189+
resultBuilderTransformed;
11901190

11911191
/// Simplify the given type by substituting all occurrences of
11921192
/// type variables for their fixed types.
@@ -1300,8 +1300,8 @@ class Solution {
13001300
/// Retrieve the builder transform that was applied to this function, if any.
13011301
const AppliedBuilderTransform *getAppliedBuilderTransform(
13021302
AnyFunctionRef fn) const {
1303-
auto known = functionBuilderTransformed.find(fn);
1304-
return known != functionBuilderTransformed.end()
1303+
auto known = resultBuilderTransformed.find(fn);
1304+
return known != resultBuilderTransformed.end()
13051305
? &known->second
13061306
: nullptr;
13071307
}
@@ -2130,7 +2130,7 @@ class ConstraintSystem {
21302130
///
21312131
/// Tracking this information is useful to avoid producing duplicate
21322132
/// diagnostics when result builder has multiple overloads.
2133-
llvm::SmallDenseSet<AnyFunctionRef> InvalidFunctionBuilderBodies;
2133+
llvm::SmallDenseSet<AnyFunctionRef> InvalidResultBuilderBodies;
21342134

21352135
/// Maps node types used within all portions of the constraint
21362136
/// system, instead of directly using the types on the
@@ -2220,7 +2220,7 @@ class ConstraintSystem {
22202220

22212221
/// The set of functions that have been transformed by a result builder.
22222222
std::vector<std::pair<AnyFunctionRef, AppliedBuilderTransform>>
2223-
functionBuilderTransformed;
2223+
resultBuilderTransformed;
22242224

22252225
/// Cache of the effects any closures visited.
22262226
llvm::SmallDenseMap<ClosureExpr *, FunctionType::ExtInfo, 4> closureEffectsCache;
@@ -2687,7 +2687,7 @@ class ConstraintSystem {
26872687

26882688
unsigned numFavoredConstraints;
26892689

2690-
unsigned numFunctionBuilderTransformed;
2690+
unsigned numResultBuilderTransformed;
26912691

26922692
/// The length of \c ResolvedOverloads.
26932693
unsigned numResolvedOverloads;
@@ -2759,7 +2759,7 @@ class ConstraintSystem {
27592759

27602760
// FIXME: Perhaps these belong on ConstraintSystem itself.
27612761
friend Optional<BraceStmt *>
2762-
swift::TypeChecker::applyFunctionBuilderBodyTransform(FuncDecl *func,
2762+
swift::TypeChecker::applyResultBuilderBodyTransform(FuncDecl *func,
27632763
Type builderType);
27642764

27652765
friend Optional<SolutionApplicationTarget>
@@ -4607,7 +4607,7 @@ class ConstraintSystem {
46074607
///
46084608
/// \returns \c None when the result builder cannot be applied at all,
46094609
/// otherwise the result of applying the result builder.
4610-
Optional<TypeMatchResult> matchFunctionBuilder(
4610+
Optional<TypeMatchResult> matchResultBuilder(
46114611
AnyFunctionRef fn, Type builderType, Type bodyResultType,
46124612
ConstraintKind bodyResultConstraintKind,
46134613
ConstraintLocatorBuilder locator);
@@ -6002,7 +6002,7 @@ std::string describeGenericType(ValueDecl *GP, bool includeName = false);
60026002
/// type-checked version.
60036003
///
60046004
/// \returns the transformed body
6005-
BraceStmt *applyFunctionBuilderTransform(
6005+
BraceStmt *applyResultBuilderTransform(
60066006
const constraints::Solution &solution,
60076007
constraints::AppliedBuilderTransform applied,
60086008
BraceStmt *body,

0 commit comments

Comments
 (0)