[NFC] Refactor self type computation to return a Param

Remove a user of InOutType::get and flip a few users of
FunctionType::get to pass Params instead of naked input
types.
This commit is contained in:
Robert Widmann
2017-07-23 21:36:16 -07:00
parent bd02831599
commit e5918f70e8
15 changed files with 180 additions and 165 deletions

View File

@@ -159,26 +159,25 @@ static ValueDecl *deriveInitDecl(TypeChecker &tc, Decl *parentDecl,
Type retInterfaceType =
OptionalType::get(parentDC->getDeclaredInterfaceType());
Type interfaceType = FunctionType::get(interfaceArgType, retInterfaceType);
Type selfInterfaceType = initDecl->computeInterfaceSelfType();
Type selfInitializerInterfaceType =
initDecl->computeInterfaceSelfType(/*init*/ true);
auto selfParam = computeSelfParam(initDecl);
auto initSelfParam = computeSelfParam(initDecl, /*init*/ true);
Type allocIfaceType;
Type initIfaceType;
if (auto sig = parentDC->getGenericSignatureOfContext()) {
initDecl->setGenericEnvironment(parentDC->getGenericEnvironmentOfContext());
allocIfaceType = GenericFunctionType::get(sig, selfInterfaceType,
allocIfaceType = GenericFunctionType::get(sig, {selfParam},
interfaceType,
FunctionType::ExtInfo());
initIfaceType = GenericFunctionType::get(sig, selfInitializerInterfaceType,
initIfaceType = GenericFunctionType::get(sig, {initSelfParam},
interfaceType,
FunctionType::ExtInfo());
} else {
allocIfaceType = FunctionType::get(selfInterfaceType,
interfaceType);
initIfaceType = FunctionType::get(selfInitializerInterfaceType,
interfaceType);
allocIfaceType = FunctionType::get({selfParam},
interfaceType, FunctionType::ExtInfo());
initIfaceType = FunctionType::get({initSelfParam},
interfaceType, FunctionType::ExtInfo());
}
initDecl->setInterfaceType(allocIfaceType);
initDecl->setInitializerInterfaceType(initIfaceType);