This commit is contained in:
Бондарев Иван 2020-09-27 18:07:00 +02:00
parent 48a68a32f7
commit c4576faff0
3 changed files with 23 additions and 0 deletions

View file

@ -0,0 +1,14 @@
type
t1 = class
i: object;
constructor(i: object);
begin
self.i := i;
end;
static function operator implicit<T>(val: T): t1 := new t1(val);
end;
begin
var a: t1 := 5;
assert(integer(a.i) = 5);
end.

View file

@ -14882,6 +14882,7 @@ namespace PascalABCCompiler.TreeConverter
if (expr is common_constructor_call_as_constant)
return expr as common_constructor_call_as_constant;
convertion_data_and_alghoritms.check_convert_type(expr,tn,expr.location);
return constant;
//AddError(new CanNotConvertTypes(expr,expr.type,tn,expr.location));
//throw new NotSupportedError(loc);
}

View file

@ -2327,6 +2327,10 @@ namespace PascalABCCompiler.TreeRealization
{
fn = fn.get_instance(ctn.instance_params, true, null);
}
else if (fn.get_generic_params_list() != null && fn.get_generic_params_list().Count > 0)
{
fn = fn.get_instance(new List<type_node>(new type_node[] { ctn }), true, null);
}
}
return fn;
}
@ -2358,6 +2362,10 @@ namespace PascalABCCompiler.TreeRealization
{
fn = fn.get_instance(ctn.instance_params, true, null);
}
else if (fn.get_generic_params_list() != null && fn.get_generic_params_list().Count > 0)
{
fn = fn.get_instance(new List<type_node>(new type_node[] { ctn }), true, null);
}
}
return fn;
}