Skip to content

Commit 47ca24d

Browse files
authored
Merge pull request #36977 from bnbarham/cherry-pick-75379780
[5.5][Serialization] Add some checks for invalid types
2 parents 785288b + fbb8d1f commit 47ca24d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/Serialization/Serialization.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2236,6 +2236,8 @@ static bool contextDependsOn(const NominalTypeDecl *decl,
22362236
static void collectDependenciesFromType(llvm::SmallSetVector<Type, 4> &seen,
22372237
Type ty,
22382238
const DeclContext *excluding) {
2239+
if (!ty)
2240+
return;
22392241
ty.visit([&](Type next) {
22402242
auto *nominal = next->getAnyNominal();
22412243
if (!nominal)
@@ -3064,6 +3066,9 @@ class Serializer::DeclSerializer : public DeclVisitor<DeclSerializer> {
30643066

30653067
SmallVector<TypeID, 8> inheritedAndDependencyTypes;
30663068
for (auto inherited : extension->getInherited()) {
3069+
if (extension->getASTContext().LangOpts.AllowModuleWithCompilerErrors &&
3070+
!inherited.getType())
3071+
continue;
30673072
assert(!inherited.getType()->hasArchetype());
30683073
inheritedAndDependencyTypes.push_back(S.addTypeRef(inherited.getType()));
30693074
}

test/Frontend/allow-errors.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public func invalidFuncBody() -> ValidStructInvalidMember {
5555
}
5656

5757
public func invalidFunc() -> undefined {} // expected-error {{cannot find type 'undefined'}}
58+
59+
extension undefined: undefined {} // expected-error {{cannot find type 'undefined'}}
60+
61+
class GenericClass<T> {}
62+
class InvalidSuperclass: GenericClass<undefined> {} // expected-error {{cannot find type 'undefined'}}
5863
#endif
5964

6065
// RUN: %target-swift-frontend -emit-module -o %t/validUses.swiftmodule -experimental-allow-module-with-compiler-errors -I%t -D VALID_USES %s 2>&1 | %FileCheck -check-prefix=CHECK-VALID %s

0 commit comments

Comments
 (0)