Skip to content

Sema: Fix crash when property type references type alias with unsatisfied requirements #29544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions lib/Sema/TypeCheckType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1463,10 +1463,6 @@ static Type resolveNestedIdentTypeComponent(
inferredAssocType);
}

// At this point, we need to have resolved the type of the member.
if (memberType->hasError())
return memberType;

// If there are generic arguments, apply them now.
return applyGenericArguments(memberType, resolution, comp, options);
};
Expand Down
12 changes: 12 additions & 0 deletions test/Constraints/conditionally_defined_types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,15 @@ let _ = Conforms<X>.Decl4<Z2>.Decl2.self // expected-error {{type 'Z2.T' (aka 'Y
let _ = Conforms<X>.Decl4<Z2>.Decl3.self // expected-error {{type 'Z2.T' (aka 'Y') does not conform to protocol 'P'}}
let _ = Conforms<X>.Decl4<Z2>.Decl4<X>.self // expected-error {{type 'Z2.T' (aka 'Y') does not conform to protocol 'P'}}
let _ = Conforms<X>.Decl4<Z2>.Decl5<X>.self // expected-error {{type 'Z2.T' (aka 'Y') does not conform to protocol 'P'}}

// rdar://problem/45271663
protocol PP { associatedtype V }
struct SS<PI : PP> {}
enum EE<A, B> {}
extension EE : PP where A : PP, B : PP { typealias V = EE<A.V, B.V> }

protocol P2 { associatedtype U }
func f<PI : PP & P2>(s: SS<PI>) -> SS<EE<PI.U, PI.U>> where PI.U : PP, PI.V : P2 {
let t: EE<PI.V.U, PI.V.U>.V
// expected-error@-1 {{type 'PI.V.U' does not conform to protocol 'PP'}}
}