Skip to content

Commit b1afaca

Browse files
authored
Merge pull request #33084 from xedin/rdar-50819554-5.3
[5.3][CSGen] Add a null check to prevent using invalid superclass type
2 parents d736586 + 8343c7f commit b1afaca

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
@@ -3037,6 +3037,9 @@ namespace {
30373037
typeContext->getDeclaredInterfaceType());
30383038
auto superclassTy = selfTy->getSuperclass();
30393039

3040+
if (!superclassTy)
3041+
return Type();
3042+
30403043
if (selfDecl->getInterfaceType()->is<MetatypeType>())
30413044
superclassTy = MetatypeType::get(superclassTy);
30423045

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)