On Saturday, 18 June 2016 at 08:41:30 UTC, Johan Engelen wrote:
Without going in too much detail, the problem is that I am not linking to opaque .o files.

The problem is the compiler has to assume you *might* be linking to opaque .o files, so it can't provide any introspection capabilities. There's no way to tell which "hidden type" that the getObject function is returning, since that's decided in the (possibly opaque) function body.

You could hack something with debugging, I suppose. (Probably not. DWARF/ptrace is ridiculously undocumented.) Perhaps you could make an alternate version of the function with the same source code, that returns auto instead of an Object type? As in...

Object evil() {
  class Vold {...}
  Vold v = new Vold(...);
  return v;
}


auto notevil() {
  static class Vold {...}
  Vold v = new Vold(...);
  return v;
}

...

auto hack = new typeof(notevil());

That can magically allow you to return type Vold, even though it's an error to say

Vold notevil() {
  static class Vold { ... }
  ...
}

Reply via email to