Compiler always says "local classes must not extend sealed classes" even if class is anonymous
Zheka Kozlov
orionllmain at gmail.com
Mon Jun 8 12:32:01 UTC 2020
Hello!
Compiling this program
public class Main {
public static void main(String[] args) {
Shape shape = new Shape() {};
}
}
sealed interface Shape {
}
leads to an error:
error: local classes must not extend sealed classes
Shape shape = new Shape() {};
^
But the class of `shape` is an anonymous class rather than a local class.
By definition, a local class must have a name (JLS 14.3). I think the error
message should say " anonymous classes must not extend sealed classes".
Bith best regards, Zheka.
More information about the amber-dev
mailing list