@@ -2171,6 +2171,9 @@ class GenericParameterReferenceInfo final {
21712171 using OptionalTypePosition = OptionalEnum<decltype (TypePosition::Covariant)>;
21722172
21732173public:
2174+ // / Whether the uncurried interface type of the declaration, stipped of any
2175+ // / optionality, is a direct reference to the generic parameter at hand. For
2176+ // / example, "func foo(x: Int) -> () -> Self?" has a covariant 'Self' result.
21742177 bool hasCovariantSelfResult;
21752178
21762179 OptionalTypePosition selfRef;
@@ -2181,6 +2184,12 @@ class GenericParameterReferenceInfo final {
21812184 return GenericParameterReferenceInfo (false , position, llvm::None);
21822185 }
21832186
2187+ // / A reference to the generic parameter in covariant result position.
2188+ static GenericParameterReferenceInfo forCovariantResult () {
2189+ return GenericParameterReferenceInfo (true , TypePosition::Covariant,
2190+ llvm::None);
2191+ }
2192+
21842193 // / A reference to 'Self' through an associated type.
21852194 static GenericParameterReferenceInfo forAssocTypeRef (TypePosition position) {
21862195 return GenericParameterReferenceInfo (false , llvm::None, position);
@@ -2681,13 +2690,14 @@ class ValueDecl : public Decl {
26812690 // / that this declaration dynamically replaces.
26822691 ValueDecl *getDynamicallyReplacedDecl () const ;
26832692
2684- // / Report 'Self' references within the type of this declaration as a
2685- // / member of the given existential base type.
2693+ // / Find references to 'Self' in the type signature of this declaration in the
2694+ // / context of the given existential base type.
26862695 // /
2687- // / \param treatNonResultCovariantSelfAsInvariant If true, 'Self' or 'Self?'
2688- // / is considered covariant only when it appears as the immediate type of a
2689- // / property, or the uncurried result type of a method/subscript, e.g.
2690- // / '() -> () -> Self'.
2696+ // / \param treatNonResultCovariantSelfAsInvariant When set, covariant 'Self'
2697+ // / references that are not in covariant result type position are considered
2698+ // / invariant. This position is the uncurried interface type of a declaration,
2699+ // / stipped of any optionality. For example, this is true for 'Self' in
2700+ // / 'func foo(Int) -> () -> Self?'.
26912701 GenericParameterReferenceInfo findExistentialSelfReferences (
26922702 Type baseTy, bool treatNonResultCovariantSelfAsInvariant) const ;
26932703};
@@ -7948,8 +7958,11 @@ class MissingMemberDecl : public Decl {
79487958 }
79497959};
79507960
7951- // / Find references to the given generic paramaeter in the generic signature
7952- // / and the type of the given value.
7961+ // / Find references to the given generic paramater in the type signature of the
7962+ // / given declaration using the given generic signature.
7963+ // /
7964+ // / \param skipParamIndex If the value is a function or subscript declaration,
7965+ // / specifies the index of the parameter that shall be skipped.
79537966GenericParameterReferenceInfo findGenericParameterReferences (
79547967 const ValueDecl *value,
79557968 CanGenericSignature sig, GenericTypeParamType *genericParam,
0 commit comments