Updated "Autocasts" test data in JetPsiCheckerTest. Replaced types with their FQ names.

This commit is contained in:
Evgeny Gerashchenko
2012-04-04 16:01:36 +04:00
parent 8f6e6065ff
commit c989b2e5ba
+19 -19
View File
@@ -147,78 +147,78 @@ fun f15(a : A?) {
fun getStringLength(obj : Any) : Char? {
if (obj !is String)
return null
return <info descr="Automatically cast to String">obj</info>.get(0) // no cast to String is needed
return <info descr="Automatically cast to jet.String">obj</info>.get(0) // no cast to jet.String is needed
}
fun toInt(i: Int?): Int = if (i != null) <info descr="Automatically cast to Int">i</info> else 0
fun toInt(i: Int?): Int = if (i != null) <info descr="Automatically cast to jet.Int">i</info> else 0
fun illegalWhenBody(a: Any): Int = when(a) {
is Int -> <info descr="Automatically cast to Int">a</info>
is Int -> <info descr="Automatically cast to jet.Int">a</info>
is String -> <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any but Int was expected">a</error>
else -> 1
}
fun illegalWhenBlock(a: Any): Int {
when(a) {
is Int -> return <info descr="Automatically cast to Int">a</info>
is Int -> return <info descr="Automatically cast to jet.Int">a</info>
is String -> return <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any but Int was expected">a</error>
else -> return 1
}
}
fun declarations(a: Any?) {
if (a is String) {
val <warning>p4</warning>: #(Int, String) = #(2, <info descr="Automatically cast to String">a</info>)
val <warning>p4</warning>: #(Int, String) = #(2, <info descr="Automatically cast to jet.String">a</info>)
}
if (a is String?) {
if (a != null) {
val <warning>s</warning>: String = <info descr="Automatically cast to String">a</info>
val <warning>s</warning>: String = <info descr="Automatically cast to jet.String">a</info>
}
}
if (a != null) {
if (a is String?) {
val <warning>s</warning>: String = <info descr="Automatically cast to String">a</info>
val <warning>s</warning>: String = <info descr="Automatically cast to jet.String">a</info>
}
}
}
fun vars(a: Any?) {
var <warning>b</warning>: Int = 0
if (a is Int) {
b = <info descr="Automatically cast to Int"><warning>a</warning></info>
b = <info descr="Automatically cast to jet.Int"><warning>a</warning></info>
}
}
fun tuples(a: Any?) {
if (a != null) {
val <warning>s</warning>: #(Any, String) = #(<info descr="Automatically cast to Any">a</info>, <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but String was expected">a</error>)
val <warning>s</warning>: #(Any, String) = #(<info descr="Automatically cast to jet.Any">a</info>, <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but String was expected">a</error>)
}
if (a is String) {
val <warning>s</warning>: #(Any, String) = #(<info descr="Automatically cast to Any">a</info>, <info descr="Automatically cast to String">a</info>)
val <warning>s</warning>: #(Any, String) = #(<info descr="Automatically cast to jet.Any">a</info>, <info descr="Automatically cast to jet.String">a</info>)
}
fun illegalTupleReturnType(): #(Any, String) = #(<error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but Any was expected">a</error>, <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but String was expected">a</error>)
if (a is String) {
fun legalTupleReturnType(): #(Any, String) = #(<info descr="Automatically cast to Any">a</info>, <info descr="Automatically cast to String">a</info>)
fun legalTupleReturnType(): #(Any, String) = #(<info descr="Automatically cast to jet.Any">a</info>, <info descr="Automatically cast to jet.String">a</info>)
}
val <warning>illegalFunctionLiteral</warning>: Function0<Int> = <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Function0<Any?> but Function0<Int> was expected">{ <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but Int was expected">a</error> }</error>
val <warning>illegalReturnValueInFunctionLiteral</warning>: Function0<Int> = { (): Int -> <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but Int was expected">a</error> }
if (a is Int) {
val <warning>legalFunctionLiteral</warning>: Function0<Int> = { <info descr="Automatically cast to Int">a</info> }
val <warning>alsoLegalFunctionLiteral</warning>: Function0<Int> = { (): Int -> <info descr="Automatically cast to Int">a</info> }
val <warning>legalFunctionLiteral</warning>: Function0<Int> = { <info descr="Automatically cast to jet.Int">a</info> }
val <warning>alsoLegalFunctionLiteral</warning>: Function0<Int> = { (): Int -> <info descr="Automatically cast to jet.Int">a</info> }
}
}
fun returnFunctionLiteralBlock(a: Any?): Function0<Int> {
if (a is Int) return { <info descr="Automatically cast to Int">a</info> }
if (a is Int) return { <info descr="Automatically cast to jet.Int">a</info> }
else return { 1 }
}
fun returnFunctionLiteral(a: Any?): Function0<Int> =
if (a is Int) { (): Int -> <info descr="Automatically cast to Int">a</info> }
if (a is Int) { (): Int -> <info descr="Automatically cast to jet.Int">a</info> }
else { () -> 1 }
fun illegalTupleReturnType(a: Any): #(Any, String) = #(a, <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any but String was expected">a</error>)
fun declarationInsidePattern(x: #(Any, Any)): String = when(x) { is #(val a is String, *) -> <info descr="Automatically cast to String">a</info>; else -> "something" }
fun declarationInsidePattern(x: #(Any, Any)): String = when(x) { is #(val a is String, *) -> <info descr="Automatically cast to jet.String">a</info>; else -> "something" }
fun mergeAutocasts(a: Any?) {
if (a is String || a is Int) {
a.<error descr="Unresolved reference: compareTo">compareTo</error>("")
<info descr="Automatically cast to Any">a</info>.toString()
<info descr="Automatically cast to jet.Any">a</info>.toString()
}
if (a is Int || a is String) {
a.<error descr="Unresolved reference: compareTo">compareTo</error>("")
@@ -227,9 +227,9 @@ fun mergeAutocasts(a: Any?) {
is String, is Any -> a.<error descr="Unresolved reference: compareTo">compareTo</error>("")
}
if (a is String && a is Any) {
val <warning>i</warning>: Int = <info descr="Automatically cast to String">a</info>.compareTo("")
val <warning>i</warning>: Int = <info descr="Automatically cast to jet.String">a</info>.compareTo("")
}
if (a is String && <info descr="Automatically cast to String">a</info>.compareTo("") == 0) {}
if (a is String && <info descr="Automatically cast to jet.String">a</info>.compareTo("") == 0) {}
if (a is String || a.<error descr="Unresolved reference: compareTo">compareTo</error>("") == 0) {}
}