Implemented missed checks for local functions #KT-10449 Fixed

Relevant code/test fixes
This commit is contained in:
Mikhail Glukhikh
2015-12-23 11:35:25 +03:00
parent 15746cbf56
commit 99a32b93fb
14 changed files with 58 additions and 38 deletions
@@ -1,5 +1,5 @@
fun testInvoke() {
operator fun Nothing.invoke() = this
operator fun Nothing.invoke(): Nothing = this
todo()<!UNREACHABLE_CODE!>()<!>
}
@@ -8,5 +8,8 @@ interface A3<K, <!BOUNDS_NOT_ALLOWED_IF_BOUNDED_BY_TYPE_PARAMETER!>V<!>> where V
interface A4<<!BOUNDS_NOT_ALLOWED_IF_BOUNDED_BY_TYPE_PARAMETER!>K<!>, V> where K : I1, K : I2, K : C, K : V, V : I2, V : I1
fun <K, V> f1() where V : K, V : <!REPEATED_BOUND!>K<!> {}
fun <K, V, W> f2() where W : K, W : <!BOUNDS_NOT_ALLOWED_IF_BOUNDED_BY_TYPE_PARAMETER!>V<!> {}
fun <K, V, W> f2() where W : K, W : <!BOUNDS_NOT_ALLOWED_IF_BOUNDED_BY_TYPE_PARAMETER!>V<!> {
fun <T> f3() where T : K, T : <!BOUNDS_NOT_ALLOWED_IF_BOUNDED_BY_TYPE_PARAMETER!>V<!> {}
fun <T> f4() where T : K, T : <!REPEATED_BOUND!>K<!> {}
}
fun <K, V, <!BOUNDS_NOT_ALLOWED_IF_BOUNDED_BY_TYPE_PARAMETER!>W<!>> f3() where W : K, W : V, W : Any {}
@@ -19,5 +19,7 @@ class My(b: B) {
fun bar(b: B): String {
// Ok: local variable
val tmp = if (b is A && b is C) b else null
// Error: local function
fun <!IMPLICIT_INTERSECTION_TYPE!>foo<!>(b: B) = if (b is A && b is C) b else null
return tmp.toString()
}
+1 -1
View File
@@ -12,7 +12,7 @@ val y: Nothing = throw Exception()
fun check() {
// Error: KT-10449
fun local() = bar()
fun <!IMPLICIT_NOTHING_RETURN_TYPE!>local<!>() = bar()
// Unreachable / unused, but not implicit Nothing
<!UNREACHABLE_CODE!>val <!UNUSED_VARIABLE!>x<!> =<!> null!!
}
@@ -1,2 +1,3 @@
fun foo<!DEPRECATED_TYPE_PARAMETER_SYNTAX!><T><!>() {
fun bar<!DEPRECATED_TYPE_PARAMETER_SYNTAX!><T><!>() {}
}
@@ -1,5 +1,6 @@
class Foo<<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>T : Cloneable<!>> where T : Comparable<T> {
fun <<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>U : Cloneable<!>> foo(u: U): U where U: Comparable<U> {
fun <<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS, BOUNDS_NOT_ALLOWED_IF_BOUNDED_BY_TYPE_PARAMETER!>T: Any<!>> bar() where T: U {}
return u
}