JET-50 Drop the 'new' keyword

This commit is contained in:
Andrey Breslav
2011-06-15 18:00:10 +04:00
parent c9d9001ad8
commit c2fbbff782
103 changed files with 921 additions and 980 deletions
@@ -11,7 +11,7 @@ fun vl(l : Left) : Int = l.v
fun vr(r : Right) : Int = r.v
fun box() : String {
val d = new D()
val d = D()
d.v = 42
if (d.v != 42) return "Fail #1"
@@ -10,8 +10,8 @@ class Derived2() : Abstract, Base() {}
fun test(s : Base) : Boolean = s.n(238) == 239
fun box() : String {
if (!test(new Base())) return "Fail #1"
if (!test(new Derived1())) return "Fail #2"
if (!test(new Derived2())) return "Fail #3"
if (!test(Base())) return "Fail #1"
if (!test(Derived1())) return "Fail #2"
if (!test(Derived2())) return "Fail #3"
return "OK"
}
@@ -11,22 +11,22 @@ class P3(x : Int, yy : Y) : X(x), Y by yy, Abstract {}
class P4(x : Int, yy : Y) : Y by yy, Abstract, X(x) {}
fun box() : String {
if (new X(239).x != 239) return "FAIL #1"
if (new Y(239).y != 239) return "FAIL #2"
if (X(239).x != 239) return "FAIL #1"
if (Y(239).y != 239) return "FAIL #2"
val p = new Point(240, -1)
val p = Point(240, -1)
if (p.x + p.y != 239) return "FAIL #3"
val y = new Y(-1)
val p1 = new P1(240, y)
val y = Y(-1)
val p1 = P1(240, y)
if (p1.x + p1.y != 239) return "FAIL #4"
val p2 = new P2(240, y)
val p2 = P2(240, y)
if (p2.x + p2.y != 239) return "FAIL #5"
val p3 = new P3(240, y)
val p3 = P3(240, y)
if (p3.x + p3.y != 239) return "FAIL #6"
val p4 = new P4(240, y)
val p4 = P4(240, y)
if (p4.x + p4.y != 239) return "FAIL #7"
"OK"
@@ -5,10 +5,10 @@ class Outer() {
class InnerDerived(): InnerBase() {
}
public val foo: InnerBase? = new InnerDerived()
public val foo: InnerBase? = InnerDerived()
}
fun box() {
val o = new Outer()
val o = Outer()
return if (o.foo === null) "fail" else "OK"
}
@@ -7,7 +7,7 @@ class Bar(): Foo {
}
fun box() {
val bar = new Bar()
val bar = Bar()
val f = bar.test()
return if (f == "xyzzy") "OK" else "fail"
}
@@ -7,7 +7,7 @@ class C() {
}
fun box(): String {
val c = new C()
val c = C()
if (c.f != 610) return "fail"
return "OK"
}
@@ -2,7 +2,7 @@ import java.util.*
import java.io.*
class World() {
public val items: ArrayList<Item> = new ArrayList<Item>
public val items: ArrayList<Item> = ArrayList<Item>
class Item() {
{
@@ -10,11 +10,11 @@ class World() {
}
}
val foo = new Item()
val foo = Item()
}
fun box() {
val w = new World()
val w = World()
if (w.items.size() != 1) return "fail"
return "OK"
}
+3 -3
View File
@@ -6,13 +6,13 @@ class Outer(val foo: StringBuilder) {
}
fun test() {
return new Inner()
return Inner()
}
}
fun box(): String {
val sb = new StringBuilder("xyzzy")
val o = new Outer(sb)
val sb = StringBuilder("xyzzy")
val o = Outer(sb)
val i = o.test()
val l = i.len()
return if (l != 5) "fail" else "OK"
@@ -3,6 +3,6 @@ class SimpleClass() {
}
fun test() {
val c = new SimpleClass()
val c = SimpleClass()
return c.foo()
}
+2 -2
View File
@@ -3,10 +3,10 @@ class Outer() {
val outer: Outer get() = this@Outer
}
public val x = new Inner()
public val x = Inner()
}
fun box() {
val o = new Outer()
val o = Outer()
return if (o === o.x.outer) "OK" else "fail"
}
@@ -26,8 +26,8 @@ fun code(s : Base) : Int {
fun test(s : Base) : Boolean = code(s) == 0
fun box() : String {
if (!test(new Base())) return "Fail #1"
if (!test(new Derived1())) return "Fail #2"
if (!test(new Derived2())) return "Fail #3"
if (!test(Base())) return "Fail #1"
if (!test(Derived1())) return "Fail #2"
if (!test(Derived2())) return "Fail #3"
return "OK"
}
@@ -7,10 +7,10 @@ class Outer() {
class InnerDerived(): InnerBase(s) {
}
public val x = new InnerDerived()
public val x = InnerDerived()
}
fun box() {
val o = new Outer()
val o = Outer()
return if (o.x.name != "xyzzy") "fail" else "OK"
}
@@ -8,8 +8,8 @@ class D() : Left(), Right() {
}
fun box() : String {
val r : Right = new Right()
val d : D = new D()
val r : Right = Right()
val d : D = D()
if (r.f() != 42) return "Fail #1"
if (d.f() != 239) return "Fail #2"
@@ -1,7 +1,7 @@
import java.util.*
fun concat(l: List<String>): String? {
val sb = new StringBuilder()
val sb = StringBuilder()
for(s in l) {
sb.append(s)
}
@@ -1,5 +1,5 @@
fun concat(l: Array<String>): String? {
val sb = new StringBuilder()
val sb = StringBuilder()
for(s in l) {
sb.append(s)
}
@@ -1,3 +1,3 @@
fun StringBuilder.first() = this.charAt(0)
fun foo() = new StringBuilder("foo").first()
fun foo() = StringBuilder("foo").first()
@@ -8,7 +8,7 @@ fun StringBuilder.takeFirst(): Char {
fun foo(expr: StringBuilder): Int {
val c = expr.takeFirst()
when(c) {
'\0' => throw new Exception("zero")
else => throw new Exception("nonzero" + c)
'\0' => throw Exception("zero")
else => throw Exception("nonzero" + c)
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
fun f() {
val x = new StringBuilder();
val x = StringBuilder();
g(x);
return x.toString();
}
@@ -5,6 +5,6 @@ class SimpleClass {
}
fun test() {
val c = new SimpleClass()
val c = SimpleClass()
return c.foo()
}
+1 -1
View File
@@ -1,6 +1,6 @@
import java.io.*
fun main(args: Array<String>) {
val reader = new BufferedReader(new InputStreamReader(System.`in`))
val reader = BufferedReader(InputStreamReader(System.`in`))
while(true) {
val cmd = reader.readLine() as String
}
@@ -3,6 +3,6 @@ class Wrapper<T>() {
}
fun foo() {
val wrapper = new Wrapper<Int>()
return wrapper.castToSelf(new Wrapper<String>())
val wrapper = Wrapper<Int>()
return wrapper.castToSelf(Wrapper<String>())
}
@@ -1,4 +1,4 @@
class Point() {
}
fun foo() = new Point()
fun foo() = Point()
@@ -3,6 +3,6 @@ class Wrapper<T>() {
}
fun foo() {
val wrapper = new Wrapper<Int>()
return wrapper.isSameWrapper(new Wrapper<String>())
val wrapper = Wrapper<Int>()
return wrapper.isSameWrapper(Wrapper<String>())
}
@@ -2,6 +2,6 @@ class Wrapper<T>() {
}
fun foo() {
val wrapper = new Wrapper<Int>()
val wrapper = Wrapper<Int>()
return wrapper is Wrapper<String>
}
@@ -2,6 +2,6 @@ class Point() {
}
fun foo() {
val p = new Point();
val p = Point();
return typeof(p);
}