Most of the tests fixed

This commit is contained in:
Andrey Breslav
2011-11-10 21:33:46 +03:00
parent 586f4c34b2
commit 4224e00cbd
6 changed files with 44 additions and 47 deletions
@@ -1,5 +1,6 @@
trait A { trait A {
fun foo() : Int = 1 fun foo() : Int = 1
fun foo2() : Int = 1
fun foo1() : Int = 1 fun foo1() : Int = 1
val a : Int val a : Int
val a1 : Int val a1 : Int
@@ -12,7 +13,7 @@ trait A {
abstract class B() : A { abstract class B() : A {
override fun <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>foo<!>() { override fun <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>foo<!>() {
} }
override fun foo() : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Unit<!> { override fun foo2() : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Unit<!> {
} }
override val a : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Double<!> = 1.dbl override val a : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Double<!> = 1.dbl
@@ -10,7 +10,7 @@ fun test2() : Any = @a {return@a 1}
fun test3() : Any { <!RETURN_TYPE_MISMATCH!>return<!> } fun test3() : Any { <!RETURN_TYPE_MISMATCH!>return<!> }
fun test4(): fun(): Unit = { <!RETURN_TYPE_MISMATCH, RETURN_NOT_ALLOWED!>return@test4<!> } fun test4(): fun(): Unit = { <!RETURN_TYPE_MISMATCH, RETURN_NOT_ALLOWED!>return@test4<!> }
fun test5(): Any = @{ return@ } fun test5(): Any = @{ return@ }
fun test5(): Any = {<!RETURN_NOT_ALLOWED!>return 1<!>} fun test6(): Any = {<!RETURN_NOT_ALLOWED!>return 1<!>}
fun bbb() { fun bbb() {
return <!TYPE_MISMATCH!>1<!> return <!TYPE_MISMATCH!>1<!>
@@ -34,7 +34,7 @@ fun intShortInfer() = 1
fun intShort() : Int = 1 fun intShort() : Int = 1
//fun intBlockInfer() {1} //fun intBlockInfer() {1}
fun intBlock() : Int {return 1} fun intBlock() : Int {return 1}
fun intBlock() : Int {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1<!>} fun intBlock1() : Int {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1<!>}
fun intString(): Int = <!TYPE_MISMATCH!>"s"<!> fun intString(): Int = <!TYPE_MISMATCH!>"s"<!>
fun intFunctionLiteral(): Int = <!TYPE_MISMATCH!>{ 10 }<!> fun intFunctionLiteral(): Int = <!TYPE_MISMATCH!>{ 10 }<!>
@@ -47,70 +47,70 @@ fun blockReturnValueTypeMismatchUnit() : Int {return <!TYPE_MISMATCH!>()<!>}
fun blockAndAndMismatch() : Int { fun blockAndAndMismatch() : Int {
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>true && false<!> <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>true && false<!>
} }
fun blockAndAndMismatch() : Int { fun blockAndAndMismatch1() : Int {
return <!TYPE_MISMATCH!>true && false<!> return <!TYPE_MISMATCH!>true && false<!>
} }
fun blockAndAndMismatch() : Int { fun blockAndAndMismatch2() : Int {
<!UNREACHABLE_CODE!>(return <!ERROR_COMPILE_TIME_VALUE!>true<!>) && (return <!ERROR_COMPILE_TIME_VALUE!>false<!>)<!> <!UNREACHABLE_CODE!>(return <!ERROR_COMPILE_TIME_VALUE!>true<!>) && (return <!ERROR_COMPILE_TIME_VALUE!>false<!>)<!>
} }
fun blockAndAndMismatch() : Int { fun blockAndAndMismatch3() : Int {
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>true || false<!> <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>true || false<!>
} }
fun blockAndAndMismatch() : Int { fun blockAndAndMismatch4() : Int {
return <!TYPE_MISMATCH!>true || false<!> return <!TYPE_MISMATCH!>true || false<!>
} }
fun blockAndAndMismatch() : Int { fun blockAndAndMismatch5() : Int {
<!UNREACHABLE_CODE!>(return <!ERROR_COMPILE_TIME_VALUE!>true<!>) || (return <!ERROR_COMPILE_TIME_VALUE!>false<!>)<!> <!UNREACHABLE_CODE!>(return <!ERROR_COMPILE_TIME_VALUE!>true<!>) || (return <!ERROR_COMPILE_TIME_VALUE!>false<!>)<!>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch1() : Int {
return if (1 > 2) <!ERROR_COMPILE_TIME_VALUE!>1.0<!> else <!ERROR_COMPILE_TIME_VALUE!>2.0<!> return if (1 > 2) <!ERROR_COMPILE_TIME_VALUE!>1.0<!> else <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch2() : Int {
return <!TYPE_MISMATCH!>if (1 > 2) 1<!> return <!TYPE_MISMATCH!>if (1 > 2) 1<!>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch3() : Int {
return <!TYPE_MISMATCH!>if (1 > 2) else 1<!> return <!TYPE_MISMATCH!>if (1 > 2) else 1<!>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch4() : Int {
if (1 > 2) if (1 > 2)
return <!ERROR_COMPILE_TIME_VALUE!>1.0<!> return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
else return <!ERROR_COMPILE_TIME_VALUE!>2.0<!> else return <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch5() : Int {
if (1 > 2) if (1 > 2)
return <!ERROR_COMPILE_TIME_VALUE!>1.0<!> return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
return <!ERROR_COMPILE_TIME_VALUE!>2.0<!> return <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch6() : Int {
if (1 > 2) if (1 > 2)
else return <!ERROR_COMPILE_TIME_VALUE!>1.0<!> else return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
return <!ERROR_COMPILE_TIME_VALUE!>2.0<!> return <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch7() : Int {
if (1 > 2) if (1 > 2)
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1.0<!> <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1.0<!>
else <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>2.0<!> else <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>2.0<!>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch8() : Int {
if (1 > 2) if (1 > 2)
1.0 1.0
else 2.0 else 2.0
return 1 return 1
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch9() : Int {
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>if (1 > 2) <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>if (1 > 2)
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1.0<!><!> <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1.0<!><!>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch10() : Int {
return <!TYPE_MISMATCH!>if (1 > 2) return <!TYPE_MISMATCH!>if (1 > 2)
1<!> 1<!>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch11() : Int {
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>if (1 > 2) <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>if (1 > 2)
else <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1.0<!><!> else <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1.0<!><!>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch12() : Int {
if (1 > 2) if (1 > 2)
return 1 return 1
else return <!ERROR_COMPILE_TIME_VALUE!>1.0<!> else return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
@@ -166,9 +166,9 @@ fun f(): Int {
if (1 < 2) { return 1 } else returnNothing() if (1 < 2) { return 1 } else returnNothing()
} }
fun f(): Int = if (1 < 2) 1 else returnNothing() fun f1(): Int = if (1 < 2) 1 else returnNothing()
public fun <!PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE!>f<!>() = 1 public fun <!PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE!>f2<!>() = 1
class B() { class B() {
protected fun <!PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE!>f<!>() = "ss" protected fun <!PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE!>f<!>() = "ss"
} }
@@ -18,7 +18,3 @@ fun test(a : java.util.ArrayList<Int>) {
fun test(a : java.lang.Class<Int>) { fun test(a : java.lang.Class<Int>) {
} }
fun test(a : java.lang.Class<Int>) {
}
@@ -46,7 +46,7 @@ class C() : A() {
} }
} }
fun f10(a : A?) { fun f101(a : A?) {
if (a is C) { if (a is C) {
a.bar(); a.bar();
} }
+19 -19
View File
@@ -31,7 +31,7 @@ fun intShortInfer() = 1
fun intShort() : Int = 1 fun intShort() : Int = 1
//fun intBlockInfer() {1} //fun intBlockInfer() {1}
fun intBlock() : Int {return 1} fun intBlock() : Int {return 1}
fun intBlock() : Int {<error>1</error>} fun intBlock1() : Int {<error>1</error>}
fun intString(): Int = <error>"s"</error> fun intString(): Int = <error>"s"</error>
fun intFunctionLiteral(): Int = <error>{ 10 }</error> fun intFunctionLiteral(): Int = <error>{ 10 }</error>
@@ -44,70 +44,70 @@ fun blockReturnValueTypeMismatchUnit() : Int {return <error>()</error>}
fun blockAndAndMismatch() : Int { fun blockAndAndMismatch() : Int {
<error>true && false</error> <error>true && false</error>
} }
fun blockAndAndMismatch() : Int { fun blockAndAndMismatch1() : Int {
return <error>true && false</error> return <error>true && false</error>
} }
fun blockAndAndMismatch() : Int { fun blockAndAndMismatch2() : Int {
<error>(return <error>true</error>) && (return <error>false</error>)</error> <error>(return <error>true</error>) && (return <error>false</error>)</error>
} }
fun blockAndAndMismatch() : Int { fun blockAndAndMismatch3() : Int {
<error>true || false</error> <error>true || false</error>
} }
fun blockAndAndMismatch() : Int { fun blockAndAndMismatch4() : Int {
return <error>true || false</error> return <error>true || false</error>
} }
fun blockAndAndMismatch() : Int { fun blockAndAndMismatch5() : Int {
<error>(return <error>true</error>) || (return <error>false</error>)</error> <error>(return <error>true</error>) || (return <error>false</error>)</error>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch1() : Int {
return if (1 > 2) <error>1.0</error> else <error>2.0</error> return if (1 > 2) <error>1.0</error> else <error>2.0</error>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch2() : Int {
return <error>if (1 > 2) 1</error> return <error>if (1 > 2) 1</error>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch3() : Int {
return <error>if (1 > 2) else 1</error> return <error>if (1 > 2) else 1</error>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch4() : Int {
if (1 > 2) if (1 > 2)
return <error>1.0</error> return <error>1.0</error>
else return <error>2.0</error> else return <error>2.0</error>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch5() : Int {
if (1 > 2) if (1 > 2)
return <error>1.0</error> return <error>1.0</error>
return <error>2.0</error> return <error>2.0</error>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch6() : Int {
if (1 > 2) if (1 > 2)
else return <error>1.0</error> else return <error>1.0</error>
return <error>2.0</error> return <error>2.0</error>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch7() : Int {
if (1 > 2) if (1 > 2)
<error>1.0</error> <error>1.0</error>
else <error>2.0</error> else <error>2.0</error>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch8() : Int {
if (1 > 2) if (1 > 2)
1.0 1.0
else 2.0 else 2.0
return 1 return 1
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch9() : Int {
<error>if (1 > 2) <error>if (1 > 2)
<error>1.0</error></error> <error>1.0</error></error>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch10() : Int {
return <error>if (1 > 2) return <error>if (1 > 2)
1</error> 1</error>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch11() : Int {
<error>if (1 > 2) <error>if (1 > 2)
else <error>1.0</error></error> else <error>1.0</error></error>
} }
fun blockReturnValueTypeMatch() : Int { fun blockReturnValueTypeMatch12() : Int {
if (1 > 2) if (1 > 2)
return 1 return 1
else return <error>1.0</error> else return <error>1.0</error>
@@ -163,4 +163,4 @@ fun f(): Int {
if (1 < 2) { return 1 } else returnNothing() if (1 < 2) { return 1 } else returnNothing()
} }
fun f(): Int = if (1 < 2) 1 else returnNothing() fun f1(): Int = if (1 < 2) 1 else returnNothing()
+1 -1
View File
@@ -44,7 +44,7 @@ class C() : A() {
} }
} }
fun f10(a : A?) { fun f101(a : A?) {
if (a is C) { if (a is C) {
<info descr="Automatically cast to C">a</info>.bar(); <info descr="Automatically cast to C">a</info>.bar();
} }