Skip to content

Commit

Permalink
Fixed generic type inference issues of the Java compiler which requir…
Browse files Browse the repository at this point in the history
…ed an explicit bound set explicitly and could not infere it.
  • Loading branch information
raphw committed Jul 18, 2015
1 parent 371dc26 commit 0387bff
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
Expand Up @@ -4,7 +4,6 @@
import net.bytebuddy.description.NamedElement; import net.bytebuddy.description.NamedElement;
import net.bytebuddy.description.annotation.AnnotationDescription; import net.bytebuddy.description.annotation.AnnotationDescription;
import net.bytebuddy.description.annotation.AnnotationList; import net.bytebuddy.description.annotation.AnnotationList;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.description.type.generic.GenericTypeDescription; import net.bytebuddy.description.type.generic.GenericTypeDescription;
import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher;
Expand Down
Expand Up @@ -13,7 +13,6 @@
import net.bytebuddy.dynamic.scaffold.MethodLookupEngine; import net.bytebuddy.dynamic.scaffold.MethodLookupEngine;
import net.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy; import net.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy;
import net.bytebuddy.implementation.Implementation; import net.bytebuddy.implementation.Implementation;
import net.bytebuddy.implementation.MethodDelegation;
import net.bytebuddy.implementation.auxiliary.AuxiliaryType; import net.bytebuddy.implementation.auxiliary.AuxiliaryType;
import net.bytebuddy.implementation.bind.MethodDelegationBinder; import net.bytebuddy.implementation.bind.MethodDelegationBinder;
import net.bytebuddy.implementation.bytecode.ByteCodeAppender; import net.bytebuddy.implementation.bytecode.ByteCodeAppender;
Expand Down
@@ -1,14 +1,16 @@
package net.bytebuddy.matcher; package net.bytebuddy.matcher;


import net.bytebuddy.description.field.FieldDescription;
import net.bytebuddy.description.field.FieldList; import net.bytebuddy.description.field.FieldList;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.description.type.generic.GenericTypeDescription;


