SIL: Canonicalize capture types with the AST function's generic signature.

When lowering closures, we avoid capturing the enclosing generic context when possible. However, the generic context may still be necessary to canonicalize types mentioned inside the closure, such as when an associated type is referred to that is same-typed to a concrete type. Fixes rdar://problem/30254048.
This commit is contained in:
Joe Groff
2017-02-03 12:07:28 -08:00
parent 93b7cbfa65
commit a7f23f5019
5 changed files with 51 additions and 6 deletions

View File

@@ -176,6 +176,16 @@ public:
}
llvm_unreachable("unexpected AnyFunctionRef representation");
}
GenericSignature *getGenericSignature() const {
if (auto afd = TheFunction.dyn_cast<AbstractFunctionDecl *>()) {
return afd->getGenericSignature();
}
if (auto ce = TheFunction.dyn_cast<AbstractClosureExpr *>()) {
return ce->getGenericSignatureOfContext();
}
llvm_unreachable("unexpected AnyFunctionRef representation");
}
};
#if SWIFT_COMPILER_IS_MSVC
#pragma warning(pop)