aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinier Zwitserloot <r.zwitserloot@projectlombok.org>2023-01-12 01:50:17 +0100
committerGitHub <noreply@github.com>2023-01-12 01:50:17 +0100
commitfd64adb9f0320310a2f7cea909a9abd56624ed82 (patch)
treee0acfc541be3763c84a478c9c8191aa0e3ae34a5
parent3c9e4770b38de4ac3df51c696562b3ff212cba05 (diff)
parentea14879df8492613f563b9130667ae3d0c3719e1 (diff)
downloadlombok-fd64adb9f0320310a2f7cea909a9abd56624ed82.tar.gz
lombok-fd64adb9f0320310a2f7cea909a9abd56624ed82.tar.bz2
lombok-fd64adb9f0320310a2f7cea909a9abd56624ed82.zip
Merge pull request #3288 from Rawi01/val-default-method
Use real type for enclosing class
-rw-r--r--src/core/lombok/javac/JavacResolution.java11
-rw-r--r--test/transform/resource/after-delombok/ValSuperDefaultMethod.java12
-rw-r--r--test/transform/resource/after-ecj/ValSuperDefaultMethod.java14
-rw-r--r--test/transform/resource/before/ValSuperDefaultMethod.java16
4 files changed, 51 insertions, 2 deletions
diff --git a/src/core/lombok/javac/JavacResolution.java b/src/core/lombok/javac/JavacResolution.java
index f1109f4e..6ff6efe7 100644
--- a/src/core/lombok/javac/JavacResolution.java
+++ b/src/core/lombok/javac/JavacResolution.java
@@ -244,8 +244,15 @@ public class JavacResolution {
}
private void attrib(JCTree tree, Env<AttrContext> env) {
- if (env.enclClass.type == null) try {
- env.enclClass.type = Type.noType;
+ try {
+ if (env.enclClass.type == null) {
+ if (env.enclClass.sym != null) {
+ env.enclClass.type = env.enclClass.sym.type;
+ }
+ }
+ if (env.enclClass.type == null) {
+ env.enclClass.type = Type.noType;
+ }
} catch (Throwable ignore) {
// This addresses issue #1553 which involves JDK9; if it doesn't exist, we probably don't need to set it.
}
diff --git a/test/transform/resource/after-delombok/ValSuperDefaultMethod.java b/test/transform/resource/after-delombok/ValSuperDefaultMethod.java
new file mode 100644
index 00000000..5275a5e8
--- /dev/null
+++ b/test/transform/resource/after-delombok/ValSuperDefaultMethod.java
@@ -0,0 +1,12 @@
+// version :9
+class ValSuperDefaultMethod implements Default {
+ public void test() {
+ final java.lang.String a = "";
+ Default.super.method();
+ }
+}
+
+interface Default {
+ default void method() {
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/ValSuperDefaultMethod.java b/test/transform/resource/after-ecj/ValSuperDefaultMethod.java
new file mode 100644
index 00000000..cb0ec47c
--- /dev/null
+++ b/test/transform/resource/after-ecj/ValSuperDefaultMethod.java
@@ -0,0 +1,14 @@
+import lombok.val;
+class ValSuperDefaultMethod implements Default {
+ ValSuperDefaultMethod() {
+ super();
+ }
+ public void test() {
+ final @val java.lang.String a = "";
+ Default.super.method();
+ }
+}
+interface Default {
+ default void method() {
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/before/ValSuperDefaultMethod.java b/test/transform/resource/before/ValSuperDefaultMethod.java
new file mode 100644
index 00000000..93bcb153
--- /dev/null
+++ b/test/transform/resource/before/ValSuperDefaultMethod.java
@@ -0,0 +1,16 @@
+// version :9
+import lombok.val;
+
+class ValSuperDefaultMethod implements Default {
+ public void test() {
+ val a = "";
+ Default.super.method();
+ }
+
+}
+
+interface Default {
+ default void method() {
+
+ }
+} \ No newline at end of file