xp-framework/xp-language — Issue #5: Extension methods resolution broken
Author: thekid
Created: 2012-02-11 12:24:16+00:00
State: open
Labels: bug

When an extension method is not defined within the same file, the resolution is deferred until runtime.

Test.xp

```groovy
import lang.types.StringExtensions;

public class Test{

public static void main(string[] $args) {
Console::writeLine($args[0].substring(2));
}
}`
```

lang/types/StringExtensions.xp

```groovy
package lang.types;

import native standard.substr;

public class StringExtensions {
public static string substring(this string? $self, int? $start, int? $end= null) {
return null === $end ? substr($self, $start) : substr($self, $start, $end);
}
}
```

The resulting sourcecode contains `$args[0]->substring(2)` because the extension method is not resolved, resulting in a fatal error.