Commit Graph

1461 Commits

Author SHA1 Message Date
Doug Gregor
aa8b3c4d0e [AST] Move lazily-computed @objc bits into a separate LazySemanticInfo field.
To help us isolate the state that is primarily managed through the
request-evaluator, encapsulate that information in a LazySemanticInfo member
(as we do with superclass info and enum raw type info) rather than scattering
it around the AST.
2018-07-02 13:32:40 -07:00
Doug Gregor
be3974a4f2 [AST] Drop unnecessary pass-by-reference from simple_display for ValueDecls. 2018-07-02 13:32:39 -07:00
Hamish Knight
893d33128c Add a convenience PatternBindingDecl::createImplicit member and mark some PBDs as implicit (#17441)
Previously, some PBDs weren't being marked implicit even though the associated vars were implicit. PatternBindingDecl::createImplicit will be even nicer when we start parsing the location of the equals token.
2018-07-02 10:42:03 -07:00
John McCall
f81036202d Merge pull request #17566 from rjmccall/storage-impls
Generalize storage implementations to support generalized accessors
2018-06-30 12:58: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
Slava Pestov
94feb373c8 AST: Remove 'checked inheritance clause' bit from TypeDecl and ExtensionDecl 2018-06-30 00:20:36 -07:00
Doug Gregor
346e5da333 [AST] Add bits to capture ValueDecl's "isObjC" state and whether it has been computed.
One small step toward computing "isObjC" via the request-evaluator.
2018-06-28 20:22:44 -07:00
Slava Pestov
6d88ab3ab5 Merge pull request #17611 from slavapestov/protocol-superclass-part-1
Protocols with superclass constraints - part 1
2018-06-28 19:00:26 -07:00
Slava Pestov
fcfa1786c8 IRGen: Add another lldb resilience hack
When accessing global variables defined in the REPL, lldb does not consult
debug info, so it does not see that the DW_OP_deref was emitted.

So instead, set a special bit on globals defined in the REPL which bypasses
resilience for them altogether.

Part of the fix <rdar://problem/39722386>.
2018-06-28 16:56:55 -07:00
Slava Pestov
5f4f55caf8 AST: Add superclass field to ProtocolDecl 2018-06-28 15:19:20 -07:00
Slava Pestov
0a60619b70 Sema: Declaration signatures should respect @usableFromInline
Previously we made sure that inlinable function bodies only
reference @usableFromInline or public declarations, but we
also have to make sure that @usableFromInline declarations
only reference other declarations that are at least as
visible.

Otherwise, you could, for example, define a @usableFromInline
typealias which referenced an internal type, and then
reference the typealias from a @usableFromInline function body.
2018-06-26 00:31:32 -07:00
Slava Pestov
aade63e45e AST: Some tweaks for ValueDecl::isUsableFromInline()
Make this method public and fix it to do the right thing for
associated types.
2018-06-25 21:27:49 -07:00
Joe Groff
d82137b3da Merge pull request #17404 from jckarter/trivial-property-descriptors
SILGen: Emit "trivial" property descriptors for properties that withhold no information about their implementation.
2018-06-21 20:33:36 -07:00
Joe Groff
3e4e00c163 SILGen: Emit "trivial" property descriptors for properties that withhold no information about their implementation.
Client code can make a best effort at emitting a key path referencing a property with its publicly exposed API, which in the common case will match what the defining module would produce as the canonical key path component representation of the declaration. We can reduce the code size impact of these descriptors by not emitting them when there's no hidden or possibly-resiliently-changed-in-the-past information about a storage declaration, having the property descriptor symbol reference a sentinel value telling client key paths to use their definition of the key path component.
2018-06-21 15:18:24 -07:00
Doug Gregor
81bee08369 [AST] Make ValueDecls displayable via their DeclRefs. 2018-06-21 06:39:03 -07:00
David Zarzycki
cc0976a678 [AST] NFC: Reorder inline bitfield for performance
As documented in the inline bitfield header, naturally sized fields
should be last for optimal code gen.
2018-06-17 08:11:29 -04: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
Doug Gregor
7bf8623b52 [AST] Clean up whitespace 2018-06-16 13:05:18 -07:00
swift-ci
27b450180b Merge pull request #17199 from DougGregor/remove-iterative-type-checker 2018-06-16 09:12:18 -07:00
Doug Gregor
3e56d88a92 [AST] Block recursion through ProtocolDecl::getInheritedProtocols(). 2018-06-16 02:14:07 -06:00
Doug Gregor
d098b3e571 [Sema] Remove the IterativeTypeChecker. 2018-06-15 22:46:55 -07:00
Doug Gregor
2b2e143f59 [Request-Evaluator] Introduce a request for getting an "inherited type". 2018-06-14 15:29:57 -07:00
Doug Gregor
99e540f588 [Evaluator] Add an “enum raw type” request and use it consistently.
Similar to get “superclass of class” request, introduce an “enum raw type”
request that is accessed via EnumDecl::getRawType().
2018-06-14 15:29:57 -07:00
Doug Gregor
ef337bb8ba [Evaluator] Use the request-evaluator for the superclass of a class.
Wire up the request-evaluator with an instance in ASTContext, and
introduce two request kinds: one to retrieve the superclass of a class
declaration, and one to compute the type of an entry in the
inheritance clause.

Teach ClassDecl::getSuperclass() to go through the request-evaluator,
centralizing the logic to compute and extract the superclass
type.

Fixes the crasher from rdar://problem/26498438.
2018-06-14 15:28:36 -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
fischertony
7313a90eb1 [Sema] Generalize the 'declared here' diagnostic 2018-05-22 18:17:15 +03:00
Slava Pestov
8bf90f21d4 AST: Remove unneeded isDefinition and needsCapture methods from ValueDecl 2018-05-13 22:42:47 -07:00
Rintaro Ishizaki
9fc09858ae [AST] Stop using side-table for local discriminators 2018-05-11 15:37:01 +09:00
Jordan Rose
4714fcd50c Revert "Merge pull request #16211 from slavapestov/fix-inlinable-vs-autolinking"
This reverts commit bb16ee049d,
reversing changes made to a8d831f5f5.
It's not sufficient to solve the problem, and the choices were to do
something more complicated, or just take a simple brute force
approach. We're going with the latter.
2018-05-03 22:40:31 -06:00
Slava Pestov
753967411a AST: Support '@_usableFromInline import' 2018-05-01 17:53:51 -07:00
Slava Pestov
22fe6181dd AST: Fix uninitialized memory 2018-04-20 10:21:58 -07:00
Slava Pestov
a73bc7b899 AST: Add AbstractFunctionDecl::isSynthesized() flag 2018-04-19 18:22:34 -07:00
Jordan Rose
3cf00637fa AST-verify that 'open' is only used on classes and overridable members (#15996)
...and fix places where it was being used inappropriately.

- Don't use 'open' on non-class members in the importer.
- Use the existing 'copyFormalAccessFrom' instead of an ad hoc version
  for synthesized typealiases for protocol conformances. (This can
  change 'internal' down to 'fileprivate', but only where the
  enclosing type was already 'private' or 'fileprivate'.)
- Fix 'copyFormalAccessFrom' to not copy '@usableFromInline' onto
  declarations that don't support it (namely, the above typealiases).

This should have no visible effect in practice.
2018-04-18 16:47:54 -07:00
Jordan Rose
28a1dc7770 Use 'fileprivate' for synthesized members of 'private' decls (#15980)
Since 'private' means "limit to the enclosing scope (and extensions
thereof)", putting it on a member means that the member can't be
accessed everywhere the type might show up. That's normally a good
thing, but it's not the desired effect for synthesized members used
for derived conformances, and when it comes to class initializers this
actually violates AST invariants.

rdar://problem/39478298
2018-04-17 15:19:35 -07:00
Slava Pestov
75db43b978 AST: Replace ProtocolType::compareProtocols() with TypeDecl::compare() 2018-04-06 15:41:07 -07:00
Slava Pestov
a5579d1cff AST: Plug a hole in access control checking
A protocol extension of a private protocol can define internal
or public members. We should not be able to find these members
from another file or module if an internal or public type
conforms to the protocol.

Fixes <rdar://problem/21380336>.
2018-04-05 23:24:48 -07:00
Slava Pestov
ff56a074af AST: Clean up the terminology around @usableFromInline in a couple of places 2018-04-05 14:31:32 -07:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Xi Ge
7224ef84bb Merge pull request #15595 from johnfairh/whither-where
[SourceKit] Include trailing where clause in SourceRange
2018-03-29 10:58:55 -07:00
John Fairhurst
f99321a092 [SourceKit] Include trailing where clause in SourceRange 2018-03-29 11:38:21 +01:00
Doug Gregor
a506f602ea Merge branch 'master' into redeclaration-fixes 2018-03-27 21:59:50 -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
David Zarzycki
7c7fa61f0c [AST] NFC: Fix -Wextra-semi warning 2018-03-27 09:00:15 -04:00
Doug Gregor
69099a8f8b Merge pull request #15527 from DougGregor/typealias-from-debugger
[AST] Skip verification of typealiases marked as "debugger aliases".
2018-03-26 16:50:31 -07:00
Doug Gregor
9aaa1f146a [AST] Skip verification of typealiases marked as "debugger aliases".
LLDB creates global typealiases that have archetypes in them, which
violates AST invariants and trips up the AST verifier. Introduce a specific
bit that LLDB can set to indicate that a given typealias is such an alias.
We'll skip AST verification for such typealiases.

As a way to stage in this change without requiring synchronization
across the Swift and LLDB repos, also match typealiases with the names
$.*lldb in the AST verifier and skip verification. Once LLDB is
setting the bit appropriately, we'll remove this hack.
2018-03-26 15:47:54 -07:00
Jordan Rose
9d72a2b9dc Merge pull request #15280 from hamishknight/didset-recursion
[Sema] Only directly access members within didSet if accessed on 'self'
2018-03-26 15:33:46 -07:00
Doug Gregor
c43f96a855 [AST] Remove now-unused NameAliasType. 2018-03-25 21:35:16 -07:00
Hamish
5f43627235 [Sema] Revise #15280 in response to feedback
Instead of passing the base expression of a member access to `getAccessSemanticsFromContext`, we now just pass a bool flag for whether this is a member access on the implicit 'self' declaration.
2018-03-24 21:13:47 +00:00
Hamish
8a78e15a0f [Sema] Only directly access members within didSet if accessed on 'self'
Currently we always directly access a member when mutating it in its own didSet/willSet observer (in order to prevent infinite recursion). However we also do this even when accessing the same member on a *different* instance.

This commit changes the behaviour such that only member accesses on the implicit 'self' declaration are accessed directly within that member's own willSet/didSet.

Note that this change has the potential to cause recursion in cases where it didn't previously, for example this will now infinitely recurse:

    struct S {
      var i = 0 {
        didSet {
          var s = self
          s.i = 5
        }
      }
    }

    var s = S()
    s.i = 2

I don't know how serious this impact is though.

Resolves SR-419.
2018-03-24 21:13:47 +00:00
Hamish
ae8b125f82 [Sema] Revise #15412 in response to feedback (2)
- Emit a warning in Swift 4 for performing a redeclaration that will be illegal in Swift 5

- Minor fixes
2018-03-24 15:44:27 +00:00