From 0a029bd7ffdf08ccc2c33c3735c7a16ffd79cae1 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Thu, 16 May 2024 12:21:53 -0400 Subject: [PATCH] [javac] fresh new batch of binding fixes - fix resolveWellKnownType - implement resolve constructor Signed-off-by: David Thompson --- .../jdt/core/dom/JavacBindingResolver.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 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 8a65fd63599..00bc809ca71 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 @@ -258,6 +258,22 @@ IMethodBinding resolveMethod(MethodDeclaration method) { return null; } + @Override + IMethodBinding resolveConstructor(SuperConstructorInvocation expression) { + resolve(); + JCTree javacElement = this.converter.domToJavac.get(expression); + if (javacElement instanceof JCMethodInvocation javacMethodInvocation) { + javacElement = javacMethodInvocation.getMethodSelect(); + } + if (javacElement instanceof JCIdent ident && ident.sym instanceof MethodSymbol methodSymbol) { + return canonicalize(new JavacMethodBinding(ident.type.asMethodType(), methodSymbol, this)); + } + if (javacElement instanceof JCFieldAccess fieldAccess && fieldAccess.sym instanceof MethodSymbol methodSymbol) { + return canonicalize(new JavacMethodBinding(fieldAccess.type.asMethodType(), methodSymbol, this)); + } + return null; + } + @Override IBinding resolveName(Name name) { resolve(); @@ -470,7 +486,7 @@ ITypeBinding resolveWellKnownType(String typeName) { com.sun.tools.javac.code.Symtab symtab = com.sun.tools.javac.code.Symtab.instance(this.context); com.sun.tools.javac.code.Type type = switch (typeName) { case "byte", "java.lang.Byte" -> symtab.byteType; - case "char", "java.lang.Char" -> symtab.charType; + case "char", "java.lang.Character" -> symtab.charType; case "double", "java.lang.Double" -> symtab.doubleType; case "float", "java.lang.Float" -> symtab.floatType; case "int", "java.lang.Integer" -> symtab.intType; @@ -487,7 +503,7 @@ ITypeBinding resolveWellKnownType(String typeName) { case "java.lang.Error" -> symtab.errorType; case "java.lang.Class" -> symtab.classType; case "java.lang.Cloneable" -> symtab.cloneableType; - case "java.lang.Serializable" -> symtab.serializableType; + case "java.io.Serializable" -> symtab.serializableType; default -> null; }; if (type == null) {