Skip to content

Commit 8349615

Browse files
authored
Merge pull request #61714 from matklad/patch-1
Correct typo in generics.tex
2 parents d6e8123 + f5f8fa8 commit 8349615

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/Generics/generics.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3249,7 +3249,7 @@ \section{Requirement Signatures}\label{requirement sig}
32493249
\paragraph{Protocol inheritance clauses}
32503250
Recall from Section~\ref{protocols} that a constraint type written in a protocol's inheritance clause is equivalent to a \texttt{where} clause requirement with a subject type of \texttt{Self}, just like a constraint type in a generic parameter's inheritance clause is equivalent to a \texttt{where} clause requirement with the generic parameter type as the subject type. This correspondence comes with an important caveat, though.
32513251

3252-
Qualified name lookup into a protocol type must also look into inherited protocols and the protocol's superclass type, if there is one. However, name lookup can only look directly at syntactic constructs, because in the compiler implementation, name lookup is ``downstream'' of generics. Building a protocol's requirement signature performs type resolution, which queries name lookup; those name lookups cannot in turn depend on the requirement signature having already been constructed.
3252+
Qualified name lookup into a protocol type must also look into inherited protocols and the protocol's superclass type, if there is one. However, name lookup can only look directly at syntactic constructs, because in the compiler implementation, name lookup is ``upstream'' of generics. Building a protocol's requirement signature performs type resolution, which queries name lookup; those name lookups cannot in turn depend on the requirement signature having already been constructed.
32533253

32543254
For this reason, any \texttt{where} clause requirements which introduce protocol inheritance relationships must be written with a subject type of exactly \texttt{Self} for qualified name lookup to ``understand'' them. Protocol inheritance implied by some combination of same-type requirements is not allowed. After a protocol's requirement signature has been built, conformance requirements on \texttt{Self} are compared against the protocol's inheritance clause; any unexpected conformance requirements are diagnosed with a warning.
32553255

0 commit comments

Comments
 (0)