Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4313,7 +4313,14 @@ case TypeKind::Id:
case TypeKind::SILFunction: {
auto fnTy = cast<SILFunctionType>(base);
bool changed = false;

auto hasTypeErasedGenericClassType = [](Type ty) -> bool {
return ty.findIf([](Type subType) -> bool {
if (subType->getCanonicalType().isTypeErasedGenericClassType())
return true;
else
return false;
});
};
auto updateSubs = [&](SubstitutionMap &subs) -> bool {
// This interface isn't suitable for updating the substitution map in a
// substituted SILFunctionType.
Expand All @@ -4323,9 +4330,8 @@ case TypeKind::Id:
auto transformed = type.transformRec(fn);
assert((type->isEqual(transformed) ||
(type->hasTypeParameter() && transformed->hasTypeParameter()) ||
(type->getCanonicalType().isTypeErasedGenericClassType() &&
transformed->getCanonicalType()
.isTypeErasedGenericClassType())) &&
(hasTypeErasedGenericClassType(type) &&
hasTypeErasedGenericClassType(transformed))) &&
"Substituted SILFunctionType can't be transformed into a "
"concrete type");
newReplacements.push_back(transformed->getCanonicalType());
Expand Down
10 changes: 10 additions & 0 deletions test/IRGen/generic_classes_objc.sil
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,13 @@ bb0(%0 : $Optional< @callee_guaranteed @substituted <τ_0_1> (@in_guaranteed Res
%2 = tuple ()
return %2 : $()
}

struct PlainGeneric<T> {}

// This used to assert.
sil @repo2 : $@convention(thin) (@guaranteed Optional< @callee_guaranteed @substituted <τ_0_1> (@in_guaranteed Result<τ_0_1, Error>) -> () for <PlainGeneric<ObjcGenericClass<SomeClass>>>>) -> () {
bb0(%0 : $Optional< @callee_guaranteed @substituted <τ_0_1> (@in_guaranteed Result<τ_0_1, Error>) -> () for <PlainGeneric<ObjcGenericClass<SomeClass>>> >):
debug_value %0 : $Optional<@callee_guaranteed @substituted <τ_0_1> (@in_guaranteed Result<τ_0_1, Error>) -> () for <PlainGeneric<ObjcGenericClass<SomeClass>>>>, let, name "completion", argno 1
%2 = tuple ()
return %2 : $()
}