Skip to content

Commit f48d7a9

Browse files
committed
ClassGeneric.GetClass now returns BorrowedReference to indicate that the value should not be disposed
1 parent cf8823f commit f48d7a9

File tree

5 files changed

+6
-5
lines changed

5 files changed

+6
-5
lines changed

src/runtime/ClassManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ internal static void RestoreRuntimeData(ClassManagerState storage)
133133
/// Return the ClassBase-derived instance that implements a particular
134134
/// reflected managed type, creating it if it doesn't yet exist.
135135
/// </summary>
136-
internal static ReflectedClrType GetClass(Type type) => ReflectedClrType.GetOrCreate(type);
136+
internal static BorrowedReference GetClass(Type type) => ReflectedClrType.GetOrCreate(type);
137137

138138
internal static ClassBase GetClassImpl(Type type)
139139
{

src/runtime/Types/ClassObject.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public override NewReference type_subscript(BorrowedReference idx)
236236
return Exceptions.RaiseTypeError("type expected");
237237
}
238238
Type a = t.MakeArrayType();
239-
PyType o = ClassManager.GetClass(a);
239+
BorrowedReference o = ClassManager.GetClass(a);
240240
return new NewReference(o);
241241
}
242242

src/runtime/Types/ClrObject.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ internal static NewReference GetReference(object ob, BorrowedReference pyType)
4343

4444
internal static NewReference GetReference(object ob, Type type)
4545
{
46-
PyType cc = ClassManager.GetClass(type);
46+
BorrowedReference cc = ClassManager.GetClass(type);
4747
return Create(ob, cc);
4848
}
4949

5050
internal static NewReference GetReference(object ob)
5151
{
52-
PyType cc = ClassManager.GetClass(ob.GetType());
52+
BorrowedReference cc = ClassManager.GetClass(ob.GetType());
5353
return Create(ob, cc);
5454
}
5555

src/runtime/Types/MethodObject.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public static NewReference tp_descr_get(BorrowedReference ds, BorrowedReference
191191
&& obj.inst is IPythonDerivedType
192192
&& self.type.Value.IsInstanceOfType(obj.inst))
193193
{
194-
var basecls = ClassManager.GetClass(self.type.Value);
194+
var basecls = ReflectedClrType.GetOrCreate(self.type.Value);
195195
return new MethodBinding(self, new PyObject(ob), basecls).Alloc();
196196
}
197197

src/runtime/Types/ReflectedClrType.cs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ internal sealed class ReflectedClrType : PyType
1212
{
1313
private ReflectedClrType(StolenReference reference) : base(reference, prevalidated: true) { }
1414
internal ReflectedClrType(ReflectedClrType original) : base(original, prevalidated: true) { }
15+
internal ReflectedClrType(BorrowedReference original) : base(original) { }
1516
ReflectedClrType(SerializationInfo info, StreamingContext context) : base(info, context) { }
1617

1718
internal ClassBase Impl => (ClassBase)ManagedType.GetManagedObject(this)!;

0 commit comments

Comments
 (0)