File tree Expand file tree Collapse file tree 2 files changed +37
-3
lines changed
lib/AST/RequirementMachine Expand file tree Collapse file tree 2 files changed +37
-3
lines changed Original file line number Diff line number Diff line change @@ -646,7 +646,10 @@ void RewriteSystem::minimizeRewriteSystem(const PropertyMap &map) {
646
646
}
647
647
648
648
// / Returns flags indicating if the rewrite system has unresolved or
649
- // / conflicting rules in our minimization domain.
649
+ // / conflicting rules in our minimization domain. If these flags are
650
+ // / set, we do not install this rewrite system in the rewrite context
651
+ // / after minimization. Instead, we will rebuild a new rewrite system
652
+ // / from the minimized requirements.
650
653
GenericSignatureErrors RewriteSystem::getErrors () const {
651
654
assert (Complete);
652
655
assert (Minimized);
@@ -668,10 +671,19 @@ GenericSignatureErrors RewriteSystem::getErrors() const {
668
671
if (rule.isConflicting () || rule.isRecursive ())
669
672
result |= GenericSignatureErrorFlags::HasInvalidRequirements;
670
673
671
- if (!rule.isRedundant ())
672
- if (auto property = rule.isPropertyRule ())
674
+ if (!rule.isRedundant ()) {
675
+ if (auto property = rule.isPropertyRule ()) {
673
676
if (property->getKind () == Symbol::Kind::ConcreteConformance)
674
677
result |= GenericSignatureErrorFlags::HasConcreteConformances;
678
+
679
+ if (property->hasSubstitutions ()) {
680
+ for (auto t : property->getSubstitutions ()) {
681
+ if (t.containsUnresolvedSymbols ())
682
+ result |= GenericSignatureErrorFlags::HasInvalidRequirements;
683
+ }
684
+ }
685
+ }
686
+ }
675
687
}
676
688
677
689
return result;
Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift
2
+
3
+ struct G < T, U, V> { }
4
+
5
+ struct Foo < T> { }
6
+
7
+ // The first extension has the same generic signature as the
8
+ // second extension, because we drop the invalid requirement.
9
+ //
10
+ // But the rewrite system used for minimization with the first
11
+ // extension should not be installed in the rewrite context,
12
+ // because of this invalid requirement.
13
+
14
+ extension G where T == Foo < V . Bar > , U == Foo < Int > { }
15
+ // expected-error@-1 {{'Bar' is not a member type of type 'V'}}
16
+
17
+ extension G where U == Foo < Int > {
18
+ func f( ) {
19
+ print ( T . self)
20
+ print ( U . self)
21
+ }
22
+ }
You can’t perform that action at this time.
0 commit comments