Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/Sema/CSSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,8 +836,12 @@ void ConstraintSystem::shrink(Expr *expr) {
return expr;
}

// Or it's a function application with other candidates present.
if (isa<ApplyExpr>(expr)) {
// Or it's a function application or assignment with other candidates
// present. Assignment should be easy to solve because we'd get a
// contextual type from the destination expression, otherwise shrink
// might produce incorrect results without considering aforementioned
// destination type.
if (isa<ApplyExpr>(expr) || isa<AssignExpr>(expr)) {
Candidates.push_back(Candidate(CS, PrimaryExpr));
return expr;
}
Expand Down
23 changes: 23 additions & 0 deletions test/Constraints/generics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -770,3 +770,26 @@ func rdar_50007727() {
// expected-error@-1 {{generic parameter 'T' could not be inferred in cast to 'A.B'}}
// expected-note@-2 {{explicitly specify the generic arguments to fix this issue}} {{12-12=<Any>}}
}

// rdar://problem/51413254

infix operator ==>

struct Key {
init(_ key: String) {}
}

func ==> (lhs: Any, rhs: Key) throws -> Any {
return 0
}

func ==> <A>(lhs: Any, rhs: Key) throws -> A {
fatalError()
}

struct R_51413254 {
var str: String = ""
mutating func test(_ anyDict: Any) throws {
self.str = try anyDict ==> Key("a") // Ok
}
}