Commit Graph

62 Commits

Author SHA1 Message Date
Hamish Knight
2d7500eda6 [AST] Remove ParenType
Today ParenType is used:

1. As the type of ParenExpr
2. As the payload type of an unlabeled single
   associated value enum case (and the type of
   ParenPattern).
3. As the type for an `(X)` TypeRepr

For 1, this leads to some odd behavior, e.g the
type of `(5.0 * 5).squareRoot()` is `(Double)`. For
2, we should be checking the arity of the enum case
constructor parameters and the presence of
ParenPattern respectively. Eventually we ought to
consider replacing Paren/TuplePattern with a
PatternList node, similar to ArgumentList.

3 is one case where it could be argued that there's
some utility in preserving the sugar of the type
that the user wrote. However it's really not clear
to me that this is particularly desirable since a
bunch of diagnostic logic is already stripping
ParenTypes. In cases where we care about how the
type was written in source, we really ought to be
consulting the TypeRepr.
2024-10-31 11:32:40 +00:00
Anthony Latsis
7f6d3bcd41 ASTPrinter: Turn on explicit any printing for everything and remove the option to disable it 2023-05-13 02:55:49 +03:00
Alex Hoppen
32eff21977 [IDE] Remove "Begin completions" and "End completions" from test cases
These test lines weren't actually providing any value and were annoying to write. Let's jut remove them.
2023-03-22 09:07:17 -07:00
Anthony Latsis
8c1f391878 Gardening: Migrate test suite to GH issues: IDE 2022-08-31 03:00:06 +03:00
Rintaro Ishizaki
eade9b7bc9 [LookupVisibleDecls] Implement shadowing for unqualified lookups
Tweaked usable check:
  * Local type/func decls are usable even before declaration
  * Outer nominal Instance member are not usable
  * Type context cannot close over values in outer type contexts

Added shadowing rule by the base name:
  * Type members don't shadow each other as long as they are in the
    same type context.
  * Local values shadow everything in outer scope
    * Except that 'func' decl doesn't shadow 'var' decl if they are in the
      same scope.

rdar://86285396
2022-04-28 16:36:54 -07:00
Slava Pestov
4655fc359b Sema: Make a couple of TypeResolver methods idempotent
When emitting a diagnostic, mark the TypeRepr as invalid and
return an ErrorType to ensure that the diagnostic is not
emitted again, and to muffle downstream diagnostics.
2022-02-15 04:02:46 -05:00
Rintaro Ishizaki
7e7b2c3557 [CodeCompletion] Annotate override completions
* "description" for override completion is now annotatable
* "description" doesn't include attributes and decl introducer, but it
  includes generic paramters, effects specifiers, result type clause,
  and generic where clauses
* "name" now only include the name and the parameter names
* "sourcetext" should be the same

rdar://63835352
2021-09-02 12:12:26 -07:00
Alex Hoppen
fec7f6c3c0 [CodeCompletion] Fix issue causing the completion status to not be set correctly for pattern completion
We weren’t setting the code completion token status correctly when parsing patterns with code completion tokens.

Because of this, in the added test case, the `searchSubject` gets added as a member of `Foo` twice - once in the first pass and once in the second pass, causing an assertion failure.

Fixes rdar://80575116 [SR-14687]
2021-07-26 20:50:10 +02:00
Rintaro Ishizaki
18dc9c1c27 [CodeCompletion] Remove CodeComletionString::getName()
`CodeCompletioString::getName()` was used only as the sorting keys in
`CodeCompletionContext::sortCompletionResults()` which is effectively
deprecated. There's no reason to check them in `swift-ide-test`. Instead,
check `printCodeCompletionResultFilterName()` that is actually used for
filtering.
2021-07-16 13:24:19 -07:00
Doug Gregor
568e943115 Enable import of the _Concurrency module by default. 2021-04-13 23:14:06 -07:00
Arnold Schwaighofer
9286ece71c Revert "Enable import of the _Concurrency module by default." 2021-04-09 13:20:30 -07:00
Doug Gregor
95fd3ede09 Update tests and testing tools for implicit _Concurrency import 2021-04-06 14:08:41 -07:00
Rintaro Ishizaki
6e84c01a48 [CodeCompletion] Migrate some tests to batch completion test 2021-04-01 22:18:49 -07:00
Slava Pestov
3ae31d5173 Sema: Don't need to derive CaseIterable's AllCases associated type
Just declaring a default in the standard library works fine.
2020-08-07 16:48:40 -04:00
Rintaro Ishizaki
75a0c9f819 [CodeCompletion] Add 'IsSystem' flag to code completion result item
'key.is_system: 1' is added if the associated declaration is from a
system module.

