Skip to content

Commit fe9c48c

Browse files
committed
Serialization: Protect getType for params and classes
1 parent 06d2d4c commit fe9c48c

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

lib/Serialization/Deserialization.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4084,7 +4084,9 @@ class DeclDeserializer {
40844084

40854085
declOrOffset = param;
40864086

4087-
auto paramTy = MF.getType(interfaceTypeID);
4087+
Type paramTy;
4088+
SET_OR_RETURN_ERROR(paramTy, MF.getTypeChecked(interfaceTypeID));
4089+
40884090
if (paramTy->hasError() && !MF.allowCompilerErrors()) {
40894091
// FIXME: This should never happen, because we don't serialize
40904092
// error types.
@@ -4106,7 +4108,9 @@ class DeclDeserializer {
41064108
if (auto defaultArg = getActualDefaultArgKind(rawDefaultArg)) {
41074109
param->setDefaultArgumentKind(*defaultArg);
41084110

4109-
if (auto exprType = MF.getType(defaultExprType))
4111+
Type exprType;
4112+
SET_OR_RETURN_ERROR(exprType, MF.getTypeChecked(defaultExprType));
4113+
if (exprType)
41104114
param->setDefaultExprType(exprType);
41114115

41124116
auto isoKind = *getActualActorIsolationKind(rawDefaultArgIsolation);
@@ -4952,7 +4956,11 @@ class DeclDeserializer {
49524956
if (isImplicit)
49534957
theClass->setImplicit();
49544958
theClass->setIsObjC(isObjC);
4955-
theClass->setSuperclass(MF.getType(superclassID));
4959+
4960+
Type superclass;
4961+
SET_OR_RETURN_ERROR(superclass, MF.getTypeChecked(superclassID));
4962+
theClass->setSuperclass(superclass);
4963+
49564964
ctx.evaluator.cacheOutput(InheritsSuperclassInitializersRequest{theClass},
49574965
std::move(inheritsSuperclassInitializers));
49584966
ctx.evaluator.cacheOutput(HasMissingDesignatedInitializersRequest{theClass},

test/Serialization/Recovery/implementation-only-missing.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public protocol HiddenProtocolWithOverride {
6161
func hiddenOverride()
6262
}
6363

64-
public class HiddenClass {}
64+
open class HiddenClass {}
6565

6666
public struct HiddenRawType: ExpressibleByStringLiteral, Equatable, CustomStringConvertible {
6767

@@ -148,6 +148,14 @@ enum InternalEnumWithRawType: HiddenRawType {
148148
case a
149149
}
150150

151+
class InternalSubclass: HiddenClass {}
152+
class GenericBase<T> {}
153+
class Sub: GenericBase<Sub.Nested> {
154+
class Nested: HiddenClass {}
155+
}
156+
157+
func InternalFuncWithParam(a: HiddenRawType) {}
158+
151159
//--- Client.swift
152160

153161
import PublicLib

0 commit comments

Comments
 (0)