Skip to content

Commit 38d3169

Browse files
authored
Merge pull request #59245 from xedin/rename-closure-to-syntactic-element-5.7
[5.7][CSClosure] (Mostly NFC) Renames and introduction of `AnyFunctionRef`
2 parents ba6cb0c + 5702250 commit 38d3169

11 files changed

+180
-165
lines changed

include/swift/Sema/Constraint.h

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,9 @@ enum class ConstraintKind : char {
209209
/// inferred from a conversion, so the check is more relax comparing to
210210
/// `ConformsTo`.
211211
TransitivelyConformsTo,
212-
/// Represents an AST node contained in a body of a closure. It has only
213-
/// one type - type variable representing type of a node, other side is
214-
/// the AST node to infer the type for.
215-
ClosureBodyElement,
212+
/// Represents an AST node contained in a body of a function/closure.
213+
/// It only has an AST node to generate constraints and infer the type for.
214+
SyntacticElement,
216215
/// Do not add new uses of this, it only exists to retain compatibility for
217216
/// rdar://85263844.
218217
///
@@ -240,8 +239,8 @@ enum class ConstraintClassification : char {
240239
/// A conjunction constraint.
241240
Conjunction,
242241

243-
/// An element of a closure body.
244-
ClosureElement,
242+
/// An element of a closure/function body.
243+
SyntacticElement,
245244
};
246245

247246
/// Specifies a restriction on the kind of conversion that should be
@@ -450,7 +449,7 @@ class Constraint final : public llvm::ilist_node<Constraint>,
450449
ContextualTypeInfo Context;
451450
/// Identifies whether result of this node is unused.
452451
bool IsDiscarded;
453-
} ClosureElement;
452+
} SyntacticElement;
454453
};
455454

456455
/// The locator that describes where in the expression this
@@ -591,12 +590,12 @@ class Constraint final : public llvm::ilist_node<Constraint>,
591590
Optional<TrailingClosureMatching> trailingClosureMatching,
592591
ConstraintLocator *locator);
593592

594-
static Constraint *createClosureBodyElement(ConstraintSystem &cs,
593+
static Constraint *createSyntacticElement(ConstraintSystem &cs,
595594
ASTNode node,
596595
ConstraintLocator *locator,
597596
bool isDiscarded = false);
598597

599-
static Constraint *createClosureBodyElement(ConstraintSystem &cs,
598+
static Constraint *createSyntacticElement(ConstraintSystem &cs,
600599
ASTNode node,
601600
ContextualTypeInfo context,
602601
ConstraintLocator *locator,
@@ -710,8 +709,8 @@ class Constraint final : public llvm::ilist_node<Constraint>,
710709
case ConstraintKind::Conjunction:
711710
return ConstraintClassification::Conjunction;
712711

713-
case ConstraintKind::ClosureBodyElement:
714-
return ConstraintClassification::ClosureElement;
712+
case ConstraintKind::SyntacticElement:
713+
return ConstraintClassification::SyntacticElement;
715714
}
716715

717716
llvm_unreachable("Unhandled ConstraintKind in switch.");
@@ -734,7 +733,7 @@ class Constraint final : public llvm::ilist_node<Constraint>,
734733
case ConstraintKind::ValueWitness:
735734
return Member.First;
736735

737-
case ConstraintKind::ClosureBodyElement:
736+
case ConstraintKind::SyntacticElement:
738737
llvm_unreachable("closure body element constraint has no type operands");
739738

740739
default:
@@ -748,7 +747,7 @@ class Constraint final : public llvm::ilist_node<Constraint>,
748747
case ConstraintKind::Disjunction:
749748
case ConstraintKind::Conjunction:
750749
case ConstraintKind::BindOverload:
751-
case ConstraintKind::ClosureBodyElement:
750+
case ConstraintKind::SyntacticElement:
752751
llvm_unreachable("constraint has no second type");
753752

754753
case ConstraintKind::ValueMember:
@@ -857,19 +856,19 @@ class Constraint final : public llvm::ilist_node<Constraint>,
857856
return Member.UseDC;
858857
}
859858

860-
ASTNode getClosureElement() const {
861-
assert(Kind == ConstraintKind::ClosureBodyElement);
862-
return ClosureElement.Element;
859+
ASTNode getSyntacticElement() const {
860+
assert(Kind == ConstraintKind::SyntacticElement);
861+
return SyntacticElement.Element;
863862
}
864863

865864
ContextualTypeInfo getElementContext() const {
866-
assert(Kind == ConstraintKind::ClosureBodyElement);
867-
return ClosureElement.Context;
865+
assert(Kind == ConstraintKind::SyntacticElement);
866+
return SyntacticElement.Context;
868867
}
869868

870869
bool isDiscardedElement() const {
871-
assert(Kind == ConstraintKind::ClosureBodyElement);
872-
return ClosureElement.IsDiscarded;
870+
assert(Kind == ConstraintKind::SyntacticElement);
871+
return SyntacticElement.IsDiscarded;
873872
}
874873

875874
/// For an applicable function constraint, retrieve the trailing closure

include/swift/Sema/ConstraintLocator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,11 +1012,11 @@ class LocatorPathElt::ConstructorMemberType final
10121012
}
10131013
};
10141014

