Commit Graph

2551 Commits

Author SHA1 Message Date
swift-ci
d02c1400a9 Merge pull request #30899 from nathawes/improve-enum-case-trailing-comma-recovery 2020-04-10 20:30:42 -07:00
Nathan Hawes
8edeab75ce [Parse] Don't drop the EnumCaseDecl when it has a trailing comma.
This meant we weren't producing sema diagnostics for the case, and it didn’t
get full syntactic/semantic highlighting or indentation.

enum CasesWithMissingElement {
  case a(Int, String),
  case b(Int, String),
}

Resolves rdar://problem/61476844
2020-04-10 18:22:33 -07:00
Rintaro Ishizaki
315f65f962 [CodeCompletion] Use AnyFunctionType::Param::getParameterType()
instead of getOldType() in KeyPath as funtions completion.
Also, don't think keypath's are convertible to functions that receives
variadic parameters.
2020-04-10 15:55:32 -07:00
Suyash Srijan
724f8c23db [Typechecker] Implement SE-0268 Refine didSet Semantics (#26632) 2020-04-09 01:23:15 +01:00
Rintaro Ishizaki
339ebbfa89 [CodeCompletion] Update annotation description test case to test cache 2020-04-07 00:50:43 -07:00
Rintaro Ishizaki
28de43b7ca [CodeCompletion] Trim whitespaces around the content 2020-04-07 00:50:43 -07:00
Rintaro Ishizaki
c633da047d [CodeCompletion] Add IDE test case for annotated description 2020-04-07 00:50:43 -07:00
Nathan Hawes
1a65b84a42 [IDE] Completion after a qualifying module should return symbols from its shadowing cross-import overlays. 2020-04-03 16:04:32 -07:00
Anthony Latsis
41fe367a7e [CodeCompletion] Don't skip derived conformance members on override completion lookup 2020-03-28 23:59:18 +03:00
Hamish Knight
6f212634c8 Add getOperatorDecls to FileUnit and ModuleDecl
Query the SourceLookupCache for the operator decls,
and use ModuleDecl::getOperatorDecls for both
frontend stats and to clean up some code
completion logic.

In addition, this commit switches getPrecedenceGroups
over to querying SourceLookupCache.
2020-03-27 09:44:55 -07:00
Dan Zheng
bbe86e908d [AutoDiff upstream] Add Differentiable protocol derived conformances. (#30671)
Add `AdditiveArithmetic` derived conformances for structs and classes, gated by
the `-enable-experimental-differentiable-programming` flag.

Structs and classes whose stored properties all conform to `Differentiable` can
derive `Differentiable`:

- `associatedtype TangentVector: Differentiable & AdditiveArithmetic`
  - Member `TangentVector` structs are synthesized whose stored properties are
    all `var` stored properties that conform to `Differentiable` and that are
    not `@noDerivative`.
- `mutating func move(along: TangentVector)`

The `@noDerivative` attribute may be declared on stored properties to opt out of
inclusion in synthesized `TangentVector` structs.

Some stored properties cannot be used in `TangentVector` struct synthesis and
are implicitly marked as `@noDerivative`, with a warning:

- `let` stored properties.
  - These cannot be updated by `mutating func move(along: TangentVector)`.
- Non-`Differentiable`-conforming stored properties.

`@noDerivative` also implies `@_semantics("autodiff.nonvarying")`, which is
relevant for differentiable activity analysis.

Add type-checking and SILGen tests.

Resolves TF-845.
2020-03-27 06:40:04 -07:00
Anthony Latsis
403004b4c7 [ASTPrinter] Account for contextual where clauses when printing requirements 2020-03-26 04:48:39 +03:00
Anthony Latsis
8f306261ea Merge pull request #30574 from AnthonyLatsis/code-complete-broken-conf-no-static
[CodeCompletion] Add overlooked 'isDeclVisibleInLookupMode' check when collecting value requirements
2020-03-24 01:26:41 +03:00
Anthony Latsis
cf43a564a2 [CodeCompletion] Check visibility in lookup mode when collecting value requirements 2020-03-23 21:40:41 +03:00
Anthony Latsis
7c5b4d1fdf Merge pull request #30552 from AnthonyLatsis/assoc-coloring
[ASTWalker] Associated type defaults deserve syntax coloring
2020-03-21 10:22:19 +03:00
Anthony Latsis
016d3bbfae [ASTWalker] Associated type defaults deserve syntax coloring 2020-03-21 08:37:53 +03:00
swift-ci
41301c2597 Merge pull request #30542 from marcrasi/fix-autocomplete-crash-callasfunction 2020-03-20 16:57:49 -07:00
Marc Rasi
5772ddda7e fix autocomplete crash 2020-03-20 14:43:46 -07:00
Rintaro Ishizaki
80848682cc [LookupVisibleDecls] Tweak unquialified lookup
- Show static var decls in non-qualified metatype lookup
- Show enum element decls in non-qualified metatype lookup
- Never show initializers in non-qualified lookup
- Perform instance lookups in lazy var initializer
- Perform non-qualified metatype lookup inside static func

rdar://problem/57622639
2020-03-20 10:44:24 -07:00
Rintaro Ishizaki
cbeffb69cd [CodeCompletion] Don't ignore CovariantReturnConversionExpr
in typechecked AST. This is needed to correctly get the type of the
parsed expression when the expression is a calling to a method in super
class returning 'Self'.

rdar://problem/51504896
2020-03-19 11:05:04 -07:00
Nathan Hawes
fd82d87db0 Merge pull request #30402 from nathawes/cross-import-code-completion
[IDE/CodeCompletion] Add code completion support for cross import overlays.
2020-03-18 18:16:03 -07:00
Ben Langmuir
c04a8a9076 Merge pull request #30011 from AnthonyLatsis/mutating_dup_quick_help
[ASTPrinter] Fix duplicate «mutating» modifiers when printing file interface
2020-03-18 13:17:05 -07:00
Nathan Hawes
63636100be [IDE/CodeCompletion] Add code completion support for cross import overlays.
If a cross-import overlay shadows another module and has a name starting with
'_', don't present that overlay in places where module name completions are
offered and present symbols comining from that module as if they came from
the shadowed module instead.

Resolves rdar://problem/59445688
2020-03-18 12:02:20 -07:00
Rintaro Ishizaki
9225cfce3d [CodeCompletion] Type annotation for call argument completions 2020-03-12 17:46:25 -07:00
Rintaro Ishizaki
f8147f72d9 [CodeCompletion] Call argument label with value placeholder
When a completion happens at a call argument position, insert
'label: <#T##TypeName#>' instead of just 'label: '.

rdar://problem/60379654
2020-03-12 11:48:15 -07:00
Rintaro Ishizaki
fbc79d2f47 [CodeCompletion] Support SE-0253 callAsFunction()
- In member completions, when 'callAsFunction' decls are found, suggest
  call patterns
- In call pattern completions, fallback to search 'callAsFunction' if
  the base type is not a function type

rdar://problem/59792682
2020-03-11 16:27:27 -07:00
Rintaro Ishizaki
8f7340cd6e [CodeCompletion] Re-typecheck TypeExpr without call arguments
Call arguments sometimes affect the inference for the generic parameters of the
type expression. When we want to show all initializers from all
extensions, we do not want to infer any generic arguments.

rdar://problem/53516588
2020-03-09 15:48:54 -07:00
fischertony
c498ad0283 IDE: Ensure syntax coloring for contextual where clauses 2020-03-05 07:29:28 +03:00
Rintaro Ishizaki
12fd864543 Merge pull request #30136 from rintaro/ide-completion-rdar59285399
[CodeCompletion] Primarily use getPossibleCallees() for calling signature completion
2020-03-03 11:10:53 -08:00
Rintaro Ishizaki
78d0f6aa4a [CodeCompletion] Primarily use getPossibleCallees() for call signature completion
instead of the pre-typechecked type and the referenced decl in the AST
so that we can suggests all overloads even if it happen to be
typechecked to a method. For example

    struct MyType {
      func foo() {}
      func foo(_ int: Int) {}
      func foo(name: String, value: String) {}
    }
    func test(val: MyType) {
      value.foo(#^COMPLETE^#)
    }

In this case, the call is typechecked to 'MyType.foo(_:)', but we want
to suggest all overloads.

rdar://problem/59285399
2020-02-28 16:44:03 -08:00
Rintaro Ishizaki
fc28f909b8 [CodeCompletion] Tweak canBeUsedAsRequirementFirstType() 2020-02-26 10:58:01 -08:00
Rintaro Ishizaki
0dd0092e9e [CodeCompletion] Only suggest generic params in where for non-protocol
nominal types
2020-02-26 09:57:18 -08:00
Rintaro Ishizaki
ea6886114a [CodeCompletion] Generalize generic requirement completion
Align completion logics for all 'where' clauses.
2020-02-26 09:57:18 -08:00
Doug Gregor
e1c0decdf0 Update some test cases for the OptionalSomePattern change. 2020-02-24 00:48:14 -08:00
Anthony Latsis
f45c338e38 [ASTPrinter] Fix duplicate «mutating» modifiers when printing file interface 2020-02-22 18:09:43 +03:00
Rintaro Ishizaki
bfa385c0b7 [CodeCompletion] Update for SE-0249 KeyPath as functions
If the context type is a function type that receives one argument, infer
the key path expressions root type from the context.

rdar://problem/59302416
2020-02-13 13:11:36 -08:00
Rintaro Ishizaki
63772d04a8 Merge pull request #29789 from rintaro/ide-completion-rdar58851121
[CodeCompletion] Enable fast-completion at the top of implicit getter
2020-02-13 10:34:57 -08:00
Nathan Hawes
5e1985c989 [SourceKit] Fix SyntaxModel assertion failures due to consuming tokens twice or prematurely
The SyntaxModel walker would end up visiting the attributes attached to a
PatternBindingDecl twice if it contained more than one VarDecl, hitting the
below assertion on the second visit because the tokens corresponding to the
attribute had already been consumed the first time around:
```
Assertion failed: (0 && "Attribute's TokenNodes already consumed?"), function
  handleSpecialDeclAttribute
```
It would also hit the same assertion for attributes on an EnumCaseDecl, but even
when it only had a single child EnumElementDecl.  This because when we visited
the EnumCaseDecl and pushed its structure node, we'd consume and emit any tokens
before it's start position. This meant that when we tried to process the
attributes attached to the child EnumElementDecl its tokens had already been
consumed, triggering the assertion.

In both cases the attributes syntactically attach to the parent
PatternBindingDecl or EnumCaseDecl, but in the AST they're accessed via their
child VarDecls or EnumElementDecls.

Resolves rdar://problem/53747546
2020-02-12 13:44:04 -08:00
Rintaro Ishizaki
7b4db904a1 [CodeCompletion] Complete at the top of accessor block in body parsing
If a CC token is right after the '{' we still don't know it's an implicit
getter or a start of a accessor block. Previously, the parser used to
parse it as an accessor block, but it prevents fast-completion kicks in.

Instead handle it as a part of function body parsing so the
fast-completion works.

rdar://problem/58851121
2020-02-12 10:19:18 -08:00
Argyrios Kyrtzidis
73c3e1c693 [IDE/SyntaxModel] For syntactic structure, make sure to not visit the captured list variables twice
rdar://59302427
2020-02-11 15:37:22 -08:00
swift-ci
895294a7d1 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-02-05 11:03:43 -08:00
Rintaro Ishizaki
71aeffdf17 [CodeCompletion] Calculate type relation for EnumElementDecl 2020-02-03 17:20:50 -08:00
swift-ci
72229ba355 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-24 16:43:36 -08:00
Slava Pestov
305620b354 ClangImporter: Reconcile Clang declaration hidden-ness between loadAllMembers() and lazy loading
Lazy loading checked if the ClangDecl was hidden, but loading all
members did not. Let's make loadAllMembers() behave like the lazy
path, and fix some of the mock SDKs in the test suite.
2020-01-24 17:07:08 -05:00
swift-ci
5224ef8b72 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-22 13:44:41 -08:00
Rintaro Ishizaki
0a7c3b9014 Merge pull request #29346 from rintaro/ide-completion-rdar58778439
[LookupVisibleDecls] Look through DynamicSelfType in meta type lookup
2020-01-22 13:24:24 -08:00
Rintaro Ishizaki
43ad81c907 [LookupVisibleDecls] Look through DynamicSelfType in meta type lookup
We need to unwrap DynamicSelfType to get the visible decls on the meta
type.

rdar://problem/58778439
2020-01-22 09:45:00 -08:00
Erik Eckstein
bbfaccda4b Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-22 08:25:23 +01:00
Devin Coughlin
082421048a [AST/Sema] Add availability attributes for macCatalyst
Add a platform kind and availability attributes for macCatalyst. macCatalyst
uses iOS version numbers and inherits availability from iOS attributes unless
a macCatalyst attribute is explicitly provided.
2020-01-21 20:27:14 -08:00
swift-ci
df197066cf Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-21 18:02:52 -08:00