Commit Graph

1005 Commits

Author SHA1 Message Date
Slava Pestov
3b60ae153d AST: Rename AnyFunctionType::Param::getType() to getOldType() 2018-09-26 11:05:23 -07:00
Joe Groff
93b5de61e7 Implement the final approved syntax for SE-227 identity key paths.
`\.self` is the final chosen syntax. Implement support for this syntax, and remove the stopgap builtin and `WritableKeyPath._identity` property that were in place before.
2018-09-19 11:45:13 -07:00
swift-ci
cc329fee03 Merge pull request #19141 from aschwaighofer/remove_constant_string_literal 2018-09-10 15:51:47 -07:00
Mark Lacey
1e7dae3741 Merge pull request #19145 from rudkx/parse-designated-protocol
Add support for parsing designated protocols in operator declarations.
2018-09-06 22:01:02 -07:00
Arnold Schwaighofer
73df12c09f Remove dead constant_string_literal
constant_string_literal was added to support a one word representation
of String that never materialized.
2018-09-05 12:13:57 -07:00
Mark Lacey
039d10b709 Add support for parsing designated protocols in operator declarations.
The support is gated by a frontend option,
-enable-operator-designated-protocols.

This means that in an operator declaration we can declare a protocol
which has one or more requirements specifying this operator. The
operators from that designated protocol will be the first ones we try
when type checking an expression. If we successfully typecheck using
the operators specified in that protocol, we do not attempt any other
overloads of the same operator.

This makes it possible to dramatically speed up successful
typechecking.
2018-09-05 11:58:43 -07:00
Doug Gregor
0972111c60 [Type checker] Start tracking overrides of protocol requirements.
When a protocol that inherits another protocol restates a requirement
from its inherited protocol, track that as an override in the AST.
2018-09-04 16:42:06 -07:00
John McCall
b80618fc80 Replace materializeForSet with the modify coroutine.
Most of this patch is just removing special cases for materializeForSet
or other fairly mechanical replacements.  Unfortunately, the rest is
still a fairly big change, and not one that can be easily split apart
because of the quite reasonable reliance on metaprogramming throughout
the compiler.  And, of course, there are a bunch of test updates that
have to be sync'ed with the actual change to code-generation.

This is SR-7134.
2018-08-27 03:24:43 -04:00
Robert Widmann
2fb5afb755 Remove the @_downgrade_exhaustivity_check hack
This hack was only needed for Swift 3 mode in a narrow case.  Flush it out of the compiler so we can simplify the space engine.
2018-08-24 10:54:43 -07:00
John McCall
a30d91e3cb Implement vararg expansion well enough to support argument forwarding.
I needed this for materializeForSet remission, but it makes inherited
variadic initializers work, too.

I tried to make this a reasonable starting point for a real language
feature.  Here's what's still missing:

- syntax
- semantic restrictions to ensure that the expression isn't written in
  invalid places or arbitrarily converted
- SILGen support for expansions that aren't the only variadic argument

