Skip to content

Commit da14e36

Browse files
committed
[nfc] refactor isUnsupportedKeyPathValueType
1 parent 8178eb0 commit da14e36

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lib/SIL/IR/SIL.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,14 @@ bool SILModule::isTypeMetadataForLayoutAccessible(SILType type) {
296296
return ::isTypeMetadataForLayoutAccessible(*this, type);
297297
}
298298

299-
static bool isUnsupportedKeyPathValueType(Type ty, GenericEnvironment *env) {
299+
static bool isUnsupportedKeyPathValueType(Type ty) {
300300
// Visit lowered positions.
301301
if (auto tupleTy = ty->getAs<TupleType>()) {
302302
for (auto eltTy : tupleTy->getElementTypes()) {
303303
if (eltTy->is<PackExpansionType>())
304304
return true;
305305

306-
if (isUnsupportedKeyPathValueType(eltTy, env))
306+
if (isUnsupportedKeyPathValueType(eltTy))
307307
return true;
308308
}
309309

@@ -321,19 +321,19 @@ static bool isUnsupportedKeyPathValueType(Type ty, GenericEnvironment *env) {
321321
if (paramTy->is<PackExpansionType>())
322322
return true;
323323

324-
if (isUnsupportedKeyPathValueType(paramTy, env))
324+
if (isUnsupportedKeyPathValueType(paramTy))
325325
return true;
326326
}
327327

328-
if (isUnsupportedKeyPathValueType(funcTy->getResult(), env))
328+
if (isUnsupportedKeyPathValueType(funcTy->getResult()))
329329
return true;
330330
}
331331

332332
// Noncopyable types aren't supported by key paths in their current form.
333333
// They would also need a new ABI that's yet to be implemented in order to
334334
// be properly supported, so let's suppress the descriptor for now if either
335335
// the container or storage type of the declaration is non-copyable.
336-
if (ty->isNoncopyable(env))
336+
if (ty->isNoncopyable())
337337
return true;
338338

339339
return false;
@@ -398,8 +398,11 @@ bool AbstractStorageDecl::exportsPropertyDescriptor() const {
398398
llvm_unreachable("should be definition linkage?");
399399
}
400400

401-
auto *env = getDeclContext()->getGenericEnvironmentOfContext();
402-
if (isUnsupportedKeyPathValueType(getValueInterfaceType(), env)) {
401+
auto valueType = getValueInterfaceType();
402+
if (auto *env = getDeclContext()->getGenericEnvironmentOfContext())
403+
valueType = env->mapTypeIntoContext(valueType);
404+
405+
if (isUnsupportedKeyPathValueType(valueType)) {
403406
return false;
404407
}
405408

0 commit comments

Comments
 (0)