Do not allow inference of type arguments on the rhs if there's no information available

This commit is contained in:
Andrey Breslav
2013-09-12 21:13:11 +02:00
parent 5c86a5bd7c
commit a9134f8eff
20 changed files with 219 additions and 44 deletions
@@ -0,0 +1,8 @@
trait Tr
trait G<T>
fun test(tr: Tr) {
val v = tr as <!NO_TYPE_ARGUMENTS_ON_RHS!>G?<!>
// If v is not nullable, there will be a warning on this line:
v!!: G<*>
}
@@ -0,0 +1,6 @@
class G<T>
fun foo(p: <!UNRESOLVED_REFERENCE!>P<!>) {
val v = <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>p<!> <!USELESS_CAST!>as<!> <!NO_TYPE_ARGUMENTS_ON_RHS!>G?<!>
v!!: G<*>
}
@@ -0,0 +1,7 @@
trait Tr
trait G<T>
fun test(tr: Tr?) {
val v = tr as <!NO_TYPE_ARGUMENTS_ON_RHS!>G<!>
v: G<*>
}
@@ -0,0 +1,8 @@
trait Tr<T>
trait G<T> : Tr<T>
fun test(tr: Tr<String>?) {
val v = tr as G?
// If v is not nullable, there will be a warning on this line:
v!!: G<String>
}
@@ -0,0 +1,7 @@
trait Tr
trait G<T>
fun test(tr: Tr?) {
val v = tr as <!NO_TYPE_ARGUMENTS_ON_RHS!>G?<!>
v!!: G<*>
}
@@ -2,6 +2,6 @@ trait Tr
trait G<T>
fun test(tr: Tr) {
val v = tr as G
val v = tr as <!NO_TYPE_ARGUMENTS_ON_RHS!>G<!>
v: G<*>
}
}
@@ -1,4 +1,4 @@
trait Tr
trait G<T>
fun test(tr: Tr) = tr is G
fun test(tr: Tr) = tr is <!NO_TYPE_ARGUMENTS_ON_RHS!>G<!>
@@ -2,15 +2,13 @@ package p
public fun foo(a: Any) {
a is Map<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>
a is <!NO_TYPE_ARGUMENTS_ON_RHS_OF_IS_EXPRESSION!>Map<!>
a is <!NO_TYPE_ARGUMENTS_ON_RHS!>Map<!>
a is Map<out Any?, Any?>
a is Map<*, *>
a is Map<<!SYNTAX!><!>>
a is List<<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Map<!>>
a is <!NO_TYPE_ARGUMENTS_ON_RHS_OF_IS_EXPRESSION!>List<!>
a is <!NO_TYPE_ARGUMENTS_ON_RHS!>List<!>
a is Int
(a <!USELESS_CAST!>as<!> <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Map<!>) is Int
}
(a as <!NO_TYPE_ARGUMENTS_ON_RHS!>Map<!>) is <!INCOMPATIBLE_TYPES!>Int<!>
}
@@ -1,12 +1,12 @@
public fun foo(a: Any, <!UNUSED_PARAMETER!>b<!>: <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Map<!>) {
when (a) {
is Map<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!> -> {}
is <!NO_TYPE_ARGUMENTS_ON_RHS_OF_IS_EXPRESSION!>Map<!> -> {}
is <!NO_TYPE_ARGUMENTS_ON_RHS!>Map<!> -> {}
is Map<out Any?, Any?> -> {}
is Map<*, *> -> {}
is Map<<!SYNTAX!><!>> -> {}
is List<<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Map<!>> -> {}
is <!NO_TYPE_ARGUMENTS_ON_RHS_OF_IS_EXPRESSION!>List<!> -> {}
is <!NO_TYPE_ARGUMENTS_ON_RHS!>List<!> -> {}
is Int -> {}
else -> {}
}