Array Extension Methods
See original GitHub issueIs there a way to create an extension method for an array type? e.g.
@Extension
public class ArrayExt{
public static void sort(@This int[] array){
Arrays.sort(array);
}
//or, for objects...
public static <T> void sort(@This T[] array){
Arrays.sort(array);
}
}
The documentation reads,
the remainder of the package must be the qualified name of the extended class
…but arrays are not real classes, and thus don’t have a fully qualified name.
Extensions made for java.lang.Object
do function properly and show up in autocompletion for array types, but placing methods like sort()
in Object
would pollute autocompletion for non-array types and force me to use casting.
Related ““issue””: In my tests, I attempted creating an @Extension
class in an empty package, which caused a crash due to ExtensionTransformer#getExtendedClassName
calling toString()
on getPackageName()
, which was null.
This shouldn’t have compiled anyway, but a nicer error message than a NullPointerException
could be used (although I don’t see this being much of a problem).
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (8 by maintainers)
Top GitHub Comments
in progress
See https://github.com/manifold-systems/manifold/issues/207