Error highlighting for records: record constructors (except compact) (8.10.4) IDEA-228460

Also ChangeModifierIntention: do not suggest to change canonical constructor access modifier
Also AddExceptionToThrowsFix: do not suggest to add throws to canonical constructor

GitOrigin-RevId: 43c21af324c35a6b65633ab8cc3882bb972f993f
This commit is contained in:
Tagir Valeev
2019-12-18 10:32:28 +00:00
committed by intellij-monorepo-bot
parent cc130f3daa
commit 811b8fca50
8 changed files with 128 additions and 21 deletions
@@ -0,0 +1,29 @@
record NotPublic(int x, int y) {
<error descr="Canonical constructor must be 'public'">NotPublic</error>(int x, int y) {this.x = x; this.y = y;}
NotPublic() {this(0,0);}
}
record Generic(String x) {
public <error descr="Canonical constructor cannot have type parameters"><T></error> Generic(String x) {this.x = x;}
public <T> Generic() {this("");}
}
record Throws() {
public Throws() <error descr="Canonical constructor cannot declare thrown exceptions">throws Throwable</error> {}
public Throws(int x) throws Throwable { this(); }
}
record TypeMismatch<T>(T t) {
public TypeMismatch(<error descr="Incorrect parameter type for record component 't'. Expected: 'T', found: 'Object'">Object</error> t) {
this.t = null;
}
}
record Delegate(int x) {
public Delegate(int x) {
<error descr="Canonical constructor cannot delegate to another constructor">this()</error>;
}
public <error descr="Non-canonical record constructor must delegate to another constructor">Delegate</error>() {
}
public <error descr="Non-canonical record constructor must delegate to another constructor">Delegate</error>(int x, int y) {
super();
}
}