Skip to content

Commit

Permalink
Expand test case for issue solven-eu#846
Browse files Browse the repository at this point in the history
  • Loading branch information
mches committed Oct 10, 2024
1 parent f064f10 commit 15ba420
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,19 @@ public class MyInnerClass {
// public and static are redundant
public static enum MyEnum {
}

// final is redundant
private static final void privateStaticFinalMethod() {
}

// final is not redundant
// https://stackoverflow.com/questions/1743715/behaviour-of-final-static-method/1743748#1743748
static final void staticFinalMethod() {
}

// final is redundant
private final void privateFinalMethod() {
}
}

public static class Post {
Expand Down Expand Up @@ -269,6 +282,19 @@ public class MyInnerClass {
// public and static are redundant
public enum MyEnum {
}

// final is redundant
private static void privateStaticFinalMethod() {
}

// final is not redundant
// https://stackoverflow.com/questions/1743715/behaviour-of-final-static-method/1743748#1743748
static final void staticFinalMethod() {
}

// final is redundant
private void privateFinalMethod() {
}
}
}

Expand Down Expand Up @@ -424,17 +450,51 @@ public static class Issue844_record {

@CompareCompilationUnitsAsStrings(
pre = "public class NestingRecord {\n"
+ " public static final record Person (String name, String address) {}\n"
+ " }",
post = "public class NestingRecord {\n" + " public record Person (String name, String address) {}\n"
+ " }")
public static class Issue846_record_nested {
+ "\tpublic static final record Person (String name, String address) {}\n"
+ "}",
post = "public class NestingRecord {\n" + "\tpublic record Person (String name, String address) {}\n" + "}")
public static class Issue846_record_nested_within_class {
}

@CompareCompilationUnitsAsStrings(
pre = "public interface NestingRecord {\n" + ";\n"
+ "\n"
+ "\tpublic static final record Person (String name, String address) {}\n"
+ "}",
post = "public interface NestingRecord {\n" + ";\n"
+ "\n"
+ "\trecord Person (String name, String address) {}\n"
+ "}")
public static class Issue846_record_nested_within_interface {
}

@CompareCompilationUnitsAsStrings(
pre = "public @interface NestingRecord {\n" + ";\n"
+ "\n"
+ "\tpublic static final record Person (String name, String address) {}\n"
+ "}",
post = "public @interface NestingRecord {\n" + ";\n"
+ "\n"
+ "\trecord Person (String name, String address) {}\n"
+ "}")
public static class Issue846_record_nested_within_annotation {
}

@CompareCompilationUnitsAsStrings(
pre = "public enum NestingRecord {\n" + ";\n"
+ "\n"
+ "\tpublic static final record Person (String name, String address) {}\n"
+ "}",
post = "public enum NestingRecord {\n" + ";\n"
+ "\n"
+ "\tpublic record Person (String name, String address) {}\n"
+ "}")
public static class Issue846_record_nested_within_enum {
}

@CompareCompilationUnitsAsResources(
pre = "/source/do_not_format_me/UnnecessaryModifier/" + "NestingRecord_Issue846_Pre.java",
post = "/source/do_not_format_me/UnnecessaryModifier/" + "NestingRecord_Issue846_Post.java")
pre = "/source/do_not_format_me/UnnecessaryModifier/NestingRecord_Issue846_Pre.java",
post = "/source/do_not_format_me/UnnecessaryModifier/NestingRecord_Issue846_Post.java")
public static class Issue846_record_nesting {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ public abstract class SomeAbstractInnerClass {

public @interface SomeAnnotation {
}
}

public enum SomeEnum {
}

public record SomeRecord(int i) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ public abstract class SomeAbstractInnerClass {

public static abstract @interface SomeAnnotation {
}
}

public static enum SomeEnum {
}

public static final record SomeRecord(int i) {
}
}

0 comments on commit 15ba420

Please sign in to comment.