Slava Pestov
bfcaa39d37
Remove the GenericSignatureBuilder
...
Resolves rdar://problem/88136582.
2022-05-10 11:47:06 -04:00
Slava Pestov
f901cc72b4
RequirementMachine: Move diagnostics code into a new Diagnostics.cpp
2022-05-10 01:49:56 -04:00
Slava Pestov
504b2ebd4e
RequirementMachine: Change an isExistentialType() to isConstraintType()
2022-04-21 13:49:34 -04:00
Doug Gregor
f3fd64a71b
Support missing Sendable conformances everywhere in the requirement machine
2022-04-08 16:10:38 -07:00
Slava Pestov
4d15fa0087
RequirementMachine: Don't diagnose trivial circularity 'protocol P : P' as redundant
...
Every protocol gets an 'identity conformance' rule [P].[P] => [P].
A trivially-stated circularity is always redundant because of this
rule, and we diagnose circular inheritance elsewhere as a hard
error, so just add a special case to skip adding such a rule here
to avoid the useless warning on top of the existing error.
2022-04-05 21:12:51 -04:00
Slava Pestov
bc43cdd104
RequirementMachine: Generalize hack that allows associated type inheritance clauses to reference protocol typealiases
...
We want to allow this for all conformance requirements written in protocols
or the `where` clause of protocol extensions.
Fixes rdar://problem/91304291.
2022-04-05 18:42:35 -04:00
Slava Pestov
d385b73cd6
RequirementMachine: Plumb source locations through concrete contraction
2022-04-01 22:33:03 -04:00
Slava Pestov
0e297b0fbb
RequirementMachine: Use Requirement::hasError() method
2022-04-01 21:40:55 -04:00
Slava Pestov
75161ce6b0
RequirementMachine: Tweak fixit that turns 'T : Int' into 'T == Int' slightly to match GSB
2022-04-01 01:05:54 -04:00
Slava Pestov
01fea564fb
RequirementMachine: Skip emitting diagnostics containing ErrorTypes
2022-04-01 01:04:54 -04:00
Holly Borla
a4230a6061
[RequirementMachine] Simplify computing and emitting conflict diagnostics.
...
Instead of computing different combinations of conflicting requirement kinds,
emit the same error message for all of them.
2022-03-29 18:27:45 -07:00
Holly Borla
964c11a4d0
[RequirementMachine] Consolidate the various RequirementError::Kind cases
...
that represent conflict diagnostics.
2022-03-29 18:27:45 -07:00
Holly Borla
caee699560
[RequirementMachine] Mention the type parameter that is the subject of
...
two conflicting requirements in diagnostics where possible.
2022-03-29 18:27:45 -07:00
Holly Borla
e512e7a824
[RequirementMachine] Add a RequirementError for diagnosing a conflicting
...
same-type requirement.
2022-03-29 18:23:53 -07:00
Slava Pestov
a631d8aa3a
RequirementMachine: Write some comments
2022-03-28 22:16:09 -04:00
Slava Pestov
b859ac1444
RequirementMachine: Unwrap outer TypeAliasType on protocol typealiases
...
A protocol typealias 'typealias T = X' introduces a same-type requirement
'Self.T == Self.X'. However the right hand side of the requirement was
wrapped in a sugared TypeAliasType.
This meant if the requirement surfaced in a redundancy diagnostic, it
would print as 'Self.T == Self.T'. It could also trigger a request cycle
via isInterestingTypealias() in DiagnosticEngine.cpp.
2022-03-26 19:06:20 -04:00
Slava Pestov
298a84a202
RequirementMachine: Preserve sugar in desugarSameTypeRequirement()
2022-03-21 16:26:40 -04:00
Slava Pestov
cca936e790
RequirementMachine: Don't consider protocol typealiases with UnboundGenericType
...
These are stealth generic typealiases and should not participate in the
rewrite system.
2022-03-21 12:19:29 -04:00
Slava Pestov
1e731d3a18
RequirementMachine: Don't assert on abstract conformance in desugarConformanceRequirement()
2022-03-17 17:45:52 -04:00
Slava Pestov
ef1636a462
RequirementMachine: Split off RuleBuilder.{cpp,h} from RequirementLowering.{cpp,h}
2022-03-16 12:24:20 -04:00
Slava Pestov
7c006190dd
RequirementMachine: Fold getRuleForRequirement() into RuleBuilder::addRequirement()
2022-03-16 12:24:20 -04:00
Slava Pestov
652de97cfd
RequirementMachine: Introduce RuleBuilder::initWithConditionalRequirements()
2022-03-16 12:24:20 -04:00
Slava Pestov
8176b61d60
RequirementMachine: Tweak debug output and add an assertion
2022-03-16 12:24:10 -04:00
Slava Pestov
d7f84454c4
RequirementMachine: Filter duplicates in ProtocolDependenciesRequest
2022-03-16 00:58:30 -04:00
Slava Pestov
653977a51c
RequirementMachine: Rule sharing
...
All the pieces are now in place so that the RuleBuilder can assemble
a confluent rewrite system for downstream protocol dependencies,
instead of building rules from protocol requirement signatures.
2022-03-16 00:58:30 -04:00
Slava Pestov
aaf84ac6c2
RequirementMachine: Implement RequirementMachine::initWithProtocolSignatureRequirements()
2022-03-15 18:34:54 -04:00
Slava Pestov
564f626f62
RequirementMachine: Rename some RuleBuilder methods for clarity
2022-03-15 18:34:54 -04:00
Slava Pestov
1d8dd94501
RequirementMachine: Refactor RuleBuilder in preparation for rule sharing
2022-03-15 18:34:54 -04:00
Slava Pestov
6a74ad7065
RequirementMachine: Drop GSB compatibility hack involving ErrorTypes
...
Another hack we can remove now that 'verify' mode skips checking if
there was a conflict.
2022-03-14 12:33:18 -04:00
Slava Pestov
a61f67a0e8
RequirementMachine: Hack to allow protocol typealiases to appear in associated type inheritance clauses
...
If you have something like
protocol P {
typealias A = C
associatedtype T : A
}
class C {}
Then ::Structural resolution of 'A' in the inheritance clause will
produce a DependentMemberType 'Self.A'. Check for this case and
attempt ::Interface resolution to get the correct underlying type.
Fixes rdar://problem/90219229.
2022-03-14 12:33:18 -04:00
Holly Borla
b18e815436
[RequirementMachine] Preserve structural requirements during rule construction,
...
and diagnose trivially redundant rules in the rewrite system.
2022-03-09 12:14:58 -08:00
Holly Borla
80a2eee2bf
[Diagnostics] Remove a few special cases of printing 'any' for specific
...
error messages.
2022-03-05 14:26:45 -08:00
Slava Pestov
c75337c986
RequirementMachine: Remove lookupMemberType() in favor of existing substBaseType()
2022-02-18 22:24:25 -05:00
Slava Pestov
d7f8f2067a
Sema: Generalize ProtocolDecl::getPrimaryAssociatedType() to ProtocolDecl::getPrimaryAssociatedTypes()
2022-02-18 22:24:25 -05:00
Slava Pestov
7e5d6f4cb0
AST: Rework ParameterizedProtocolTypes to store multiple argument types
...
For now, this is NFC since we still assume one argument elsewhere.
2022-02-18 18:22:20 -05:00
Holly Borla
1dddd9c047
[RequirementMachine] Move gating emitting diagnostics on the requirement
...
macine flags to callers.
Callers gate this decision on different flags; InferredGenericSignatureRequestRQM
needs RequirementMachineInferredSignatures to be enabled, and the other
callsites need RequirementMachineProtocolSignatures to be enabled.
2022-02-16 13:11:57 -08:00
Holly Borla
04a91fe61d
[RequirementMachine] Suppress requirement diagnostics when one of the
...
types already has an error.
2022-02-16 13:11:57 -08:00
Holly Borla
d5814ae3e5
[RequirementMachine] Only emit a redundancy warning for layout constraints
...
if the type is constrained to a class layout, and add a few more test cases
for type requirement conflicts.
2022-02-16 13:11:57 -08:00
Holly Borla
a992917f1c
[NFC][RequirementMachine] Rename some of the RequirementError::Kind cases,
...
add documentation for each case, and move RequirementError to
lib/AST/RequirementMachine/Diagnostics.h.
2022-02-16 13:11:57 -08:00
Holly Borla
1f1125098b
[NFC][RequirementMachine] Add documentation for diagnoseRequirementErrors.
2022-02-16 13:11:57 -08:00
Holly Borla
e6dc7e69c1
[RequirementMachine] Emit diagnostics for structural requirements in protocol
...
and typealias requirement signatures.
2022-02-16 13:11:57 -08:00
Holly Borla
ec45d960d8
[RequirementMachine] Always store an invalid requirement in RequirementError.
2022-02-16 13:11:57 -08:00
Holly Borla
3837b4def4
[RequirementMachine] Diagnose early redundant requirements.
2022-02-16 13:11:57 -08:00
Holly Borla
203734bea4
[RequirementMachine] Diagnose conformance, layout, and superclass constraints
...
on non-type-parameters in the requirement machine.
2022-02-16 13:11:57 -08:00
Holly Borla
e4cba889c2
[RequirementMachine] Diagnose concrete same-type mismatches, such as
...
`where String == Int`.
2022-02-16 13:11:57 -08:00
Holly Borla
3c2b588037
[RequirementMachine] Plumb the requirement errors vector through desugarRequirement.
2022-02-16 13:11:57 -08:00
Holly Borla
a74717ab69
[RequirementMachine] Diagnose non-protocol, non-class conformance/subtype
...
constraints in the requirement machine.
2022-02-16 13:11:56 -08:00
Slava Pestov
4a06e21bf9
RequirementMachine: Introduce rules for protocol typealiases from requirement signatures
...
When building a rewrite system for a generic signature or protocol,
we would add requirements from the requirement signature of every
protocol dependency. Now, also add protocol typealias rules as well.
2022-02-13 00:24:23 -05:00
Slava Pestov
a1c03db381
AST: Generalize ProtocolDecl::getRequirementSignature() to a new RequirementSignature type
...
The RequirementSignature generalizes the old ArrayRef<Requirement>
which stores the minimal requirements that a conforming type's
witnesses must satisfy, to also record the protocol typealiases
defined in the protocol.
2022-02-13 00:24:23 -05:00
Slava Pestov
c58d9d8974
Sema: StructuralRequirementsRequest collects protocol typealiases
...
Introduces rewrite rules for typealiases defined inside the protocol
itself.
Typealiases defined in protocol extensions do not participate
in the rewrite system, except for when they have the same name as
an associated type, as per the weird rule codified in the
TypeAliasRequirementsRequest for GSB compatibility.
2022-02-13 00:24:23 -05:00