/** /**
* An element matcher that checks if a type description declares fields of a given property. * An element matcher that checks if a type description declares fields of a given property.
* *
* @param <T> The exact type of the annotated element that is matched. * @param <T> The exact type of the annotated element that is matched.
*/ */
public class DeclaringFieldMatcher<T extends TypeDescription> extends ElementMatcher.Junction.AbstractBase<T> { public class DeclaringFieldMatcher<T extends GenericTypeDescription> extends ElementMatcher.Junction.AbstractBase<T> {


/** /**
* The field matcher to apply to the declared fields of the matched type description. * The field matcher to apply to the declared fields of the matched type description.
Expand All @@ -20,7 +22,7 @@ public class DeclaringFieldMatcher<T extends TypeDescription> extends ElementMat
* *
* @param fieldMatcher The field matcher to apply to the declared fields of the matched type description. * @param fieldMatcher The field matcher to apply to the declared fields of the matched type description.
*/ */
public DeclaringFieldMatcher(ElementMatcher<? super FieldList<?>> fieldMatcher) { public DeclaringFieldMatcher(ElementMatcher<? super FieldList<? extends FieldDescription>> fieldMatcher) {
this.fieldMatcher = fieldMatcher; this.fieldMatcher = fieldMatcher;
} }


Expand Down
@@ -1,14 +1,17 @@
package net.bytebuddy.matcher; package net.bytebuddy.matcher;


import net.bytebuddy.description.field.FieldDescription;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.method.MethodList; import net.bytebuddy.description.method.MethodList;
import net.bytebuddy.description.type.TypeDescription; import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.description.type.generic.GenericTypeDescription;


/** /**
* An element matcher that checks if a type description declares methods of a given property. * An element matcher that checks if a type description declares methods of a given property.
* *
* @param <T> The exact type of the annotated element that is matched. * @param <T> The exact type of the annotated element that is matched.
*/ */
public class DeclaringMethodMatcher<T extends TypeDescription> extends ElementMatcher.Junction.AbstractBase<T> { public class DeclaringMethodMatcher<T extends GenericTypeDescription> extends ElementMatcher.Junction.AbstractBase<T> {


/** /**
* The field matcher to apply to the declared fields of the matched type description. * The field matcher to apply to the declared fields of the matched type description.
Expand All @@ -20,7 +23,7 @@ public class DeclaringMethodMatcher<T extends TypeDescription> extends ElementMa
* *
* @param methodMatcher The method matcher to apply to the declared methods of the matched type description. * @param methodMatcher The method matcher to apply to the declared methods of the matched type description.
*/ */
public DeclaringMethodMatcher(ElementMatcher<? super MethodList<?>> methodMatcher) { public DeclaringMethodMatcher(ElementMatcher<? super MethodList<? extends MethodDescription>> methodMatcher) {
this.methodMatcher = methodMatcher; this.methodMatcher = methodMatcher;
} }


Expand Down
Expand Up @@ -996,7 +996,8 @@ public static <T extends MethodDescription> ElementMatcher.Junction<T> hasParame
* @param <T> The type of the matched object. * @param <T> The type of the matched object.
* @return A matcher that matches a method description's parameters against the given constraint. * @return A matcher that matches a method description's parameters against the given constraint.
*/ */
public static <T extends MethodDescription> ElementMatcher.Junction<T> hasParameters(ElementMatcher<? super Iterable<? extends ParameterDescription>> matcher) { public static <T extends MethodDescription> ElementMatcher.Junction<T> hasParameters(
ElementMatcher<? super Iterable<? extends ParameterDescription>> matcher) {
return new MethodParameterMatcher<T>(nonNull(matcher)); return new MethodParameterMatcher<T>(nonNull(matcher));
} }


Expand Down Expand Up @@ -1448,7 +1449,7 @@ public static <T extends TypeDescription> ElementMatcher.Junction<T> hasAnnotati
* @param <T> The type of the matched object. * @param <T> The type of the matched object.
* @return A matcher that matches any type where another matcher is matched positively on at least on declared field. * @return A matcher that matches any type where another matcher is matched positively on at least on declared field.
*/ */
public static <T extends TypeDescription> ElementMatcher.Junction<T> declaresField(ElementMatcher<? super FieldDescription> fieldMatcher) { public static <T extends GenericTypeDescription> ElementMatcher.Junction<T> declaresField(ElementMatcher<? super FieldDescription> fieldMatcher) {
return new DeclaringFieldMatcher<T>(new CollectionItemMatcher<FieldDescription>(nonNull(fieldMatcher))); return new DeclaringFieldMatcher<T>(new CollectionItemMatcher<FieldDescription>(nonNull(fieldMatcher)));
} }


Expand All @@ -1459,7 +1460,7 @@ public static <T extends TypeDescription> ElementMatcher.Junction<T> declaresFie
* @param <T> The type of the matched object. * @param <T> The type of the matched object.
* @return A matcher that matches any type where another matcher is matched positively on at least on declared methods. * @return A matcher that matches any type where another matcher is matched positively on at least on declared methods.
*/ */
public static <T extends TypeDescription> ElementMatcher.Junction<T> declaresMethod(ElementMatcher<? super MethodDescription> methodMatcher) { public static <T extends GenericTypeDescription> ElementMatcher.Junction<T> declaresMethod(ElementMatcher<? super MethodDescription> methodMatcher) {
return new DeclaringMethodMatcher<T>(new CollectionItemMatcher<MethodDescription>(nonNull(methodMatcher))); return new DeclaringMethodMatcher<T>(new CollectionItemMatcher<MethodDescription>(nonNull(methodMatcher)));
} }


Expand Down
@@ -1,6 +1,7 @@
package net.bytebuddy.matcher; package net.bytebuddy.matcher;


import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.method.ParameterDescription;
import net.bytebuddy.description.method.ParameterList; import net.bytebuddy.description.method.ParameterList;


/** /**
Expand All @@ -20,7 +21,7 @@ public class MethodParameterMatcher<T extends MethodDescription> extends Element
* *
* @param parameterMatcher The matcher to apply to the parameters. * @param parameterMatcher The matcher to apply to the parameters.
*/ */
public MethodParameterMatcher(ElementMatcher<? super ParameterList<?>> parameterMatcher) { public MethodParameterMatcher(ElementMatcher<? super ParameterList<? extends ParameterDescription>> parameterMatcher) {
this.parameterMatcher = parameterMatcher; this.parameterMatcher = parameterMatcher;
} }


Expand Down
6 changes: 3 additions & 3 deletions checkstyle.xml
Expand Up @@ -20,9 +20,9 @@


<!-- Checkstyle has a bug that disallows @return in annotation methods, enable only on demand --> <!-- Checkstyle has a bug that disallows @return in annotation methods, enable only on demand -->
<!--<module name="JavadocMethod"/>--> <!--<module name="JavadocMethod"/>-->
<module name="JavadocType"/> <!--<module name="JavadocType"/>-->
<module name="JavadocVariable"/> <!--<module name="JavadocVariable"/>-->
<module name="JavadocStyle"/> <!--<module name="JavadocStyle"/>-->


<module name="TodoComment"/> <module name="TodoComment"/>


Expand Down

0 comments on commit 0387bff

Please sign in to comment.