Commit Graph

1710 Commits

Author SHA1 Message Date
fischertony
44dfba81e4 Parse: Reinterpret associativity kinds as contextual keywords 2019-04-11 21:27:39 +03:00
Brent Royal-Gordon
d9732a050f Allow the declaration of static subscripts
In this commit, MyStruct.self[0] parses and typechecks but the solution doesn’t apply correctly. MyStruct[0] gets diagnosed as an error.
2019-04-10 23:09:44 -07:00
Slava Pestov
003a9a47b2 Parse: Remove obsolete @autoclosure(escaping) and @noescape type attributes
Some diagnostics got worse, but I think the reduction in compiler complexity
is worth it, and copy-and-pasting Swift 2 code is not likely to produce great
results anyway.

Also, this corrects an oversight where we did not reject @pseudogeneric on
function types in AST parsing.
2019-04-09 15:02:14 -04:00
Slava Pestov
6bb36b5c01 Sema: Subscript default arguments
Fixes <https://bugs.swift.org/browse/SR-6118>.
2019-04-02 20:37:01 -04:00
Brent Royal-Gordon
972eda2316 [NFC] AST-level support for static subscripts
* Moves the IsStatic flag from VarDecl to AbstractStorageDecl.
* Adds a StaticSubscriptKind to SubscriptDecl.
* Updates serialization for these changes.
* Updates SubscriptDecl constructor call sites for these changes.
2019-04-01 18:04:00 -07:00
Doug Gregor
a848d12665 Parse unknown attributes as "custom" attributes.
Parse custom attributes with the grammar:

```
'@' type-identifier expr-paren?
```
2019-03-29 23:10:36 -07:00
Ben Langmuir
e255bac6be [code-completion] Fix type context for single-expression implicit getter
This adds an implicit body so that we can dig out the return type
context the same way as a normal function. For now, we are also treating
the first expression in a multi-statement implicit getter body the same
way; we'll need to refactor how we complete in accessors to
differentiate those cases.
2019-03-26 16:45:32 -07:00
Rintaro Ishizaki
1038011c67 [CodeCompletion] Force type check pattern binding for initializer
Also, do not handle parsed decls in first-pass. Because they are
re-parsed, they used to case duplicated decls in AST.

rdar://problem/40944761
2019-03-08 13:42:08 -08: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
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
Robert Widmann
944d8d06d7 [SE-0155] Default Arguments in Enum Cases
The bulk of the changes are to SILGenApply.  As we must now evaluate the
payload ArgumentSource to an RValue, we follow the example of subscripts
and lie to the argument emitter.  This evaluates arguments at +1 which
can lead to slightly worse codegen at -Onone.
2019-02-12 10:06:48 -05:00
Slava Pestov
d41eec9510 Parse: Simplify Parser::canDelayMemberDeclParsing() 2019-01-18 00:15:53 -05:00
Slava Pestov
93c386d263 Parse: Skip function bodies when delayed member parsing mode is on
Fixes <rdar://problem/47305142>.
2019-01-18 00:15:53 -05:00
Slava Pestov
fb0fbc099b Parse: Rename DisableDelayedParsing to DelayBodyParsing and change polarity 2019-01-18 00:15:41 -05:00
Slava Pestov
d540682e24 Parse: Use ScopeKind::EnumBody not ScopeKind::ClassBody for enum body 2019-01-18 00:15:41 -05:00
Slava Pestov
5ae2f76370 Parse: Factor out new Parser::delayParsingDeclList() method 2019-01-18 00:15:41 -05:00
Slava Pestov
0bdf0fdca3 Parse: Refactor parseDeclList() to take an IterableDeclContext instead of a callback function 2019-01-18 00:15:41 -05:00
Slava Pestov
acb37b2b55 AST: Set ClassDecl's HasDestructor bit in one place 2019-01-18 00:15:41 -05:00
Saleem Abdulrasool
03af9467d8 ParseSIL: prevent _weakLinked on COFF targets
PE/COFF does not provide weak linking semantics.  Ensure that we
diagnose use of `_weakLinked` on those targets rather than consuming it
and attempting to generate IR for that.
2019-01-11 12:36:00 -08:00
Xi Ge
6057a60aca [Parser] Expose a flag to allow users explicitly disable delayed parsing. NFC
Discussed with @dcci, this patch is necessary to fix an lldb test failure. rdar://38396444
2019-01-09 14:32:41 -08:00
Argyrios Kyrtzidis
1f1eab638f [Parse/Syntax] Replace ParsedSyntaxRecorder::record* calls from the parser with ParsedSyntaxRecorder::make*
Doing a "direct ParsedSyntaxRecorder::record[some syntax]" call from the parser is not a good idea due to possibility
of being in a backtracking context when the call is made. Replace them with "ParsedSyntaxRecorder::make[some syntax]"
which will implicitly check for backtracking and create a recorded or deferred node accordingly.
2019-01-07 19:56:36 -08:00
Argyrios Kyrtzidis
ab7427723e [Parse/Syntax] Refactoring to decouple the parser from syntax tree creation
Instead of creating syntax nodes directly, modify the parser to invoke an abstract interface 'SyntaxParseActions' while it is parsing the source code.
This decouples the act of parsing from the act of forming a syntax tree representation.
'SyntaxTreeCreator' is an implementation of SyntaxParseActions that handles the logic of creating a syntax tree.
To enforce the layering separation of parsing and syntax tree creation, a static library swiftSyntaxParse is introduced to compose the two.

