Merge remote branch 'origin/master'
Conflicts: idea/src/org/jetbrains/jet/lang/resolve/BindingContext.java idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fun test() {
|
||||
1 : Byte
|
||||
1 : Int
|
||||
<error>1</error> : Double
|
||||
1 <warning>as</warning> Byte
|
||||
1 <warning>as</warning> Int
|
||||
1 <warning>as</warning> Double
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package variance
|
||||
|
||||
abstract class Consumer<in T> {}
|
||||
|
||||
abstract class Producer<out T> {}
|
||||
|
||||
abstract class Usual<T> {}
|
||||
|
||||
fun foo(c: Consumer<Int>, p: Producer<Int>, u: Usual<Int>) {
|
||||
val c1: Consumer<Any> = <error>c</error>
|
||||
val c2: Consumer<Int> = c1
|
||||
|
||||
val p1: Producer<Any> = p
|
||||
val p2: Producer<Int> = <error>p1</error>
|
||||
|
||||
val u1: Usual<Any> = <error>u</error>
|
||||
val u2: Usual<Int> = <error>u1</error>
|
||||
}
|
||||
|
||||
//Arrays copy example
|
||||
class Array<T>(val length : Int) {
|
||||
fun get(index : Int) : T { return null }
|
||||
fun set(index : Int, value : T) { /* ... */ }
|
||||
}
|
||||
|
||||
fun copy1(from : Array<Any>, to : Array<Any>) {}
|
||||
|
||||
fun copy2(from : Array<out Any>, to : Array<in Any>) {}
|
||||
|
||||
fun <T> copy3(from : Array<out T>, to : Array<in T>) {}
|
||||
|
||||
fun copy4(from : Array<out Number>, to : Array<in Int>) {}
|
||||
|
||||
fun f(ints: Array<Int>, any: Array<Any>, numbers: Array<Number>) {
|
||||
copy1<error>(ints, any)</error>
|
||||
copy2(ints, any) //ok
|
||||
copy2<error>(ints, numbers)</error>
|
||||
copy3<Int>(ints, numbers)
|
||||
copy4(ints, numbers) //ok
|
||||
}
|
||||
@@ -231,6 +231,8 @@ fun mergeAutocasts(a: Any?) {
|
||||
if (a is String && a is Any) {
|
||||
val i: Int = <info descr="Automatically cast to String">a</info>.compareTo("")
|
||||
}
|
||||
if (a is String && <info descr="Automatically cast to String">a</info>.compareTo("") == 0) {}
|
||||
if (a is String || a.<error>compareTo</error>("") == 0) {}
|
||||
}
|
||||
|
||||
//mutability
|
||||
|
||||
Reference in New Issue
Block a user