Covariance улучшения:

IEnumerable<BaseCompiled> можно присвоить IEnumerable<DerivedCompiled> и любой класс, его реализующий
This commit is contained in:
Mikhalkovich Stanislav 2023-04-19 10:21:00 +03:00
parent d0397a4641
commit 65bdec22a0
6 changed files with 16 additions and 10 deletions

View file

@ -15,7 +15,7 @@ internal static class RevisionClass
public const string Major = "3";
public const string Minor = "8";
public const string Build = "3";
public const string Revision = "3259";
public const string Revision = "3262";
public const string MainVersion = Major + "." + Minor;
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;

View file

@ -1,4 +1,4 @@
%MINOR%=8
%REVISION%=3259
%COREVERSION%=3
%REVISION%=3262
%MINOR%=8
%MAJOR%=3

View file

@ -1 +1 @@
3.8.3.3259
3.8.3.3262

View file

@ -1 +1 @@
!define VERSION '3.8.3.3259'
!define VERSION '3.8.3.3262'

View file

@ -4259,7 +4259,7 @@ function BillboardText(p: Point3D; Text: string; Fontsize: real) := BillboardTex
function CoordinateSystem(ArrowsLength, Diameter: real): CoordinateSystemT := Inv(()->CoordinateSystemT.Create(0, 0, 0, arrowslength, diameter));
function CoordinateSystem(ArrowsLength: real) := CoordinateSystem(arrowslength, arrowslength / 10);
function CoordinateSystem(ArrowsLength: real) := CoordinateSystem(arrowslength, (arrowslength / 10).ClampTop(0.2));
function Text3D(x, y, z: real; Text: string; Height: real; fontname: string; c: Color): TextT := Inv(()->TextT.Create(x, y, z, text, height, fontname, c));

View file

@ -571,8 +571,8 @@ namespace PascalABCCompiler.TreeRealization
implements = false;
// Цикл по всем реализуемым интерфейсам. А если tnode сам является интерфейсом?
var ImplementingInterfaces = tnode.ImplementingInterfaces.ToList();
//if (tnode.IsInterface)
// ImplementingInterfaces.Add(tnode);
if (tnode.IsInterface)
ImplementingInterfaces.Add(tnode);
foreach (var interf in ImplementingInterfaces)
{
var ctn = interf as compiled_type_node;
@ -597,10 +597,11 @@ namespace PascalABCCompiler.TreeRealization
// Тут можно проверить на ковариантность
// еще где то надо проверять, что IEnumerable<Derived> -> IEnumerable<Base>, но здесь base_class предполагает,
// что это - класс, и рассматривает все его интерфейсы, упуская ситуацию, когда base_class - это и есть интерфейс
//else if ((cgitn != null || ctn != null) && (bcgitn != null || bcctn != null))
else if ((cgitn != null || ctn != null) && (bcgitn != null || bcctn != null)) // SSM 19/04
//else if (cgitn != null && (bcgitn != null || bcctn != null))
//else if ((cgitn != null || ctn != null) && bcgitn != null)
else if (cgitn != null && bcgitn != null)
//else if (cgitn != null && bcgitn != null)
//else if (cgitn != null && bcgitn != null || ctn != null && bcctn != null) // SSM 18/04 немного большие ограничения
{
compiled_type_node interf_original_generic = cgitn != null ? cgitn.original_generic as compiled_type_node : ctn.original_generic as compiled_type_node;
compiled_type_node base_original_generic = bcgitn != null ? bcgitn.original_generic as compiled_type_node : bcctn.original_generic as compiled_type_node;
@ -636,6 +637,11 @@ namespace PascalABCCompiler.TreeRealization
{
// OK
}
else // SSM 19/04/23 -вот эта ветка была решающей
{
impl = false;
break;
}
}
// Почему то когда это закомментировано, то работает. А так не вызывается ??!
/*else if (base_instance_params[i] == interf_instance_params[i])