@@ -2171,6 +2171,9 @@ class GenericParameterReferenceInfo final {
2171
2171
using OptionalTypePosition = OptionalEnum<decltype (TypePosition::Covariant)>;
2172
2172
2173
2173
public:
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.
2174
2177
bool hasCovariantSelfResult;
2175
2178
2176
2179
OptionalTypePosition selfRef;
@@ -2181,6 +2184,12 @@ class GenericParameterReferenceInfo final {
2181
2184
return GenericParameterReferenceInfo (false , position, llvm::None);
2182
2185
}
2183
2186
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
+
2184
2193
// / A reference to 'Self' through an associated type.
2185
2194
static GenericParameterReferenceInfo forAssocTypeRef (TypePosition position) {
2186
2195
return GenericParameterReferenceInfo (false , llvm::None, position);
@@ -2681,13 +2690,14 @@ class ValueDecl : public Decl {
2681
2690
// / that this declaration dynamically replaces.
2682
2691
ValueDecl *getDynamicallyReplacedDecl () const ;
2683
2692
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.
2686
2695
// /
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?'.
2691
2701
GenericParameterReferenceInfo findExistentialSelfReferences (
2692
2702
Type baseTy, bool treatNonResultCovariantSelfAsInvariant) const ;
2693
2703
};
@@ -7948,8 +7958,11 @@ class MissingMemberDecl : public Decl {
7948
7958
}
7949
7959
};
7950
7960
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.
7953
7966
GenericParameterReferenceInfo findGenericParameterReferences (
7954
7967
const ValueDecl *value,
7955
7968
CanGenericSignature sig, GenericTypeParamType *genericParam,
0 commit comments