Commit Graph

1994 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
Doug Gregor
58d60e268f [Code completion] Delete redundant code handling declarations.
A significant chunk of the handling for LookupKind::ValueExpr
was duplicated in the handling for the ValueInDeclContext and
ImportFromModule cases. Use a fall through to unify the
code paths here.
2018-08-14 08:31:01 -07: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
fedc36e4fb [IDE] Don't walk to ExplicitCast expr twice in ModelASTWalker
Explict cast expressions (i.e. 'as', 'as!`, 'as?', and 'is') appear twice in
'SequenceExpr'. For instance, 'a as B' is parsed as:
  (sequence_expr
    (unresolved_declref_expr name='a')
    (coerce_expr writtenType='B')
    (coerce_expr writtenType='B'))
This patch prevents ModelASTWalker from walking into them twice.

rdar://problem/43135727
2018-08-14 08:19:48 +09: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
swift-ci
71f0248b0a Merge remote-tracking branch 'origin/master' into master-next 2018-08-06 11:07:55 -07: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
bd5f5d80e4 [AST] Add ExtensionDecl::getExtendedNominal().
Introduce ExtensionDecl::getExtendedNominal() to provide the nominal
type declaration that the extension declaration extends. Move most
of the existing callers of the callers to getExtendedType() over to
getExtendedNominal(), because they don’t need the full type information.

ExtensionDecl::getExtendedNominal() is itself not very interesting yet,
because it depends on getExtendedType().
2018-08-03 11:26:48 -07:00
swift-ci
91d78b5212 Merge remote-tracking branch 'origin/master' into master-next 2018-08-01 19:28:59 -07:00
Rintaro Ishizaki
49f6a28637 [IDE] Use collected token to retrieve range of type identifier
Previously, it used to use length from AST. Because AST doesn't necessarily
holds actual source information, it may emits inacculate syntax info
which cause mis-coloring or compiler crash in the worst case. Instead, use
collected token info which contains actual token length.

https://bugs.swift.org/browse/SR-8378
rdar://problem/42653982
2018-08-02 10:02:58 +09:00
swift-ci
5830e237ff Merge remote-tracking branch 'origin/master' into master-next 2018-07-31 13:29:50 -07:00
Doug Gregor
9eb9898321 Merge pull request #18364 from DougGregor/name-lookup-requests
[Name lookup] Introduce requests for several name lookup operations.
2018-07-31 13:23:38 -07:00
Jordan Rose
2dfa303975 [Serialization] Preserve source order in serialization (#18361)
We previously shied away from this in order to not /accidentally/
depend on it, but it becomes interesting again with textual
interfaces, which can certainly be read by humans. The cross-file
order is the order of input files, which is at least controllable by
users.
2018-07-31 13:15:07 -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
Doug Gregor
2860557a77 [Name lookup] Use the declaration-based lookupQualified() where it’s easy.
Switch a number of callers of the Type-based lookupQualified() over to
the newer (and preferred) declaration-based lookupQualified(). These are
the easy ones; NFC.
2018-07-31 10:14:44 -07:00
swift-ci
158cf1f948 Merge remote-tracking branch 'origin/master' into master-next 2018-07-30 10:29:13 -07:00
Pavel Yaskevich
0781aee89c Merge pull request #16896 from xedin/cs-params-cache
[CSSolver] Add closure parameter type caching
2018-07-30 10:17:55 -07:00
swift-ci
be19f650fd Merge remote-tracking branch 'origin/master' into master-next 2018-07-30 10:08:59 -07:00
Xi Ge
4b379db1bf Merge pull request #18231 from keith/ks/indent-closing-square
IDE: Fix formatting of closing square brackets
2018-07-30 09:51:32 -07:00
swift-ci
0e773085ef Merge remote-tracking branch 'origin/master' into master-next 2018-07-30 09:49:19 -07:00
Rintaro Ishizaki
f4fc479818 [IDE] Handle MakeTemporarilyEscapableExpr in SemaAnnotator 2018-07-30 09:50:37 +09:00
Rintaro Ishizaki
1a624413c6 [IDE] Handle OpenExistentialExpr in SemaAnnotator
As for `OpenExistentialExpr`, normal ASTWalker walks into the existential
expression first, then walks into sub expression. However,
`SourceEntitiyWalker` must walk AST tree by source order. Handle
`OpenExistentialExpr` and its `OpaqueValueExpr` so that
`SourceEntityWalker` walks to them in "outer to inner" manner.

rdar://problem/41147733
2018-07-30 09:50:37 +09:00
Pavel Yaskevich
0a404529c3 [Sema] Adjust Diagnostics/IDE to not assume that parameters always have types 2018-07-28 20:28:41 -07:00
swift-ci
ce3c206eee Merge remote-tracking branch 'origin/master' into master-next 2018-07-26 13:09:13 -07:00
Xi Ge
bff3f8adcc Merge pull request #16983 from mohitathwani/SR-7292
[WIP] Generating member wise initializer with local refactoring
2018-07-26 13:05:08 -07:00
Mohit Athwani
ce1122921a SR-7292 - Refactoring tool for generating member wise init 2018-07-26 11:31:30 -07:00
Keith Smiley
2d91af2077 IDE: Fix formatting of closing square brackets
Previously closing square brackets would be caught in the logic for
elements in collections, indenting them to the same level. Now they are
indented with the normal non-sibling logic, which indents them
correctly.
2018-07-25 20:27:32 -07:00
swift-ci
b456a11c2e Merge remote-tracking branch 'origin/master' into master-next 2018-07-25 17:29:24 -07:00
swift-ci
78cacf2a80 Merge remote-tracking branch 'origin/master' into master-next 2018-07-25 16:09:16 -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
879a10aa57 Merge remote-tracking branch 'origin/master' into master-next 2018-07-25 15:29:05 -07:00
Rintaro Ishizaki
395885505a Merge pull request #18198 from rintaro/ide-rdar41100570
[IDE] Fix asstion failure when querying cursor info in defer statement body
2018-07-26 07:13:32 +09:00
swift-ci
69e82c2578 Merge remote-tracking branch 'origin/master' into master-next 2018-07-24 23:49:47 -07: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