rdar://problem/62617558
2020-05-11 12:24:36 -07:00
Anthony Latsis
41fe367a7e [CodeCompletion] Don't skip derived conformance members on override completion lookup 2020-03-28 23:59:18 +03:00
Rintaro Ishizaki
62078c79dd [ASTPrinter/CodeCompletion] Stop printing base type when possible
rdar://problem/57033931
2019-12-17 16:26:37 -08:00
Rintaro Ishizaki
97b16ce5e3 [CodeCompletion] Remove unsound check in override completion
In override completion, we didn't use to emit 'class var' with the initial
expression. However, having initial expression does not have any bearing
on whether the declaration is overridable or not.
2019-11-12 17:40:36 +09:00
Rintaro Ishizaki
3a2454c2c7 [CodeCompletion] Use opaque type for override completion if preferable
rdar://problem/49354106
2019-04-19 17:34:08 -07:00
Rintaro Ishizaki
e80c4d1959 Merge pull request #22966 from AnthonyLatsis/test_for_SR2560
[CodeCompletion] Add a regression test for SR-2560
2019-02-28 10:32:08 -08:00
fischertony
f6cad5fc2b Add a regression test for SR-2560 2019-02-28 03:24:09 +03:00
fischertony
ae415b2a4b When followed by an 'override' or CC token inside a class, treat 'class' as a modifier rather than an introducer. 2019-02-16 16:02:22 +03:00
fischertony
ecfce56110 Don't exclude @autoclosure from the attribute list when printing override completions 2019-02-16 16:02:22 +03:00
fischertony
86d9d7a6b5 Fix override completions when a valid introducer is present but the override keyword is not. 2019-02-16 16:02:22 +03:00
fischertony
bb9482bab5 [CodeCompletion][Parser] Completions for overridable static members 2019-02-16 16:02:06 +03:00
David Zarzycki
995dec5d82 [Sema] Error if ObjC interop is needed when disabled 2018-05-07 14:43:04 -04:00
Ben Langmuir
0ba9baf3f0 [ASTPrinter] Allow error type in printTransformedType
When printing an associated type that is not provided (e.g. during
code-completion of overrides), we want to print the type even if there
are errors.

rdar://problem/30451236
2017-06-16 17:01:28 -07:00
Ben Langmuir
5434afc67b [codecompletion] Fix completion after 'let' inside a nominal type
Previously, we ignoring 'let', so you would get ridiculous completions:
  let var foo: Int
  override let func bar() {}

Now, will complete protocol requirements after 'let' the same way we do
for 'var'.  For instance property overrides, we only show them if the
'override' keyword is specified.  You can't actually override using a
'let', but if the keyword is present then the intention is clear and we
can let the user fix it afterwards when the compiler diagnoses it.

rdar://problem/31091172
2017-03-17 11:33:03 -07:00
Rintaro Ishizaki
6f167e9d04 [CodeComplete] Don't emit 'override' in protocol extension
Also, don't emit any inherited decls in protocol declaration.
2017-01-30 20:30:21 +09:00
David Farler
b7d17b25ba Rename -parse flag to -typecheck
A parse-only option is needed for parse performance tracking and the
current option also includes semantic analysis.
2016-11-28 10:50:55 -08:00
Michael Ilseman
8923a12585 [ASTPrinter] Switch to new ParameterTypeFlags
Switch printing off of using Function's ExtInfo for autoclosure and
escaping, and onto the ParameterTypeFlags, which let us do precise and
accurate context-sensitive printing of these parameter type
attributes. This fixes a huge list of issues where we were printing
@escaping for things like optional ObjC completion handlers, among
many others. We now correctly print @escaping in more places, and
don't print it when it's not correct.

Also updates the dumper to be consistent and give a good view of the
AST as represented in memory. Tests updated, more involved testing
coming soon.
2016-09-22 12:24:02 -07:00
Rintaro Ishizaki
b827298892 [CodeCompletion] Modifier related improvements in CompletionOverrideLookup
* If "required" or "convenience" is specified, emit only initializers
* If "final" or "open" is specified, don't emit initializers or typealias
* If "typealias" is specified, emit only associated type implementation
* Emit "override" or "required" modifier for initializers
* Emit access modifier for initializers
* Emit designated initializers even if "override" is specified
* Don't emit inheritance clause for associated type implentation
2016-08-27 03:48:51 +09:00
Ben Langmuir
89fd31d78f [codecompletion] Add @escaping to override completions
Flush out the ASTPrinter's ability to exclude and include specific
attributes to cover TypeAttrKinds and have code-completion use this to
print @escaping in override completions.  Incidentally fix a case where
we weren't forwarding important options after type transformation, which
prevented printing @escaping in transformed parameter types.

