fix KT-9652 Warning to specify expected type as Any? when it is already Any?

#KT-9652 Fixed
This commit is contained in:
Michael Nedzelsky
2015-10-29 21:16:19 +03:00
parent c318a13e6c
commit e6a2bd05d4
3 changed files with 40 additions and 0 deletions
@@ -114,6 +114,39 @@ fun testImplicitCoercion() {
})
}
fun fooWithAnyArg(<!UNUSED_PARAMETER!>arg<!>: Any) {}
fun fooWithAnyNullableArg(<!UNUSED_PARAMETER!>arg<!>: Any?) {}
fun testCoercionToAny() {
val d = 21
val <!UNUSED_VARIABLE!>x1<!>: Any = if (1>2) 1 else 2.0
val <!UNUSED_VARIABLE!>x2<!>: Any? = if (1>2) 1 else 2.0
val <!UNUSED_VARIABLE!>x3<!>: Any? = if (1>2) 1 else (if (1>2) null else 2.0)
fooWithAnyArg(if (1>2) 1 else 2.0)
fooWithAnyNullableArg(if (1>2) 1 else 2.0)
fooWithAnyNullableArg(if (1>2) 1 else (if (1>2) null else 2.0))
val <!UNUSED_VARIABLE!>y1<!>: Any = when(d) { 1 -> 1.0 else -> 2.0 }
val <!UNUSED_VARIABLE!>y2<!>: Any? = when(d) { 1 -> 1.0 else -> 2.0 }
val <!UNUSED_VARIABLE!>y3<!>: Any? = when(d) { 1 -> 1.0; 2 -> null; else -> 2.0 }
fooWithAnyArg(when(d) { 1 -> 1.0 else -> 2.0 })
fooWithAnyNullableArg(when(d) { 1 -> 1.0 else -> 2.0 })
fooWithAnyNullableArg(when(d) { 1 -> 1.0; 2 -> null; else -> 2.0 })
}
fun fooWithAnuNullableResult(s: String?, name: String, optional: Boolean): Any? {
return if (s == null) {
if (!optional) {
throw java.lang.IllegalArgumentException("Parameter '$name' was not found in the request")
}
null
} else {
name
}
}
fun bar(<!UNUSED_PARAMETER!>a<!>: Unit) {}
fun testStatementInExpressionContext() {
@@ -6,9 +6,13 @@ package kt770_351_735 {
public fun box(): kotlin.Int
public fun doSmth(/*0*/ i: kotlin.Int): kotlin.Unit
public fun foo(): kotlin.Unit
public fun fooWithAnuNullableResult(/*0*/ s: kotlin.String?, /*1*/ name: kotlin.String, /*2*/ optional: kotlin.Boolean): kotlin.Any?
public fun fooWithAnyArg(/*0*/ arg: kotlin.Any): kotlin.Unit
public fun fooWithAnyNullableArg(/*0*/ arg: kotlin.Any?): kotlin.Unit
public fun main(/*0*/ args: kotlin.Array<kotlin.String>): kotlin.Unit
public fun test1(): kotlin.Unit
public fun test2(): kotlin.Unit
public fun testCoercionToAny(): kotlin.Unit
public fun testCoercionToUnit(): kotlin.Unit
public fun testImplicitCoercion(): kotlin.Unit
public fun testStatementInExpressionContext(): kotlin.Unit