mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[CodeCompletion] Don’t crash if constructors in member lookup have an error type
This commit is contained in:
@@ -9171,8 +9171,12 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
|
||||
|
||||
// Only try and favor monomorphic unary initializers.
|
||||
if (!ctor->isGenericContext()) {
|
||||
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();
|
||||
->castTo<FunctionType>()
|
||||
->getParams();
|
||||
if (args.size() == 1 && !args[0].hasLabel() &&
|
||||
args[0].getPlainType()->isEqual(favoredType)) {
|
||||
if (!isDeclUnavailable(decl, memberLocator))
|
||||
@@ -9180,6 +9184,7 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const auto isUnsupportedExistentialMemberAccess = [&] {
|
||||
// We may not be able to derive a well defined type for an existential
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// Make sure we don't crash
|
||||
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token COMPLETE
|
||||
|
||||
public struct AnyError {
|
||||
|
||||
public init(_ error: Swift.
|
||||
|
||||
extension AnyError {
|
||||
public static func error(from error: Error) -> AnyError {
|
||||
return AnyError(error)#^COMPLETE^#
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user