rdar://problem/27772722
2016-08-11 16:43:32 -07:00
Dmitri Gribenko
d175b3b66d Migrate FileCheck to %FileCheck in tests 2016-08-10 23:52:02 -07:00
Michael Ilseman
25ac879aea [noescape by default] Fix benchmarks and incorporate feedback
Adds @escaping to internal benchmark code to fix it. References SR for
known limitation. Use stdlib coding style for arguments.
2016-07-29 13:49:08 -07:00
Michael Ilseman
c37751ae96 [noescape by defaul] make noescape the default
This flips the switch to have @noescape be the default semantics for
function types in argument positions, for everything except property
setters. Property setters are naturally escaping, so they keep their
escaping-by-default behavior.

Adds contentual printing, and updates the test cases.

There is some further (non-source-breaking) work to be done for
SE-0103:

- We need the withoutActuallyEscaping function
- Improve diagnostics and QoI to at least @noescape's standards
- Deprecate / drop @noescape, right now we allow it
- Update internal code completion printing to be contextual
- Add more tests to explore tricky corner cases
- Small regressions in fixits in attr/attr_availability.swift
2016-07-29 13:49:08 -07:00
Slava Pestov
ddc51c5917 AST: Implement SE-0102, introducing new semantics for Never alongside @noreturn
No migrator support yet, and the code for @noreturn is still in
place.
2016-07-22 14:56:39 -07:00
Ben Langmuir
a629d668ac [CodeCompletion] Mark deprecated completions as "not recommended"
If a declaration is marked deprecated (but not unavailable) we want to
mark it as "not recommended" so that users know this probably isn't what
you want. We already do something like this in Clang code completions of
deprecated ObjC declarations.

rdar://problem/26335424
2016-05-23 09:25:30 -07:00
Jorge Bernal
0a3f913b20 SE-0070: Make Optional Requirements Objective-C-only.
Optional protocol requirements now require an explicit @objc attribute.

Fixes SR-1395
2016-05-06 11:05:52 +02:00
Doug Gregor
743b07ffd7 [Code completion] Be more lack when suppressing witnesses for requirements.
Semantic analysis may match up a witness to a requirement with
renaming; when performing code completion, we still want to see the
requirement because it's possible that the user just hasn't written it
yet. Fixes the regression I caused earlier today.
2016-04-18 20:54:32 -07:00
Xi Ge
23d1b51e6f [CodeCompletion] Teach override completion to collect the associatedtypes that need to be specified from conforming protocols. 2016-03-29 11:17:00 -07:00
Ben Langmuir
812d1566a7 [CodeCompletion] Don't look through non-type contexts in override
We don't actually want to skip non-type contexts here, since we should
only be showing override completions in the type context itself. This
was pretty obscure to hit in practice, but I noticed it while fixing the
crasher.
2016-03-12 08:39:11 -08:00
Ben Langmuir
da9c68d373 [CodeCompletion] Don't complete inits after func/var/override keywords
When completing nominal members (overrides, etc.), don't show inits if
the user already added a keyword that can't go before an init.
2016-03-11 23:00:11 -08:00
Ben Langmuir
5bbc06b35c [CodeCompletion] Fix override completion parser lookback issues
This allows us to get override completions correct when
* There are multiple decls on one line
* The preceding attributes/keywords span multiple lines

Resolving a longstanding FIXME.
2016-03-11 23:00:11 -08:00
Joe Groff
fbd2e4d872 Rename @asmname to @_silgen_name.
This reflects the fact that the attribute's only for compiler-internal use, and isn't really equivalent to C's asm attribute, since it doesn't change the calling convention to be C-compatible.
2015-11-17 14:13:48 -08:00
Ben Langmuir
889b033964 [CodeCompletion] Add completion for property overrides
This mostly works the same as for functions. It required a slight tweak
to how we handle 'var <complete>' to avoid consuming the code completion
token prematurely.

rdar://problem/21012767

Swift SVN r32844
2015-10-23 05:38:07 +00:00
Slava Pestov
3803938419 AST: Get some @objc tests (stupidly) passing on Linux again
Of course, the real fix is to split off the @objc parts of these
tests.

Fixes <rdar://problem/21745434>.

Swift SVN r31780
2015-09-08 22:12:16 +00:00
Arnold Schwaighofer
97faefa88e Tests failing on linux
rdar://21745434

Swift SVN r30019
2015-07-09 14:54:59 +00:00
Ben Langmuir
169aa6ac27 [CodeCompletion] Print 'throws' on types in override completions
Also fixes -print-ast for the same case.

Thanks to Doug for helping me figure out which layer was broken!

Swift SVN r28797
2015-05-19 23:01:33 +00:00
Doug Gregor
332e4d14e7 Replace a manual crawl through conformances with a use of getAllConformances().
Also, improve duplicate detection by looking at the actual witnesses that have been recorded thus far.

Swift SVN r26325
2015-03-19 22:10:07 +00:00