rdar://16331406
2018-08-22 06:46:08 -04:00
Jordan Rose
1958d7aea3 [AST] Add an AccessScope::dump helper (#18756)
And factor an existing getAccessLevelString out into a
generally-available swift::getAccessLevelSpelling.
2018-08-16 10:30:30 -07:00
swift-ci
71f0248b0a Merge remote-tracking branch 'origin/master' into master-next 2018-08-06 11:07:55 -07:00
Doug Gregor
bd5f5d80e4 [AST] Add ExtensionDecl::getExtendedNominal().
Introduce ExtensionDecl::getExtendedNominal() to provide the nominal
type declaration that the extension declaration extends. Move most
of the existing callers of the callers to getExtendedType() over to
getExtendedNominal(), because they don’t need the full type information.

ExtensionDecl::getExtendedNominal() is itself not very interesting yet,
because it depends on getExtendedType().
2018-08-03 11:26:48 -07:00
swift-ci
685b007c3f Merge remote-tracking branch 'origin/master' into master-next 2018-07-23 20:39:45 -07:00
John McCall
7a4aeed570 Implement generalized accessors using yield-once coroutines.
For now, the accessors have been underscored as `_read` and `_modify`.
I'll prepare an evolution proposal for this feature which should allow
us to remove the underscores or, y'know, rename them to `purple` and
`lettuce`.

`_read` accessors do not make any effort yet to avoid copying the
value being yielded.  I'll work on it in follow-up patches.

Opaque accesses to properties and subscripts defined with `_modify`
accessors will use an inefficient `materializeForSet` pattern that
materializes the value to a temporary instead of accessing it in-place.
That will be fixed by migrating to `modify` over `materializeForSet`,
which is next up after the `read` optimizations.

SIL ownership verification doesn't pass yet for the test cases here
because of a general fault in SILGen where borrows can outlive their
borrowed value due to being cleaned up on the general cleanup stack
when the borrowed value is cleaned up on the formal-access stack.
Michael, Andy, and I discussed various ways to fix this, but it seems
clear to me that it's not in any way specific to coroutine accesses.

rdar://35399664
2018-07-23 18:59:58 -04:00
swift-ci
80e4678ece Merge remote-tracking branch 'origin/master' into master-next 2018-07-19 14:29:44 -07:00
Slava Pestov
585b06e647 AST: Remove uses of AbstractFunctionDecl::getParameterLists() 2018-07-19 12:28:26 -07:00
swift-ci
9eb4e3a0a4 Merge remote-tracking branch 'origin/master' into master-next 2018-07-16 18:48:54 -07:00
Slava Pestov
fc80f75273 AST: Create new 'invalid' state for ProtocolConformanceRef 2018-07-16 16:44:27 -07:00
swift-ci
9e940b1782 Merge remote-tracking branch 'origin/master' into master-next 2018-07-15 16:49:04 -07:00
danielzheng
7dc8dd6fb0 [ASTDumper] Use consistent coloring.
- Print "assign_expr" with color (using `printCommon`).
- Print "function_ref" for UnresolvedDotExpr with color, to be
consistent with all other "function_ref" printing.
2018-07-15 05:11:24 -07:00
danielzheng
8239cf8c57 [ASTDumper] Use consistent coloring for ValueDecls ("decl=").
Most instances of "decl=" were printed with color but some were not.
Now, all instances of "decl=" (and the subsequent ValueDecl or
ConcreteDeclRef) are printed with color.
2018-07-15 05:11:16 -07:00
danielzheng
ad66f23a68 [ASTDumper] Use consistent coloring for closing parentheses.
Some colored open parentheses (printed by `printCommon`) had uncolored
closing parenthesis counterparts. Now, all such closing parentheses are
colored.
2018-07-15 03:18:35 -07:00
swift-ci
f9fbeb1068 Merge remote-tracking branch 'origin/master' into master-next 2018-07-06 06:08:58 -07:00
Slava Pestov
b102964729 AST: Remove unused function 2018-07-06 02:24:14 -07:00
swift-ci
0b12c9a5fa Merge remote-tracking branch 'origin/master' into master-next 2018-07-06 00:49:00 -07:00
Slava Pestov
381483bd74 AST: Remove Expr's LValueAccessKind 2018-07-05 23:54:13 -07:00
swift-ci
decf2b1130 Merge remote-tracking branch 'origin/master' into master-next 2018-07-05 11:49:26 -07:00
John McCall
34b0cbc11d Merge pull request #16237 from davezarzycki/metaprogram_ref_storage_types
[AST] NFC: Enable reference storage type meta-programming
2018-07-05 14:45:38 -04:00
swift-ci
f3b8a3cbaf Merge remote-tracking branch 'origin/master' into master-next 2018-06-30 10:09:20 -07:00
David Zarzycki
5b9f5062f9 [AST] NFC: Adopt reference storage type meta-programming macros 2018-06-30 06:44:33 -04: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
9885d9e133 Merge remote-tracking branch 'origin/master' into master-next 2018-06-21 09:10:01 -07:00
Joe Groff
d17b767361 Merge pull request #17219 from fedetrim/master
[SR-7904] Add source filenames in the output of `-dump-ast`
2018-06-21 08:59:43 -07:00
swift-ci
01fe4cdcd7 Merge remote-tracking branch 'origin/master' into master-next 2018-06-20 19:09:02 -07:00
Huon Wilson
10b30fef78 [GSB] Explicit error on unsupported conditional conformance recursion.
This doesn't fix the fundamental problem of correctly handling such cases, but
it is better than the "error message" that occurred previously:

    Assertion failed: ((bool)typeSig == (bool)extensionSig && "unexpected generic-ness mismatch on conformance").

Fixes the crash rdar://problem/41281406 (that in
https://bugs.swift.org/browse/SR-6569 (rdar://problem/36068136)),
https://bugs.swift.org/browse/SR-8019 (rdar://problem/41216423) and
https://bugs.swift.org/browse/SR-7989 (rdar://problem/41126254).
2018-06-21 10:53:30 +10:00
swift-ci
8eae3f0fc4 Merge remote-tracking branch 'origin/master' into master-next 2018-06-18 17:09:50 -07:00
swift-ci
8f23048c85 Merge pull request #17097 from brentdax/noescape-from-the-ast-dump-scrape 2018-06-18 16:59:37 -07:00
Federico Trimboli
63f0697df1 [SR-7904] Add source filenames in the output of -dump-ast 2018-06-15 11:29:29 -03:00
Bob Wilson
5df3d1f100 Merge remote-tracking branch 'origin/master' into master-next 2018-06-14 20:51:48 -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
swift-ci
1bb550e4ea Merge remote-tracking branch 'origin/master' into master-next 2018-06-11 16:49:21 -07:00
Bob Wilson
033b884de6 [master-next] Replace use of F_RW flag that was removed in LLVM r334221
Use a combination of the new FA_Read and FA_Write flags instead.
2018-06-11 14:53:35 -07:00
Robert Widmann
7d82e70f2c Excise getInput() from printing
Not NFC because it changes the printing behavior for function type
parameters.  They are no longer reported as types (paren, tuple, or raw),
but as Params.
2018-06-10 19:40:26 -07:00
Brent Royal-Gordon
fb79b8f44e Indicate which closures are escaping in AST dumps 2018-06-10 14:03:01 -07:00
Doug Gregor
147e6e937f Merge pull request #16778 from brentdax/semantic-expr-dump
Dump semantic expressions in AST consistently
2018-05-23 15:06:11 -07:00
Brent Royal-Gordon
e6debec9c4 Dump various nodes’ semanticExprs
Previously, only DictionaryExpr dumped its semanticExpr, and it replaced the direct contents. With this change, all nodes with a semanticExpr dump it, and they all handle it in the same way: they append it to the end of the list of children, in a separate S-expression marked by “semantic_expr”.
2018-05-22 14:17:21 -07:00
Brent Royal-Gordon
531109ca1f Add closing paren after ObjectLiteralExpr dump 2018-05-22 14:14:04 -07:00
Mark Rowe
88629e9dbc Include source ranges for statements in the AST dump. 2018-05-17 10:50:19 -07:00
Mark Rowe
b4481a1300 Include source ranges for parameter lists in the AST dump. 2018-05-17 10:50:19 -07:00