Commit Graph

894 Commits

Author SHA1 Message Date
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
fischertony
c88e1c983f [CodeCompletion] self for dot expressions
May dot expressions finally have a 'self' completion.
2018-05-11 09:48:53 +03:00
Jordan Rose
18162a3ed0 Revert "AST: Simplify ModuleDecl::forAllVisibleModules()"
This reverts commit 0c32c54e36.
2018-05-03 22:40:37 -06:00
Nathan Hawes
d9ca14203d [code-completion] Don't try to equate/convert GenericTypeParameterTypes computing type relations of completion results
For call argument completion, if the expected type and completion result type are
both GenericTypeParameterTypes, comparing them doesn't make sense we can't account
for their different contexts at this point in the code, and hit assertions in the
constraint solver if we try.

For now, don't attempt to add a type relation for this case.
Resolves rdar://problem/38153332.
2018-04-30 15:12:54 -07:00
Slava Pestov
af875829a7 Merge pull request #16206 from slavapestov/serialization-cleanup
Serialization cleanup
2018-04-27 05:22:40 -07:00
Slava Pestov
0c32c54e36 AST: Simplify ModuleDecl::forAllVisibleModules() 2018-04-26 23:37:16 -07:00
Pavel Yaskevich
57ad592844 [Sema] Switch computeDefaultMap to use AnyFunctionType::getParams() 2018-04-26 17:33:08 -07:00
Rintaro Ishizaki
095623b61c [code-complete] Small refactoring in addImportModuleNames (#15943)
Improves readability.
In the future, we will fix "FIXME: Add user-defined swift modules" based
on this.
2018-04-17 08:24:24 +09:00
David Zarzycki
7174d14dad [Parsing] NFC: metaprogram contextual decl keywords into Attr.def 2018-04-07 18:00:12 -04:00
Robert Widmann
03580d2fe5 Add a parameter list to EnumElementDecl
This models, but does not plumb through, default arguments.
2018-03-28 00:05:56 -04:00
Nathan Hawes
cc027287d7 Merge pull request #15471 from nathawes/rdar38188989-code-completion-assertion-failure-in-getValueExprCompletions
[code-completion] Fix assertion failure in getValueExprCompletions
2018-03-26 13:47:02 -07:00
Nathan Hawes
d4bd291569 [code-completion] Fix assertion failure in getValueExprCompletions
This was caused by two separate issues:

1. If given a function type with an IUO return, it would add function call
completions, set Done=true, and then progress to some logic to add
completions for the unwrapped type of optionals. That code would check if
the corresponding decl has the IUO attribute set and, if it was but couldn't
be unwrapped, assert. For function types, it now early exits after adding
call completions.

2. If given the type of a bound (`blah?.`) or forced (`blah!.`) optional,
the type is non-optional and can't be unwrapped and the decl still has the
IUO so it asserts. Refined the assertion to account for this case.

Resolves rdar://problem/38188989.
2018-03-26 11:12:44 -07:00
Doug Gregor
4797fae933 Merge pull request #15497 from DougGregor/remove-name-alias-type
[AST] Fully replace NameAliasType with the new, sugary-sweet BoundNameAliasType
2018-03-26 09:03:03 -07:00
Sho Ikeda
976c7f9c27 [gardening][IDE] Replace typedef with using 2018-03-26 13:45:36 +09:00
Doug Gregor
b2b69e8abf Rename BoundNameAliasType to NameAliasType.
NameAliasType is dead! Long live NameAliasType!
2018-03-25 21:35:17 -07:00
Doug Gregor
c43f96a855 [AST] Remove now-unused NameAliasType. 2018-03-25 21:35:16 -07:00