Skip to content

Commit 61dea21

Browse files
committed
Fix crash in DependentGenericTypeResolver::resolveDependentMemberType
An erroneous `baseTy` would cause resolveArchetype to return nullptr, resulting in a null dereference.
1 parent 21f081f commit 61dea21

File tree

551 files changed

+555
-551
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

551 files changed

+555
-551
lines changed

lib/Sema/TypeCheckGeneric.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ Type DependentGenericTypeResolver::resolveDependentMemberType(
3030
DeclContext *DC,
3131
SourceRange baseRange,
3232
ComponentIdentTypeRepr *ref) {
33-
return Builder.resolveArchetype(baseTy)->getRepresentative()
33+
auto archetype = Builder.resolveArchetype(baseTy);
34+
if (!archetype)
35+
return ErrorType::get(DC->getASTContext());
36+
37+
return archetype->getRepresentative()
3438
->getNestedType(ref->getIdentifier(), Builder)
3539
->getDependentType(Builder, true);
3640
}

validation-test/compiler_crashers/00066-diagnoseunknowntype.swift renamed to validation-test/compiler_crashers_fixed/00066-diagnoseunknowntype.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)
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/00318-swift-diagnosticengine-flushactivediagnostic.swift renamed to validation-test/compiler_crashers_fixed/00318-swift-diagnosticengine-flushactivediagnostic.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/00409-llvm-raw-fd-ostream-write-impl.swift renamed to validation-test/compiler_crashers_fixed/00409-llvm-raw-fd-ostream-write-impl.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/00492-swift-metatypetype-get.swift renamed to validation-test/compiler_crashers_fixed/00492-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/00530-swift-metatypetype-get.swift renamed to validation-test/compiler_crashers_fixed/00530-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/00539-swift-nominaltypedecl-getdeclaredtypeincontext.swift renamed to validation-test/compiler_crashers_fixed/00539-swift-nominaltypedecl-getdeclaredtypeincontext.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/00626-swift-lexer-lexidentifier.swift renamed to validation-test/compiler_crashers_fixed/00626-swift-lexer-lexidentifier.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/00637-swift-lexer-getlocforendoftoken.swift renamed to validation-test/compiler_crashers_fixed/00637-swift-lexer-getlocforendoftoken.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)