Commit Graph

6725 Commits

Author SHA1 Message Date
swift-ci
3e45eb75c9 Merge pull request #12763 from graydon/rdar-35198678-add-implicit-dtor-outside-typecheck 2017-11-04 05:00:19 -07:00
Graydon Hoare
7e363ff97a [AST] Add implicit dtors outside typechecking, rdar://35198678 2017-11-04 02:59:52 -07:00
Xi Ge
6af5d3c0bf libSyntax: rename KeepTokensInSourceFile to KeepSyntaxInfoInSourceFile. 2017-11-03 18:39:01 -07:00
Xi Ge
4ee32a125e [test] Always enable libSyntax creation in swift-ide-test to get some free test coverage. NFC 2017-11-03 18:39:01 -07:00
swift-ci
17f89f324c Merge pull request #12742 from xedin/preserve-param-flags-in-mangling 2017-11-03 17:58:29 -07:00
Pavel Yaskevich
7a2117bdcf [Mangling] Preserve all parameter flags in single parameter function mangling
Currently if function has a single parameter we'd skip mangling some of the
parameter flags e.g. `__shared`, `inout` still works because it's part of
the type itself (currently) but would be broken too if that were to change.
2017-11-03 17:00:24 -07:00
swift-ci
2d0ed92854 Merge pull request #12741 from graydon/named-lazy-member-loading-write-by-default 2017-11-03 02:35:32 -07:00
Graydon Hoare
bbeec57182 [NamedLazyMemberLoading] Handle case of source extension on deserialized type. 2017-11-03 00:35:03 -07:00
Mark Lacey
d83374449b Add a declaration attribute for implicitly unwrapped optional.
Attach this attribute to VarDecls declared as IUO, and to function decls
that have a result type that is an IUO.

NFC at the moment. Eventually we'll use these to determine where to
implicitly unwrap optional values.
2017-11-02 22:44:37 -07:00
Doug Gregor
5ad254bf3f [GSB] Stop walking associated types of a protocol just due to a superclass req. 2017-11-02 15:17:42 -07:00
Doug Gregor
0416292e5c [GSB] Eliminate unnecessary walk over the associated types.
We lazily resolve all of this information about nested potential archetypes
anyway; there's no need to do it eagerly.
2017-11-02 14:56:43 -07:00
Graydon Hoare
ad24e0fd87 Merge pull request #12669 from graydon/named-lazy-member-loading-3
[WIP] Named lazy member loading 3
2017-11-01 22:18:12 -07:00
Graydon Hoare
ed0b43cbce [NamedLazyMemberLoading] Move SerialID to IDC, get extensions working. 2017-11-01 17:35:46 -07:00
Graydon Hoare
f96c0d9b63 [NamedLazyMemberLoading] Address review comments. 2017-11-01 17:35:46 -07:00
Graydon Hoare
fa0f2ec991 [NamedLazyMemberLoading] Equip ValueDecl with a serialization::DeclID. 2017-11-01 17:34:56 -07:00
Graydon Hoare
e9fbd2ce53 [NamedLazyMemberLoading] Add diagram + comment of IDC + MemberLookupTable. 2017-11-01 17:34:56 -07:00
Graydon Hoare
2d36f5cdae [NamedLazyMemberLoading] Use NominalTypeDecl::LookupTable as proper cache. 2017-11-01 17:34:56 -07:00
Doug Gregor
6007783fa5 [AST Verifier] Eliminate “sharding” of AST verification.
The only client of this (the parse_stdlib) tests didn’t need it and
are no longer using it.
2017-11-01 16:07:25 -07:00
Huon Wilson
161dd6a362 Merge pull request #12430 from huonw/silfunctiontype-conformance
[SIL] Witness methods store the conformance from which they come.
2017-11-01 13:36:18 -07:00
Davide Italiano
2b1921b207 Merge pull request #12686 from dcci/unused2
[gardening] More unused variables/lambda captures. NFCI.
2017-11-01 12:48:21 -07:00
Huon Wilson
b5eb418ef1 [AST] Handle classes properly in ProtocolConformanceRef::subst.
Previously ProtocolConformance::subst would crash because it was receiving
things with an unexpected relationship between the conformance's type and the
substituted self type. The compiler doesn't quite properly model "abstract"
inherited conformances, so we end up using normal conformances instead, and we
need to work around this in some cases.
2017-11-01 11:33:27 -07:00
Huon Wilson
0236db7be1 [SIL] Witness methods store the conformance from which they come. 2017-11-01 11:33:26 -07:00
Doug Gregor
fe54e70fce [GSB] Don't infer requirements from types in the definitions of protocols.
Previously, we were inferring requirements from types within the definitions
of protocols, e.g., given something like:

    protocol P {
      associatedtype A: Collection
      associatedtype B where A.Element == Set<B>
    }

