Fix warning about unchecked cast to generic by being less specific

Casting to `Foo<Bar>` results in an unchecked-cast warning due to Java
generics type erasure.  However, sometimes we don't really need a
`Foo<Bar>`, but could simply use any `Foo<?>`.  Casting to the latter
creates no warning.
This commit is contained in:
Ben Liblit 2017-08-06 20:07:33 -05:00 committed by Manu Sridharan
parent 5bcc985069
commit ba84b5a403
2 changed files with 2 additions and 2 deletions

View File

@ -183,7 +183,7 @@ public class AnnotationTest extends WalaTestCase {
IMethod methodUnderTest = cha.resolveMethod(methodRefUnderTest);
harness.assertTrue(methodRefUnderTest.toString() + " not found", methodUnderTest != null);
harness.assertTrue(methodUnderTest + " must be bytecode method", methodUnderTest instanceof IBytecodeMethod);
IBytecodeMethod<IInstruction> IBytecodeMethodUnderTest = (IBytecodeMethod<IInstruction>) methodUnderTest;
IBytecodeMethod<?> IBytecodeMethodUnderTest = (IBytecodeMethod<?>) methodUnderTest;
Collection<Annotation>[] parameterAnnotations = IBytecodeMethodUnderTest.getParameterAnnotations();
harness.assertEquals(expected.length, parameterAnnotations.length);

View File

@ -191,7 +191,7 @@ public class CodeScanner {
return false;
}
private static Collection<CallSiteReference> getCallSitesFromShrikeBT(IBytecodeMethod M) throws InvalidClassFileException {
private static Collection<CallSiteReference> getCallSitesFromShrikeBT(IBytecodeMethod<?> M) throws InvalidClassFileException {
return M.getCallSites();
}