Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IRGen: Work around crash lowering generic base class-constrained type parameter. #1258

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/IRGen/GenArchetype.cpp
Expand Up @@ -248,7 +248,11 @@ const TypeInfo *TypeConverter::convertArchetypeType(ArchetypeType *archetype) {
ClassDecl *superClass = super->getClassOrBoundGenericClass();
refcount = getReferenceCountingForClass(IGM, superClass);

auto &superTI = IGM.getTypeInfoForUnlowered(super);
// FIXME: Bypass type lowering here, since lowering a generic superclass
// requirement triggers a crash when it's dependent on generic params
// (rdar://problem/24590570). Nominal class types are currently
// unaffected by type lowering (and are likely to remain so).
auto &superTI = IGM.getTypeInfoForLowered(super->getCanonicalType());
reprTy = cast<llvm::PointerType>(superTI.StorageType);
}

Expand Down
12 changes: 12 additions & 0 deletions test/IRGen/dependent_generic_base_class_constraint.swift
@@ -0,0 +1,12 @@
// RUN: %target-swift-frontend -emit-ir -verify %s
class GenericClass<T> { }

protocol MyProtocol { }

class MyClass {
func myFunction<T, O: GenericClass<T> where T: MyProtocol>(myArg: O) -> T {
fatalError()
}
}