Commit Graph

1645 Commits

Author SHA1 Message Date
Hamish Knight
c66e68fb93 [Parse][Sema] Emit immediate deallocation warning on the '=' token for PBDs (#17700)
Pass through the location of the equal '=' token for pattern binding decl entries, and use this location for the immediate deallocation diagnostic. Previously, we were just diagnosing on the start of the initialiser expression.

Additionally, this commit moves the call to `diagnoseUnownedImmediateDeallocation` from `typeCheckBinding` to `typeCheckPatternBinding`. This not only gives us easier access to the PBD entry, but also avoids calling the diagnostic logic for statement conditions such as `if let x = <expr>`. We currently never diagnose on these anyway, as the 'weak' and 'unowned' keywords cannot be applied to such bindings.

Resolves [SR-7340](https://bugs.swift.org/browse/SR-7340).
2018-07-06 10:47:49 -07:00
swift-ci
f3b8a3cbaf Merge remote-tracking branch 'origin/master' into master-next 2018-06-30 10:09:20 -07:00
John McCall
9bee3cac5a Generalize storage implementations to support generalized accessors.
The storage kind has been replaced with three separate "impl kinds",
one for each of the basic access kinds (read, write, and read/write).
This makes it far easier to mix-and-match implementations of different
accessors, as well as subtleties like implementing both a setter
and an independent read/write operation.

AccessStrategy has become a bit more explicit about how exactly the
access should be implemented.  For example, the accessor-based kinds
now carry the exact accessor intended to be used.  Also, I've shifted
responsibilities slightly between AccessStrategy and AccessSemantics
so that AccessSemantics::Ordinary can be used except in the sorts of
semantic-bypasses that accessor synthesis wants.  This requires
knowing the correct DC of the access when computing the access strategy;
the upshot is that SILGenFunction now needs a DC.

Accessor synthesis has been reworked so that only the declarations are
built immediately; body synthesis can be safely delayed out of the main
decl-checking path.  This caused a large number of ramifications,
especially for lazy properties, and greatly inflated the size of this
patch.  That is... really regrettable.  The impetus for changing this
was necessity: I needed to rework accessor synthesis to end its reliance
on distinctions like Stored vs. StoredWithTrivialAccessors, and those
fixes were exposing serious re-entrancy problems, and fixing that... well.
Breaking the fixes apart at this point would be a serious endeavor.
2018-06-30 05:19:03 -04:00
swift-ci
69be2c0150 Merge remote-tracking branch 'origin/master' into master-next 2018-06-26 09:49:25 -07:00
Graydon Hoare
c2d67d8eaa [Parse] <rdar://41154797> Detect eof in non-string-arg recovery loop in #error arg list. 2018-06-25 23:39:55 -07:00
swift-ci
4538ce9818 Merge remote-tracking branch 'origin/master' into master-next 2018-06-17 15:38:24 -07:00
John McCall
69f4dd1ec9 Generalize accessor storage to preserve the original accessor list.
Only not NFC because it's detectable by source tools.
2018-06-16 18:16:31 -04:00
swift-ci
bfe796b93e Merge remote-tracking branch 'origin/master' into master-next 2018-06-16 01:32:31 -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
Bob Wilson
5df3d1f100 Merge remote-tracking branch 'origin/master' into master-next 2018-06-14 20:51:48 -07:00
Slava Pestov
de9f3bb37c Parse: Remove unused findFirstNonNull() function 2018-06-14 16:03:34 -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
John McCall
9022b5152f Rename accessor kinds from IsGetter -> IsGet, etc.
Introduce some metaprogramming of accessors and generally prepare
for storing less-structured accessor lists.

NFC except for a change to the serialization format.
2018-06-14 17:08:55 -04:00
Bob Wilson
c3e02955bb [master-next] Adjust for VersionTuple moving from clang to llvm.
LLVM r334399 (and related Clang changes) moved clang::VersionTuple to
llvm::VersionTuple. Update Swift to match.

Patch by Jason Molenda.
rdar://problem/41025046
2018-06-12 16:44:11 -07:00
Slava Pestov
00cb08d9b3 Parse: Only diagnose renamed @_inlineable and @_versioned in -swift-version 4.2
Normally we don't gate *warnings* on -swift-version flags, but
SwiftNIO makes use of @_inlineable / @_versioned and wants to
continue building with Swift 4.1 until 4.2 is released.

Fixes <https://bugs.swift.org/browse/SR-7578>,
<rdar://problem/40717640>.
2018-06-09 22:41:54 -07:00
enomoto
bfff091fa8 Fix error message for a subscript without accessors says "computed property" 2018-06-08 20:45:05 -07:00
Mox Soini
965124708a Better error message for 'class func/var' usage in protocols 2018-06-04 08:49:28 +03:00
Rintaro Ishizaki
7c4aaef4f5 [CodeCompletion] Disable completion for declaration name position (#16898)
Code completion should not suggest anything when declaring a new name.

rdar://problem/29392238
2018-05-30 12:29:58 -07:00
Alex Hoppen
9d3233c556 [incrParse] Allow reuse of MemberDeclListItems 2018-05-22 08:52:38 -07:00
Alex Hoppen
b904194998 [libSyntax] Add support for parsing #sourceLocation directives 2018-05-22 08:52:31 -07:00
Wesley Wickwire
9e8f8d9acb centralized it a little better 2018-05-15 00:16:49 -04:00
Wesley Wickwire
d0c1fd6e72 added suggestion for inlinable misspelling 2018-05-14 23:53:10 -04:00
Rintaro Ishizaki
a6f7a8ea35 [Parser] Set local discriminator to ParamDecls
We have to discriminate between params and local variables.
2018-05-11 15:37:40 +09:00
Rintaro Ishizaki
df10afd1a2 [Parse] Discriminate local variables
Set local discriminator for all local `VarDecl`s. Otherwise, they cannot
be discriminated with USRs. This change is needed for rename refactoring which
uses USR for discrimiating variable names.

https://bugs.swift.org/browse/SR-7205,
rdar://problem/34701880
2018-05-11 15:34:42 +09:00
Pavel Yaskevich
adfaf8bab4 Merge pull request #16394 from xedin/rdar-39909829
[Parser] Set decl context to be typealias when completing its underly…
2018-05-07 14:14:37 -07:00
Kazutaka Homma
cfc91fd7b3 [SR-6996]Better diagnostic when declaring a class inheritance with parentheses (#15010)
add diagnosis for python style inheritance clause
2018-05-07 13:27:08 +09:00
Pavel Yaskevich
f49aad16b7 [Parser] Set decl context to be typealias when completing its underlying type
Parser didn't capture correct context when code completion
was attempted on typealias' right-hand side which, if there are
generic parameters present, would result in a crash. These
changes make it so completion gets a correct declaration
context in aforementioned case and typealias declaration is marked
invalid because it doesn't have a proper type.

Resolves: rdar://problem/39909829
2018-05-04 17:39:55 -07:00
Alex Hoppen
4c1b27db83 [libSyntax] Fix parsing of delayed function bodies 2018-04-27 21:05:36 -07:00
Alex Hoppen
82df80ad9d [libSyntax] Allow declarations with external asm name to not have a body
This covers declarations of functions with the @_silgen_name attribute
used in the stdlib.
2018-04-27 21:03:19 -07:00
Alex Hoppen
05350cd0bb [libSyntax] Fix parsing of delayed function bodies 2018-04-27 08:10:19 -07:00
Alex Hoppen
94b8a3545b [libSyntax] Fix parsing for KeyPath 2018-04-25 13:30:31 -07:00
Alex Hoppen
28973f23b6 [libSyntax] Fix parsing of member declarations with trailing semicolon 2018-04-24 14:19:24 -07:00
Alex Hoppen
c6a11097e8 [libSyntax] Fix parsing of #if inside type declarations 2018-04-24 14:16:11 -07:00
Alex Hoppen
3e9ae802c2 [libSyntax] Make parsing of attribute arguments more structured
This also fixes several issues where attribute arguments could not be
parsed as a TokenList since some of its arguments already had structure
and were not tokens
2018-04-24 13:18:15 -07:00
Alex Hoppen
75406c895c [libSyntax] Enable parsing of class restrictions for protocols 2018-04-23 12:23:27 -07:00
Rintaro Ishizaki
f1202c4563 Merge pull request #15891 from rintaro/syntax-operator-selector
[Syntax] Parse 'operator' decl and '#selector' expr syntax.
2018-04-13 15:45:43 +09:00
Rintaro Ishizaki
203496f048 [Parse] Hoist diagnostics for named 'subscript'/'init'
Mainly for code readability.
2018-04-13 11:58:33 +09:00
Rintaro Ishizaki
eb69497d64 [Syntax] Parse 'operator' declaration syntax 2018-04-12 13:55:55 +09:00
Rintaro Ishizaki
b457500389 [Syntax] Parse 'precedencegroup' declaration syntax 2018-04-11 23:21:54 +09:00
Jordan Rose
6d30272bfd Merge pull request #14382 from jrose-apple/unknown-case
Implementation for `@unknown default`
2018-04-10 11:19:53 -07:00
David Zarzycki
7174d14dad [Parsing] NFC: metaprogram contextual decl keywords into Attr.def 2018-04-07 18:00:12 -04:00
Jordan Rose
701975ad1d Add parsing support for @unknown (SE-0192)
This is our first statement attribute, made more complicated by the
fact that a 'case'/'default' isn't really a normal statement. I've
chosen /not/ to implement a general statement attribute logic like we
have for types and decls at this time, but I did get the compiler
parsing arbitrary attributes before 'case' and 'default'. As a bonus,
we now treat all cases within functions as being switch-like rather
than enum-like, which is better for recovery when not in a switch.
2018-04-05 16:35:14 -07:00
Sho Ikeda
63d5d0994a [ParseDecl] Fix typo in comment
dyntamic -> dynamic
2018-04-05 13:32:28 +09:00
Rintaro Ishizaki
6d402888ad [Parse] Don't swallow 'try' at declaration member position (#15733)
Previously, this used to be accepted:
  class Foo {
    try func bar() { }
  }
2018-04-05 07:59:53 +09:00
Rintaro Ishizaki
66d400eb1b [Syntax] Parse 'enum' and 'case' declaration (#15704) 2018-04-04 08:38:08 +09:00
Rintaro Ishizaki
2e14337e4a [Parse] Don't allow attributed #errror/#warning (#15705) 2018-04-04 08:36:18 +09:00
Rintaro Ishizaki
18b28b9184 [Parse] Factor out declaration modifier list parsing (#15702) 2018-04-03 19:58:57 +09:00
Slava Pestov
f7697291df Parse: Backward compatibility for old spellings @_inlineable and @_versioned
Just parse these as @inlinable and @versioned, then emit a warning
(Swift 4.2 and below) or error (Swift 5).
2018-03-30 21:55:31 -07:00
Slava Pestov
d3e32388c5 Parse: Better error recovery from invalid attributes 2018-03-30 21:55:30 -07: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