[chuck-users] class abuse

Michael Heuer heuermh at gmail.com
Thu Oct 1 02:50:19 EDT 2009


Ge Wang wrote:

> Yes, it would seem something is definitely amiss here - will look into this
> bug more deeply!  Thanks for the heads-up!

Another head-scratcher that I've run into on more than one occasion:
the order of class definition within a .ck file shouldn't matter, or
if it does matter, the error messages need work.

If in the file ArraySet.ck (link below), the order is

public class ArraySet extends Set
{
  public Iterator iterator()
  {
    ArraySetIterator iterator;
    ...
    return iterator;
  }
}

class ArraySetIterator extends Iterator
{
  ...
}

I receive this odd error message:

[ArraySet.ck]:line(84): function 'iterator at 0@Set' was defined with
return type 'Iterator' -- but returning type 'ArraySetIterator'
[ArraySet.ck]: ...in function 'iterator'

The compiler appears to know about the type ArraySetIterator but
doesn't know its type hierarchy.  If the classes are defined in the
opposite order

class ArraySetIterator extends Iterator { ... }
public class ArraySet extends Set { ... }

everything is ok.

   michael

http://github.com/heuermh/lick/blob/6b06cf6955fa0f85c9e25c2e663f6a5af1fc0247/ArraySet.ck


More information about the chuck-users mailing list