Skip to content

Commit 3ba3bd3

Browse files
committed
Merge pull request #620 from jtbandes/member-fix
More error checking for member type lookup
2 parents cf411ed + ac95c13 commit 3ba3bd3

10 files changed

+19
-16
lines changed

lib/AST/Type.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,9 +2313,12 @@ static Type getMemberForBaseType(Module *module,
23132313
// If the parent is an archetype, extract the child archetype with the
23142314
// given name.
23152315
if (auto archetypeParent = substBase->getAs<ArchetypeType>()) {
2316-
if (!archetypeParent->hasNestedType(name) &&
2317-
archetypeParent->getParent()->isSelfDerived()) {
2318-
return archetypeParent->getParent()->getNestedTypeValue(name);
2316+
if (!archetypeParent->hasNestedType(name)) {
2317+
const auto parent = archetypeParent->getParent();
2318+
if (!parent)
2319+
return ErrorType::get(module->getASTContext());
2320+
if (parent->isSelfDerived())
2321+
return parent->getNestedTypeValue(name);
23192322
}
23202323

23212324
return archetypeParent->getNestedTypeValue(name);

validation-test/IDE/crashers/018-swift-type-transform.swift

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %target-swift-ide-test -code-completion -code-completion-token=A -source-filename=%s
2+
protocol A{
3+
typealias e
4+
class A{let A{
5+
protocol A{typealias f=e
6+
#^A^#

validation-test/compiler_crashers/00647-std-function-func-swift-type-subst.swift renamed to validation-test/compiler_crashers_fixed/00647-std-function-func-swift-type-subst.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: not --crash %target-swift-frontend %s -parse
1+
// RUN: not %target-swift-frontend %s -parse
22

33
// Distributed under the terms of the MIT license
44
// Test case submitted to project by https://github.com/practicalswift (practicalswift)

validation-test/compiler_crashers/01487-std-function-func-swift-type-subst.swift renamed to validation-test/compiler_crashers_fixed/01487-std-function-func-swift-type-subst.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: not --crash %target-swift-frontend %s -parse
1+
// RUN: not %target-swift-frontend %s -parse
22

33
// Distributed under the terms of the MIT license
44
// Test case submitted to project by https://github.com/practicalswift (practicalswift)

validation-test/compiler_crashers/02030-std-function-func-swift-type-subst.swift renamed to validation-test/compiler_crashers_fixed/02030-std-function-func-swift-type-subst.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: not --crash %target-swift-frontend %s -parse
1+
// RUN: not %target-swift-frontend %s -parse
22

33
// Distributed under the terms of the MIT license
44
// Test case submitted to project by https://github.com/practicalswift (practicalswift)

validation-test/compiler_crashers/24531-swift-metatypetype-get.swift renamed to validation-test/compiler_crashers_fixed/24531-swift-metatypetype-get.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: not --crash %target-swift-frontend %s -parse
1+
// RUN: not %target-swift-frontend %s -parse
22

33
// Distributed under the terms of the MIT license
44
// Test case submitted to project by https://github.com/practicalswift (practicalswift)

validation-test/compiler_crashers/24879-getmemberforbasetype.swift renamed to validation-test/compiler_crashers_fixed/24879-getmemberforbasetype.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: not --crash %target-swift-frontend %s -parse
1+
// RUN: not %target-swift-frontend %s -parse
22

33
// Distributed under the terms of the MIT license
44
// Test case submitted to project by https://github.com/zneak (zneak)

validation-test/compiler_crashers/25488-std-function-func-swift-type-subst.swift renamed to validation-test/compiler_crashers_fixed/25488-std-function-func-swift-type-subst.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: not --crash %target-swift-frontend %s -parse
1+
// RUN: not %target-swift-frontend %s -parse
22

33
// Distributed under the terms of the MIT license
44
// Test case submitted to project by https://github.com/practicalswift (practicalswift)

validation-test/compiler_crashers/27169-swift-typechecker-validategenericfuncsignature.swift renamed to validation-test/compiler_crashers_fixed/27169-swift-typechecker-validategenericfuncsignature.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: not --crash %target-swift-frontend %s -parse
1+
// RUN: not %target-swift-frontend %s -parse
22

33
// Distributed under the terms of the MIT license
44
// Test case submitted to project by https://github.com/practicalswift (practicalswift)

0 commit comments

Comments
 (0)