Skip to content

Commit 802f5cd

Browse files
committed
[CSOptimizer] Desugar types before checking for equality
1 parent 8d5cb11 commit 802f5cd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/Sema/CSOptimizer.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,11 +380,15 @@ static Constraint *determineBestChoicesInContext(
380380
scoreCandidateMatch = [&](GenericSignature genericSig,
381381
Type candidateType, Type paramType,
382382
MatchOptions options) -> double {
383+
auto areEqual = [](Type a, Type b) {
384+
return a->getDesugaredType()->isEqual(b->getDesugaredType());
385+
};
386+
383387
if (options.contains(MatchFlag::ExactOnly))
384-
return candidateType->isEqual(paramType) ? 1 : 0;
388+
return areEqual(candidateType, paramType) ? 1 : 0;
385389

386390
// Exact match between candidate and parameter types.
387-
if (candidateType->isEqual(paramType))
391+
if (areEqual(candidateType, paramType))
388392
return options.contains(MatchFlag::Literal) ? 0.3 : 1;
389393

390394
if (options.contains(MatchFlag::Literal))

0 commit comments

Comments
 (0)