You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[CSFix] Check for constrained associated types via generic signature
Instead of checking for presence of `where` clause, let's use
requirement signature and check whether any of the requires are
anchored on a particular associated type.
Copy file name to clipboardExpand all lines: test/decl/protocol/existential_member_accesses_self_assoctype.swift
+2-3Lines changed: 2 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -694,7 +694,7 @@ protocol MiscTestsProto {
694
694
do{
695
695
func miscTests(_ arg:anyMiscTestsProto){
696
696
varr:anySequence&IteratorProtocol= arg.getR()
697
-
r.makeIterator() // expected-warning {{result of call to 'makeIterator()' is unused}}
697
+
r.makeIterator() // expected-error {{inferred result type 'any IteratorProtocol' requires explicit coercion due to loss of generic requirements}} {{19-19=as any IteratorProtocol}}
698
698
r.next() // expected-warning {{result of call to 'next()' is unused}}
699
699
r.nonexistent() // expected-error {{value of type 'any IteratorProtocol & Sequence' has no member 'nonexistent'}}
700
700
@@ -786,8 +786,7 @@ do {
786
786
_ = arg.method3 // expected-error {{member 'method3' cannot be used on value of type 'any ConcreteAssocTypes'; consider using a generic constraint instead}}
787
787
_ = arg.property1 // expected-error {{member 'property1' cannot be used on value of type 'any ConcreteAssocTypes'; consider using a generic constraint instead}}
788
788
// Covariant 'Self' erasure works in conjunction with concrete associated types.
789
-
let _:(Bool,anyConcreteAssocTypes)= arg.property2 // expected-error {{inferred result type '(Bool, any ConcreteAssocTypes)' requires explicit coercion due to loss of generic requirements}} {{58-58=as (Bool, any ConcreteAssocTypes)}}
790
-
let _:(Bool,anyConcreteAssocTypes)= arg.property2 as(Bool,anyConcreteAssocTypes) // Ok
789
+
let _:(Bool,anyConcreteAssocTypes)= arg.property2 // ok
791
790
_ = arg.property3 // expected-error {{member 'property3' cannot be used on value of type 'any ConcreteAssocTypes'; consider using a generic constraint instead}}
792
791
_ =arg[subscript1:false] // expected-error {{member 'subscript' cannot be used on value of type 'any ConcreteAssocTypes'; consider using a generic constraint instead}}
793
792
_ =arg[subscript2:false] // expected-error {{member 'subscript' cannot be used on value of type 'any ConcreteAssocTypes'; consider using a generic constraint instead}}
0 commit comments