Commit Graph

13 Commits

Author SHA1 Message Date
Joe Groff
e99961eb8f AST: Fix Substitution::subst to substitute associated types from conformance witnesses instead of by name.
Fixes a crash when property behavior uses are run through the specializer, since they set up associated type conformances that are not recoverable by name lookup.
2016-02-22 15:31:14 -08:00
Chris Lattner
89e94008a0 add newline to end of file, NFC 2016-01-09 09:47:09 -08:00
John McCall
5112864dad Remove the archetype from Substitution.
This eliminates some minor overheads, but mostly it eliminates
a lot of conceptual complexity due to the overhead basically
appearing outside of its context.
2016-01-08 15:27:13 -08:00
John McCall
2df6880617 Introduce ProtocolConformanceRef. NFC.
The main idea here is that we really, really want to be
able to recover the protocol requirement of a conformance
reference even if it's abstract due to the conforming type
being abstract (e.g. an archetype).  I've made the conversion
from ProtocolConformance* explicit to discourage casual
contamination of the Ref with a null value.

As part of this change, always make conformance arrays in
Substitutions fully parallel to the requirements, as opposed
to occasionally being empty when the conformances are abstract.

As another part of this, I've tried to proactively fix
prospective bugs with partially-concrete conformances, which I
believe can happen with concretely-bound archetypes.

In addition to just giving us stronger invariants, this is
progress towards the removal of the archetype from Substitution.
2016-01-08 00:19:59 -08:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Doug Gregor
88258ed268 Allow substitution^2's to look up the conformance for a class to AnyObject.
AnyObject conformances are weird beasts, because we're able to
synthesize them fairly arbitrarily for classes. Do so also within
substitution into a Substitution, fixing rdar://problem/20338028.

Longer term, the AnyObject protocol needs to die.

Swift SVN r28118
2015-05-04 16:36:12 +00:00
Doug Gregor
02d25888c9 Clean up the interface to Type::subst(), NFC.
Replace the 'ignoreMissing' boolean flag with a new option set type,
SubstOptions, which is easier to extend. It is not an OptionSet<>
because a follow-on commit will introduce a non-trivial option that
will require more storage.

Also eliminate the LazyResolver parameter, which is no longer
needed. Eliminate the silly TypeChecker::substType(), whose only
purpose was to provide the resolver.

Swift SVN r27656
2015-04-23 23:36:18 +00:00
Mark Lacey
fedf1abec6 Fix assertion when substituting for class-constrained generics.
The class-constrained generic has no conformances to substitute for, so
we should just bail out early rather than expecting to find a
conformance for each thing the archetype conforms to.

Fixes rdar://problem/19336878.

Swift SVN r24583
2015-01-21 01:40:52 +00:00
Joe Groff
01da305569 Factor out a TypeBase::hasDependentProtocolConformances() method.
Make it easier to get the "do I expect null ProtocolConformance* pointers" logic right. Audit existing uses of is<ArchetypeType>() for this purpose.

Swift SVN r23479
2014-11-20 18:43:17 +00:00
Joe Groff
a247f5d98c SIL parser: Populate conformances of init_existential insns.
And fix some bugs with existential conformances, where we were creating a bogus conformance instead of just using null conformances like other code expects.

Swift SVN r23461
2014-11-20 02:43:23 +00:00
Erik Eckstein
f6c68fb1d5 SILGen: fix crash in case a function is specialized which contains an Array/Dictionary up- or downcast.
The apply insts for the call to the collection-casts were generated with substitutions w/o an ArcheType.



Swift SVN r21740
2014-09-05 14:07:25 +00:00
Joe Groff
623aba1786 Encapsulate Substitution's state.
Expose Substitution's archetype, replacement, and conformances only through getters so we can actually assert invariants about them. To start, require  replacement types to be materializable in order to catch cases where the type-checker tries to bind type variables to lvalue or inout types, and require the conformance array to match the number of protocol conformances required by the archetype. This exposes some latent bugs in the test suite I've marked as failures for now:

- test/Constraints/overload.swift was quietly suffering from <rdar://problem/17507421>, but we didn't notice because we never tried to codegen it.
- test/SIL/Parser/array_roundtrip.swift doesn't correctly roundtrip substitutions, which I filed as <rdar://problem/17781140>.

Swift SVN r20418
2014-07-23 18:00:38 +00:00
John McCall
b8c2967567 Create a dedicated implementation file for Substitution. NFC.
Swift SVN r18295
2014-05-18 02:16:21 +00:00