Skip to content

[ConstraintSystem] Order VarDecls before other kinds of decls in disjunctions. #72755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 3, 2024
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
12 changes: 12 additions & 0 deletions lib/Sema/CSSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2365,6 +2365,18 @@ void DisjunctionChoiceProducer::partitionDisjunction(
return true;
}

// Order VarDecls before other kinds of declarations because they are
// effectively favored over functions when the two are in the same
// overload set. This disjunction order allows SK_UnappliedFunction
// to prune later overload choices that are functions when a solution
// has already been found with a property.
if (auto *decl = getOverloadChoiceDecl(constraint)) {
if (isa<VarDecl>(decl)) {
everythingElse.push_back(index);
return true;
}
}

return false;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,23 @@ struct DatabaseLog {
}
}

extension Sequence {
public func count(
where predicate: (Element) throws -> Bool
) rethrows -> Int { 0 }
}


func rdar47742750(arr1: [Int], arr2: [Int]?) {
let _ = {
assert(arr1.count == arr1.count + (arr2 == nil ? 0 : 1 + arr2!.count + arr2!.count + arr2!.count))
}
}

func f(
a: String?,
b: String?,
c: Int,
d: String?,
e: String?
) -> Int {
return (a?.unicodeScalars.count ?? 0) +
(b?.unicodeScalars.count ?? 0) +
c +
(d?.unicodeScalars.count ?? 0) +
(e?.unicodeScalars.count ?? 0)
}