Commit Graph

767 Commits

Author SHA1 Message Date
Rintaro Ishizaki
c68157a27d [CodeCompletion] Remove unresolved type in prepareForRetypechecking()
Unresolved type attached to expressions may fail re-typechecking.
Also, disallow unresolved type in typeCheckCompletionSequence(). It doesn't
provide useful completions to developers.

rdar://problem/41224316
2018-08-15 20:39:12 +09:00
Slava Pestov
31a570d53c AST: Replace TypeBase::getRValueInstanceType() with getMetatypeInstanceType()
That is, don't look through InOutType anymore, and update callers to
call getInOutObjectType() as well (or not, where it was obvious to me
that InOutType could not appear).

This surfaces more remaining uses of getInOutObjectType() directly.
2018-08-13 21:13:10 -07:00
Rintaro Ishizaki
aac92da252 [CodeCompletion] Completion for UnresolvedMember via CodeCompletionExpr
Using dummy UnresolvedMemberExpr doesn't give us much benefit. Instead, use
CodeCompletionExpr which is type checked as type variable so can use
CodeCompletionTypeContextAnalyzer to infer context types.
This way, we can eliminate most of special logic for UnresolvedMember.

rdar://problem/39098974
2018-08-10 22:23:23 +09:00
Rintaro Ishizaki
254be25f4d Merge pull request #18564 from rintaro/ide-completion-contextanalysis
[CodeCompletion] Improve context type analysis
2018-08-10 10:53:44 +09:00
Rintaro Ishizaki
31f0f28236 [CodeCompletion] Guard for null interface type in calculateTypeRelationForDecl (#18591)
Fixes a crash.

https://bugs.swift.org/browse/SR-8470
rdar://problem/43057054
2018-08-10 10:51:45 +09:00
Rintaro Ishizaki
137ca6551b [CodeCompletion] Simplify getPositionInArgs()
* Don't need to look for CodeCompletionExpr. It's wrong anyway because
  what we are looking for is not neccessarily a 'CodeCompletionExpr'.
* Use getElementLoc(i).isValid() instead of !getElementName(i).empty().
  Just in case users write '_:' for call argument.
* Don't suggest argument labels for implicit call expression. For
  instance, string interpolation segments.
2018-08-09 19:49:43 +09:00
Rintaro Ishizaki
18582d3406 [CodeCompletion] Handle ExprPattern in context type analysis
This improves type inference for code completion in argument position of
EnumElementPattern.
2018-08-09 19:49:25 +09:00
Rintaro Ishizaki
c01eb93e9a [CodeCompletion][NFC] Use ASTWalker::ParentTy instead of ASTNode
in 'ExprParentFinder'. There's no reason to re-pack into ASTNode.
2018-08-09 19:48:23 +09:00
Rintaro Ishizaki
d898f6d664 [CodeCompletetion] Handle binary/unary expression in context type analyzer
Don't discard parsed expression in Parser. This improves type inference
for CodeCompletionExpr.
2018-08-09 19:48:23 +09:00
Rintaro Ishizaki
0dfbf76354 [CodeCompletion] Improve getReturnTypeFromContext()
* For methods, un-curry function interface type so we can get declared
return type.
* For closures, fall back to getting explicit result type in case we
cannot retrieve it from the type of closure itself.
2018-08-09 19:48:16 +09:00
Rintaro Ishizaki
4e1147df04 [IDE][gardening] Inline getPositionInTupleExpr() 2018-08-07 12:57:14 +09:00
Rintaro Ishizaki
f04be1457c [IDE][gardening] Inline overloaded collectArgumentExpectation 2018-08-07 12:57:14 +09:00
Rintaro Ishizaki
733e96b877 [IDE][gardening] Refactoring around collectArgumentExpectation() 2018-08-07 11:43:05 +09:00
Rintaro Ishizaki
46d418f232 [IDE][gardening] Factor out getPositionInArgs()
This function get the index of specified expression in the arguments.
2018-08-07 11:43:05 +09:00
Rintaro Ishizaki
81cae7309d [IDE][gardening] Rename collectionInputTypes()
To 'collectPossibleParamLists()'.
2018-08-07 11:43:05 +09:00
Rintaro Ishizaki
6088b794a8 [IDE][gardening] Removed unused function
The last usage have been removed in
c0f5711ee5.
2018-08-07 10:42:54 +09:00
Doug Gregor
3018becde7 [Type checker] Eliminate type checking from early extension binding.
Use ExtensionDecl::getExtendedNominal() to wire up extensions to their
nominal types early in type checking (the bindExtensions()) operation,
rather than going through type validation to do so.
2018-08-03 11:26:49 -07:00
Doug Gregor
792d934e3e [Clang importer] Avoid recursion through isObjC more directly.
Also address some review comments related to the name lookup requests.
2018-07-31 10:20:15 -07:00
Doug Gregor
d07fa5ab69 Switch many callers of ClassDecl::getSuperclass() to ClassDecl::getSuperclassDecl().
ClassDecl::getSuperclass() produces a complete interface type describing the
superclass of a class, including any generic arguments (for a generic type).
Most callers only need the referenced ClassDecl, which is (now) cheaper
to compute: switch those callers over to ClassDecl::getSuperclassDecl().

Fixes an existing test for SR-5993.
2018-07-31 10:14:44 -07:00
Pavel Yaskevich
0a404529c3 [Sema] Adjust Diagnostics/IDE to not assume that parameters always have types 2018-07-28 20:28:41 -07:00
Rintaro Ishizaki
9e7fa99689 [CodeComplete] Use PrintOptionalAsImplicitlyUnwrapped to print IUO
Other instances of fb9c65e. Consistently use
PrintOption.PrintOptionalAsImplicitlyUnwrapped to print IUO.

rdar://problem/41046225
rdar://problem/42443512
2018-07-26 07:55:25 +09:00
Rintaro Ishizaki
0547f1bcdc Merge pull request #18209 from rintaro/ide-compilation-rdar42452085
[CodeComplete] Strip out try and optional eval expo in operator completion
2018-07-26 07:52:19 +09:00
swift-ci
e9cb62d476 Merge pull request #17987 from brentdax/youll-get-no-argument 2018-07-24 23:39:05 -07:00
Rintaro Ishizaki
2babbc3a44 [CodeComplete] Handle ternary expression in sequence completion
Follow-up to f577578a6a. The same
treatment for ternary expression (IfExpr). Plus, fix a regression
introduced in f577578a where infix operators were disappeard from
results.
2018-07-25 13:59:20 +09:00
Rintaro Ishizaki
4c0892fdc6 [CodeComplete] Strip out try and optional eval expr in operator compilation
foldSequence() may hoist these expression up by mutating their sub
expression. When completing operators, this behavior ruins reusability
of operand. Since these expression doesn't affect completion, we can
strip them out.

rdar://problem/42452085
2018-07-25 13:58:53 +09:00
John McCall
7a4aeed570 Implement generalized accessors using yield-once coroutines.
For now, the accessors have been underscored as `_read` and `_modify`.
I'll prepare an evolution proposal for this feature which should allow
us to remove the underscores or, y'know, rename them to `purple` and
`lettuce`.

`_read` accessors do not make any effort yet to avoid copying the
value being yielded.  I'll work on it in follow-up patches.

Opaque accesses to properties and subscripts defined with `_modify`
accessors will use an inefficient `materializeForSet` pattern that
materializes the value to a temporary instead of accessing it in-place.
That will be fixed by migrating to `modify` over `materializeForSet`,
which is next up after the `read` optimizations.

SIL ownership verification doesn't pass yet for the test cases here
because of a general fault in SILGen where borrows can outlive their
borrowed value due to being cleaned up on the general cleanup stack
when the borrowed value is cleaned up on the formal-access stack.
Michael, Andy, and I discussed various ways to fix this, but it seems
clear to me that it's not in any way specific to coroutine accesses.

rdar://35399664
2018-07-23 18:59:58 -04:00
Slava Pestov
90cd772228 AST: Remove getParameterLists() and friends from AbstractFunctionDecl subclasses
Now, an AbstractFunctionDecl always stores a single parameter list.

Furthermore, ConstructorDecl and DestructorDecl always store a
ParamDecl for 'self'.

FuncDecl only has a 'self' if it is a member of a nominal type or
extension, so we tail-allocate the storage for it.
2018-07-22 20:56:56 -07:00
Slava Pestov
5213f80e7e IDE: Remove uses of AbstractFunctionDecl::getParameterLists() 2018-07-22 20:56:56 -07:00
Brent Royal-Gordon
e797fe5976 [IDE] Add call parens to postfix operator completion 2018-07-22 19:34:29 -07:00
Rintaro Ishizaki
fb9c65e108 [CodeComplete] Fix crasher when completing inout IUO variable
Use `PrintOptionalAsImplicitlyUnwrapped` option.

rdar://problem/40956846
2018-07-14 00:52:57 +09:00
Ben Langmuir
b394e35fdd [codecomplete] Add completion of if after else
At some point we stopped completing keywords after `else` in an if
statement. Bring back the completion of `if`, which is the only valid
continuation other than a brace.

rdar://37467474
2018-07-10 11:45:10 -07:00
Ben Langmuir
2ace21276e [codecomplete] Factor common code for adding keyword completions NFC 2018-07-09 16:10:42 -07:00
Slava Pestov
19de53f6cf Sema: Remove dead code from access level computation rework 2018-07-06 23:50:36 -07:00
Doug Gregor
793ba723f7 [AST] Delete the unused FileUnitKind::Derived.
The last use of this went away a loooooong time ago. NFC.
2018-07-02 13:32:39 -07:00
Slava Pestov
1d2d653844 IDE: Redo typeCheckContext()
- Don't type check top-level contexts multiple times
- Use validateDecl() instead of typeCheckDecl() when possible
2018-06-30 00:20:37 -07:00
Rintaro Ishizaki
bccfd85b70 [CodeComplete] Typecheck SubscriptDecl context prior to completion
Completing signature depends on its GenericEnvironment which is set
during typechecking. Previously, completing signature using generic type
used to cause assertion failure. e.g.

  extension Collection {
    subscript(some index: Int) -> Iterator.<COMPLETE HERE>

rdar://problem/41227754
2018-06-28 17:39:07 +09:00
Rintaro Ishizaki
52e3109231 [CodeComplete] Restore original type in getOperatorCompletions
In getOperatorCompletions(), for each every known operators, temporary
expressions are created and typechecked. In this process, typechecker
may set the type of the parsed expression. That may cause non-accurate
completion results or crash at worst.

rdar://problem/28188259
2018-06-27 19:35:25 +09:00
Rintaro Ishizaki
8c970ab26d [CodeComplete] Handle assign expression in sequence completion
rdar://problem/41232519
rdar://problem/41159258
2018-06-27 19:35:25 +09:00
Robert Widmann
a7c9bd09db Merge pull request #17181 from CodaFi/in-put-up-and-in-shut-up
[IDE] Scrub SwiftIDE of References to getInput()
2018-06-16 11:14:49 -07:00
Doug Gregor
18569e5f77 Merge pull request #16963 from DougGregor/evaluator-type-checker
[Type checker] Use the request-evaluator in the type checker.
2018-06-15 22:41:31 -07:00
Robert Widmann
b7580493f5 [Gardening] 'throw' is not an expression keyword
Remove the workaround in CodeCompletion for this.
2018-06-15 13:25:06 -07:00
Doug Gregor
b7fbe57bf9 [AST] Remove “validated” bit from TypeLoc.
TypeLocs have been “validated” when they have a non-null Type, so eliminate
the separate “validated” bit that was out-of-sync with the Type field.
2018-06-14 15:29:57 -07:00
Slava Pestov
296ce3f312 AST: Remove hack-around for getInterfaceType() on ParamDecl returning InOutType
Most callers did not want the InOutType here, and checked
the ParamDecl's flags instead.
2018-06-13 15:38:52 -07:00
Robert Widmann
e8eba29cd9 [IDE] Scrub SwiftIDE of References to getInput() 2018-06-13 14:43:54 -07:00
Robert Widmann
e4181886f7 Merge pull request #17157 from CodaFi/inaccessible-decl-attribute-kardinals
[CodeCompletion] Reject all UserInaccessible decl attributes
2018-06-13 11:28:00 -07:00
Robert Widmann
a1ee6e953d [CodeCompletion] Reject all UserInaccessible decl attributes
Generalize a fix that removes __consuming from Code Completion to all inaccessible decl attributes.
2018-06-12 15:21:34 -07:00
Robert Widmann
26d2795efc Excise simpler uses of getInput 2018-06-11 17:29:29 -07:00
Robert Widmann
df698d2ee8 Remove __consuming from CodeCompletion
Set the UserInaccessible bit to remove __consuming from code
completion until we commit to a real keyword.

rdar://40828289
2018-06-10 15:06:28 -07:00
Ben Langmuir
e8b08de29f Merge pull request #16868 from AnthonyLatsis/code-compl-missing-init-dotexpr
[CodeCompletion] Missing init completions for dotExpr
2018-06-08 08:31:07 -07:00
Robert Widmann
6585c92395 Merge pull request #16935 from CodaFi/mos-def
[NFC] Refactor default argument info
2018-06-04 14:57:31 -07:00