Strongly prefer available declarations to unavailable ones in type checking.

Fixes rdar://problem/18847642, rdar://problem/16554496, and the
current 1_stdlib/Array.swift.

Swift SVN r25212
This commit is contained in:
Doug Gregor
2015-02-12 01:01:11 +00:00
parent 26ee4c324b
commit 0e74268ea5
6 changed files with 36 additions and 12 deletions

View File

@@ -37,7 +37,11 @@ void ConstraintSystem::increaseScore(ScoreKind kind) {
log.indent(solverState->depth * 2);
log << "(increasing score due to ";
switch (kind) {
case SK_Fix:
case SK_Unavailable:
log << "use of an unavailable declaration";
break;
case SK_Fix:
log << "attempting to fix the source";
break;
@@ -671,17 +675,6 @@ SolutionCompareResult ConstraintSystem::compareSolutions(
}
}
// If one declaration is available and the other is not,
bool unavail1 = decl1->getAttrs().isUnavailable(cs.getASTContext());
bool unavail2 = decl2->getAttrs().isUnavailable(cs.getASTContext());
if (unavail1 != unavail2) {
if (unavail1)
++score2;
else
++score1;
continue;
}
// If both declarations come from Clang, and one is a type and the other
// is a function, prefer the function.
if (decl1->hasClangNode() &&