Fix assertion failure code completing after nil literal

We were asserting (and doing the wrong thing) when trying to code
complete
    nil #^HERE^#

The issue is that we tried to apply a solution to the expression that
contained free type variables (converted to generic parameters). This
trips us up when we expect the new type to conform to protocols. In code
completion we generally only need the type of the expression, so this
commit switches to getting that more explicitly.  That said, this did
cause us to drop non-API parameter names in call patterns after an
opening '(' in some cases (covered by rdar://20962472).

Thanks to Doug for suggesting this solution!

rdar://problem/20891867

Swift SVN r28584
This commit is contained in:
Ben Langmuir
2015-05-14 22:22:37 +00:00
parent 5685121505
commit 69fdca43da
7 changed files with 176 additions and 50 deletions

View File

@@ -33,11 +33,18 @@ namespace swift {
/// \returns true on success, false on error.
bool typeCheckCompletionDecl(Decl *D);
/// \brief Typecheck an expression parsed during code completion.
/// \brief Return the type of an expression parsed during code completion, or
/// None on error.
Optional<Type> getTypeOfCompletionContextExpr(ASTContext &Ctx,
DeclContext *DC,
Expr *&parsedExpr);
/// \brief Typecheck a single parsed expression.
///
/// \returns true on success, false on error.
bool typeCheckCompletionContextExpr(ASTContext &Ctx, DeclContext *DC,
Expr *&parsedExpr);
// FIXME: this is not used by code completion; we should probably move it.
bool typeCheckContextExpr(ASTContext &Ctx, DeclContext *DC,
Expr *&parsedExpr);
/// Partially typecheck the specified function body.
bool typeCheckAbstractFunctionBodyUntil(AbstractFunctionDecl *AFD,