Slava Pestov
80f8487d32
RequirementMachine: Use Requirement::checkRequirement() to desugar layout requirements
2023-04-05 23:42:17 -04:00
Slava Pestov
8d219442c8
RequirementMachine: Use Requirement::checkRequirement() to desugar superclass requirements
2023-04-05 23:42:17 -04:00
Slava Pestov
58822544bc
RequirementMachine: Use Requirement::checkRequirement() to desugar conformance requirements
2023-04-05 23:42:17 -04:00
Slava Pestov
e14ac9e482
RequirementMachine: Clean up desugarRequirement() a bit
2023-04-05 23:42:17 -04:00
Holly Borla
74cc62735b
[RequirementMachine] Diagnose same-element requirements.
...
The rewrite rules are not quite right yet for same-element requirements, so
let's ban them for now.
2023-03-06 21:32:30 -08:00
Holly Borla
679825063a
[RequirementMachine] Only skip Sendable requirements inferred from preconcurrency
...
decls if the decl we're inferring the generic signature for is not itself
preconcurrency.
2023-01-19 20:28:50 -08:00
Holly Borla
d526e4c0e7
[RequirementMachine] Skip Sendable conformance requirements from preconcurrency
...
declarations in requirement inference.
2023-01-19 20:28:30 -08:00
Slava Pestov
c11a4240df
RequirementMachine: Fix a typo
2022-11-28 23:58:06 -05:00
Slava Pestov
23abf74c0a
RequirementMachine: Better error recovery from invalid protocol inheritance clauses
...
getInheritedProtocols() skips type resolution and directly resolves
TypeReprs to TypeDecls.
On the other hand, when building a protocol requirement signature,
we use type resolution to resolve inheritance clause entries so
that we can properly support parameterized protocol types, and
protocol compositions that contain classes.
Since a TypeRepr with an invalid sub-component resolves to an
ErrorType, this meant that in invalid code, the first list of
protocols might contain protocols that don't appear in the second.
This broke rewrite system invariants. Fix this by checking if
type resolution failed when building the requirement signature of
a protocol, and if so, also look at getInheritedProtocols().
Fixes https://github.com/apple/swift/issues/61020 .
2022-11-01 11:05:36 -04:00
Holly Borla
c4b946195e
[AST] Replace the "type sequence" terminology with "parameter pack".
2022-10-10 16:28:13 -07:00
Holly Borla
41ce264a7f
[RequirementMachine] Simplify same-shape requirement inference from pack
...
expansion types by equating the pack expansion count/shape type with each
shape of the referenced packs in the expansion.
2022-10-06 20:48:40 -07:00
Holly Borla
38a2c8218b
[Requirement] Rename RequirementKind::SameCount to SameShape.
2022-10-06 20:48:40 -07:00
Holly Borla
ae5ebba2c1
[RequirementMachine] Add same-length requirement inference for pack
...
expansion types.
2022-10-06 20:38:30 -07:00
Slava Pestov
5c32f2136e
AST: Introduce RequirementKind::SameCount
2022-08-23 11:12:00 -04:00
Slava Pestov
7d8f3e6b63
AST: Change return type of Requirement::subst() to Requirement
...
Instead of returning None, let callers check hasError() if they need to.
Fixes rdar://problem/98565072.
2022-08-12 14:03:57 -04:00
Slava Pestov
25fb866239
RequirementMachine: Fix a request cycle
...
RequirementSignatureRequest
=> TypeAliasRequirementsRequest
=> isConstrainedExtension()
=> GenericSignatureRequest
=> RequirementSignatureRequest
Instead, use getTrailingWhereClause() as an approximation of
isConstrainedExtension().
Fixes rdar://problem/97236936.
2022-07-19 11:06:01 -04:00
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