[CS] Don't favor based on tuple element types

Previously this check was guarding against this
case, however with the argument list refactoring,
it's now possible for regular tuples to have
ApplyExpr parents. As such, broaden the check to
handle any tuple expr.
This commit is contained in:
Hamish Knight
2021-11-08 13:16:31 +00:00
parent 9c5e5efc9e
commit 691da86383
2 changed files with 17 additions and 3 deletions

View File

@@ -238,10 +238,9 @@ namespace {
return { false, expr };
}
// For exprs of a structural type that are not modeling argument lists,
// avoid merging the type variables. (We need to allow for cases like
// For exprs of a tuple, avoid favoring. (We need to allow for cases like
// (Int, Int32).)
if (isa<TupleExpr>(expr) && !isa<ApplyExpr>(Parent.getAsExpr())) {
if (isa<TupleExpr>(expr)) {
return { false, expr };
}

View File

@@ -58,3 +58,18 @@ struct S4 {
_ = S4() // expected-error {{ambiguous use of 'init'}}
}
}
infix operator ^^^
func ^^^ (lhs: (Int, Int), rhs: Int) -> Int { 0 } // expected-note {{found this candidate}}
func ^^^ (lhs: (Int, Int), rhs: Int) -> String { "" } // expected-note {{found this candidate}}
// We shouldn't favor based on the type of a tuple element.
struct S5 {
init(_ x: Int) {}
init(_ x: String) {}
func testFavoring() {
let x = 0
_ = S5((x, 0) ^^^ 0) // expected-error {{ambiguous use of operator '^^^'}}
}
}