JS frontend: additional check for nativeSetter -- check that the return type is either Unit or a supertype of the second parameter's type.

This commit is contained in:
Zalim Bashorov
2014-12-30 16:49:16 +03:00
parent 76bafb9634
commit 619854a7a3
17 changed files with 134 additions and 34 deletions
@@ -5,10 +5,19 @@ fun foo() {
fun Int.set(a: String, v: Int) {}
[nativeSetter]
fun Int.set2(a: Number, v: String?) = "OK"
fun Int.set2(a: Number, v: String?): Any? = null
[nativeSetter]
fun Int.set3(a: Double, v: String?) = "OK"
fun Int.set3(a: Double, v: String) = "OK"
[nativeSetter]
fun Int.set4(a: Double, v: String): Any = 1
[nativeSetter]
fun Int.set5(a: Double, v: String): CharSequence = "OK"
[nativeSetter]
fun Int.set6(a: Double, v: String): <!NATIVE_SETTER_WRONG_RETURN_TYPE!>Number<!> = 1
<!NATIVE_INDEXER_WRONG_PARAMETER_COUNT!>[nativeSetter]
fun Int.set(<!NATIVE_INDEXER_KEY_SHOULD_BE_STRING_OR_NUMBER!>a: Any<!>): Int?<!> = 1
@@ -20,5 +29,5 @@ fun foo() {
fun Int.set3(<!NATIVE_INDEXER_KEY_SHOULD_BE_STRING_OR_NUMBER!>a: Any<!>, b: Int, c: Any?)<!> {}
[nativeSetter]
fun Any.foo(<!NATIVE_INDEXER_CAN_NOT_HAVE_DEFAULT_ARGUMENTS!>a: Double = 0.0<!>, <!NATIVE_INDEXER_CAN_NOT_HAVE_DEFAULT_ARGUMENTS!>v: String? = null<!>) = "OK"
fun Any.<!NATIVE_SETTER_WRONG_RETURN_TYPE!>foo<!>(<!NATIVE_INDEXER_CAN_NOT_HAVE_DEFAULT_ARGUMENTS!>a: Double = 0.0<!>, <!NATIVE_INDEXER_CAN_NOT_HAVE_DEFAULT_ARGUMENTS!>v: String? = null<!>) = "OK"
}