Skip to content

Commit 182683a

Browse files
authored
Merge pull request #33083 from xedin/rdar-50819554
[CSGen] Add a null check to prevent using invalid superclass type
2 parents 6fe79fa + 8f73ff4 commit 182683a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/Sema/CSGen.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2954,6 +2954,9 @@ namespace {
29542954
typeContext->getDeclaredInterfaceType());
29552955
auto superclassTy = selfTy->getSuperclass();
29562956

2957+
if (!superclassTy)
2958+
return Type();
2959+
29572960
if (selfDecl->getInterfaceType()->is<MetatypeType>())
29582961
superclassTy = MetatypeType::get(superclassTy);
29592962

test/Constraints/super_method.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,12 @@ func use_d(_ d: D) -> Int {
5959
func not_method() {
6060
super.foo() // expected-error{{'super' cannot be used outside of class members}}
6161
}
62+
63+
// rdar://problem/50819554 - inability to properly resolve superclass shouldn't crash the solver
64+
func test_that_invalid_supertype_ref_doesnt_crash() {
65+
final class Node: ManagedBuffer<AnyObject, Undefined> { // expected-error {{cannot find type 'Undefined' in scope}}
66+
static func create() {
67+
super.create()
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)