mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -1068,21 +1068,23 @@ static ValueDecl *deriveDecodable_init(TypeChecker &tc, Decl *parentDecl,
|
||||
initDecl->getAttrs().add(reqAttr);
|
||||
}
|
||||
|
||||
Type selfType = initDecl->computeInterfaceSelfType();
|
||||
Type selfInitType = initDecl->computeInterfaceSelfType(/*init=*/true);
|
||||
auto selfParam = computeSelfParam(initDecl);
|
||||
auto initSelfParam = computeSelfParam(initDecl, /*init=*/true);
|
||||
Type interfaceType;
|
||||
Type initializerType;
|
||||
if (auto sig = target->getGenericSignatureOfContext()) {
|
||||
// Evaluate the below, but in a generic environment (if Self is generic).
|
||||
initDecl->setGenericEnvironment(target->getGenericEnvironmentOfContext());
|
||||
interfaceType = GenericFunctionType::get(sig, selfType, innerType,
|
||||
interfaceType = GenericFunctionType::get(sig, {selfParam}, innerType,
|
||||
FunctionType::ExtInfo());
|
||||
initializerType = GenericFunctionType::get(sig, selfInitType, innerType,
|
||||
initializerType = GenericFunctionType::get(sig, {initSelfParam}, innerType,
|
||||
FunctionType::ExtInfo());
|
||||
} else {
|
||||
// (Self) -> (Decoder) throws -> (Self)
|
||||
interfaceType = FunctionType::get(selfType, innerType);
|
||||
initializerType = FunctionType::get(selfInitType, innerType);
|
||||
interfaceType = FunctionType::get({selfParam}, innerType,
|
||||
FunctionType::ExtInfo());
|
||||
initializerType = FunctionType::get({initSelfParam}, innerType,
|
||||
FunctionType::ExtInfo());
|
||||
}
|
||||
|
||||
initDecl->setInterfaceType(interfaceType);
|
||||
|
||||
Reference in New Issue
Block a user