Skip to content

Commit ddd19c6

Browse files
committed
Sema: Hacky fix for infinite recursion if a class inherits from itself
This seems to come up a lot; we need to consolidate and clean up inheritance circularity breaks.
1 parent 9a65745 commit ddd19c6

4 files changed

+7
-3
lines changed

lib/Sema/ITCNameLookup.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ bool IterativeTypeChecker::isQualifiedLookupInDeclContextSatisfied(
7575

7676
if (auto superclass = classDecl->getSuperclass()) {
7777
if (auto superclassDecl = superclass->getAnyNominal()) {
78+
// Hack.
79+
if (superclassDecl == nominal)
80+
return true;
81+
7882
if (!isSatisfied(requestQualifiedLookupInDeclContext({ superclassDecl,
7983
payload.Name,
8084
payload.Loc })))

validation-test/compiler_crashers/28462-segfault-0xcdc361-0xd051ef-0xcdc361-0xd051ef.swift renamed to validation-test/compiler_crashers_fixed/28462-segfault-0xcdc361-0xd051ef-0xcdc361-0xd051ef.swift

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
typealias e=A.G{}{}class A:A
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
typealias e:A.d)class A:A}a
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
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
typealias d:A.a
1010
class A:A

0 commit comments

Comments
 (0)