1015-
class LocatorPathElt::ClosureBodyElement final
1015+
class LocatorPathElt::SyntacticElement final
10161016
: public StoredPointerElement<void> {
10171017
public:
1018-
ClosureBodyElement(ASTNode element)
1019-
: StoredPointerElement(PathElementKind::ClosureBodyElement,
1018+
SyntacticElement(ASTNode element)
1019+
: StoredPointerElement(PathElementKind::SyntacticElement,
10201020
element.getOpaqueValue()) {
10211021
assert(element);
10221022
}
@@ -1054,7 +1054,7 @@ class LocatorPathElt::ClosureBodyElement final
10541054
}
10551055

10561056
static bool classof(const LocatorPathElt *elt) {
1057-
return elt->getKind() == PathElementKind::ClosureBodyElement;
1057+
return elt->getKind() == PathElementKind::SyntacticElement;
10581058
}
10591059
};
10601060

include/swift/Sema/ConstraintLocatorPathElts.def

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,9 @@ CUSTOM_LOCATOR_PATH_ELT(ImplicitConversion)
229229
/// An implicit call to a 'dynamicMember' subscript for a dynamic member lookup.
230230
SIMPLE_LOCATOR_PATH_ELT(ImplicitDynamicMemberSubscript)
231231

232-
/// The element of the closure body e.g. statement, declaration, or expression.
233-
CUSTOM_LOCATOR_PATH_ELT(ClosureBodyElement)
232+
/// The element of the closure/function body e.g. statement, pattern,
233+
/// declaration, or expression.
234+
CUSTOM_LOCATOR_PATH_ELT(SyntacticElement)
234235

235236
/// The element of the pattern binding declaration.
236237
CUSTOM_LOCATOR_PATH_ELT(PatternBindingElement)

include/swift/Sema/ConstraintSystem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5084,9 +5084,9 @@ class ConstraintSystem {
50845084
TypeMatchOptions flags,
50855085
ConstraintLocatorBuilder locator);
50865086

5087-
/// Simplify a closure body element constraint by generating required
5087+
/// Simplify a syntactic element constraint by generating required
50885088
/// constraints to represent the given element in constraint system.
5089-
SolutionKind simplifyClosureBodyElementConstraint(
5089+
SolutionKind simplifySyntacticElementConstraint(
50905090
ASTNode element, ContextualTypeInfo context, bool isDiscarded,
50915091
TypeMatchOptions flags, ConstraintLocatorBuilder locator);
50925092

lib/Sema/CSBindings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,7 @@ void PotentialBindings::infer(Constraint *constraint) {
13851385
case ConstraintKind::EscapableFunctionOf:
13861386
case ConstraintKind::OpenedExistentialOf:
13871387
case ConstraintKind::KeyPath:
1388-
case ConstraintKind::ClosureBodyElement:
1388+
case ConstraintKind::SyntacticElement:
13891389
case ConstraintKind::Conjunction:
13901390
case ConstraintKind::BindTupleOfFunctionParams:
13911391
// Constraints from which we can't do anything.

0 commit comments

Comments
 (0)