Skip to content

Commit 96822b1

Browse files
committed
Sema: Add some comments
1 parent b362174 commit 96822b1

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,49 @@ namespace {
6969
/// generic requirements. See the \c Witness class for more information about
7070
/// this synthetic environment.
7171
class RequirementEnvironment {
72+
/// A generic signature that combines the generic parameters of the
73+
/// concrete conforming type with the generic parameters of the
74+
/// requirement.
75+
///
76+
///
77+
/// For example, if you have:
78+
///
79+
/// protocol P { func f<T>(_: T) }
80+
/// struct S<A, B> : P { func f<T>(_: T) }
81+
///
82+
/// The requirement and witness signatures are, respectively:
83+
///
84+
/// <Self : P, T>
85+
/// <A, B, T>
86+
///
87+
/// The synthetic signature in this case is just the witness signature.
88+
///
89+
/// It may be that the witness is more generic than the requirement,
90+
/// for example:
91+
///
92+
/// protocol P { func f(_: Int) }
93+
/// struct S<A, B> : P { func f<T>(_: T) { } }
94+
///
95+
/// Here, the requirement signature and witness signatures are:
96+
///
97+
/// <Self : P>
98+
/// <A, B, T>
99+
///
100+
/// The synthetic signature is just:
101+
///
102+
/// <A, B>
103+
///
104+
/// The witness thunk emitted by SILGen uses the synthetic signature.
105+
/// Therefore one invariant we preserve is that the witness thunk is
106+
/// ABI compatible with the requirement's function type.
72107
GenericSignature *syntheticSignature = nullptr;
73108
GenericEnvironment *syntheticEnvironment = nullptr;
109+
110+
/// The generic signature of the protocol requirement member.
74111
GenericSignature *reqSig = nullptr;
112+
113+
/// A substitution map mapping the requirement signature to the
114+
/// generic parameters of the synthetic signature.
75115
SubstitutionMap reqToSyntheticEnvMap;
76116

77117
public:

0 commit comments

Comments
 (0)