Skip to content

Commit a8190d8

Browse files
committed
RequirementMachine: Don't record duplicate superclass conflicts
1 parent d212041 commit a8190d8

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/AST/RequirementMachine/PropertyUnification.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,10 @@ void PropertyMap::addSuperclassProperty(
378378
}
379379

380380
auto &req = props->Superclasses[props->SuperclassDecl];
381-
for (const auto &pair : req.SuperclassRules)
382-
System.recordConflict(pair.second, ruleID);
381+
for (const auto &pair : req.SuperclassRules) {
382+
if (checkRulePairOnce(pair.second, ruleID))
383+
System.recordConflict(pair.second, ruleID);
384+
}
383385
}
384386
}
385387

test/IDE/print_ast_tc_decls_errors.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Verify errors in this file to ensure that parse and type checker errors
22
// occur where we expect them.
3-
// RUN: %target-typecheck-verify-swift -show-diagnostics-after-fatal
3+
// RUN: %target-typecheck-verify-swift -show-diagnostics-after-fatal -requirement-machine-protocol-signatures=on -requirement-machine-inferred-signatures=on
44

55
// RUN: %target-swift-ide-test -print-ast-typechecked -source-filename %s -prefer-type-repr=false > %t.printed.txt
66
// RUN: %FileCheck %s -strict-whitespace < %t.printed.txt
@@ -155,7 +155,7 @@ protocol ProtocolWithInheritance4 : FooClass, FooProtocol {}
155155
// NO-TYREPR: {{^}}protocol ProtocolWithInheritance4 : FooClass, FooProtocol {{{$}}
156156
// TYREPR: {{^}}protocol ProtocolWithInheritance4 : FooClass, FooProtocol {{{$}}
157157

158-
protocol ProtocolWithInheritance5 : FooClass, BarClass {} // expected-error{{multiple inheritance from classes 'FooClass' and 'BarClass'}} expected-error{{type 'Self' cannot be a subclass of both 'BarClass' and 'FooClass'}} // expected-note{{constraint conflicts with 'Self' : 'FooClass'}}
158+
protocol ProtocolWithInheritance5 : FooClass, BarClass {} // expected-error{{multiple inheritance from classes 'FooClass' and 'BarClass'}} expected-error{{no type for 'Self' can satisfy both 'Self : BarClass' and 'Self : FooClass'}}
159159
// NO-TYREPR: {{^}}protocol ProtocolWithInheritance5 : <<error type>>, <<error type>> {{{$}}
160160
// TYREPR: {{^}}protocol ProtocolWithInheritance5 : FooClass, BarClass {{{$}}
161161

0 commit comments

Comments
 (0)