Skip to content

Commit

Permalink
method resolution fixes
Browse files Browse the repository at this point in the history
* implemented solving array types in signature of Javassist methods
* extended method resolution logic to handling TypeVariable as actualType
  • Loading branch information
mlangkabel committed Aug 28, 2017
1 parent f15546c commit c733131
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 17 deletions.
Expand Up @@ -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 {
Expand Down
Expand Up @@ -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()) {
Expand Down
Expand Up @@ -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<R, A>, 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<R, A>, A)
Expand Down
Expand Up @@ -34,7 +34,7 @@
Line 89) Collectors.toList() ==> java.util.stream.Collectors.toList()
Line 100) ImmutableList.<ReferenceType>builder().add(getSuperClass()).addAll(superTypeDeclaration.asReferenceType().getAncestors()).build() ==> com.google.common.collect.ImmutableList.Builder.build()
Line 100) ImmutableList.<ReferenceType>builder().add(getSuperClass()).addAll(superTypeDeclaration.asReferenceType().getAncestors()) ==> com.google.common.collect.ImmutableList.Builder.addAll(java.lang.Iterable<? extends E>)
Line 100) ImmutableList.<ReferenceType>builder().add(getSuperClass()) ==> ERROR
Line 100) ImmutableList.<ReferenceType>builder().add(getSuperClass()) ==> com.google.common.collect.ImmutableList.Builder.add(E...)
Line 100) ImmutableList.<ReferenceType>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()
Expand Down Expand Up @@ -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()
Expand Up @@ -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()
Expand Down
Expand Up @@ -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<? extends E>)
Line 108) concreteEquivalentTypesAlsoIndirectly(considered, ivt) ==> com.github.javaparser.symbolsolver.logic.InferenceVariableType.concreteEquivalentTypesAlsoIndirectly(java.util.Set<com.github.javaparser.symbolsolver.logic.InferenceVariableType>, 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>, 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()
Expand Down
@@ -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()
Expand Down
Expand Up @@ -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<com.github.javaparser.symbolsolver.model.declarations.TypeParameterDeclaration, com.github.javaparser.symbolsolver.model.typesystem.Type>)

0 comments on commit c733131

Please sign in to comment.