#1345 Coerce in shortcut assignments

vkuzkokov Wed 1 Dec 2010

Here's the source:

class A
{
  @Operator A plus(A that)
  {
     return A()
  }
  static Void main()
  {
    x := B()
    x += A()
    x.doNothing
  }
}

class B : A
{
  Void doNothing()
  {
  }
}

If you try to run it. You'll get java.lang.VerifyError because x += A() doesn't add coerce. From fanp -c -f test.fan A.main:

12: CallVirtual         script::A.plus(script::A) -> script::A
15: StoreVar            0

If I change problematic line to x = x + A() it will become:

12: CallVirtual         script::A.plus(script::A) -> script::A
15: Coerce              script::A => script::B
20: StoreVar            0

and code will fail with sys::CastErr as expected.

brian Wed 1 Dec 2010

Promoted to ticket #1345 and assigned to brian

brian Mon 3 Jan 2011

Ticket resolved in 1.0.57

changeset

Login or Signup to reply.