diff --git a/NETGenerator/NETGenegratorTools.cs b/NETGenerator/NETGenegratorTools.cs index ddf947e36..f4cae332a 100644 --- a/NETGenerator/NETGenegratorTools.cs +++ b/NETGenerator/NETGenegratorTools.cs @@ -47,6 +47,7 @@ namespace PascalABCCompiler.NETGenerator public static Type GCHandleType = typeof(GCHandle); public static Type MarshalType = typeof(Marshal); public static Type TypeType = typeof(Type); + public static Type ValueType = typeof(ValueType); public static Type IEnumerableType = typeof(System.Collections.IEnumerable); public static Type IEnumeratorType = typeof(System.Collections.IEnumerator); public static Type IEnumerableGenericType = typeof(System.Collections.Generic.IEnumerable<>); @@ -110,6 +111,7 @@ namespace PascalABCCompiler.NETGenerator sizes[UInt64Type] = sizeof(UInt64); sizes[SingleType] = sizeof(Single); sizes[DoubleType] = sizeof(Double); + //sizes[UIntPtr] = sizeof(UIntPtr); //types[TypeType] = TypeType; ArrayCopyMethod = typeof(Array).GetMethod("Copy", new Type[3] { typeof(Array), typeof(Array), typeof(int) }); diff --git a/NETGenerator/NETGenerator.cs b/NETGenerator/NETGenerator.cs index eef16fd34..12cec9214 100644 --- a/NETGenerator/NETGenerator.cs +++ b/NETGenerator/NETGenerator.cs @@ -1132,7 +1132,6 @@ namespace PascalABCCompiler.NETGenerator if (ctn != null) throw new PascalABCCompiler.Errors.CommonCompilerError(ex.Message, ctn.Location.document.file_name, ctn.Location.begin_line_num, ctn.Location.begin_column_num); } - } for (int i = 0; i < enums.Count; i++) @@ -1325,7 +1324,7 @@ namespace PascalABCCompiler.NETGenerator private void AddTypeWithoutConvert(ICommonTypeNode t) { if (helper.GetTypeReference(t) != null) return; - TypeBuilder tb = mb.DefineType(BuildTypeName(t.name), ConvertAttributes(t), null, new Type[0]); + TypeBuilder tb = mb.DefineType(BuildTypeName(t.name), ConvertAttributes(t), t.is_value_type?TypeFactory.ValueType:null, new Type[0]); helper.AddType(t, tb); //(ssyy) обрабатываем generics if (t.is_generic_type_definition) @@ -6660,6 +6659,7 @@ namespace PascalABCCompiler.NETGenerator if (value.is_final) { + attrs |= MethodAttributes.Virtual | MethodAttributes.Final; } diff --git a/TestSuite/generics28.pas b/TestSuite/generics28.pas new file mode 100644 index 000000000..84611a059 --- /dev/null +++ b/TestSuite/generics28.pas @@ -0,0 +1,13 @@ +type + SomeType = record(IComparable) + public + function CompareTo(other: SomeType): integer; + begin + Result := 2; + end; + end; + +begin + var obj := new SomeType(); + assert(obj.CompareTo(obj) = 2); +end. \ No newline at end of file