Commit Graph

310 Commits

Author SHA1 Message Date
Slava Pestov
cb3ddc2200 SIL: Fix type lowering to correctly handle concrete same-type constraints
When a dependent type is mapped into context, the result will either be
an archetype or a concrete type. The latter occurs if a same-type
constraint exists between the dependent type and the concrete type.

The logic to decide if a type should be passed directly or indirectly
was not handling this case if an interface type was passed down -- we
would just check if there was a class constraint present.

This resulted in mismatching conventions between an interface type and
its corresponding contextual type, which would trigger assertions.

Note that same-type constraints between generic parameters and concrete
types are still not supported for other reasons; the subject of the
constraint must still be an associated type of a generic parameter.

Fixes <rdar://problem/24687460>.
2016-02-17 00:22:03 -08:00
John McCall
1f3b3142b4 Distinguish conformance and superclass generic requirements.
As part of this, use a different enum for parsed generic requirements.

NFC except that I noticed that ASTWalker wasn't visiting the second
type in a conformance constraint; fixing this seems to have no effect
beyond producing better IDE annotations.
2016-01-11 16:07:37 -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
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
John McCall
2d38e26eca Move IRGen's PolymorphicConvention off of ArchetypeBuilder and onto
direct queries against the GenericSignature.

Thanks to Doug for some fixes to GenericSignature and a lot of advice.

Swift SVN r32481
2015-10-07 00:44:09 +00:00
Doug Gregor
8dc0e135e0 Minimize and sort the protocols returned by GenericSignature::getConformsTo.
Swift SVN r32445
2015-10-05 19:41:24 +00:00
Doug Gregor
3a5a540b4c Add GenericSignature APIs to query the requirements on dependent types.
Extend GenericSignature to be able to answer queries about the
requirements placed on dependent types, e.g, are the class-bound, to
what protocols must they conform, etc. Implement this using a
lazily-created ArchetypeBuilder on the canonical generic signature.

NFC and as-yet-untested; this is staging for reducing our dependence
on the "all archetypes" list.

Swift SVN r32340
2015-09-30 18:17:31 +00:00
Doug Gregor
ff03d2ce09 Move more GenericSignature method implementations in GenericSignature.cpp NFC
Swift SVN r32339
2015-09-30 18:17:18 +00:00
Doug Gregor
0b2b0df907 Clean up canonicalization of GenericSignatures. NFC
GenericSignature's factory method determining whether the signature
was canonical based solely on whether the types in the parameters and
requirments were canonical. While that is currently true (for legacy
reasons), it is wrong: canonicalization also needs to canonicalize
requirements, including same-type requirements, as is currently done
in the canonical signature "for mangling". Move the "this is
canonical" dependency to the point where the canonical signature is
actually computed, so we can change the definition of canonical
signatures later.

While we're here, don't eagerly compute the canonical generic
signature in GenericSignature::getASTContext().

Swift SVN r32309
2015-09-29 22:05:47 +00:00
Doug Gregor
f460cb7376 Factor GenericSignature implementation into its own file. NFC
Swift SVN r32308
2015-09-29 22:05:44 +00:00