Skip to content

Commit 54883e8

Browse files
committed
Sema: Fix type lookup from protocol extensions with a class-constrained 'Self'
A protocol extension can add additional generic constraints on 'Self' or associated types thereof. In particular, 'Self' itself can have a superclass constraint placed on it. There were a couple of problems with this corner case: - Type aliases defined in protocols that 'Self' conforms to _as a concrete type_ to were not handled properly, triggering an assertion. For example, protocol P { typealias T = ... } class C : P {} protocol Q {} extension Q where Self : C { ... T ... } The conformance o P comes from the 'Self : C' constraint. - If the type was found in a superclass of 'Self', we used the wrong base type for the substitution. For example, protocol P {} class C<T> { typealias A = T } class D : C<Int> {} extension P where Self : D { ... A ... } The substituted type of 'A' should be computed with a self type of C<Int> here. Also, take another stab at cleaning up the mess that is resolveTypeInContext() and related bits of code.
1 parent 819dfd5 commit 54883e8

File tree

2 files changed

+206
-97
lines changed

2 files changed

+206
-97
lines changed

0 commit comments

Comments
 (0)