This commit is contained in:
parent
7e0a13c6d0
commit
73de1ce639
27
TestSuite/implicitexplicit27.pas
Normal file
27
TestSuite/implicitexplicit27.pas
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
var i: integer;
|
||||
type
|
||||
t1<T> = class
|
||||
|
||||
static function operator implicit(o: T): t1<T>;
|
||||
begin
|
||||
i := 1;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
procedure p1<T>;
|
||||
begin
|
||||
var a: t1<T> := new t1<T>();
|
||||
//Ошибка: Возможны два преобразования типа: к типу t1<T> и к типу t1<T>
|
||||
var b := if false then a else nil;
|
||||
assert(i = 0);
|
||||
b := nil;
|
||||
assert(i = 0);
|
||||
var v: T;
|
||||
b := v;
|
||||
assert(i = 1);
|
||||
end;
|
||||
|
||||
begin
|
||||
p1&<integer>;
|
||||
end.
|
||||
|
|
@ -663,7 +663,13 @@ namespace PascalABCCompiler.TreeConverter
|
|||
syntax_tree_visitor.try_convert_typed_expression_to_function_call(ref en);
|
||||
return en;
|
||||
}
|
||||
AddError(new TwoTypeConversionsPossible(en,pct.first,pct.second));
|
||||
if (en is null_const_node && pct.first.convertion_method is basic_function_node)
|
||||
{
|
||||
en.type = to;
|
||||
return en;
|
||||
}
|
||||
else
|
||||
AddError(new TwoTypeConversionsPossible(en,pct.first,pct.second));
|
||||
}
|
||||
|
||||
if (pct.first==null)
|
||||
|
|
|
|||
Loading…
Reference in a new issue