#2486 Constructor Return Type: Void

Jeremy Criquet Mon 19 Oct 2015

class Foo {
  new make() {}
  static new staticMake() { Foo() }


Foo#.method("make").returns            -> Void#
Foo#.method("make").func.returns       -> Void#
Foo#.method("staticMake").returns      -> Foo#
Foo#.method("staticMake").func.returns -> Foo#

It seems they should all return Foo#, not Void#

Context: I'm creating an List through method reflection, instantiating the type based off the return type of the method. This returning of Void# mucks it up.

SlimerDude Mon 19 Oct 2015

Could you inspect the type with Slot.isCtor() and return the Slot's parent if true?

brian Mon 19 Oct 2015

Instance constructors are unique - they look like static methods with a return value on the outside, but on the inside they are Void (you don't return anything). So its really a special case, and the semantics are defined now - wouldn't want to change that. But as SlimerDude mentioned you can add isCtor check.

Login or Signup to reply.