#1215 Compiler error when setter method invokes the same setter of another instance

qualidafial Sat 18 Sep 2010

In a setter method, setting the same field on a different instance results in a compiler error "Cannot use field accessor inside accessor itself - use & operator."

Example:

class A
{
  A? child := null

  |Event| handler
  {
    get { &handler }
    set
    {
      &handler = it;

      if (child != null)
      {
        child.handler = it // ERROR
      }
    }
  }
}

qualidafial Sat 18 Sep 2010

My current workaround is to use a private setter:

|Event| handler
{
  get { &handler }
  set
  {
    &handler = it;

    if (child != null)
    {
      child.setHandler(it) // works fine
    }
  }
}

private Void setHandler(|Event| val)
{
  handler = val
}

brian Sat 18 Sep 2010

Promoted to ticket #1215 and assigned to brian

brian Wed 22 Sep 2010

Ticket resolved in 1.0.56

changeset

Login or Signup to reply.