Support [throws] annotation

This commit is contained in:
Andrey Breslav
2014-01-22 15:37:27 +04:00
parent b66a76e7d2
commit 4ab0b00bd3
17 changed files with 284 additions and 7 deletions
@@ -0,0 +1,17 @@
class JavaClass {
void testMethod() {
Test test = new Test();
test.none();
try {
test.one();
}
catch (E1 e) {}
try {
test.two();
}
catch (E1 e) {}
catch (E2 e) {}
}
}
@@ -0,0 +1,13 @@
class E1: Exception()
class E2: Exception()
class Test {
throws()
fun none() {}
throws(javaClass<E1>())
fun one() {}
throws(javaClass<E1>(), javaClass<E2>())
fun two() {}
}
@@ -0,0 +1,21 @@
class JavaClass {
void testMethod() {
new None();
try {
new One();
}
catch (E1 e) {}
try {
new OneWithParam(1);
}
catch (E1 e) {}
try {
new Two();
}
catch (E1 e) {}
catch (E2 e) {}
}
}
@@ -0,0 +1,8 @@
class E1: Exception()
class E2: Exception()
class None [throws()]() {}
class One [throws(javaClass<E1>())]()
class Two [throws(javaClass<E1>(), javaClass<E2>())]()
class OneWithParam [throws(javaClass<E1>())](a: Int)
@@ -0,0 +1,33 @@
class JavaClass {
void testMethod(One instance) {
try {
new One(1);
}
catch (E1 e) {}
try {
new One(1, 0);
}
catch (E1 e) {}
try {
new One();
}
catch (E1 e) {}
try {
One.one$default(instance, 1, 1);
}
catch (E1 e) {}
try {
_DefaultPackage.one(1);
}
catch (E1 e) {}
try {
_DefaultPackage.one$default(1, 0);
}
catch (E1 e) {}
}
}
@@ -0,0 +1,9 @@
class E1: Exception()
throws(javaClass<E1>())
fun one(a: Int = 1) {}
class One [throws(javaClass<E1>())] (a: Int = 1) {
throws(javaClass<E1>())
fun one(a: Int = 1) {}
}
@@ -0,0 +1,17 @@
class JavaClass {
void testMethod() {
Test test = new Test();
test.none();
try {
test.one();
}
catch (E1 e) {}
try {
test.two();
}
catch (E1 e) {}
catch (E2 e) {}
}
}
@@ -0,0 +1,21 @@
class E1: Exception()
class E2: Exception()
trait Trait {
throws()
fun none()
throws(javaClass<E1>())
fun one()
throws(javaClass<E1>(), javaClass<E2>())
fun two()
}
class Impl: Trait {
override fun none() {}
override fun one() {}
override fun two() {}
}
class Test: Trait by Impl()
@@ -0,0 +1,16 @@
class JavaClass {
void testMethod() {
_DefaultPackage.none();
try {
_DefaultPackage.one();
}
catch (E1 e) {}
try {
_DefaultPackage.two();
}
catch (E1 e) {}
catch (E2 e) {}
}
}
@@ -0,0 +1,11 @@
class E1: Exception()
class E2: Exception()
throws()
fun none() {}
throws(javaClass<E1>())
fun one() {}
throws(javaClass<E1>(), javaClass<E2>())
fun two() {}
@@ -0,0 +1,17 @@
class JavaClass {
void testMethod() {
Test test = new Test();
test.none();
try {
test.one();
}
catch (E1 e) {}
try {
test.two();
}
catch (E1 e) {}
catch (E2 e) {}
}
}
@@ -0,0 +1,15 @@
class E1: Exception()
class E2: Exception()
trait Trait {
throws()
fun none() {}
throws(javaClass<E1>())
fun one() {}
throws(javaClass<E1>(), javaClass<E2>())
fun two() {}
}
class Test: Trait