#676 Compiler bug? walkback in closure type inference

KevinKelley Wed 22 Jul 2009

This testcase:

class test
{
  Void test(Obj? obj) {
    if (obj is List) {
      List list := obj
      list.each |item| {}
    } 
  }
}

generates this stack trace:

sys::UnknownTypeErr: sys::V
  at fan.sys.UnknownTypeErr.<init>(UnknownTypeErr.java:39)
  at fan.sys.UnknownTypeErr.make(UnknownTypeErr.java:25)
  at fan.sys.UnknownTypeErr.make(UnknownTypeErr.java:22)
  at fan.sys.Pod.findType(Pod.java:385)
  at fan.sys.ClassType.map(ClassType.java:457)
  at fan.sys.ClassType.doReflect(ClassType.java:336)
  at fan.sys.ClassType.reflect(ClassType.java:293)
  at fan.sys.ClassType.slot(ClassType.java:104)
  at fan.sys.Type.method(Type.java:226)
  at fanx.tools.Fan.executeFile(Fan.java:79)
  at fanx.tools.Fan.execute(Fan.java:35)
  at fanx.tools.Fan.run(Fan.java:230)
  at fanx.tools.Fan.main(Fan.java:268)

If I change it to:

list.each |Obj? item| {}

it's okay. Also changing List list to Obj?[] list gets rid of the error.

I'm thinking either reflection ought to assume Obj?, or that be a compile error.

tompalmer Wed 22 Jul 2009

I think I like Obj? better than making it an error.

brian Wed 22 Jul 2009

Promoted to ticket #676 and assigned to brian

brian Tue 8 Sep 2009

Ticket resolved in 1.0.46

Fix closure type inference against generic parameters like V to infer as Obj?

changeset

Login or Signup to reply.