Commit Graph

7 Commits

Author SHA1 Message Date
Rintaro Ishizaki
6cbdca43ce [Sema] Remove LeaveFunctionBodyUnchecked flag from DeclChecker
At least for now, ide::typeCheckContextAt() doesn't call
'typeCheckASTNodeAtLoc()' with function decl signature position.
Also, 'getIntefaceType()' on function reference doesn't call decl
checker. So we don't need to propagate it.
2020-07-24 10:48:51 -07:00
Rintaro Ishizaki
12762a2a30 [CodeCompletion] Only type check related statements in function body
Introduce 'TypeCheckSingleASTNode' mode that only type checks single body
element and dependent necessities (i.e. referencing ValueDecls and their
dependencies).

Renamed swift::typeCheckAbstractFunctionBodyAtLoc() to
swift::typeCheckASTNodeAtLoc(DeclContext *, SourceLoc). That type checks
innermost 'ASTNode' at the location. Also, 'TypeCheckSingleASTNode' mode
skips type checking any "body" of the node (i.e. BraceStmt elements for
function body, if statement body, closure body, etc.)

Added on-demand type checking using it:
 - VarDecl in TapExpr
 - ParamDecl in ClosureExpr
 - Return type of ClosureExpr
 - Binding value in control statements
   (e.g. ForEachStmt, SwitchStmt, DoCatchStmt, etc.)

rdar://problem/63932852
2020-07-24 10:48:51 -07:00
Rintaro Ishizaki
3ec250f701 [CodeCompletion] Wrap base expression with CodeCompletionExpr
For example for:

  funcName(base.<HERE>)

Wrap 'base' with 'CodeCompletionExpr' so that type checker can check
'base' independently without preventing the overload choice of 'funcName'.

This increases the chance of successful type checking.

rdar://problem/63965160
2020-06-05 15:51:07 -07:00
Rintaro Ishizaki
36123a7ed3 Update a test case 2020-06-01 12:36:39 -07:00
Rintaro Ishizaki
6c61e605f2 [CodeCompletion] Skip typechecking preceding top level decls 2020-05-29 14:45:04 -07:00
Rintaro Ishizaki
a22fd6fc41 [TypeChecker] Typecheck statement condition on demand
from NamingPatternRequest.
2020-05-29 14:45:04 -07:00
Rintaro Ishizaki
3e200b7783 [CodeCompletion] Skip typechecking unrelated statements in func bodies
rdar://problem/58687608
2020-05-29 14:45:04 -07:00