IDEA-92588 (check for AutoCloseable on interface extraction)

This commit is contained in:
Roman Shevchenko
2012-10-10 10:35:51 +02:00
parent 37941c490f
commit 0dc1191c25
10 changed files with 155 additions and 8 deletions
@@ -0,0 +1,15 @@
class Test {
void test() throws Exception {
MyIterableImpl r = new MyIterableImpl();
for (String s : r) {
r.length();
}
}
interface MyIterable {
}
static class MyIterableImpl implements MyIterable, Iterable<String> {
public Iterator<String> iterator() { return null; }
}
}
@@ -0,0 +1,15 @@
class Test {
void test() throws Exception {
MyIterableImpl r = new MyIterableImpl();
for (String s : r) {
r.length();
}
}
interface MyIterable {
}
static class MyIterableImpl implements MyIterable, Iterable<String> {
public Iterator<String> iterator() { return null; }
}
}
@@ -0,0 +1,15 @@
class Test {
void test() throws Exception {
MyIterable r = new MyIterableImpl();
for (String s : r) {
r.length();
}
}
interface MyIterable extends Iterable<String> {
}
static class MyIterableImpl implements MyIterable {
public Iterator<String> iterator() { return null; }
}
}
@@ -0,0 +1,15 @@
class Test {
void test() throws Exception {
MyIterableImpl r = new MyIterableImpl();
for (String s : r) {
r.length();
}
}
interface MyIterable extends Iterable<String> {
}
static class MyIterableImpl implements MyIterable {
public Iterator<String> iterator() { return null; }
}
}
@@ -0,0 +1,16 @@
class Test {
void test() throws Exception {
try (MyResourceImpl r = new MyResourceImpl()) {
r.getName();
}
}
interface MyResource {
String getName();
}
static class MyResourceImpl implements MyResource, AutoCloseable {
public String getName() { return ""; }
public void close() throws Exception { }
}
}
@@ -0,0 +1,16 @@
class Test {
void test() throws Exception {
try (MyResourceImpl r = new MyResourceImpl()) {
r.getName();
}
}
interface MyResource {
String getName();
}
static class MyResourceImpl implements MyResource, AutoCloseable {
public String getName() { return ""; }
public void close() throws Exception { }
}
}
@@ -0,0 +1,16 @@
class Test {
void test() throws Exception {
try (MyResource r = new MyResourceImpl()) {
r.getName();
}
}
interface MyResource extends AutoCloseable {
String getName();
}
static class MyResourceImpl implements MyResource {
public String getName() { return ""; }
public void close() throws Exception { }
}
}
@@ -0,0 +1,16 @@
class Test {
void test() throws Exception {
try (MyResourceImpl r = new MyResourceImpl()) {
r.getName();
}
}
interface MyResource extends AutoCloseable {
String getName();
}
static class MyResourceImpl implements MyResource {
public String getName() { return ""; }
public void close() throws Exception { }
}
}