Skip to content

Commit fd1e248

Browse files
Suyash SrijanSuyash Srijan
authored andcommitted
[test] add new tests
1 parent a8698d7 commit fd1e248

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4629,6 +4629,10 @@ ConstraintResult GenericSignatureBuilder::addTypeRequirement(
46294629
->getDependentType(getGenericParams());
46304630

46314631
Impl->HadAnyError = true;
4632+
4633+
if (subjectType->is<DependentMemberType>()) {
4634+
subjectType = resolveDependentMemberTypes(*this, subjectType);
4635+
}
46324636

46334637
auto invalidConstraint = InvalidConstraint(
46344638
subjectType, constraintType, source.getSource(*this, subjectType));

test/Constraints/generics.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,3 +668,12 @@ func SR_7984_F<T: Sequence>(foo: T) where T.Element: String {} // expected-error
668668
protocol SR_7984_P {
669669
func S<T : Sequence>(bar: T) where T.Element: String // expected-error {{type 'T.Element' constrained to non-protocol, non-class type 'String'}} expected-note {{use 'T.Element == String' to require 'T.Element' to be 'String'}} {{47-48= ==}}
670670
}
671+
672+
struct A<T: String> {} // expected-error {{type 'T' constrained to non-protocol, non-class type 'String'}}
673+
struct B<T> where T: String {} // expected-error {{type 'T' constrained to non-protocol, non-class type 'String'}}
674+
protocol C {
675+
associatedtype Foo: String // expected-error {{inheritance from non-protocol, non-class type 'String'}} expected-error {{type 'Self.Foo' constrained to non-protocol, non-class type 'String'}}
676+
}
677+
protocol D {
678+
associatedtype Foo where Foo: String // expected-error {{type 'Self.Foo' constrained to non-protocol, non-class type 'String'}}
679+
}

0 commit comments

Comments
 (0)