Type annotations required on functions

This commit is contained in:
Andrey Breslav
2011-06-15 21:21:19 +04:00
parent 317877d67a
commit 8786c6a667
20 changed files with 62 additions and 58 deletions
@@ -8,7 +8,7 @@ class Outer() {
public val foo: InnerBase? = InnerDerived()
}
fun box() {
fun box() : String {
val o = Outer()
return if (o.foo === null) "fail" else "OK"
}
@@ -6,7 +6,7 @@ class Bar(): Foo {
fun test(): String = xyzzy()
}
fun box() {
fun box() : String {
val bar = Bar()
val f = bar.test()
return if (f == "xyzzy") "OK" else "fail"
@@ -13,7 +13,7 @@ class World() {
val foo = Item()
}
fun box() {
fun box() : String {
val w = World()
if (w.items.size() != 1) return "fail"
return "OK"
+3 -3
View File
@@ -1,16 +1,16 @@
class Outer(val foo: StringBuilder) {
class Inner() {
fun len() {
fun len() : Int {
return foo.length()
}
}
fun test() {
fun test() : Inner {
return Inner()
}
}
fun box(): String {
fun box() : String {
val sb = StringBuilder("xyzzy")
val o = Outer(sb)
val i = o.test()
@@ -2,7 +2,7 @@ class SimpleClass() {
fun foo() = 610
}
fun test() {
fun test() : Int {
val c = SimpleClass()
return c.foo()
}
+1 -1
View File
@@ -6,7 +6,7 @@ class Outer() {
public val x = Inner()
}
fun box() {
fun box() : String {
val o = Outer()
return if (o === o.x.outer) "OK" else "fail"
}
@@ -10,7 +10,7 @@ class Outer() {
public val x = InnerDerived()
}
fun box() {
fun box() : String {
val o = Outer()
return if (o.x.name != "xyzzy") "fail" else "OK"
}
@@ -1,5 +1,5 @@
class SimpleClass {
fun foo() {
fun foo() : Int {
return 0;
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
fun f() {
fun f() : String? {
val x = StringBuilder();
g(x);
return x.toString();
@@ -1,8 +1,8 @@
class Wrapper<T>() {
fun castToSelf(wrapper: Any) = wrapper as? Wrapper<T>
fun castToSelf(wrapper: Any) : Wrapper<T>? = wrapper as? Wrapper<T>
}
fun foo() {
fun foo() : Wrapper<Int>? {
val wrapper = Wrapper<Int>()
return wrapper.castToSelf(Wrapper<String>())
}
@@ -2,7 +2,7 @@ class Wrapper<T>() {
fun isSameWrapper(wrapper: Any) = wrapper is Wrapper<T>
}
fun foo() {
fun foo() : Boolean {
val wrapper = Wrapper<Int>()
return wrapper.isSameWrapper(Wrapper<String>())
}
@@ -1,7 +1,7 @@
class Wrapper<T>() {
}
fun foo() {
fun foo() : Boolean {
val wrapper = Wrapper<Int>()
return wrapper is Wrapper<String>
}
@@ -1,7 +1,7 @@
class Point() {
}
fun foo() {
fun foo() : typeinfo.TypeInfo<Point> {
val p = Point();
return typeof(p);
}