forked from phoedos/pmd
Add test for UnnecessaryCast
This commit is contained in:
@ -866,4 +866,26 @@ class MyClass {
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description>Unboxing in lambda</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<expected-linenumbers>4</expected-linenumbers>
|
||||
<code><![CDATA[
|
||||
public abstract class Example {
|
||||
VoidSpecies<Integer> mismatch = payload -> (int) payload; // nowarn: here the cast does a null check
|
||||
RefSpecies<Integer, Object> i = t -> (int) t; // nowarn: here the cast does a null check
|
||||
IntSpecies<Integer> i = t -> (int) t; // warn: in this context t->t is equivalent because it will be unboxed
|
||||
|
||||
interface VoidSpecies<T> {
|
||||
void doSomething(T t);
|
||||
}
|
||||
interface RefSpecies<T, X> {
|
||||
X foo(T t);
|
||||
}
|
||||
interface IntSpecies<T> {
|
||||
int foo(T t);
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
</test-data>
|
||||
|
Reference in New Issue
Block a user