Commit Graph

19 Commits

Author SHA1 Message Date
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
b8995b0aa3 Transform the Module class into ModuleDecl.
Modules occupy a weird space in the AST now: they can be treated like
types (Swift.Int), which is captured by ModuleType. They can be
treated like values for disambiguation (Swift.print), which is
captured by ModuleExpr. And we jump through hoops in various places to
store "either a module or a decl".

Start cleaning this up by transforming Module into ModuleDecl, a
TypeDecl that's implicitly created to describe a module. Subsequent
changes will start folding away the special cases (ModuleExpr ->
DeclRefExpr, name lookup results stop having a separate Module case,
etc.).

Note that the Module -> ModuleDecl typedef is there to limit the
changes needed. Much of this patch is actually dealing with the fact
that Module used to have Ctx and Name public members that now need to
be accessed via getASTContext() and getName(), respectively.

Swift SVN r28284
2015-05-07 21:10:50 +00:00
Slava Pestov
59c4900af9 Improved Substitution::print()
Swift SVN r27605
2015-04-22 21:29:25 +00:00
Michael Gottesman
d64c08662a Revert "Improved Substitution::print()"
This reverts commit r27584. Fixes the build.

Swift SVN r27597
2015-04-22 19:38:45 +00:00
Slava Pestov
367f796fea Improved Substitution::print()
Swift SVN r27584
2015-04-22 17:18:44 +00:00
Manman Ren
c4233e98ff [Printer] use SIL print options when printing SILWitnessTable.
Add PrintOptions to Substitution::print and ProtocolConformance::printName.
rdar://18021102


Swift SVN r22366
2014-09-29 21:59:03 +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
Nadav Rotem
001533d1eb Fix the build by adding the '==' operator to Substitution.
Swift SVN r16565
2014-04-19 05:47:00 +00:00
Joe Groff
fbd2d946f2 Add a big comment about the caveats of using Substitution::Archetype for anything.
We don't have time to kill it completely, so leave a warning sign for people who might consider using it again.

Swift SVN r14966
2014-03-12 20:46:12 +00:00
Joe Groff
a404b0cd49 Rework Substitution::subst not to depend on the meaningless 'Archetype' field of Substitutions.
Pass in the context generic parameters that correspond to the substitution vector in Substitution::subst. When we build the type substitution map, also collect the conformances from the substitutions into a map we can use to fill in those conformances in substituted substitutions where necessary, without relying on the '.Archetype' field.

Swift SVN r14964
2014-03-12 20:29:46 +00:00
Joe Groff
92f7b5512d AST: Add a "Substitution::subst" API.
Substitute a...um...substitution by remapping its Replacement mapping and recursively remapping any ProtocolConformances it has. Modify the Specializer to use Substitution::subst when specializing the substitutions of ArchetypeMethod and Apply instructions.

Swift SVN r12900
2014-01-24 04:35:49 +00:00
Nadav Rotem
ccf3a127f2 Add a simple generic specialization pass.
Swift SVN r10885
2013-12-05 22:20:05 +00:00
Joe Groff
1f7192f7f2 Add print/dump methods to Substitution.
Swift SVN r9512
2013-10-19 00:21:54 +00:00
Dmitri Hrybenko
d0455ca1c6 Remove unneeded llvm:: qualifier for llvm::ArrayRef
Swift SVN r7093
2013-08-09 20:05:02 +00:00
Doug Gregor
709882c2b8 Capture complete associated type substitution information in the AST.
Previously, we only tracked the mapping from associated types to their
type witnesses. Now, also track the protocol conformances for each of
the requirements placed on the associated types.


Swift SVN r6655
2013-07-26 22:04:53 +00:00
John McCall
00126779d6 The world demands a common generics header, and who am I
to disagree with billions of other people?

Swift SVN r2926
2012-10-03 08:57:36 +00:00