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 @@ -829,8 +829,12 @@ void ConstraintSystem::shrink(Expr *expr) {
829
829
return expr;
830
830
}
831
831
832
- // Or it's a function application with other candidates present.
833
- if (isa<ApplyExpr>(expr)) {
832
+ // Or it's a function application or assignment with other candidates
833
+ // present. Assignment should be easy to solve because we'd get a
834
+ // contextual type from the destination expression, otherwise shrink
835
+ // might produce incorrect results without considering aforementioned
836
+ // destination type.
837
+ if (isa<ApplyExpr>(expr) || isa<AssignExpr>(expr)) {
834
838
Candidates.push_back (Candidate (CS, PrimaryExpr));
835
839
return expr;
836
840
}
Original file line number Diff line number Diff line change @@ -750,3 +750,26 @@ func test_generic_subscript_with_missing_arg() {
750
750
_ = s [ 0 ] // expected-error {{generic parameter 'U' could not be inferred}}
751
751
}
752
752
}
753
+
754
+ // rdar://problem/51413254
755
+
756
+ infix operator ==>
757
+
758
+ struct Key {
759
+ init ( _ key: String ) { }
760
+ }
761
+
762
+ func ==> ( lhs: Any , rhs: Key ) throws -> Any {
763
+ return 0
764
+ }
765
+
766
+ func ==> < A> ( lhs: Any , rhs: Key ) throws -> A {
767
+ fatalError ( )
768
+ }
769
+
770
+ struct R_51413254 {
771
+ var str : String = " "
772
+ mutating func test( _ anyDict: Any ) throws {
773
+ self . str = try anyDict ==> Key ( " a " ) // Ok
774
+ }
775
+ }
You can’t perform that action at this time.
0 commit comments