@@ -47,16 +47,17 @@ class ProtocolConformance;
4747// / specified error messages when the conversion fails.
4848// /
4949enum ContextualTypePurpose : uint8_t {
50- CTP_Unused, // /< No contextual type is specified.
51- CTP_Initialization, // /< Pattern binding initialization.
52- CTP_ReturnStmt, // /< Value specified to a 'return' statement.
53- CTP_ReturnSingleExpr, // /< Value implicitly returned from a function.
54- CTP_YieldByValue, // /< By-value yield operand.
55- CTP_YieldByReference, // /< By-reference yield operand.
56- CTP_ThrowStmt, // /< Value specified to a 'throw' statement.
57- CTP_DiscardStmt, // /< Value specified to a 'discard' statement.
58- CTP_EnumCaseRawValue, // /< Raw value specified for "case X = 42" in enum.
59- CTP_DefaultParameter, // /< Default value in parameter 'foo(a : Int = 42)'.
50+ CTP_Unused, // /< No contextual type is specified.
51+ CTP_Initialization, // /< Pattern binding initialization.
52+ CTP_ReturnStmt, // /< Value specified to a 'return' statement.
53+ CTP_ImpliedReturnStmt, // /< Value from an implied 'return', e.g a single expr
54+ // / function body.
55+ CTP_YieldByValue, // /< By-value yield operand.
56+ CTP_YieldByReference, // /< By-reference yield operand.
57+ CTP_ThrowStmt, // /< Value specified to a 'throw' statement.
58+ CTP_DiscardStmt, // /< Value specified to a 'discard' statement.
59+ CTP_EnumCaseRawValue, // /< Raw value specified for "case X = 42" in enum.
60+ CTP_DefaultParameter, // /< Default value in parameter 'foo(a : Int = 42)'.
6061
6162 // / Default value in @autoclosure parameter
6263 // / 'foo(a : @autoclosure () -> Int = 42)'.
@@ -819,11 +820,13 @@ class LocatorPathElt::TypeParameterRequirement final
819820
820821class LocatorPathElt ::ClosureBody final : public StoredIntegerElement<1 > {
821822 public:
822- ClosureBody (bool hasExplicitReturn = false )
823- : StoredIntegerElement(ConstraintLocator::ClosureBody, hasExplicitReturn ) {}
823+ ClosureBody (bool hasImpliedReturn )
824+ : StoredIntegerElement(ConstraintLocator::ClosureBody, hasImpliedReturn ) {}
824825
825- // / Indicates whether body of the closure has any `return` statements.
826- bool hasExplicitReturn () const { return bool (getValue ()); }
826+ // / Indicates whether body of the closure has an implied `return` statement,
827+ // / this is the case for single expression bodies where the `return` was not
828+ // / written explicitly.
829+ bool hasImpliedReturn () const { return bool (getValue ()); }
827830
828831 static bool classof (const LocatorPathElt *elt) {
829832 return elt->getKind () == ConstraintLocator::ClosureBody;
0 commit comments