Skip to content

Commit ba8e86d

Browse files
committed
[Deserialization] Weakened DeclContext asssertion in maybeReadGenericParams.
An over-eager assertion in ModuleFile::maybeReadGenericParams() rejected deserialization into the context of a generic subscript for a generic parameter within one of its accessors. Weaken the assertion; the DeclContext of the generic parameter will be overwritten with the correct context later. Fixes rdar://problem/37408205.
1 parent 3888b5b commit ba8e86d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/Serialization/Deserialization.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,8 @@ GenericParamList *ModuleFile::maybeReadGenericParams(DeclContext *DC,
738738
// precede SIL linkage, we should be ok.
739739
assert((genericParam->getDeclContext()->isModuleScopeContext() ||
740740
DC->isModuleScopeContext() ||
741-
genericParam->getDeclContext() == DC) &&
741+
genericParam->getDeclContext() == DC ||
742+
genericParam->getDeclContext()->isChildContextOf(DC)) &&
742743
"Mismatched decl context for generic types.");
743744
params.push_back(genericParam);
744745
break;

test/SIL/Serialization/Inputs/def_generic.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@ public class A<T> {
1010
@_versioned
1111
@_inlineable
1212
init() {}
13+
14+
@_inlineable public subscript<U>(value: T) -> U? {
15+
return nil
16+
}
1317
}

0 commit comments

Comments
 (0)