@@ -2175,6 +2175,9 @@ class GenericParameterReferenceInfo final {
21752175 using OptionalTypePosition = OptionalEnum<decltype (TypePosition::Covariant)>;
21762176
21772177public:
2178+ // / Whether the uncurried interface type of the declaration, stipped of any
2179+ // / optionality, is a direct reference to the generic parameter at hand. For
2180+ // / example, "func foo(x: Int) -> () -> Self?" has a covariant 'Self' result.
21782181 bool hasCovariantSelfResult;
21792182
21802183 OptionalTypePosition selfRef;
@@ -2185,6 +2188,12 @@ class GenericParameterReferenceInfo final {
21852188 return GenericParameterReferenceInfo (false , position, llvm::None);
21862189 }
21872190
2191+ // / A reference to the generic parameter in covariant result position.
2192+ static GenericParameterReferenceInfo forCovariantResult () {
2193+ return GenericParameterReferenceInfo (true , TypePosition::Covariant,
2194+ llvm::None);
2195+ }
2196+
21882197 // / A reference to 'Self' through an associated type.
21892198 static GenericParameterReferenceInfo forAssocTypeRef (TypePosition position) {
21902199 return GenericParameterReferenceInfo (false , llvm::None, position);
@@ -2685,13 +2694,14 @@ class ValueDecl : public Decl {
26852694 // / that this declaration dynamically replaces.
26862695 ValueDecl *getDynamicallyReplacedDecl () const ;
26872696
2688- // / Report 'Self' references within the type of this declaration as a
2689- // / member of the given existential base type.
2697+ // / Find references to 'Self' in the type signature of this declaration in the
2698+ // / context of the given existential base type.
26902699 // /
2691- // / \param treatNonResultCovariantSelfAsInvariant If true, 'Self' or 'Self?'
2692- // / is considered covariant only when it appears as the immediate type of a
2693- // / property, or the uncurried result type of a method/subscript, e.g.
2694- // / '() -> () -> Self'.
2700+ // / \param treatNonResultCovariantSelfAsInvariant When set, covariant 'Self'
2701+ // / references that are not in covariant result type position are considered
2702+ // / invariant. This position is the uncurried interface type of a declaration,
2703+ // / stipped of any optionality. For example, this is true for 'Self' in
2704+ // / 'func foo(Int) -> () -> Self?'.
26952705 GenericParameterReferenceInfo findExistentialSelfReferences (
26962706 Type baseTy, bool treatNonResultCovariantSelfAsInvariant) const ;
26972707};
@@ -7885,8 +7895,11 @@ class MissingMemberDecl : public Decl {
78857895 }
78867896};
78877897
7888- // / Find references to the given generic paramaeter in the generic signature
7889- // / and the type of the given value.
7898+ // / Find references to the given generic paramater in the type signature of the
7899+ // / given declaration using the given generic signature.
7900+ // /
7901+ // / \param skipParamIndex If the value is a function or subscript declaration,
7902+ // / specifies the index of the parameter that shall be skipped.
78907903GenericParameterReferenceInfo findGenericParameterReferences (
78917904 const ValueDecl *value,
78927905 CanGenericSignature sig, GenericTypeParamType *genericParam,
0 commit comments