Commit Graph

10 Commits

Author SHA1 Message Date
Alex Hoppen
32eff21977 [IDE] Remove "Begin completions" and "End completions" from test cases
These test lines weren't actually providing any value and were annoying to write. Let's jut remove them.
2023-03-22 09:07:17 -07:00
Alex Hoppen
20985eaecd [CodeCompletion] Don’t pass LeaveClosureBodiesUnchecked for solver-based code completion 2023-02-14 09:40:55 +01:00
Alex Hoppen
5d01a097e1 [CodeCompletion] Don't distinguish convertible and idenical type relation
I think that preferring identical over convertible makes sense in e.g. C++ where we have implicit user-defined type conversions but since we don’t have them in Swift, I think the distinction doesn’t make too much sense, because if we have a `func foo(x: Int?)`, want don’t really want to  prioritize variables of type `Int?` over `Int` Similarly if we have `func foo(x: View)`, we don’t want to prioritize a variable of type `View` over e.g. `Text`.

rdar://91349364
2022-04-13 08:28:17 +02:00
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