diff --git a/java-symbol-solver-core/src/main/java/com/github/javaparser/symbolsolver/javassistmodel/JavassistUtils.java b/java-symbol-solver-core/src/main/java/com/github/javaparser/symbolsolver/javassistmodel/JavassistUtils.java index dbead2e763..2b9b77f821 100644 --- a/java-symbol-solver-core/src/main/java/com/github/javaparser/symbolsolver/javassistmodel/JavassistUtils.java +++ b/java-symbol-solver-core/src/main/java/com/github/javaparser/symbolsolver/javassistmodel/JavassistUtils.java @@ -150,8 +150,11 @@ static Type signatureTypeToType(SignatureAttribute.Type signatureType, TypeSolve } TypeParameterDeclaration typeParameterDeclaration = typeParameterDeclarationOpt.get(); return new TypeVariable(typeParameterDeclaration); + } else if (signatureType instanceof SignatureAttribute.ArrayType) { + SignatureAttribute.ArrayType arrayType = (SignatureAttribute.ArrayType) signatureType; + return new ArrayType(signatureTypeToType(arrayType.getComponentType(), typeSolver, typeParametrizable)); } else if (signatureType instanceof SignatureAttribute.BaseType) { - SignatureAttribute.BaseType baseType = (SignatureAttribute.BaseType)signatureType; + SignatureAttribute.BaseType baseType = (SignatureAttribute.BaseType) signatureType; if (baseType.toString().equals("void")) { return VoidType.INSTANCE; } else { diff --git a/java-symbol-solver-core/src/main/java/com/github/javaparser/symbolsolver/resolution/MethodResolutionLogic.java b/java-symbol-solver-core/src/main/java/com/github/javaparser/symbolsolver/resolution/MethodResolutionLogic.java index b2fbb1e1ce..31896960b9 100644 --- a/java-symbol-solver-core/src/main/java/com/github/javaparser/symbolsolver/resolution/MethodResolutionLogic.java +++ b/java-symbol-solver-core/src/main/java/com/github/javaparser/symbolsolver/resolution/MethodResolutionLogic.java @@ -208,7 +208,21 @@ private static boolean isAssignableMatchTypeParametersMatchingQName(ReferenceTyp } } } else if (expectedParam.isReferenceType()) { - if (!expectedParam.equals(actualParam)) { + if (actualParam.isTypeVariable()) { + String actualParamName = actualParam.asTypeParameter().getName(); + if (matchedParameters.containsKey(actualParamName)) { + Type matchedParameter = matchedParameters.get(actualParamName); + if (matchedParameter.isAssignableBy(expectedParam)) { + return true; + } else if (expectedParam.isAssignableBy(matchedParameter)) { + matchedParameters.put(actualParamName, expectedParam); + return true; + } + return false; + } else { + matchedParameters.put(actualParamName, expectedParam); + } + } else if (!expectedParam.equals(actualParam)) { return false; } } else if (expectedParam.isWildcard()) { diff --git a/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-core/com_github_javaparser_symbolsolver_javaparsermodel_TypeExtractor.txt b/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-core/com_github_javaparser_symbolsolver_javaparsermodel_TypeExtractor.txt index 6b4b92246e..9291a06b53 100644 --- a/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-core/com_github_javaparser_symbolsolver_javaparsermodel_TypeExtractor.txt +++ b/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-core/com_github_javaparser_symbolsolver_javaparsermodel_TypeExtractor.txt @@ -40,7 +40,7 @@ Line 146) node.getType() ==> com.github.javaparser.ast.expr.ClassExpr.getType() Line 147) facade.convertToUsage(astType, node.getType()) ==> com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade.convertToUsage(com.github.javaparser.ast.type.Type, com.github.javaparser.ast.Node) Line 147) node.getType() ==> com.github.javaparser.ast.expr.ClassExpr.getType() - Line 148) ImmutableList.of(jssType) ==> ERROR + Line 148) ImmutableList.of(jssType) ==> com.google.common.collect.ImmutableList.of(E) Line 153) node.getThenExpr().accept(this, solveLambdas) ==> com.github.javaparser.ast.visitor.Visitable.accept(com.github.javaparser.ast.visitor.GenericVisitor, A) Line 153) node.getThenExpr() ==> com.github.javaparser.ast.expr.ConditionalExpr.getThenExpr() Line 158) node.getInner().accept(this, solveLambdas) ==> com.github.javaparser.ast.visitor.Visitable.accept(com.github.javaparser.ast.visitor.GenericVisitor, A) diff --git a/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-core/com_github_javaparser_symbolsolver_javaparsermodel_declarations_JavaParserAnonymousClassDeclaration.txt b/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-core/com_github_javaparser_symbolsolver_javaparsermodel_declarations_JavaParserAnonymousClassDeclaration.txt index 3a57a6699c..a195f82d93 100644 --- a/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-core/com_github_javaparser_symbolsolver_javaparsermodel_declarations_JavaParserAnonymousClassDeclaration.txt +++ b/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-core/com_github_javaparser_symbolsolver_javaparsermodel_declarations_JavaParserAnonymousClassDeclaration.txt @@ -34,7 +34,7 @@ Line 89) Collectors.toList() ==> java.util.stream.Collectors.toList() Line 100) ImmutableList.builder().add(getSuperClass()).addAll(superTypeDeclaration.asReferenceType().getAncestors()).build() ==> com.google.common.collect.ImmutableList.Builder.build() Line 100) ImmutableList.builder().add(getSuperClass()).addAll(superTypeDeclaration.asReferenceType().getAncestors()) ==> com.google.common.collect.ImmutableList.Builder.addAll(java.lang.Iterable) - Line 100) ImmutableList.builder().add(getSuperClass()) ==> ERROR + Line 100) ImmutableList.builder().add(getSuperClass()) ==> com.google.common.collect.ImmutableList.Builder.add(E...) Line 100) ImmutableList.builder() ==> com.google.common.collect.ImmutableList.builder() Line 102) getSuperClass() ==> com.github.javaparser.symbolsolver.javaparsermodel.declarations.JavaParserAnonymousClassDeclaration.getSuperClass() Line 103) superTypeDeclaration.asReferenceType().getAncestors() ==> com.github.javaparser.symbolsolver.model.declarations.ReferenceTypeDeclaration.getAncestors() @@ -82,6 +82,6 @@ Line 185) JavaParserFacade.get(typeSolver).getTypeDeclaration(typeMember) ==> com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade.getTypeDeclaration(com.github.javaparser.ast.body.TypeDeclaration) Line 185) JavaParserFacade.get(typeSolver) ==> com.github.javaparser.symbolsolver.javaparsermodel.JavaParserFacade.get(com.github.javaparser.symbolsolver.model.resolution.TypeSolver) Line 186) Collectors.toSet() ==> java.util.stream.Collectors.toSet() - Line 196) Lists.newArrayList() ==> ERROR + Line 196) Lists.newArrayList() ==> com.google.common.collect.Lists.newArrayList() Line 201) this.getClass().getCanonicalName() ==> java.lang.Class.getCanonicalName() Line 201) this.getClass() ==> java.lang.Object.getClass() diff --git a/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-core/com_github_javaparser_symbolsolver_javaparsermodel_declarations_JavaParserClassDeclaration.txt b/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-core/com_github_javaparser_symbolsolver_javaparsermodel_declarations_JavaParserClassDeclaration.txt index f10788c031..af627c4e2a 100644 --- a/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-core/com_github_javaparser_symbolsolver_javaparsermodel_declarations_JavaParserClassDeclaration.txt +++ b/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-core/com_github_javaparser_symbolsolver_javaparsermodel_declarations_JavaParserClassDeclaration.txt @@ -38,7 +38,7 @@ Line 173) wrappedNode.getMembers() ==> com.github.javaparser.ast.body.TypeDeclaration.getMembers() Line 176) declared.add(new JavaParserConstructorDeclaration(this, constructorDeclaration, typeSolver)) ==> java.util.List.add(E) Line 179) declared.isEmpty() ==> java.util.List.isEmpty() - Line 181) ImmutableList.of(new DefaultConstructorDeclaration(this)) ==> ERROR + Line 181) ImmutableList.of(new DefaultConstructorDeclaration(this)) ==> com.google.common.collect.ImmutableList.of(E) Line 189) wrappedNode.getAnnotations() ==> com.github.javaparser.ast.body.BodyDeclaration.getAnnotations() Line 190) solveType(annotationExpr.getName().getId(), typeSolver).getCorrespondingDeclaration().getQualifiedName().equals(canonicalName) ==> java.lang.String.equals(java.lang.Object) Line 190) solveType(annotationExpr.getName().getId(), typeSolver).getCorrespondingDeclaration().getQualifiedName() ==> com.github.javaparser.symbolsolver.model.declarations.TypeDeclaration.getQualifiedName() diff --git a/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-logic/com_github_javaparser_symbolsolver_logic_InferenceVariableType.txt b/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-logic/com_github_javaparser_symbolsolver_logic_InferenceVariableType.txt index b0b95a3326..1cfbf6ad1b 100644 --- a/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-logic/com_github_javaparser_symbolsolver_logic_InferenceVariableType.txt +++ b/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-logic/com_github_javaparser_symbolsolver_logic_InferenceVariableType.txt @@ -23,7 +23,7 @@ Line 107) considered.contains(ivt) ==> java.util.Set.contains(java.lang.Object) Line 108) result.addAll(concreteEquivalentTypesAlsoIndirectly(considered, ivt)) ==> java.util.Set.addAll(java.util.Collection) Line 108) concreteEquivalentTypesAlsoIndirectly(considered, ivt) ==> com.github.javaparser.symbolsolver.logic.InferenceVariableType.concreteEquivalentTypesAlsoIndirectly(java.util.Set, com.github.javaparser.symbolsolver.logic.InferenceVariableType) - Line 115) concreteEquivalentTypesAlsoIndirectly(new HashSet<>(), this) ==> UNSOLVED + Line 115) concreteEquivalentTypesAlsoIndirectly(new HashSet<>(), this) ==> com.github.javaparser.symbolsolver.logic.InferenceVariableType.concreteEquivalentTypesAlsoIndirectly(java.util.Set, com.github.javaparser.symbolsolver.logic.InferenceVariableType) Line 116) concreteEquivalent.isEmpty() ==> java.util.Set.isEmpty() Line 118) objectProvider.object() ==> com.github.javaparser.symbolsolver.logic.ObjectProvider.object() Line 123) concreteEquivalent.size() ==> java.util.Set.size() diff --git a/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-model/com_github_javaparser_symbolsolver_model_typesystem_PrimitiveType.txt b/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-model/com_github_javaparser_symbolsolver_model_typesystem_PrimitiveType.txt index beb47e7538..723b5f5d0a 100644 --- a/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-model/com_github_javaparser_symbolsolver_model_typesystem_PrimitiveType.txt +++ b/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-model/com_github_javaparser_symbolsolver_model_typesystem_PrimitiveType.txt @@ -1,20 +1,20 @@ Line 32) Byte.class.getCanonicalName() ==> java.lang.Class.getCanonicalName() - Line 32) ImmutableList.of() ==> ERROR + Line 32) ImmutableList.of() ==> com.google.common.collect.ImmutableList.of() Line 33) Short.class.getCanonicalName() ==> java.lang.Class.getCanonicalName() - Line 33) ImmutableList.of(BYTE) ==> ERROR + Line 33) ImmutableList.of(BYTE) ==> com.google.common.collect.ImmutableList.of(E) Line 34) Character.class.getCanonicalName() ==> java.lang.Class.getCanonicalName() - Line 34) ImmutableList.of() ==> ERROR + Line 34) ImmutableList.of() ==> com.google.common.collect.ImmutableList.of() Line 35) Integer.class.getCanonicalName() ==> java.lang.Class.getCanonicalName() - Line 35) ImmutableList.of(BYTE, SHORT, CHAR) ==> ERROR + Line 35) ImmutableList.of(BYTE, SHORT, CHAR) ==> com.google.common.collect.ImmutableList.of(E, E, E) Line 36) Long.class.getCanonicalName() ==> java.lang.Class.getCanonicalName() - Line 36) ImmutableList.of(BYTE, SHORT, INT, CHAR) ==> ERROR + Line 36) ImmutableList.of(BYTE, SHORT, INT, CHAR) ==> com.google.common.collect.ImmutableList.of(E, E, E, E) Line 37) Boolean.class.getCanonicalName() ==> java.lang.Class.getCanonicalName() - Line 37) ImmutableList.of() ==> ERROR + Line 37) ImmutableList.of() ==> com.google.common.collect.ImmutableList.of() Line 38) Float.class.getCanonicalName() ==> java.lang.Class.getCanonicalName() - Line 38) ImmutableList.of(LONG, INT, SHORT, BYTE, CHAR) ==> ERROR + Line 38) ImmutableList.of(LONG, INT, SHORT, BYTE, CHAR) ==> com.google.common.collect.ImmutableList.of(E, E, E, E, E) Line 39) Double.class.getCanonicalName() ==> java.lang.Class.getCanonicalName() - Line 39) ImmutableList.of(FLOAT, LONG, INT, SHORT, BYTE, CHAR) ==> ERROR - Line 40) ImmutableList.of(INT, BOOLEAN, LONG, CHAR, FLOAT, DOUBLE, SHORT, BYTE) ==> ERROR + Line 39) ImmutableList.of(FLOAT, LONG, INT, SHORT, BYTE, CHAR) ==> com.google.common.collect.ImmutableList.of(E, E, E, E, E, E) + Line 40) ImmutableList.of(INT, BOOLEAN, LONG, CHAR, FLOAT, DOUBLE, SHORT, BYTE) ==> com.google.common.collect.ImmutableList.of(E, E, E, E, E, E, E, E) Line 57) name.toLowerCase() ==> java.lang.String.toLowerCase() Line 59) ptu.describe().equals(name) ==> java.lang.String.equals(java.lang.Object) Line 59) ptu.describe() ==> com.github.javaparser.symbolsolver.model.typesystem.PrimitiveType.describe() diff --git a/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-model/com_github_javaparser_symbolsolver_model_typesystem_Type.txt b/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-model/com_github_javaparser_symbolsolver_model_typesystem_Type.txt index 46d9283815..afd7bd4090 100644 --- a/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-model/com_github_javaparser_symbolsolver_model_typesystem_Type.txt +++ b/java-symbol-solver-testing/src/test/resources/javasymbolsolver_0_6_0/expected_output/java-symbol-solver-model/com_github_javaparser_symbolsolver_model_typesystem_Type.txt @@ -14,4 +14,4 @@ Line 122) String.format("%s is not a Primitive type", this) ==> java.lang.String.format(java.lang.String, java.lang.Object...) Line 126) String.format("%s is not a Wildcard", this) ==> java.lang.String.format(java.lang.String, java.lang.Object...) Line 130) String.format("%s is not a constraint type", this) ==> java.lang.String.format(java.lang.String, java.lang.Object...) - Line 156) replaceTypeVariables(tp, replaced, new HashMap<>()) ==> UNSOLVED + Line 156) replaceTypeVariables(tp, replaced, new HashMap<>()) ==> com.github.javaparser.symbolsolver.model.typesystem.Type.replaceTypeVariables(com.github.javaparser.symbolsolver.model.declarations.TypeParameterDeclaration, com.github.javaparser.symbolsolver.model.typesystem.Type, java.util.Map)