blob: f5751377874ac64844b5c0d06df1a4c5ba650e1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
program toperator94;
{$mode objfpc}
{$modeswitch advancedrecords}
type
TString80 = String[80];
TString90 = String[90];
TString40 = String[40];
TString100 = String[100];
TTest1 = record
class operator :=(const aArg: TTest1): TString80;
end;
TTest2 = record
class operator :=(const aArg: TTest2): ShortString;
end;
var
ImplicitTest1ShortString: LongInt;
ImplicitTest1String80: LongInt;
ImplicitTest2ShortString: LongInt;
ImplicitTest2String80: LongInt;
class operator TTest1.:=(const aArg: TTest1): TString80;
begin
Writeln('TTest1 Implicit TString80');
Inc(ImplicitTest1String80);
Result := '';
end;
class operator TTest2.:=(const aArg: TTest2): ShortString;
begin
Writeln('TTest2 Implicit ShortString');
Inc(ImplicitTest2ShortString);
Result := '';
end;
operator :=(const aArg: TTest1): ShortString;
begin
Writeln('TTest1 Implicit ShortString');
Inc(ImplicitTest1ShortString);
Result := '';
end;
operator :=(const aArg: TTest2): TString80;
begin
Writeln('TTest2 Implicit TString80');
Inc(ImplicitTest2String80);
Result := '';
end;
var
t1: TTest1;
t2: TTest2;
s80: TString80;
begin
s80 := t1;
if ImplicitTest1ShortString <> 1 then
Halt(1);
s80 := t2;
if ImplicitTest2ShortString <> 1 then
Halt(2);
Writeln('ok');
end.
|