This decoupling is important for introducing a syntax parser library for SwiftSyntax to directly access parsing.
2019-01-07 19:52:59 -08:00
Ankit Aggarwal
45290837b4 Merge pull request #21110 from aciidb0mb3r/swiftpm-manifest-version
Extend @available to support PackageDescription
2019-01-07 12:20:23 -08:00
Argyrios Kyrtzidis
a8f5502228 Merge pull request #21185 from akyrtzi/syntax-parsing-finalize-tree-change
[Parse/Syntax] Simplify how the final SourceFileSyntax root is formed
2018-12-10 16:08:37 -08:00
Argyrios Kyrtzidis
cbad3492e4 [Parse/Syntax] Simplify how the final SourceFileSyntax root is formed
Instead of creating multiple CodeBlockItemList nodes, that need to get merged and discarded later on, do this:

* Ensure for libSyntax parsing that we parse the whole file
* Create top-level CodeBlockItem nodes that we just directly wrap with a single CodeBlockItemList node at the end

The importance of this change will become more obvious later on when we'll decouple syntax parsing from the formation of libSyntax tree nodes.
2018-12-10 13:37:15 -08:00
Mike Ash
ac376840dd [Parse] Allow @_objcRuntimeName to be used in source.
rdar://problem/46546165
2018-12-10 10:17:52 -05:00
Ankit Aggarwal
92d09f4e19 Extend @available to support PackageDescription
<rdar://problem/46548531> Extend @available to support PackageDescription

This introduces a new private availability kind "_PackageDescription" to
allow availability testing by an arbitary version that can be passed
using a new command-line flag "-swiftpm-manifest-version". The semantics
are exactly same as Swift version specific availability. In longer term,
it maybe possible to remove this enhancement once there is
a language-level availability support for 3rd party libraries.

Motivation:

Swift packages are configured using a Package.swift manifest file. The
manifest file uses a library called PackageDescription, which contains
various settings that can be configured for a package. The new additions
in the PackageDescription APIs are gated behind a "tools version" that
every manifest must declare. This means, packages don't automatically
get access to the new APIs. They need to update their declared tools
version in order to use the new API. This is basically similar to the
minimum deployment target version we have for our OSes.

This gating is important for allowing packages to maintain backwards
compatibility. SwiftPM currently checks for API usages at runtime in
order to implement this gating. This works reasonably well but can lead
to a poor experience with features like code-completion and module
interface generation in IDEs and editors (that use sourcekit-lsp) as
SwiftPM has no control over these features.
2018-12-08 09:38:40 +05:30
Slava Pestov
aa747dcd81 Remove property behaviors 2018-12-07 20:38:33 -05:00
Adrian Prantl
ff63eaea6f Remove \brief commands from doxygen comments.
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.

Patch produced by

      for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
