Commit Graph

1359 Commits

Author SHA1 Message Date
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
fischertony
9d5302e1eb [CodeCompletion] Remove 'self' from type identifier completions 2018-06-03 18:28:25 +03:00
Robert Widmann
24abf3ea09 [NFC] Refactor default argument info
Refactor the interface to return a bit vector. Along the way, fix up
the callers and remove some dead usages of the defaults information
that were copied and pasted around Sema.
2018-05-31 17:28:04 -07:00
Rintaro Ishizaki
66c71d1bf7 [SourceKit] Force print '?' for optional method call in code completion. (#16910)
Calling '@objc optional func' requires '?' or '!' after its name. When
completing method calls for them, 'key.sourcetext' should have '?'
whereas 'key.name' shouldn't.
Note that we deliberately do not use optional type name for
'key.typename'. This is consistent with optional chain '?.<propertyName>'
behavior.

rdar://problem/37904574
2018-05-31 16:06:23 -07:00
fischertony
45c9038d0f corrections and review amendments 2018-05-31 19:13:50 +03:00
fischertony
7ef24b10c9 [SR-7789][Additions]
restore accidentally removed constructors from 'self'
replace illegal direct call completions on dynamic metatypes with .init, except archetypes.
2018-05-30 06:05:04 +03:00
fischertony
927598fbcc [CodeCompletion] Missing init completions for dotExpr
Fixes non-visible inherited convenience initializers
Fixes non-visible initializers from protocol extensions
Fixes visible initializers on dynamic metatypes for postfix and parenPostfix expressions
2018-05-28 05:59:49 +03:00
Ben Langmuir
a90aeca095 Merge pull request #16534 from AnthonyLatsis/self-completion-dot-expr
[CodeCompletion] SR-943 'self' for dot expressions
2018-05-24 14:44:21 -07:00
fischertony
7b41a41fb6 updated tests & added completions for postfixExpr 2018-05-12 09:05:57 +03:00