Add support for declaring static field in mapped type

We know currently mapped type disallow declaring static (and non-static) fields. So I have to write code as below to bypass it:

public __mapped class TestClass => object {
    public static object staticProperty => TestClassImpl.staticField;
}

public static class TestClassImpl{
    public static object staticField = new object();
}

But for static fields, it seems very easy to add support technically. Do you think it’s appropriate?

Thanks, logged as bugs://75644

Why is this mapped and not just a class? Ie could be a plain class with inline members?

My actual case is I have made a mapped class to MotionEvent in Android. There’s an advanced point method to get the location relative to view’s parent:

public __mapped class TouchArg => MotionEvent {

    public double[] point(int index = 0) {
        new double[] {__mapped.getX(index), __mapped.getY(index)};
    }

    public double[] point(Layout relativeToParent, int index = 0) {
        var p = point(index);
        LayoutHelper.mapPointAscend(p, TouchArgImpl.currentView, relativeToParent);
        return p;
    }
}

internal static class TouchArgImpl {
    public static Layout currentView;
}

My framework will ensure the currentView is always valid during outer code accessing that TouchArg. So the outer code has no need to pass this known parameter mannually. This also benefits other API designs.

oke. that makes more sense.

bugs://75644 got closed with status fixed.

Logged as bugs://i63608.

bugs://i63608 was closed as fixed.