#2170 Mixin methods with default values

SlimerDude Sat 13 Jul 2013

Hiya,

I noticed this a while ago, but it's turning into a bigger issue than I expected...

If you have a mixin with a method with a default value:

mixin Wotever {
  abstract Void service(Uri uri := ``)
}

then any implementing class needs to specify the exact same code for the default value, else you get a compilation error:

class WoteverImpl : Wotever {
  override Void service(Uri uri := ``) { }
}

Now, afIoc generates code for, and compiles proxies for service mixins so they may subsequently be advised.

The problem is, I can't do this for any mixin that uses default values, for reflectively, I can't get a hold of what that default value source code is.

I may have missed something, but assuming not, err... any ideas? Suggestions?

Steve.

brian Sun 14 Jul 2013

Yeah that has been a bit of drag and originally meant to handle that. But its turned out to be a fairly high level of complexity and not too painful (for me at least). For reflection one technique is to just call that method without the arg and it will work. You can also sort of get the "value" from the doc properties (see how compilerDoc puts it into the documentation). But it can be any expression, so its necessarily just a literal.

SlimerDude Wed 17 Jul 2013

For reflection one technique is to just call that method without the arg and it will work.

If only I was just calling the method! I'm generating fantom source code on the fly that extends arbitrary mixins, hence the need for it to compile.

I guess I could try parsing .apidoc files in the pod, but it's not ideal as the apidocs are not guaranteed to exist (and doc parsing from pod files isn't going to be performant). But I guess it's a start...

I'm aware default values can be any expression, but as long as any Objs they use are fully qualified it shouldn't be a problem.

brian Thu 18 Jul 2013

When I get back into that code, I can take a look at maybe providing some better reflection access. But probably won't be anytime soon

Login or Signup to reply.