Commit Graph

1220 Commits

Author SHA1 Message Date
Jordan Rose
46d994fba8 [Parse] Sink all SIL parsing into SILParserTUState.
...in preparation for extracting SIL parsing into its own library.
2017-07-17 12:18:41 -06:00
Huon Wilson
2e952d2686 Merge pull request #10908 from huonw/swift3-is-behind-us-now
Upgrade some deprecation warnings from Swift 3 to errors in Swift 4.
2017-07-12 16:25:46 -07:00
Huon Wilson
55e1aa2a9f [Parse] Upgrade @noescape/@autoclosure(escaping) warnings to Swift 4 errors.
Part of rdar://problem/28961650 .
2017-07-12 13:26:09 -07:00
Huon Wilson
09f45c8f2b [Parse] Upgrade deprecated_operator_body* to Swift 4 errors.
Part of rdar://problem/28961650 .
2017-07-12 13:17:40 -07:00
Huon Wilson
e2d01f5cce [Parse] Upgrade operator_static_in_protocol to Swift 4 error.
Part of rdar://problem/28961650 .
2017-07-12 13:17:40 -07:00
Alex Hoppen
f8c2692f79 Introduce special decl names
Special DeclNames represent names that do not have an identifier in the
surface language. This implies serializing the information about whether
a name is special together with its identifier (if it is not special)
in both the module file and the swift lookup table.
2017-07-11 19:04:13 +02:00
Robert Widmann
82b13d11ac Merge pull request #10784 from CodaFi/my-sweet-noescape
[SR-5296] @autoclosure and @noescape are not decl attributes
2017-07-06 00:01:21 -07:00
Robert Widmann
ab580a3a0a Remove @autoclosure and @noescape as decl attributes
Using these in declaration position has been deprecated and
removed in Swift 3.  These attributes were not being parsed and
contained deadweight diagnostics that should have been moved
when these attributes became type attributes.
2017-07-05 21:27:04 -07:00
Robert Widmann
f11779572c Replace setLet with setSpecifier 2017-07-05 14:41:59 -07:00
Robert Widmann
4da853e7cb Rename Specifier::None to Specifier::Owned 2017-07-05 14:02:26 -07:00
Robert Widmann
ac5594dabe Use a meaningful representation of parameter specifiers
In anticipation of future attributes, and perhaps the ability to
declare lvalues with specifiers other than 'let' and 'var', expand
the "isLet" bit into a more general "specifier" field.
2017-06-29 16:03:49 -07:00
Huon Wilson
18078c104e Merge pull request #10476 from huonw/cleanups
Small clean-ups
2017-06-22 14:30:46 -07:00
Rintaro Ishizaki
e8cc8b55d8 [Parse] Fix #sourceLocation parsing in Decl position (#10444)
Fixes: https://bugs.swift.org/browse/SR-5242
`#sourceLocation` directive at end of declaration list postion was
rejected.
2017-06-22 12:35:43 +09:00
Huon Wilson
a4521c642b [NFC] Remove unnecessary radar reference. 2017-06-21 13:59:42 -07:00
Huon Wilson
61606a6616 [Parse] Provide better diagnostics for func 1() {}.
It is apparently a common mistake for beginners to start the names of functions
etc. with numbers, and before this patch the diagnostic wasn't specific about
the problem. It seems likely that most instances of `func 1(...` will be
mistakes in this vein, so this patch specifically diagnoses that case, and also
parses the number as the identifier to avoid follow on errors about top-level
closures (from the {}) and other invalid syntax.

