Merge remote branch 'origin/master'

This commit is contained in:
Andrey Breslav
2011-12-27 11:46:22 +04:00
27 changed files with 284 additions and 95 deletions
@@ -0,0 +1,76 @@
// FILE: b.kt
// +JDK
package outer
fun Int?.optint() : Unit {}
val Int?.optval : Unit = #()
fun <T, E> T.foo(<!UNUSED_PARAMETER!>x<!> : E, y : A) : T {
y.plus(1)
y plus 1
y + 1.0
this<!UNNECESSARY_SAFE_CALL!>?.<!>minus<T>(this)
return this
}
class A
fun A.plus(<!UNUSED_PARAMETER!>a<!> : Any) {
1.foo()
true.<!NONE_APPLICABLE!>foo<!>()
1
}
fun A.plus(<!UNUSED_PARAMETER!>a<!> : Int) {
1
}
fun <T> T.minus(<!UNUSED_PARAMETER!>t<!> : T) : Int = 1
fun test() {
val <!UNUSED_VARIABLE!>y<!> = 1.abs
}
val Int.abs : Int
get() = if (this > 0) this else -this;
val <T> T.<!MUST_BE_INITIALIZED!>foo<!> : T
fun Int.foo() = this
// FILE: b.kt
package null_safety
import outer.*
fun parse(<!UNUSED_PARAMETER!>cmd<!>: String): Command? { return null }
class Command() {
// fun equals(other : Any?) : Boolean
val foo : Int = 0
}
fun Any.equals(<!UNUSED_PARAMETER!>other<!> : Any?) : Boolean = true
fun Any?.equals1(<!UNUSED_PARAMETER!>other<!> : Any?) : Boolean = true
fun Any.equals2(<!UNUSED_PARAMETER!>other<!> : Any?) : Boolean = true
fun main(args: Array<String>) {
System.out?.print(1)
val command = parse("")
command.foo
command.equals(null)
command?.equals(null)
command.equals1(null)
command<!UNNECESSARY_SAFE_CALL!>?.<!>equals1(null)
val c = Command()
c<!UNNECESSARY_SAFE_CALL!>?.<!>equals2(null)
if (command == null) 1
}
@@ -0,0 +1,21 @@
trait T {
fun foo() {}
fun buzz() {}
fun buzz1(i : Int) {}
}
fun T.bar() {}
fun T.buzz() {}
fun T.buzz1() {}
class C : T {
fun test() {
fun T.buzz() {}
fun T.buzz1() {}
super.foo() // OK
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>.bar() // Error
super.buzz() // OK, resolved to a member
super.buzz1<!NO_VALUE_FOR_PARAMETER!>()<!> // Resolved to a member, but error: no parameter passed where required
}
}
@@ -0,0 +1,34 @@
//+JDK
//KT-819 Redeclaration error for extension properties with the same name and different receivers
import java.io.*
inline val InputStream.buffered : BufferedInputStream
get() = if(this is BufferedInputStream) this else BufferedInputStream(this)
inline val Reader.buffered : BufferedReader
get() = if(this is BufferedReader) this else BufferedReader(this)
//more tests
open class A() {
open fun String.foo() {}
open fun Int.foo() {}
open val String.foo = 0
open val Int.foo = 1
}
class B() : A() {
override fun String.foo() {}
override fun Int.foo() {}
override val String.foo = 0
override val Int.foo = 0
fun use(s: String) {
s.foo
s.foo()
}
}