Merge pull request #13594 from apple/bugfix_largetype
Merge pull request #13590 from shajrawi/large_type_bugfix_part1
diff --git a/lib/IRGen/LoadableByAddress.cpp b/lib/IRGen/LoadableByAddress.cpp
index 80015f4..901502a 100644
--- a/lib/IRGen/LoadableByAddress.cpp
+++ b/lib/IRGen/LoadableByAddress.cpp
@@ -637,6 +637,12 @@
if (!genEnv && loweredTy->isPolymorphic()) {
genEnv = getGenericEnvironment(F->getModule(), loweredTy);
}
+ CanType currCanType = storageType.getSwiftRValueType();
+ if (auto funcType = dyn_cast<SILFunctionType>(currCanType)) {
+ if (funcType->isPolymorphic()) {
+ genEnv = getGenericEnvironment(F->getModule(), funcType);
+ }
+ }
SILType newSILType = getNewSILType(genEnv, storageType, Mod);
// We (currently) only care about function signatures
if (!isLargeLoadableType(genEnv, storageType, Mod) &&