Commit Graph

17 Commits

Author SHA1 Message Date
Slava Pestov
f34e57c016 RequirementMachine: Use ProtocolDecl::getAllInheritedProtocols() 2024-06-25 15:20:42 -04:00
Slava Pestov
ea15d9f9b2 Stop passing -warn-redundant-requirements in tests 2024-02-02 14:57:19 -05:00
Anthony Latsis
bc4a3465a9 Gardening: Migrate test suite to GH issues: Generics 2022-08-30 01:49:59 +03: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
e4973158d8 AST: -debug-generic-signatures protocol-qualifies DependentMemberTypes 2022-01-19 22:36:15 -05:00
Slava Pestov
1d9b202719 GSB: Fix inconsistent 'redundant conformance' diagnostic 2021-03-27 00:35:19 -04:00
Doug Gregor
868f763406 [GSB] Ensure that we don’t pick a self-recursive requirement source.
When computing the conformance access path, make sure that we don’t pick
a self-recursive requirement source.
2018-08-23 14:20:25 -07:00
Doug Gregor
2b2e143f59 [Request-Evaluator] Introduce a request for getting an "inherited type". 2018-06-14 15:29:57 -07:00
Doug Gregor
3452dda95c [GSB] Stop warning about 'bare' associated type redeclarations.
Associated type redeclarations occasionally occur to push around
associated type witness inference. Suppress the warning about redeclarations
that add no requirements (i.e., have neither an inheritance nor a
where clause).
2017-10-26 14:58:00 -07:00
Doug Gregor
ea1396c364 [GSB] Only build potential archetypes for associated type "anchors".
Use the "override" information in associated type declarations to provide
AST-level access to the associated type "anchor", i.e., the canonical
associated type that will be used in generic signatures, mangling,
etc.

In the Generic Signature Builder, only build potential archetypes for
associated types that are anchors, which reduces the number of
potential archetypes we build when type-checking the standard library
by 14% and type-checking time for the standard library by 16%.

There's a minor regression here in some generic signatures that were
accidentally getting (correct) same-type constraints. There were
existing bugs in this area already (Huon found some of them), while
will be addressed as a follow-up.

Fies SR-5726, where we were failing to type-check due to missed
associated type constraints.
2017-10-07 21:52:40 -07:00
Doug Gregor
9ad768e73d Add test case for SR-5946. 2017-10-03 10:18:23 -07:00
Doug Gregor
4dee0d9cc7 [GSB] Infer equivalence of same-named nested types of the same potential archetype.
When we have two nested types of a given potential archetype that have
the same name, introduce a (quietly) inferred constraint. This is
a future-proofing step for canonicalization, for a possible future
where we no longer require all of the nested types of a given name
to be equivalent, e.g., because we have a proper disambiguation
mechanism.
2017-09-12 06:11:39 -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
Huon Wilson
a964b6ad78 [AST] Introduce the notion of a protocol requirement signature.
This is a generic signature that stores exactly the requirements that a
protocol decl introduces, not letting them be implied by the Self :
Protocol requirement, nor storing any requirements introduced by the
protocols requirements.

Specifically, suppose we have

    protocol Foo {}
    protocol Bar {}

    protocol Baz {
        associatedtype X : Foo
    }
    protocol Qux: Baz {
        associatedtype X : Bar
    }

The normal generic signature and (canonical) protocol requirement
signature of `Baz` will be, respectively

    <Self where Self : Baz>
    <Self where Self : Baz, Self.X : Foo>

And for `Qux`, they will be:

    <Self where Self : Qux>
    <Self where Self : Qux, Self : Baz, Self.X : Bar>

Note that the `Self.X : Foo` requirement is not listed.

For the moment, this is unused except for `-debug-generic-signatures`.
2017-01-25 16:06:50 -08:00