From 2dab23a7f5d77a1fc6cc933ce98e642fc3fab2a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=BD=D0=B4=D0=B0=D1=80=D0=B5=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD?= Date: Sun, 18 Mar 2018 18:50:52 +0100 Subject: [PATCH] bug fix #718 --- NETGenerator/NETGenerator.cs | 6 ++- TestSuite/CompilationSamples/graph3d.pas | 50 ++++++++++++++++++------ TestSuite/generics15.pas | 26 ++++++++++++ 3 files changed, 69 insertions(+), 13 deletions(-) create mode 100644 TestSuite/generics15.pas diff --git a/NETGenerator/NETGenerator.cs b/NETGenerator/NETGenerator.cs index fcdd7ae42..dc63e58a9 100644 --- a/NETGenerator/NETGenerator.cs +++ b/NETGenerator/NETGenerator.cs @@ -7846,8 +7846,10 @@ namespace PascalABCCompiler.NETGenerator il.Emit(OpCodes.Call, ti.assign_meth); return; } - - EmitBox(from, fi.FieldType); + if (ti != null) + EmitBox(from, ti.tp); + else + EmitBox(from, fi.FieldType); CheckArrayAssign(to, from, il); il.Emit(OpCodes.Stsfld, fi); } diff --git a/TestSuite/CompilationSamples/graph3d.pas b/TestSuite/CompilationSamples/graph3d.pas index 9781474a5..3eb167df6 100644 --- a/TestSuite/CompilationSamples/graph3d.pas +++ b/TestSuite/CompilationSamples/graph3d.pas @@ -767,15 +767,6 @@ type d(); end; - procedure BeginT; - begin - sb := CreateStoryboard; - InitAnim(sb); - ApplyAllDecorators; - sb.Completed += procedure (o, e) -> sb.Children.Clear; - sb.Begin; - end; - procedure InitAnimWait(sb: StoryBoard; waittime: real); virtual; begin end; @@ -870,9 +861,34 @@ type Result := Self; end; + private + procedure BeginT; + begin + sb := CreateStoryboard; + InitAnim(sb); + ApplyAllDecorators; + sb.Completed += procedure (o, e) -> sb.Children.Clear; + sb.Begin; + end; + procedure RemoveT := begin + sb.Pause; + sb := new Storyboard; + end; + procedure ChangeT(a: MyAnimation); + begin + sb := CreateStoryboard; + Print(a.sb); + foreach var d in a.sb.Children do + sb.Children.Add(d); + Print(2); + end; + public procedure &Begin; virtual := Invoke(BeginT); - procedure Pause := sb.Pause; - procedure Resume := sb.Resume; + procedure Remove := Invoke(RemoveT); + procedure Change(a: MyAnimation) := Invoke(ChangeT,a); + procedure Pause := if sb<>nil then sb.Pause; + procedure Resume := if sb<>nil then sb.Resume; + function Duration: real; virtual := seconds; function &Then(second: MyAnimation): MyAnimation; function Forever: MyAnimation; virtual := Self; @@ -880,6 +896,16 @@ type function AccelerationRatio(acceleration: real; deceleration: real := 0): MyAnimation; virtual := Self; end; + EmptyAnimation = class(MyAnimation) + public + constructor(wait: real); + begin + Self.Seconds := wait; + end; + procedure InitAnim(sb: StoryBoard); virtual := InitAnimWait(sb, Seconds); + end; + + Double1AnimationBase = class(MyAnimation) private v: real; @@ -1279,6 +1305,8 @@ function operator*(a, b: MyAnimation): MyAnimation; extensionmethod := Animate.G function MyAnimation.&Then(second: MyAnimation): MyAnimation := Self + second; +function EmptyAnim(sec: real) := EmptyAnimation.Create(sec); + //------------------------------ End Animation ------------------------------- diff --git a/TestSuite/generics15.pas b/TestSuite/generics15.pas new file mode 100644 index 000000000..88c97be8a --- /dev/null +++ b/TestSuite/generics15.pas @@ -0,0 +1,26 @@ +type + t1=class + class l: byte; + a: byte; + class procedure test; + begin + t1&.l := 3; + assert(t1&.l = 3); + end; + class procedure test(var a: byte); + begin + assert(a = 3); + end; + end; + +begin + t1&.l := 2; + t1&.l := 3; + assert(t1&.l = 2); + assert(t1&.l = 3); + var o := new t1; + o.a := 2; + assert(o.a = 2); + t1&.test; + t1&.test(t1&.l); +end. \ No newline at end of file