Commit Graph

2092 Commits

Author SHA1 Message Date
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
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
Doug Gregor
d4edb3d2e8 [AST] Consistently rely on the “isObjC” bit rather than the presence of ObjCAttr.
The “isObjC” bit, once computed, provides the authoritative answer. The presence of
ObjCAttr is mostly incidental, although an implicitly-created one is sometimes
needed to store additional information (“inferred with Swift 3 rules” and a
specific Objective-C name).
2018-06-28 20:23:08 -07:00
Robert Widmann
a7c9bd09db Merge pull request #17181 from CodaFi/in-put-up-and-in-shut-up
[IDE] Scrub SwiftIDE of References to getInput()
2018-06-16 11:14:49 -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
Slava Pestov
296ce3f312 AST: Remove hack-around for getInterfaceType() on ParamDecl returning InOutType
Most callers did not want the InOutType here, and checked
the ParamDecl's flags instead.
2018-06-13 15:38:52 -07:00
Robert Widmann
e8eba29cd9 [IDE] Scrub SwiftIDE of References to getInput() 2018-06-13 14:43:54 -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
John Fairhurst
32b04b8405 [ASTPrinter] Fix raw string enum cases with unicode scalars 2018-05-16 10:52:48 +01:00
Doug Gregor
ef020c74aa Eliminate all vestiges of Substitution and SubstitutionList.
Introduced during the bring-up of the generics system in July, 2012,
Substitution (and SubstitutionList) has been completely superseded by
SubstitutionMap. R.I.P.
2018-05-11 21:43:40 -07:00
Doug Gregor
c009650268 [SIL] Standardize on printing the replacement types for a SubstitutionMap.
SIL printing and parsing was based on printing substitution lists.
Change that to instead print/parse based on the replacement types
in substitution maps, which fits more closely with the rest of the
system.

This commit is papering over an issue where the substitution maps
generated for the “apply” of a partial specialization use an
ever-so-slightly different generic signature than partial
specialization itself. The TODO in the SIL printer for covers that
case.
2018-05-11 13:46:51 -07:00
Doug Gregor
d093879cab Reinstate SubstitutionList-based printing for SIL and specialized conformances.
The SIL parser depends on these, still.
2018-05-03 10:57:05 -07:00
Doug Gregor
bc5bbe8b64 [AST] Use SubstitutionMap, not SubstitutionList, in SILBoxType.
Eliminate the last place in the AST proper that stores
SubstitutionLists rather than SubstitutionMaps. Randomly fixes a
crasher, too.
2018-05-02 13:39:21 -07:00
Doug Gregor
3e2bed119b [AST] Switch SpecializedProtocolConformance over to SubstitutionMap.
Eliminate another common use of SubstitutionList from the AST.
2018-05-02 13:38:15 -07:00
Huon Wilson
b6d44f31da [AST] std::function -> llvm::function_ref for some non-escaping params. 2018-05-01 08:29:06 +10:00
Ben Langmuir
9496c63edc Merge pull request #15918 from johnfairh/typealias-where
[ASTPrinter] Print typealias generic requirements
2018-04-25 09:57:05 -07:00
David Zarzycki
f3b8b03a31 [Diag] QoI: Suggest fix-it when 'weak' has non-optional type (#16098)
Also:
1) Move and rename a type printer helper function to make this easier.
2) Improve @IBOutlet diagnostic QoI at the same time.
2018-04-23 20:55:25 -04:00
John Fairhurst
315fd8ceac [ASTPrinter] Refactor generic param/req printing 2018-04-14 12:04:34 +01:00
John Fairhurst
6e38a636aa [ASTPrinter] Print typealias where clause 2018-04-14 12:04:29 +01: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
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
Doug Gregor
b2b69e8abf Rename BoundNameAliasType to NameAliasType.
NameAliasType is dead! Long live NameAliasType!
2018-03-25 21:35:17 -07:00
Doug Gregor
c43f96a855 [AST] Remove now-unused NameAliasType. 2018-03-25 21:35:16 -07:00
swift-ci
29788f6245 Merge pull request #14963 from kitasuke/replace-of-builtin-string-with-constant 2018-03-24 18:56:17 -07:00
Doug Gregor
80eae200b6 [AST] Preserve type sugar for generic typealiases
Introduce a new Type node, BoundNameAliasType, which describes a
reference to a typealias that requires substitutions to produce the
underlying type. This new type node is used both for references to
generic typealiases and for references to (non-generic) typealiases
that occur within generic contexts, e.g., Array<Int>.Element.

