Project Coin try-with-resource support, take 2

This commit is contained in:
Roman Shevchenko
2011-02-21 19:55:45 +01:00
parent 55151743c5
commit e84bc3af06
31 changed files with 404 additions and 174 deletions
@@ -1,31 +1,45 @@
import java.io.*;
import java.lang.Exception;
class C {
void m0() throws Exception {
try (FileReader reader = new FileReader(new File("input.txt"))) {
reader.read();
} catch (Exception e) {
<error descr="Cannot resolve symbol 'reader'">reader</error> = null;
}
<error descr="Cannot resolve symbol 'reader'">reader</error> = null;
static class E extends Exception { }
static class E1 extends E { }
static class E2 extends E { }
static class E3 extends E { }
static class MyResource implements AutoCloseable {
public MyResource() throws E1 { }
public void doSomething() throws E2 { }
@Override public void close() throws E3 { }
}
void m1() {
try (final FileReader reader = new FileReader(new File("input.txt"))) {
reader.read();
}
catch (IOException ignore) { }
try (MyResource r = new MyResource()) { r.doSomething(); }
catch (E1 | E2 | E3 ignore) { }
try (final FileReader reader = new FileReader(new File("input.txt"))) {
System.out.println("Try.");
}
catch (IOException ignore) { }
try (new MyResource()) { }
catch (E1 | E3 ignore) { }
}
/*void m2() throws IOException {
try (final FileReader reader = new FileReader(new File("input.txt"))) {
reader.read();
void m2() throws Exception {
try (<error descr="Incompatible types. Found: 'java.lang.Object', required: 'java.lang.AutoCloseable'">Object r = new MyResource()</error>) { }
try (<error descr="Incompatible types. Found: 'java.lang.String', required: 'java.lang.AutoCloseable'">"resource"</error>) { }
}
void m3() throws Exception {
try (MyResource r = new MyResource()) {
r.doSomething();
}
}*/
catch (E e) {
<error descr="Cannot resolve symbol 'r'">r</error> = null;
}
finally {
<error descr="Cannot resolve symbol 'r'">r</error> = null;
}
<error descr="Cannot resolve symbol 'r'">r</error> = null;
MyResource r = null;
try (MyResource <error descr="Variable 'r' is already defined in the scope">r</error> = new MyResource()) { }
try (r = new MyResource()) { }
}
}