LVTI: explicit variable type is redundant (IDEA-179177)

This commit is contained in:
Anna Kozlova
2017-09-25 15:05:22 +02:00
parent 1aa739139c
commit 776b8f9474
23 changed files with 272 additions and 0 deletions
@@ -0,0 +1,8 @@
// "Replace explicit type with 'var'" "true"
class Main {
void m(String[] args){
for ( var arg : args) {
}
}
}
@@ -0,0 +1,8 @@
// "Replace explicit type with 'var'" "true"
class Main {
{
var str = m("hello, world");
}
static <T> T m(T t) {return t;}
}
@@ -0,0 +1,6 @@
// "Replace explicit type with 'var'" "true"
class Main {
{
var args = new String[42];
}
}
@@ -0,0 +1,6 @@
// "Replace explicit type with 'var'" "true"
class Main {
{
var i = 0;
}
}
@@ -0,0 +1,7 @@
// "Replace explicit type with 'var'" "true"
import java.io.*;
class Main {
void m(InputStream s){
try ( var in = s) {}
}
}
@@ -0,0 +1,6 @@
// "Replace explicit type with 'var'" "false"
class Main {
{
<caret>String[] args = {"hello, world"};
}
}
@@ -0,0 +1,6 @@
// "Replace explicit type with 'var'" "false"
class Main {
{
<caret>String args[] = new String[]{"hello, world"};
}
}
@@ -0,0 +1,8 @@
// "Replace explicit type with 'var'" "false"
class Main {
{
<caret>A<String> i = new A<>();
}
static class A<T> {}
}
@@ -0,0 +1,8 @@
// "Replace explicit type with 'var'" "true"
class Main {
void m(String[] args){
for (<caret>String arg : args) {
}
}
}
@@ -0,0 +1,6 @@
// "Replace explicit type with 'var'" "false"
class Main {
{
<caret>Runnable r = () -> {};
}
}
@@ -0,0 +1,8 @@
// "Replace explicit type with 'var'" "true"
class Main {
{
<caret>String str = m("hello, world");
}
static <T> T m(T t) {return t;}
}
@@ -0,0 +1,6 @@
// "Replace explicit type with 'var'" "false"
class Main {
{
<caret>String str = "", str1 = "";
}
}
@@ -0,0 +1,6 @@
// "Replace explicit type with 'var'" "true"
class Main {
{
<caret>String[] args = new String[42];
}
}
@@ -0,0 +1,6 @@
// "Replace explicit type with 'var'" "false"
class Main {
{
<caret>String[] args;
}
}
@@ -0,0 +1,8 @@
// "Replace explicit type with 'var'" "false"
class Main {
{
<caret>String str = m();
}
static <T> T m() {return t;}
}
@@ -0,0 +1,6 @@
// "Replace explicit type with 'var'" "false"
class Main {
{
<caret>String[] args = null;
}
}
@@ -0,0 +1,6 @@
// "Replace explicit type with 'var'" "true"
class Main {
{
<caret>int i = 0;
}
}
@@ -0,0 +1,7 @@
// "Replace explicit type with 'var'" "true"
import java.io.*;
class Main {
void m(InputStream s){
try (<caret>InputStream in = s) {}
}
}