From 87832d68347c9dded2bf1581417c894de588231c Mon Sep 17 00:00:00 2001 From: Mickael Istria Date: Thu, 5 Dec 2024 09:52:59 +0100 Subject: [PATCH] Prevent NPE in JavacBindingResolver --- .../eclipse/jdt/core/dom/JavacBindingResolver.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacBindingResolver.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacBindingResolver.java index a0f730ab9df..dcd4b02b641 100644 --- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacBindingResolver.java +++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacBindingResolver.java @@ -47,8 +47,11 @@ import com.sun.tools.javac.api.JavacTaskImpl; import com.sun.tools.javac.api.JavacTrees; import com.sun.tools.javac.code.Attribute; -import com.sun.tools.javac.code.Attribute.Compound; import com.sun.tools.javac.code.Symbol; +import com.sun.tools.javac.code.Symtab; +import com.sun.tools.javac.code.TypeTag; +import com.sun.tools.javac.code.Types; +import com.sun.tools.javac.code.Attribute.Compound; import com.sun.tools.javac.code.Symbol.ClassSymbol; import com.sun.tools.javac.code.Symbol.MethodSymbol; import com.sun.tools.javac.code.Symbol.ModuleSymbol; @@ -57,7 +60,6 @@ import com.sun.tools.javac.code.Symbol.TypeSymbol; import com.sun.tools.javac.code.Symbol.TypeVariableSymbol; import com.sun.tools.javac.code.Symbol.VarSymbol; -import com.sun.tools.javac.code.Symtab; import com.sun.tools.javac.code.Type.ArrayType; import com.sun.tools.javac.code.Type.ClassType; import com.sun.tools.javac.code.Type.ErrorType; @@ -69,9 +71,8 @@ import com.sun.tools.javac.code.Type.ModuleType; import com.sun.tools.javac.code.Type.PackageType; import com.sun.tools.javac.code.Type.TypeVar; -import com.sun.tools.javac.code.TypeTag; -import com.sun.tools.javac.code.Types; import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.TreeInfo; import com.sun.tools.javac.tree.JCTree.JCAnnotatedType; import com.sun.tools.javac.tree.JCTree.JCAnnotation; import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree; @@ -95,7 +96,6 @@ import com.sun.tools.javac.tree.JCTree.JCTypeParameter; import com.sun.tools.javac.tree.JCTree.JCVariableDecl; import com.sun.tools.javac.tree.JCTree.JCWildcard; -import com.sun.tools.javac.tree.TreeInfo; import com.sun.tools.javac.util.Context; /** @@ -1272,7 +1272,7 @@ && isTypeOfType(expression.type) if (expr instanceof SuperFieldAccess) { return this.bindings.getTypeBinding(jcFieldAccess.selected.type); } - return this.bindings.getTypeBinding(jcFieldAccess.type.isErroneous() ? jcFieldAccess.sym.type : jcFieldAccess.type); + return this.bindings.getTypeBinding(jcFieldAccess.type == null || jcFieldAccess.type.isErroneous() ? jcFieldAccess.sym.type : jcFieldAccess.type); } if (jcTree instanceof JCVariableDecl jcVariableDecl) { if (jcVariableDecl.type != null) {