Skip to content

Commit f4a5301

Browse files
committed
Sema: Fix crash when property type references type alias with unsatisfied requirements
The fix for <https://bugs.swift.org/browse/SR-10466> did not handle properties because those types are resolved using the archetype resolver. We would bail out early because of a bogus early return that can just be removed. Fixes <rdar://problem/45271663>.
1 parent 6f6d786 commit f4a5301

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/Sema/TypeCheckType.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1463,10 +1463,6 @@ static Type resolveNestedIdentTypeComponent(
14631463
inferredAssocType);
14641464
}
14651465

1466-
// At this point, we need to have resolved the type of the member.
1467-
if (memberType->hasError())
1468-
return memberType;
1469-
14701466
// If there are generic arguments, apply them now.
14711467
return applyGenericArguments(memberType, resolution, comp, options);
14721468
};

test/Constraints/conditionally_defined_types.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,15 @@ let _ = Conforms<X>.Decl4<Z2>.Decl2.self // expected-error {{type 'Z2.T' (aka 'Y
222222
let _ = Conforms<X>.Decl4<Z2>.Decl3.self // expected-error {{type 'Z2.T' (aka 'Y') does not conform to protocol 'P'}}
223223
let _ = Conforms<X>.Decl4<Z2>.Decl4<X>.self // expected-error {{type 'Z2.T' (aka 'Y') does not conform to protocol 'P'}}
224224
let _ = Conforms<X>.Decl4<Z2>.Decl5<X>.self // expected-error {{type 'Z2.T' (aka 'Y') does not conform to protocol 'P'}}
225+
226+
// rdar://problem/45271663
227+
protocol PP { associatedtype V }
228+
struct SS<PI : PP> {}
229+
enum EE<A, B> {}
230+
extension EE : PP where A : PP, B : PP { typealias V = EE<A.V, B.V> }
231+
232+
protocol P2 { associatedtype U }
233+
func f<PI : PP & P2>(s: SS<PI>) -> SS<EE<PI.U, PI.U>> where PI.U : PP, PI.V : P2 {
234+
let t: EE<PI.V.U, PI.V.U>.V
235+
// expected-error@-1 {{type 'PI.V.U' does not conform to protocol 'PP'}}
236+
}

0 commit comments

Comments
 (0)