@@ -1123,8 +1123,12 @@ CanType TypeBase::getCanonicalType() {
1123
1123
auto &ctx = function->getInput ()->getASTContext ();
1124
1124
auto &mod = *ctx.TheBuiltinModule ;
1125
1125
Type inputTy = function->getInput ()->getCanonicalType (sig, mod);
1126
- if (!AnyFunctionType::isCanonicalFunctionInputType (inputTy))
1127
- inputTy = ParenType::get (ctx, inputTy->getInOutObjectType (), ParameterTypeFlags ().withInOut (inputTy->is <InOutType>()));
1126
+ if (!AnyFunctionType::isCanonicalFunctionInputType (inputTy)) {
1127
+ auto flags = ParameterTypeFlags ().withInOut (inputTy->is <InOutType>());
1128
+ if (auto parenTy = dyn_cast<ParenType>(function->getInput ().getPointer ()))
1129
+ flags = flags.withShared (parenTy->getParameterFlags ().isShared ());
1130
+ inputTy = ParenType::get (ctx, inputTy->getInOutObjectType (), flags);
1131
+ }
1128
1132
auto resultTy = function->getResult ()->getCanonicalType (sig, mod);
1129
1133
1130
1134
Result = GenericFunctionType::get (sig, inputTy, resultTy,
@@ -1142,7 +1146,10 @@ CanType TypeBase::getCanonicalType() {
1142
1146
FunctionType *FT = cast<FunctionType>(this );
1143
1147
Type In = FT->getInput ()->getCanonicalType ();
1144
1148
if (!AnyFunctionType::isCanonicalFunctionInputType (In)) {
1145
- In = ParenType::get (In->getASTContext (), In->getInOutObjectType (), ParameterTypeFlags ().withInOut (In->is <InOutType>()));
1149
+ auto flags = ParameterTypeFlags ().withInOut (In->is <InOutType>());
1150
+ if (auto parenTy = dyn_cast<ParenType>(FT->getInput ().getPointer ()))
1151
+ flags = flags.withShared (parenTy->getParameterFlags ().isShared ());
1152
+ In = ParenType::get (In->getASTContext (), In->getInOutObjectType (), flags);
1146
1153
assert (AnyFunctionType::isCanonicalFunctionInputType (In));
1147
1154
}
1148
1155
Type Out = FT->getResult ()->getCanonicalType ();
0 commit comments