Commit Graph

14 Commits

Author SHA1 Message Date
Slava Pestov
ea15d9f9b2 Stop passing -warn-redundant-requirements in tests 2024-02-02 14:57:19 -05:00
Slava Pestov
dac8d666ee Stop passing -requirement-machine-{abstract,inferred,protocol}-signatures flags in tests
These flags are now no-ops.
2022-05-10 12:56:17 -04:00
Slava Pestov
f39372b33d RequirementMachine: Turn off redundant requirement warnings by default and add -warn-redundant-requirements frontend flag 2022-05-10 01:49:56 -04:00
Slava Pestov
b4b873332f Update -requirement-machine-* flags in various tests
- Don't pass 'verify' since it's now the default
- Update tests where diagnostics changed in a correct way to pass 'on' instead
- Delete compiler_scale/explicit_requirements_perf.swift since it's not testing anything with the requirement machine
2022-03-31 15:57:36 -04:00
Slava Pestov
1d9b202719 GSB: Fix inconsistent 'redundant conformance' diagnostic 2021-03-27 00:35:19 -04:00
Robert Widmann
dce1e2ea32 [Gardening] Remove unnecessary options and files from tests 2019-09-10 18:15:16 -07:00
Doug Gregor
f469928c24 [Type checker] Drop verbose conformance-access-path debugging dumps.
Under -debug-generic-signatures, we were computing and emitting
conformance access paths for one test. Given that conformance access
paths are used ubiquitously now, this test isn't providing any value
(nor is the debug dump), stop dumpoing them.
2018-12-04 20:01:14 -08:00
Doug Gregor
aa9755d149 [GSB] Start moving RequirementSource off of potential archetypes.
Eliminate potential archetypes from most of the public interface of
RequirementSource.
2017-10-20 15:18:36 -07:00
Doug Gregor
de66b0c25c [GSB] Warn about redeclarations of associated types from inherited protocols.
Introduce a warning about redeclaring the associated types from an
inherited protocol in the protocol being checked:

* If the new declaration is an associated type, note that the
  declaration could be replaced by requirements in the protocol's
  where clause.
* If the new declaration is a typealias, note that it could be
  replaced by a same-type constraint in the protocol's where clause.
2017-04-24 07:55:42 -07:00
Doug Gregor
eaee4add8a [GSB] Track all conformance constraint sources.
Move the storage for the protocols to which a particular potential
archetype conforms into EquivalenceClass, so that it is more easily
shared. More importantly, keep track of *all* of the constraint
sources that produced a particular conformance requirement, so we can
revisit them later, which provides a number of improvements:

* We can drop self-derived requirements at the end, once we've
  established all of the equivalence classes
* We diagnose redundant conformance requirements, e.g., "T: Sequence"
  is redundant if "T: Collection" is already specified.
* We can choose the best path when forming the conformance access
  path.
2017-03-16 23:15:37 -10:00
Doug Gregor
a41e44fa27 [AST] Don't use a protocol's requirement signature to canonicalize types.
Requirement signatures are a bit brittle, because they (intentionally)
don't carry the "Self: Proto" requirement. Most of the compiler never
uses requirement signatures as a signature per se, which is good,
because they canonicalize poorly.

Teach the construction of conformance access paths to use the
protocol's generic signature for canonicalization, rather than the
requirement signature.

As a future step, we should present only the *requirements* from the
requirement signature to prevent its use as a full-fledged
GenericSignature.
2017-03-09 21:55:40 -08:00
Doug Gregor
1f8b0f9b85 Canonicalize conformance access paths for sources pre-requirement-signature.
When a requirement source involving a ProtocolRequirement element is
built prior to the requirement signature of the protocol it
references, we can end up with a requirement source whose steps don't
reflect was is actually available via the requirement signatures. When
building a conformance access path from such requirement sources,
canonicalize on-the-fly using the requirement signatures (which have
been/can be computed by this point) to produce a correct access path.
2017-03-08 16:14:55 -08:00
Doug Gregor
58f794449e [GSB] Prefer shorter requirement sources to longer ones. 2017-03-07 10:23:24 -08:00
Doug Gregor
202bc7eeea [AST] Introduce GenericSignature::getConformanceAccessPath().
Introduce an API that determines the "conformance access path" that
one would follow to find the conformance of a given type parameter
(e.g., T.Iterator.Element) to a given protocol (e.g., Equatable). A
conformance access path starts at one of the explicit requirements
of that generic signature and then proceeds through zero or more
protocol-supplied requirements. For example, given this function:

  func f<C: Collection>(_: C) { }

The conformance access path for "C.Iterator: IteratorProtocol" is

  (C, Collection) -> (Self, Sequence) -> (Self.Iterator, IteratorProtocol)

because one starts with the explicit requirement "C: Collection", goes
to the inherited protocol requirement (the "Self" in Collection
conforms to Sequence) and then a requirement on the associated type
(Self.Iterator in Sequence conforms to IteratorProtocol).

This is all scaffolding now; it's intended to be used by IRGen (to
find the witness tables it needs) and SubstitutionMap (to dig out
conformances during substitution).
2017-03-07 09:25:43 -08:00