mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CSOptimizer] Use conformsToKnownProtocol to check whether parameter conforms to ExpressibleBy{Array, Dictionary}Literal
The existing check is no-op because it would never produce a null for `paramType` under the conditions in `else` branch. A better API it use here is `conformsToKnownProtocol` just like in other cases.
This commit is contained in:
@@ -1316,27 +1316,20 @@ static void determineBestChoicesInContext(
|
||||
return 0.3;
|
||||
}
|
||||
|
||||
auto &ctx = cs.getASTContext();
|
||||
|
||||
// Check if the other side conforms to `ExpressibleByArrayLiteral`
|
||||
// protocol (in some way). We want an overly optimistic result
|
||||
// here to avoid under-favoring.
|
||||
if (candidateType->isArray() &&
|
||||
checkConformanceWithoutContext(
|
||||
paramType,
|
||||
ctx.getProtocol(KnownProtocolKind::ExpressibleByArrayLiteral),
|
||||
/*allowMissing=*/true))
|
||||
TypeChecker::conformsToKnownProtocol(
|
||||
paramType, KnownProtocolKind::ExpressibleByArrayLiteral))
|
||||
return 0.3;
|
||||
|
||||
// Check if the other side conforms to
|
||||
// `ExpressibleByDictionaryLiteral` protocol (in some way).
|
||||
// We want an overly optimistic result here to avoid under-favoring.
|
||||
if (candidateType->isDictionary() &&
|
||||
checkConformanceWithoutContext(
|
||||
paramType,
|
||||
ctx.getProtocol(
|
||||
KnownProtocolKind::ExpressibleByDictionaryLiteral),
|
||||
/*allowMissing=*/true))
|
||||
TypeChecker::conformsToKnownProtocol(
|
||||
paramType, KnownProtocolKind::ExpressibleByDictionaryLiteral))
|
||||
return 0.3;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user