Skip to content

Commit df80a0c

Browse files
authored
Merge pull request #6186 from slavapestov/itc-fix-2
Sema: More ITC fixes
2 parents 9beabec + ddd19c6 commit df80a0c

12 files changed

+26
-18
lines changed

lib/AST/Decl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,6 +2404,10 @@ ObjCClassKind ClassDecl::checkObjCAncestry() const {
24042404
if (!CD->hasSuperclass())
24052405
break;
24062406
CD = CD->getSuperclass()->getClassOrBoundGenericClass();
2407+
// If we don't have a valid class here, we should have diagnosed
2408+
// elsewhere.
2409+
if (!CD)
2410+
break;
24072411
}
24082412

24092413
if (!isObjC)

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 })))

lib/Sema/TypeCheckDecl.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,6 @@ void TypeChecker::checkInheritanceClause(Decl *decl,
560560
// Set the superclass.
561561
if (auto classDecl = dyn_cast<ClassDecl>(decl)) {
562562
classDecl->setSuperclass(superclassTy);
563-
if (superclassTy)
564-
resolveImplicitConstructors(superclassTy->getClassOrBoundGenericClass());
565563
} else if (auto enumDecl = dyn_cast<EnumDecl>(decl)) {
566564
enumDecl->setRawType(superclassTy);
567565
} else {
@@ -7859,10 +7857,6 @@ void TypeChecker::addImplicitConstructors(NominalTypeDecl *decl) {
78597857
// for all of the superclass's designated initializers.
78607858
// FIXME: Currently skipping generic classes.
78617859
auto classDecl = cast<ClassDecl>(decl);
7862-
assert(!classDecl->hasSuperclass() ||
7863-
classDecl->getSuperclass()->getAnyNominal()->isInvalid() ||
7864-
classDecl->getSuperclass()->getAnyNominal()
7865-
->addedImplicitInitializers());
78667860
if (classDecl->hasSuperclass()) {
78677861
bool canInheritInitializers = !FoundDesignatedInit;
78687862

@@ -7874,6 +7868,11 @@ void TypeChecker::addImplicitConstructors(NominalTypeDecl *decl) {
78747868
}
78757869

78767870
auto superclassTy = classDecl->getSuperclass();
7871+
auto *superclassDecl = superclassTy->getClassOrBoundGenericClass();
7872+
assert(superclassDecl && "Superclass of class is not a class?");
7873+
if (!superclassDecl->addedImplicitInitializers())
7874+
addImplicitConstructors(superclassDecl);
7875+
78777876
auto ctors = lookupConstructors(classDecl, superclassTy,
78787877
NameLookupFlags::IgnoreAccessibility);
78797878

test/SILGen/accessibility_vtables.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ class InternalSub : InternalBase {
3838

3939
// CHECK-LABEL: sil_vtable InternalSub {
4040
// CHECK-NEXT: #InternalBase.method!1: _TFC21accessibility_vtables12InternalBaseP{{[0-9]+}}[[DISCRIMINATOR:_.+]]6method
41-
// CHECK-NEXT: #InternalBase.init!initializer.1: _TFC21accessibility_vtables11InternalSubc
4241
// CHECK-NEXT: #InternalBase.prop!getter.1: _TFC21accessibility_vtables11InternalSubg4propSi // accessibility_vtables.InternalSub.prop.getter : Swift.Int
4342
// CHECK-NEXT: #InternalBase.prop!setter.1: _TFC21accessibility_vtables12InternalBases4propSi // accessibility_vtables.InternalBase.prop.setter : Swift.Int
4443
// CHECK-NEXT: #InternalBase.prop!materializeForSet.1: _TFC21accessibility_vtables12InternalBasem4propSi // accessibility_vtables.InternalBase.prop.materializeForSet : Swift.Int
44+
// CHECK-NEXT: #InternalBase.init!initializer.1: _TFC21accessibility_vtables11InternalSubc
4545
// CHECK-NEXT: #InternalSub.method!1: _TFC21accessibility_vtables11InternalSub6method
4646
// CHECK-NEXT: #InternalSub.prop!setter.1: _TFC21accessibility_vtables11InternalSubs4propSi // accessibility_vtables.InternalSub.prop.setter : Swift.Int
4747
// CHECK-NEXT: #InternalSub.prop!materializeForSet.1: _TFC21accessibility_vtables11InternalSubm4propSi // accessibility_vtables.InternalSub.prop.materializeForSet : Swift.Int

test/SILGen/objc_attr_NSManaged.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ extension ProtoAdopter {
9999

100100
// The vtable should not contain any entry points for getters and setters.
101101
// CHECK-LABEL: sil_vtable SwiftGizmo {
102-
// CHECK-NEXT: #SwiftGizmo.modifyX!1: _TFC19objc_attr_NSManaged10SwiftGizmo7modifyX
103-
// CHECK-NEXT: #SwiftGizmo.testFunc!1: _TFC19objc_attr_NSManaged10SwiftGizmo8testFunc
104-
// CHECK-NEXT: #SwiftGizmo.init!initializer.1: _TFC19objc_attr_NSManaged10SwiftGizmoc
102+
// CHECK-NEXT: #SwiftGizmo.modifyX!1: _TFC19objc_attr_NSManaged10SwiftGizmo7modifyX
103+
// CHECK-NEXT: #SwiftGizmo.testFunc!1: _TFC19objc_attr_NSManaged10SwiftGizmo8testFunc
104+
// CHECK-NEXT: #SwiftGizmo.deinit!deallocator:
105+
// CHECK-NEXT: #SwiftGizmo.init!initializer.1: _TFC19objc_attr_NSManaged10SwiftGizmoc
105106
// CHECK-NEXT: #SwiftGizmo.init!initializer.1: _TFC19objc_attr_NSManaged10SwiftGizmoc
106-
// CHECK-NEXT: #SwiftGizmo.deinit!deallocator:
107107
// CHECK-NEXT: }
108108

109109
// CHECK-LABEL: sil_vtable FinalGizmo {

test/decl/class/circular_inheritance.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ protocol P : P {} // expected-error{{circular protocol inheritance P}}
1010
class Isomorphism : Automorphism { }
1111
class Automorphism : Automorphism { } // expected-error{{circular class inheritance Automorphism}}
1212

13-
let _ = A()
13+
// FIXME: Useless error
14+
let _ = A() // expected-error{{'A' cannot be constructed because it has no accessible initializers}}
1415

1516
// This should probably be made to work, but for now test that it produces a crappy
1617
// diagnostic instead of crashing

validation-test/compiler_crashers/28367-swift-declcontext-isgenericcontext.swift renamed to validation-test/compiler_crashers_fixed/28367-swift-declcontext-isgenericcontext.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 -typecheck
8+
// RUN: not %target-swift-frontend %s -typecheck
99
let a{{}protocol A{class A:d class d<U:A>:A

validation-test/compiler_crashers/28386-swift-typebase-getdesugaredtype.swift renamed to validation-test/compiler_crashers_fixed/28386-swift-typebase-getdesugaredtype.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
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 -typecheck
8+
// RUN: not %target-swift-frontend %s -typecheck
99
struct A{init(){let:A
1010
class B:A
1111
class A:B{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
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
// REQUIRES: asserts
1010
protocol A{enum S{var f=e
1111
typealias f:B

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)