2018-12-04 15:45:04 -08:00
Brent Royal-Gordon
facaad1873 A diagnosis from the argument clinic (#20997)
[Parse] Warn if the same argument is specified more than once in @available
2018-12-04 01:05:09 -08:00
Harlan Haskins
dd163f0701 [Parse] Parse @_hasStorage attribute outside of SIL 2018-11-26 18:42:02 -08:00
Harlan Haskins
66a61c5eca Rename @sil_stored to @_hasStorage 2018-11-12 11:32:32 -08:00
Pavel Yaskevich
53417f4aba [AST] Propagate @autoclosure flag to parameter decl and type flags 2018-11-10 11:59:28 -08:00
Slava Pestov
c7338d06ca AST: Remove owning addressors 2018-11-09 20:49:44 -05:00
Arnold Schwaighofer
c83f63855b Merge pull request #20428 from aschwaighofer/private_imports
Add @_private(from: "SourceFile.swift") imports
2018-11-09 07:18:25 -08:00
Arnold Schwaighofer
fbb4236eb3 Adjust to upstream change 2018-11-09 04:56:24 -08:00
Arnold Schwaighofer
e4f4dfcf84 Address feedback 2018-11-08 11:13:42 -08:00
Arnold Schwaighofer
963c64e3e7 Add @_private(from: "SourceFile.swift") imports
A module compiled with `-enable-private-imports` allows other modules to
import private declarations if the importing source file uses an
``@_private(from: "SourceFile.swift") import statement.

rdar://29318654
2018-11-08 08:00:47 -08:00
Marc Rasi
bf18697b4f parsing, typechecking, and SILGen for #assert
`#assert` is a new static assertion statement that will let us write
tests for the new constant evaluation infrastructure that we are working
on. `#assert` works by lowering to a `Builtin.poundAssert` SIL
instruction. The constant evaluation infrastructure will look for these
SIL instructions, const-evaluate their conditions, and emit errors if
the conditions are non-constant or false.

This commit implements parsing, typechecking and SILGen for `#assert`.
2018-11-07 16:34:17 -08:00
Arnold Schwaighofer
6f86e5c703 Fix unused variable warning. 2018-11-07 14:14:54 -08:00
Arnold Schwaighofer
b102c7f6b4 Parser/Sema/SILGen changes for @_dynamicReplacement(for:)
Dynamic replacements are currently written in extensions as

extension ExtendedType {
  @_dynamicReplacement(for: replacedFun())
  func replacement() { }
}

The runtime implementation allows an implementation in the future where
dynamic replacements are gather in a scope and can be dynamically
enabled and disabled.

For example:

dynamic_extension_scope CollectionOfReplacements {
  extension ExtentedType {
    func replacedFun() {}
  }

  extension ExtentedType2 {
    func replacedFun() {}
  }
}

CollectionOfReplacements.enable()
CollectionOfReplacements.disable()
2018-11-06 09:58:36 -08:00
Arnold Schwaighofer
c158106329 Allow dynamic without @objc in -swift-version 5
Dynamic functions will allow replacement of their implementation at
runtime.
2018-11-06 09:53:21 -08:00
Rintaro Ishizaki
90fe0a7e86 [CodeCompletion] Implement completion for 'get', 'set', 'willSet', 'didSet'
Implement 'get', 'set', 'willSet', 'didSet' completion at the beginning
of accessor position.

  var value: Ty {
    <HERE> // 'get', 'set', 'willSet' and 'didSet' along with normal
           // completion.
  }

  var value: Ty {
    get { return ... }
    <HERE> // 'get', 'set', 'willSet' and 'didSet' only.
  }

rdar://problem/20957182
2018-10-19 14:28:56 +09:00
Rintaro Ishizaki
797761adae [CodeCompletion] Try to parse complete expression after CC token
Type may depend on its suffix. Parsing complete expression including its
suffix improves context type info around the CC token.

rdar://problem/44143964
2018-10-16 06:08:29 +09:00
Mark Lacey
5e0cb1978a Fix libSyntax support for operator decl designated types. 2018-10-11 13:36:14 -07:00
Mark Lacey
cb5fd7f8d7 Merge branch 'master' into extend-operator-designated-type 2018-10-11 07:51:23 -07:00
Mark Lacey
703341239b Add support for multiple designated types for an operator declaration.
Add parsing, type checking, serialization, and deserialization support
for specifying multiple types as "designated" for operator lookup for
a given operator declaration.

The constraint solver still considers only the first type when
deciding the order to attempt the elements of a disjunction, so this
doesn't really change behavior yet.
2018-10-09 23:54:01 -07:00
Mark Lacey
e2529703ab Change operator decl representation for designated type.
Update the representation to allow for multiple types to be specified
for a single operator.

No parsing, serialization, or deserialization support yet, so NFC.
2018-10-09 23:17:15 -07:00
Anthony Latsis
f2ff87e652 Merge branch 'master' into code-compl-precedencegroups 2018-10-09 18:08:16 +03:00