Skip to content

Commit

Permalink
add shared checking when converting class to manager record
Browse files Browse the repository at this point in the history
Signed-off-by: Ahmad Rezaii <[email protected]>
  • Loading branch information
arezaii committed Sep 27, 2024
1 parent e12946a commit 09f0da7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion frontend/lib/resolution/can-pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,11 +829,12 @@ tryConvertClassTypeIntoManagerRecordIfNeeded(Context* context,
auto mr = mightBeManagerRecord->toRecordType();
auto ct = mightBeClass->toClassType();
auto aot = mightBeClass->toAnyOwnedType();
auto ast = mightBeClass->toAnySharedType();

bool isCtManagedAndDecorated = classTypeIsManagedAndDecorated(context, ct);
// if mightBeManagerRecord is a record type and (mightBeClass is a class type
// that is managed and decorated or mightBeClass is an AnyOwnedType) we can continue
if (!mr || (!isCtManagedAndDecorated && !aot )) return false;
if (!mr || (!isCtManagedAndDecorated && !aot && !ast )) return false;

if (!parsing::idIsInBundledModule(context, mr->id())) return false;

Expand All @@ -847,6 +848,8 @@ tryConvertClassTypeIntoManagerRecordIfNeeded(Context* context,
// now it's `_owned` of type RecordType
if (aot) {
mightBeClass = CompositeType::getOwnedRecordType(context, /*bct*/ nullptr);
} else if (ast) {
mightBeClass = CompositeType::getSharedRecordType(context, /*bct*/ nullptr);
} else {
mightBeClass = ct->managerRecordType(context);
}
Expand Down

0 comments on commit 09f0da7

Please sign in to comment.