we would infer that B: Hashable. The code for doing this was actually
incorrect due to its mis-use of requirement sources, causing a few
crashers. Plus, it's not a good idea in general because it hides the
actual requirements on B. Stop doing this.

Also stop trying to infer requirements from conditional
requirements---those have already been canonicalized and minimized, so
there's nothing to infer from.
2017-10-31 15:28:19 -07:00
Davide Italiano
87de4637fc [gardening] More unused variables/lambda captures. NFCI. 2017-10-31 10:35:24 -07:00
Doug Gregor
3a3e96cf66 Set the outer generic parameters of a protocol extension properly.
Fixes two compiler crashers.
2017-10-27 23:41:08 -07:00
Doug Gregor
e0aedef88a [AST] Handle superclass and concrete sources in conformance access paths.
If we encounter a superclass or concrete source within a conformance
access path, use the stored conformance to terminate the path. Fixes a
compiler crasher.
2017-10-27 23:41:08 -07:00
Doug Gregor
014899b7ab Merge pull request #12663 from DougGregor/gsb-fewer-potential-archetypes
[GSB] Yet more cleanup to realize fewer potential archetypes
2017-10-27 23:35:24 -07:00
Doug Gregor
5947ae9c00 Merge pull request #12645 from DougGregor/conformance-near-miss
Warn on “near-misses” when defaults are used for protocol witnesses.
2017-10-27 23:01:59 -07:00
Doug Gregor
832a154b08 [GSB] Make sure we wire up same-named type declarations consistently.
Fixes a former crasher that included well-formed code that was rejected
by my previous refactoring. Said crasher now passes, and IRGen's properly
as well. Also, account for three more fixed crashers.
2017-10-27 22:17:45 -07:00
Doug Gregor
5b8c914582 [GSB] Reimplement equivalence class "anchor" logic.
Replace the pair of PotentialArchetype's getArchetypeAnchor() and
getNestedArchetypeAnchor() with a straightforward, more-efficient
computation based on equivalence classes. This reduces the number of
times we query the archetype anchor cache by 88% when building the
standard library, as well as eliminating some
PotentialArchetype-specific APIs.
2017-10-27 21:46:45 -07:00
Nathan Hawes
351238a199 [ASTWalker/index] Walk into the trailing where clause on extension decls so we don't miss the type references there. 2017-10-27 19:27:10 -07:00
Doug Gregor
d731a948f4 [GSB] Simplify enumeration of the subject types for requirements.
The first step in enumerating the minimal, canonical set of requirements for
a generic signature is identifying which "subject" types will show up in
the left-hand side of the requirements. Previously, this would require us
to realize all of the potential archetypes, and perform a number of
archetype-anchor computations and comparisons.

Replace that with a simpler walk over the equivalence classes,
identifying the anchor types within each derived same-type component
of those equivalence classes, which form the subject types. This is
more straightforward, doesn't rely on potential archetypes, simplifies
the code, and eliminates a silly O(n^2)-for-small-n that's been
bothering me for a while.
2017-10-27 16:10:02 -07:00
Doug Gregor
4ff05fa51b [GSB] Eliminate a bunch of unnecessary PotentialArchetype* interfaces.
All of these constraint-checking functions work on the equivalence class.
2017-10-27 14:00:43 -07:00
Doug Gregor
1117eff2a8 [GSB] Eliminate PotentialArchetype from enumerateRequirements(). 2017-10-27 13:49:18 -07:00
Doug Gregor
29390e095a [GSB] Switch the anchor of a derived same-type component to UnresolvedType.
It was a PotentialArchetype*, but we don't want to have to realize a
potential archetype to model this.
2017-10-27 13:32:59 -07:00
Doug Gregor
16ea8aedf2 [GSB] Switch some more APIs away from PotentialArchetype. 2017-10-27 12:58:42 -07:00
Slava Pestov
5c45f8546f Merge pull request #12614 from slavapestov/imported-materialize-for-set-override-bugs
Sema: Fix some issues with overrides of materializeForSet
2017-10-26 22:49:08 -07:00
Slava Pestov
0f2da217a4 Sema: Fix some issues with overrides of materializeForSet
When overriding storage with a forced static dispatch materializeForSet,
the override's materializeForSet should not override the base
materializeForSet.

