File tree Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Expand file tree Collapse file tree 2 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -836,8 +836,12 @@ void ConstraintSystem::shrink(Expr *expr) {
836
836
return expr;
837
837
}
838
838
839
- // Or it's a function application with other candidates present.
840
- if (isa<ApplyExpr>(expr)) {
839
+ // Or it's a function application or assignment with other candidates
840
+ // present. Assignment should be easy to solve because we'd get a
841
+ // contextual type from the destination expression, otherwise shrink
842
+ // might produce incorrect results without considering aforementioned
843
+ // destination type.
844
+ if (isa<ApplyExpr>(expr) || isa<AssignExpr>(expr)) {
841
845
Candidates.push_back (Candidate (CS, PrimaryExpr));
842
846
return expr;
843
847
}
Original file line number Diff line number Diff line change @@ -770,3 +770,26 @@ func rdar_50007727() {
770
770
// expected-error@-1 {{generic parameter 'T' could not be inferred in cast to 'A.B'}}
771
771
// expected-note@-2 {{explicitly specify the generic arguments to fix this issue}} {{12-12=<Any>}}
772
772
}
773
+
774
+ // rdar://problem/51413254
775
+
776
+ infix operator ==>
777
+
778
+ struct Key {
779
+ init ( _ key: String ) { }
780
+ }
781
+
782
+ func ==> ( lhs: Any , rhs: Key ) throws -> Any {
783
+ return 0
784
+ }
785
+
786
+ func ==> < A> ( lhs: Any , rhs: Key ) throws -> A {
787
+ fatalError ( )
788
+ }
789
+
790
+ struct R_51413254 {
791
+ var str : String = " "
792
+ mutating func test( _ anyDict: Any ) throws {
793
+ self . str = try anyDict ==> Key ( " a " ) // Ok
794
+ }
795
+ }
You can’t perform that action at this time.
0 commit comments