mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Completion] Map failable initializer result type into context
Make sure we don't pass an interface type to `setTypeContext`. rdar://155038769
This commit is contained in:
@@ -901,7 +901,7 @@ static void addKeywordsAfterReturn(CodeCompletionResultSink &Sink, DeclContext *
|
|||||||
// Note that `TypeContext` must stay alive for the duration of
|
// Note that `TypeContext` must stay alive for the duration of
|
||||||
// `~CodeCodeCompletionResultBuilder()`.
|
// `~CodeCodeCompletionResultBuilder()`.
|
||||||
ExpectedTypeContext TypeContext;
|
ExpectedTypeContext TypeContext;
|
||||||
TypeContext.setPossibleTypes({resultType});
|
TypeContext.setPossibleTypes({DC->mapTypeIntoContext(resultType)});
|
||||||
|
|
||||||
CodeCompletionResultBuilder Builder(Sink, CodeCompletionResultKind::Literal,
|
CodeCompletionResultBuilder Builder(Sink, CodeCompletionResultKind::Literal,
|
||||||
SemanticContextKind::None);
|
SemanticContextKind::None);
|
||||||
|
|||||||
@@ -377,6 +377,11 @@ struct InInit {
|
|||||||
init?() { #^IN_INIT_1?check=KW_DECL_STMT;check=KW_RETURN;check=KW_NO_IN^# }
|
init?() { #^IN_INIT_1?check=KW_DECL_STMT;check=KW_RETURN;check=KW_NO_IN^# }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct InGenericTypeInit<T> {
|
||||||
|
init?() { return #^IN_INIT_2?check=KW_FAILABLE_INIT_NIL^# }
|
||||||
|
// KW_FAILABLE_INIT_NIL: Literal[Nil]/None: nil[#InGenericTypeInit<T>?#]; name=nil
|
||||||
|
}
|
||||||
|
|
||||||
struct InStruct {
|
struct InStruct {
|
||||||
#^IN_NOMINAL_DECL_1?check=KW_DECL_TYPECONTEXT;check=KW_NO_INOUT^#
|
#^IN_NOMINAL_DECL_1?check=KW_DECL_TYPECONTEXT;check=KW_NO_INOUT^#
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
// {"kind":"complete","signature":"swift::ide::CodeCompletionResultType::calculateTypeRelation(swift::ide::ExpectedTypeContext const*, swift::DeclContext const*, swift::ide::USRBasedTypeContext const*) const"}
|
||||||
|
// RUN: %target-swift-ide-test -code-completion --code-completion-token=COMPLETE -source-filename %s
|
||||||
|
class a<b { init ? { #^COMPLETE^#
|
||||||
Reference in New Issue
Block a user