This is the case where a dynamic property witnesses a protocol
requirement, and Sema synthesizes a materializeForSet for it.

In this case, the synthesized materializeForSet dynamically dispatches
to the dynamic property's getter and setter, and the protocol witness
thunk directly calls the synthesized materializeForSet.

The subclass only needs to override the getter and setter in this case,
since the base class's materializeForSet will already do the right
thing.

In fact, marking it as an override exposes a problem where we cannot
serialize an xref to an imported property's materializeForSet, since
it was not created by the importer.
2017-10-26 17:11:09 -07:00
Doug Gregor
493d4da667 Warn on “near-misses” when defaults are used for protocol witnesses.
When a particular nominal type or extension thereof declares conformance
to a protocol, check whether that type or extension contains any members
that *nearly* match a defaulted requirement (i.e., a requirement that 
is satisfied by something in a protocol extension), but didn’t match
for some reason and weren’t used to satisfy any other requirement of
that protocol. It’s intended to catch subtle mistakes where a default
gets picked instead of the intended member.

This is a generalization of the code we’ve had for @objc optional
requirements for a long time.

Fixes rdar://problem/24714887.
2017-10-26 17:04:46 -07:00
Doug Gregor
3452dda95c [GSB] Stop warning about 'bare' associated type redeclarations.
Associated type redeclarations occasionally occur to push around
associated type witness inference. Suppress the warning about redeclarations
that add no requirements (i.e., have neither an inheritance nor a
where clause).
2017-10-26 14:58:00 -07:00
Nathan Hawes
2f3bb5f7ce Merge pull request #12621 from nathawes/rdar35016463-cannot-rename-conformed-protocol-generic-constraints
[ASTWalker] Walk NominalTypeDecl parts in source order
2017-10-25 17:49:45 -07:00
Nathan Hawes
708c55607c [ASTWalker] When walking a NominalTypeDecl, walk any generic param requirements after its inherited/conformed-to TypeLocs to maintain a source-order walk. 2017-10-25 14:57:12 -07:00
Slava Pestov
4970d7d7e8 AST: Don't include Token.h from Module.h 2017-10-24 20:45:50 -07:00
swift-ci
652edc93f8 Merge pull request #12607 from DougGregor/gsb-less-potential-archetype-realization 2017-10-24 17:30:57 -07:00
Doug Gregor
d2f0df4b3b [GSB] Eliminate unused Constraint<T>::realizeSubjectPotentialArchetype(). 2017-10-24 16:18:07 -07:00
Graydon Hoare
30b6fdce83 Merge pull request #12429 from graydon/named-lazy-member-loading
Named lazy member loading 1/N
2017-10-24 14:27:04 -07:00
Doug Gregor
f5e44a4968 [GSB] Don't realize potential archetypes for same-type-to-concrete constraints. 2017-10-24 11:11:21 -07:00
Doug Gregor
a33dee4844 [GSB] Switch potential archetype -> component index mapping to CanType.
Switch the mapping from types to components used by the same-type
connected-components computation to be indexed by CanType instead,
eliminating a few more places where we force realization of a potential
archetype.
2017-10-24 10:18:35 -07:00
swift-ci
617d746164 Merge pull request #12592 from DougGregor/gsb-flatten-same-type-constraints 2017-10-23 23:05:53 -07:00
Doug Gregor
642b45835c [GSB] Use result of recordSameTypeConstraint() to short-circuit.
Centralizes the logic for short-circuiting based on same-type
constraints.
2017-10-23 21:51:54 -07:00