Skip to content

Commit cb3d6d1

Browse files
committed
Minor simplifications suggested by Slava
1 parent a11f9c3 commit cb3d6d1

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

lib/SIL/SILFunctionType.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -869,9 +869,6 @@ static CanSILFunctionType getSILFunctionType(SILModule &M,
869869
// signature from the AST for that.
870870
auto origGenericSig
871871
= function->getGenericSignature();
872-
auto getCanonicalType = [origGenericSig, &M](Type t) -> CanType {
873-
return t->getCanonicalType(origGenericSig);
874-
};
875872

876873
auto &Types = M.Types;
877874
auto loweredCaptures = Types.getLoweredLocalCaptures(*function);
@@ -887,7 +884,8 @@ static CanSILFunctionType getSILFunctionType(SILModule &M,
887884
dynamicSelfInterfaceType,
888885
MetatypeRepresentation::Thick);
889886

890-
auto canSelfMetatype = getCanonicalType(selfMetatype);
887+
auto canSelfMetatype =
888+
selfMetatype->getCanonicalType(origGenericSig);
891889
SILParameterInfo param(canSelfMetatype, convention);
892890
inputs.push_back(param);
893891

@@ -896,7 +894,7 @@ static CanSILFunctionType getSILFunctionType(SILModule &M,
896894

897895
auto *VD = capture.getDecl();
898896
auto type = VD->getInterfaceType();
899-
auto canType = getCanonicalType(type);
897+
auto canType = type->getCanonicalType(origGenericSig);
900898

901899
auto &loweredTL = Types.getTypeLowering(
902900
AbstractionPattern(genericSig, canType), canType);

lib/SILGen/SILGenPoly.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,10 +2822,6 @@ CanSILFunctionType SILGenFunction::buildThunkType(
28222822
? DefaultThickCalleeConvention
28232823
: ParameterConvention::Direct_Unowned});
28242824

2825-
auto getCanonicalType = [&](Type t) -> CanType {
2826-
return t->getCanonicalType(genericSig);
2827-
};
2828-
28292825
// Map the parameter and expected types out of context to get the interface
28302826
// type of the thunk.
28312827
SmallVector<SILParameterInfo, 4> interfaceParams;
@@ -2834,15 +2830,16 @@ CanSILFunctionType SILGenFunction::buildThunkType(
28342830
auto paramIfaceTy = GenericEnvironment::mapTypeOutOfContext(
28352831
genericEnv, param.getType());
28362832
interfaceParams.push_back(
2837-
SILParameterInfo(getCanonicalType(paramIfaceTy),
2833+
SILParameterInfo(paramIfaceTy->getCanonicalType(genericSig),
28382834
param.getConvention()));
28392835
}
28402836

28412837
SmallVector<SILResultInfo, 4> interfaceResults;
28422838
for (auto &result : expectedType->getResults()) {
28432839
auto resultIfaceTy = GenericEnvironment::mapTypeOutOfContext(
28442840
genericEnv, result.getType());
2845-
auto interfaceResult = result.getWithType(getCanonicalType(resultIfaceTy));
2841+
auto interfaceResult =
2842+
result.getWithType(resultIfaceTy->getCanonicalType(genericSig));
28462843
interfaceResults.push_back(interfaceResult);
28472844
}
28482845

@@ -2852,7 +2849,7 @@ CanSILFunctionType SILGenFunction::buildThunkType(
28522849
auto errorIfaceTy = GenericEnvironment::mapTypeOutOfContext(
28532850
genericEnv, errorResult.getType());
28542851
interfaceErrorResult = SILResultInfo(
2855-
getCanonicalType(errorIfaceTy),
2852+
errorIfaceTy->getCanonicalType(genericSig),
28562853
expectedType->getErrorResult().getConvention());
28572854
}
28582855

0 commit comments

Comments
 (0)