Fixes rdar://problem/32316666 .
2017-06-20 16:49:50 -07:00
Jordan Rose
77de3dc1f2 [AST] Bring 'mutating' and 'inout self' in sync. (#10375)
- A mutating method or accessor always has 'inout self'.
- A nonmutating method or accessor never has 'inout self'.
- Only instance members can be mutating.
- Addressors are still addressors even when on static members.

Came up after reviewing another patch that confused the two as
possibly distinct concepts.
2017-06-19 16:16:47 -07:00
Slava Pestov
732b215b88 Merge pull request #9413 from rintaro/ast-eliminate-ifconfigstmt
[AST] Eliminate IfConfigStmt
2017-06-16 15:39:47 -07:00
Jordan Rose
5c1967397b Update and re-enable the diagnostics for unstable runtime names.
This time, the warnings only fire when the class in question directly
conforms to NSCoding. This avoids warning on cases where the user has
subclassed something like, oh, UIViewController, and has no intention
of writing it to a persistent file.

This also removes the warning for generic classes that conform to
NSCoding, for simplicity's sake. That means
'@NSKeyedArchiverEncodeNonGenericSubclassesOnly' is also being
removed.

Actually archiving a class with an unstable mangled name is still
considered problematic, but the compiler shouldn't emit diagnostics
unless it can be sure they are relevant.

rdar://problem/32314195
2017-06-05 17:32:26 -07:00
Jordan Rose
f0aca936c7 Allow '@objc(RuntimeName)' on classes with generic ancestry.
This is accomplished by recognizing this specific situation and
replacing the 'objc' attribute with a hidden '_objcRuntimeName'
attribute. This /only/ applies to classes that are themselves
non-generic (including any enclosing generic context) but that have
generic ancestry, and thus cannot be exposed directly to Objective-C.

This commit also eliminates '@NSKeyedArchiverClassName'. It was
decided that the distinction between '@NSKeyedArchiverClassName' and
'@objc' was too subtle to be worth explaining to developers, and that
any case where you'd use '@NSKeyedArchiverClassName' was already a
place where the ObjC name wasn't visible at compile time.

This commit does not update diagnostics to reflect this change; we're
going to change them anyway.

rdar://problem/32414557
2017-06-05 17:32:25 -07:00
Alex Hoppen
de5000f9a6 [Parser] Preparations for removal of getName on ValueDecl
With the introduction of special decl names, `Identifier getName()` on
`ValueDecl` will be removed and pushed down to nominal declarations
whose name is guaranteed not to be special. Prepare for this by calling
to `DeclBaseName getBaseName()` instead where appropriate.
2017-05-28 19:13:24 -07:00
Rintaro Ishizaki
c8d717e5f4 [Parse] Cleanup #if directive parsing
Now that, IfConfigDecl holds ASTNode regardless statements position or
declarations postion. We can construct it in single method.
2017-05-16 20:52:46 +09:00
Rintaro Ishizaki
6fa84150c5 [AST] Eliminate IfConfigStmt
Resolves: https://bugs.swift.org/browse/SR-4426

* Make IfConfigDecl be able to hold ASTNodes
* Parse #if as IfConfigDecl
* Stop enclosing toplevel #if into TopLevelCodeDecl.
* Eliminate IfConfigStmt
2017-05-16 12:19:54 +09:00
Rintaro Ishizaki
f1b0285bbc [Parse] Don't Hoist IfConfig{Decl,Stmt} out of IfConfig{Decl,Stmt} 2017-05-16 12:09:56 +09:00
Doug Gregor
7955aa13e6 Rename @NSKeyedArchive* attributes.
@NSKeyedArchiveLegacy -> @NSKeyedArchiverClassName
@NSKeyedArchiveSubclassesOnly -> @NSKeyedArchiverEncodeNonGenericSubclassesOnly

Fixes rdar://problem/32178796.
2017-05-15 11:02:31 -07:00
Huon Wilson
aadb959143 [Parse] Delete incorrect comment. NFC. 2017-05-11 17:01:55 +10:00
practicalswift
492f5cd35a [gardening] Remove redundant repetition of type names (DRY): RepeatedTypeName foo = dyn_cast<RepeatedTypeName>(bar)
Replace `NameOfType foo = dyn_cast<NameOfType>(bar)` with DRY version `auto foo = dyn_cast<NameOfType>(bar)`.

The DRY auto version is by far the dominant form already used in the repo, so this PR merely brings the exceptional cases (redundant repetition form) in line with the dominant form (auto form).

See the [C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es11-use-auto-to-avoid-redundant-repetition-of-type-names) for a general discussion on why to use `auto` to avoid redundant repetition of type names.
2017-05-05 09:45:53 +02:00
Doug Gregor
aaf7933a6d Add the @NSKeyedArchiveLegacy attribute.
This attribute allows one to provide the "legacy" name of a class for
the purposes of archival (via NSCoding). At the moment, it is only
useful for suppressing the warnings/errors about classes with unstable
archiving names.
2017-05-02 22:38:32 -07:00
practicalswift
a596961187 [gardening] Make parameter name comments match actual parameter names 2017-04-20 13:47:10 +02:00
Graydon Hoare
3d5c995615 Parse @_implements(Proto, DeclName) 2017-04-18 11:12:54 -07:00
Doug Gregor
50799dc084 [AST] Track the location of the 'class' keyword for class-bounded protocols. 2017-03-21 07:36:29 -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
Huon Wilson
ca3a398b4a Merge pull request #8021 from huonw/protocol-where-clause
Parse/typecheck/print where clauses on protocols
2017-03-15 11:00:46 -07:00
David Hart
6de44b0fb1 [SR-3936] Fix it for missing property type
Solve SR-3936 by providing a fix-it for the “Computed property must have an explicit type” diagnostic that insert a type placeholder.
2017-03-14 22:47:02 +01:00
Huon Wilson
54f247693c [AST]/[Parse] parse where clauses on protocol declarations. 2017-03-09 16:08:16 -08:00
swift-ci
af53cb9778 Merge pull request #7733 from rintaro/parse-ifconfig-refactoring 2017-02-28 19:10:59 -08:00
Huon Wilson
8423018057 [Parse] Parse trailing where clauses on associated types. 2017-02-24 19:21:32 -08:00
Slava Pestov
928a74c47e Parse: Support for generic subscripts 2017-02-23 21:14:02 -08:00
Slava Pestov
fdb0a18647 AST: Add a GenericParamList::clone() method
This will be immediately needed for generic subscripts, and also
for fixing the remaining cases where initializer inheritance
doesn't work.
2017-02-23 20:57:15 -08:00
Rintaro Ishizaki
58c079e306 [Parse] Split out IfConfig related functions into ParseIfConfig.cpp 2017-02-24 11:07:27 +09:00
Rintaro Ishizaki
3a2f8c9a40 [Parse] Promote parseDeclItem() to Parser method 2017-02-24 01:37:48 +09:00
Rintaro Ishizaki
78b92a56c7 [Parse] Only one conditional compilation clause can be active (#7627) 2017-02-21 02:13:11 +09:00
Slava Pestov
880803aaba AST: Initial plumbing for generic subscripts 2017-02-19 21:34:26 -08:00
David Farler
431b7ff2af [Syntax] Add Equal '=' token location to TypeAliasDecl
Needed for full-fidelity structured editing.
2017-02-17 12:57:04 -08:00
Rintaro Ishizaki
3b42894f13 [Parse] Fix parsing three-version-components in #if
* Narrow allowance of 3+ components numeric literal to condition part of the
  directive.
* Allow 3+ components in '#if' directive in decl list position as well.
2017-02-16 11:35:51 +09:00
Rintaro Ishizaki
cfe742d1eb [Parse] Minor improvements in conditional compilation block parsing
* Don't emit duplicated 'expected #else or #endif at end of conditional
  compilation block' error.

    class Foo {
      #if true
        func foo() {}
    [EOF]

* Improve error message when seeing '}' in config block.

    class Foo {
    #if true
        func foo();
    } // error: unexpected '}' in conditional compilation block
    #else
    #endif
2017-02-16 11:35:51 +09:00
Hugh Bellamy
f001b7562b Use relatively new LLVM_FALLLTHROUGH instead of our own SWIFT_FALLTHROUGH 2017-02-12 10:47:03 +07:00
Jacob Bandes-Storch
e1fd8aa6c7 [Parse] Fix crash in conditional compilation parsing (#7331) 2017-02-08 23:10:26 -08:00
Doug Gregor
d83f311cc1 [Parser] Throw away generic parameters we parse just for QoI.
We parse generic parameters on an associated type declaration just so
that we have provide a customized diagnostic. That's fine, but do so
in a new scope so that the generic parameters aren't visible to name
lookup.
2017-02-07 15:22:50 -08:00
Slava Pestov
d880053dd5 Merge pull request #7050 from rintaro/parse-diag-consecutiveids
[Parse] Improve diagnostics for consecutive identifiers
2017-01-31 21:19:19 -08:00
Slava Pestov
dca292c652 Serialization: Don't serialize contextual enum argument type
Storing this separately is unnecessary since we already
serialize the enum element's interface type. Also, this
eliminates one of the few remaining cases where we serialize
archetypes during AST serialization.
2017-01-30 00:08:53 -08:00