mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CodeCompletion] Don’t crash if constructors in member lookup have an error type
This commit is contained in:
@@ -9171,12 +9171,17 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
|
||||
|
||||
// Only try and favor monomorphic unary initializers.
|
||||
if (!ctor->isGenericContext()) {
|
||||
auto args = ctor->getMethodInterfaceType()
|
||||
->castTo<FunctionType>()->getParams();
|
||||
if (args.size() == 1 && !args[0].hasLabel() &&
|
||||
args[0].getPlainType()->isEqual(favoredType)) {
|
||||
if (!isDeclUnavailable(decl, memberLocator))
|
||||
result.FavoredChoice = result.ViableCandidates.size();
|
||||
if (!ctor->getMethodInterfaceType()->hasError()) {
|
||||
// The constructor might have an error type because we don't skip
|
||||
// invalid decls for code completion
|
||||
auto args = ctor->getMethodInterfaceType()
|
||||
->castTo<FunctionType>()
|
||||
->getParams();
|
||||
if (args.size() == 1 && !args[0].hasLabel() &&
|
||||
args[0].getPlainType()->isEqual(favoredType)) {
|
||||
if (!isDeclUnavailable(decl, memberLocator))
|
||||
result.FavoredChoice = result.ViableCandidates.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user