Commit Graph

114 Commits

Author SHA1 Message Date
Doug Gregor
1c712e069a Archetype builder: add witness markers to requirement enumeration
Swift SVN r23009
2014-10-29 22:27:35 +00:00
Doug Gregor
f270d7cf07 Archetype builder: don't prematurely lower to a dependent type when enumerating requirements.
Extend the contract for enumerateRequirements() a bit to preserve
archetype-to-archetype same-type constraints. Use that extra
information in the debug dump. NFC elsewhere.

Swift SVN r23008
2014-10-29 22:27:34 +00:00
Doug Gregor
dfa116600f Archetype builder: introduce "redundant" requirements to better track the requirements written in the source.
Essentially NFC at this point, but can be used for display purposes.

Swift SVN r22776
2014-10-15 21:51:31 +00:00
Mark Lacey
84b8f39cf8 Revert "Add requirements among distinct associated types with the same name."
This reverts commit r22680 because it causes a failure in one of the
check-swift-validation tests (parser/parse_stdlib.sil).

Swift SVN r22713
2014-10-13 23:09:03 +00:00
Doug Gregor
af898ff2e8 Add requirements among distinct associated types with the same name.
This pushes some of the extra same-type requirements introduced in r22649 into the generic signature. Doesn’t really have an effect outside of extending generic signatures slightly.

Swift SVN r22680
2014-10-10 23:48:01 +00:00
Doug Gregor
f9a6d88c19 Archetype builder: unify different associated types with the same name across protocols.
When we have two protocol conformance requirements for the same type
T, and each of those protocols has an associated type with a given
(shared) name N, infer a same-type requirement between the two. Only
really enabled for testing now; it doesn't feed into general type
checking yet.

Swift SVN r22649
2014-10-10 00:11:31 +00:00
Doug Gregor
59a355a67b Eliminate the notion of an archetype "index"; it's useless now. NFC
Swift SVN r22644
2014-10-09 22:43:54 +00:00
Doug Gregor
1380f758a5 Archetype builder: resolve nested types to associated types directly.
Effectively NFC because we're not making use of this information yet.

Swift SVN r22643
2014-10-09 21:52:34 +00:00
Doug Gregor
57ff959529 Add conformances with ArchetypeBuilder::PotentialArchetype::addConformance().
This means we'll get proper merging of requirement sources when
merging conformances due to same-type requirements.

Swift SVN r22642
2014-10-09 21:52:33 +00:00
Doug Gregor
f844ab4331 Store the generic type parameter type for non-associated potential archetypes.
This lets us map from potential archetypes back to dependent types
more efficiently, eliminating a linear search.

Swift SVN r22640
2014-10-09 21:52:32 +00:00
Doug Gregor
c4cd133737 Archetype builder: enumerate requirements directly from the potential archetypes.
Use this for the archetype builder debug dump so we can test it
without affecting compilation (yet).

Swift SVN r22639
2014-10-09 21:52:31 +00:00
Doug Gregor
91ddaf59eb Archetype builder: start tracking the locations and reasons for specific requirements.
Whenever we add a requirement, we now know

  (1) Why we added the requirement, e.g., whether it was explicitly written, inferred from a signature, or introduced by an outer scope.
  (2) Where in the source code that requirement originated.

Also add a debugging flag for dumping the archetype builder information, so we can write tests against it.

This is effectively NFC, but it's infrastructure to help a number of requirements-related tasks.

Swift SVN r22638
2014-10-09 21:52:28 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Doug Gregor
28cc919fb4 Infer conformance requirements from the signature of a generic function.
When a specialization of a generic type occurs within the signature of
a generic function, it implies that the generic arguments meet the
requirements of the generic type. For example, in

  func printHashes<K, V>(dict : Dictionary<K, V>) {
    for (k, v) in dict {
        print("\(k.hashValue())\n")
    } 
  } 

the presence of Dictionary<K, V> in the signature implies that K and V
meet the requirements on Dictionary's generic parameters, i.e., that K
is Hashable. Thus, infer that K is Hashable in printHashes().

Fixes the easy part of <rdar://problem/14691708>. Same-type and
superclass requirements are more interesting.


<rdar://problem/14691708>


Swift SVN r7574
2013-08-26 16:46:38 +00:00