Skip to content

Commit ebd774b

Browse files
committed
[Sema] Eliminate the last use of the IterativeTypeChecker.
Implement TypeChecker::resolveInheritedProtocols() in terms of "getInheritedType()" queries, instead. [Sema] Put back resolveInheritedProtocols(). We're still depending on it to update state in some cases.
1 parent 9843190 commit ebd774b

File tree

6 files changed

+8
-10
lines changed

6 files changed

+8
-10
lines changed

include/swift/AST/LazyResolver.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ class LazyResolver {
7777
/// Resolve the raw type of the given enum.
7878
virtual Type getRawType(EnumDecl *enumDecl) = 0;
7979

80-
/// Resolve the inherited protocols of a given protocol.
81-
virtual void resolveInheritedProtocols(ProtocolDecl *protocol) = 0;
82-
8380
/// Get a specific inherited type from the given declaration.
8481
virtual Type getInheritedType(
8582
llvm::PointerUnion<TypeDecl *, ExtensionDecl *> decl,

lib/AST/Decl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3280,8 +3280,8 @@ bool ProtocolDecl::requiresClassSlow() {
32803280
//
32813281
// FIXME: Use the requirement signature if available.
32823282
Bits.ProtocolDecl.RequiresClass = false;
3283-
for (auto inherited : getInherited()) {
3284-
auto type = inherited.getType();
3283+
for (unsigned i : indices(getInherited())) {
3284+
Type type = getInheritedType(i);
32853285
assert(type && "Should have type checked inheritance clause by now");
32863286
if (type->isExistentialType()) {
32873287
auto layout = type->getExistentialLayout();

lib/Sema/TypeCheckDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ void TypeChecker::validateWhereClauses(ProtocolDecl *protocol,
275275
}
276276

277277
void TypeChecker::resolveInheritedProtocols(ProtocolDecl *protocol) {
278-
IterativeTypeChecker ITC(*this);
279-
ITC.satisfy(requestInheritedProtocols(protocol));
278+
for (unsigned i : indices(protocol->getInherited()))
279+
(void)protocol->getInheritedType(i);
280280
resolveTrailingWhereClause(protocol);
281281
}
282282

lib/Sema/TypeChecker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ class TypeChecker final : public LazyResolver {
15721572
Type getRawType(EnumDecl *enumDecl) override;
15731573

15741574
/// Resolve the inherited protocols of a given protocol.
1575-
void resolveInheritedProtocols(ProtocolDecl *protocol) override;
1575+
void resolveInheritedProtocols(ProtocolDecl *protocol);
15761576

15771577
/// Validate a protocol's where clause, along with the where clauses of
15781578
/// its associated types.

test/decl/protocol/protocols.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,12 @@ protocol CircleMiddle : CircleStart { func circle_middle() } // expected-error
102102
// expected-error@-1{{circular protocol inheritance 'CircleMiddle' -> 'CircleStart' -> 'CircleEnd' -> 'CircleMiddle'}}
103103
protocol CircleStart : CircleEnd { func circle_start() }
104104
// expected-note@-1{{protocol 'CircleStart' declared here}}
105+
// expected-error@-2{{circular protocol inheritance CircleStart}}
105106
protocol CircleEnd : CircleMiddle { func circle_end()} // expected-note{{protocol 'CircleEnd' declared here}}
106107
// expected-error@-1{{circular protocol inheritance CircleEnd}}
107108

108109
protocol CircleEntry : CircleTrivial { }
109-
protocol CircleTrivial : CircleTrivial { } // expected-error 3{{circular protocol inheritance CircleTrivial}}
110+
protocol CircleTrivial : CircleTrivial { } // expected-error 2{{circular protocol inheritance CircleTrivial}}
110111

111112
struct Circle {
112113
func circle_start() {}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
// See https://swift.org/LICENSE.txt for license information
66
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
protocol P{{}typealias e where f:A:protocol A:A}protocol A:P

0 commit comments

Comments
 (0)