At present, the new type node is mainly useful in preserving type
sugar for diagnostics purposes, as well as being reflected in other
tools (indexing, code completion, etc.). The intent is to completely
replace NameAliasType in the future.
2018-03-21 23:49:17 -07:00
Huon Wilson
e307e54098 [AST] Explicitly track things marked __owned. 2018-03-08 12:36:24 +11:00
Slava Pestov
cb1c8c8f16 AST: Simplify printExtendedTypeName() 2018-03-06 19:41:44 -08:00
Xi Ge
9f39c8494d [SourceKitd] Avoid printing parent type directly on extended type. rdar:37965902 (#14892)
When printing parent type directly, we may print generic arguments and sugared
dictionary type.
2018-03-01 09:19:44 -08:00
Joe Groff
d365c153d4 SIL: Introduce sil_property declarations for property descriptors.
This provides SILGen a place to generate the key path component information for an exported property so that it can be linked to from other modules.
2018-02-23 14:57:45 -08:00
Bartosz Polaczyk
ff05efeead Print nominal AST extended types 2018-02-19 19:25:03 +01:00
Bartosz Polaczyk
c28302836b [SIL] Print full nested enum type name
ASTPrinter should print an extended type for enums,
(same as structs and classes) along with enum parents.
2018-02-18 16:14:42 +01:00
Huon Wilson
c6ab136112 Merge pull request #14628 from huonw/no-conditional-objc-generics
[Sema] Disallow conditional conformances on objective-c generics.
2018-02-16 09:14:50 +11:00
Huon Wilson
50b6d10a4e [NFC] Move TypeOrExtensionDecl out of PrintOptions.h. 2018-02-15 16:58:24 +11:00
Huon Wilson
56cf07752d Merge pull request #14554 from huonw/doc-conditional-conformances
[IDE] Teach type checker about conditional conformance extensions.
2018-02-14 07:21:11 +11:00
Huon Wilson
cb60dbeee2 [IDE] Teach type checker about conditional conformance extensions.
Before conditional conformances, the archetypes in conformance
extensions (i.e. extension Foo: SomeProtocol) were equivalent to those
in the type decl, with the same protocol bounds and so on. The code for
printing "synthesized" members relied on this fact. This commit teaches
that code to deal with archetypes in the conditional conformance
extension when required.

Fixes rdar://problem/36553066 and SR-6930.
2018-02-13 17:37:15 +11:00
Mark Lacey
fdd86fe069 Remove ImplicitlyUnwrappedOptionalType.
We haven't been creating these since
https://github.com/apple/swift/pull/14299 but there was more
groundwork before we could actually remove the type definition.
2018-02-05 23:59:01 -08:00
Harlan
5e02d2a877 Implement #warning and #error (#14048)
* Implement #warning and #error

* Fix #warning/#error in switch statements

* Fix AST printing for #warning/#error

* Add to test case

* Add extra handling to ParseDeclPoundDiagnostic

* fix dumping

* Consume the right paren even in the failure case

* Diagnose extra tokens on the same line after a diagnostic directive
2018-02-03 18:07:05 -05:00
Mark Lacey
2008674495 Make ImplicitlyUnwrappedOptional<T> an unavailable typealias.
Also remove the decl from the known decls and remove a
bunch of code referencing that decl as well as a bunch of other
random things including deserialization support.

This includes removing some specialized diagnostics code that
matched the identifier ImplicitlyUnwrappedOptional, and tweaking
diagnostics for various modes and various issues.

Fixes most of rdar://problem/37121121, among other things.
2018-02-02 08:35:53 -08:00
David Zarzycki
3da6fe9c0d [AST] NFC: Do not reinterpret_cast pointers into CanTypeWrappers
This also introduces 'TypeArrayView' for when a 'Type' is statically
known to be a given TypeBase subclass.
2018-01-31 11:20:05 -05:00
Xi Ge
98570550c3 [SourceKit] Report synthesized protocol conformances for DocSupport request. rdar://36882292 (#14248) 2018-01-30 13:32:50 -08:00
Mark Lacey
7c71e57200 Another small update to AST printing for removal of IUOs.
7dc6d2ce30
missed a spot where we need to handle printing IUOs specially once they are
removed from the type system.
2018-01-24 23:33:39 -08:00
Mark Lacey
5518bae548 Update code completion printing for removal of IUOs from the type system.
This doesn't address any issues in loss of functionality when trying
to complete IUO-typed things, just the various printing issues.
2018-01-23 13:36:04 -08:00
John McCall
7f0f8830cd Split AccessorDecl out from FuncDecl. NFC.
This has three principal advantages:

- It gives some additional type-safety when working
  with known accessors.

- It makes it significantly easier to test whether a declaration
  is an accessor and encourages the use of a common idiom.

- It saves a small amount of memory in both FuncDecl and its
  serialized form.
2018-01-12 14:20:27 -05:00
Mark Lacey
41c37c1b46 IUO: Update AST printer to print '!' for Optionals that are implicitly unwrapped.
Once we generate Optional<T> for T! we'll need this to ensure that we
continue to print '!' in places where the user specified it.
2018-01-11 14:42:05 -08:00
Michael Ilseman
e45fba760c Merge pull request #12793 from johnfairh/nested-param-attrs
[ASTPrinter] Print parameter type attributes more often
2018-01-09 11:16:12 -08:00
David Zarzycki
9b48b5074a [AST] Perf: Unite DictionaryType with SyntaxSugarType
1) Move existing SyntaxSugarTypes under a new subclass called UnarySyntaxSugarType.
2) Make DictionaryType subclass SyntaxSugarType.

This helps improve getDesugaredType() performance by ensuring that
ImplOrContext is stored at the same field offset in memory.

This also de-boilerplates some AST walking.
2018-01-02 15:14:07 -05:00
David Zarzycki
62795501d9 [AST] NFC: De-boilerplate "has ParenType sugar" 2017-12-29 11:37:20 -05:00
John Fairhurst
87015e46d8 Print out param type attributes in more places 2017-11-20 19:36:50 +00:00
Nathan Hawes
c1079720cd [ASTPrinter] Print subscript generic parameters and requirments
These were ignored previously.
2017-11-17 15:52:23 -08:00