[FIR-TEST] Add new testdata generated after changes in previous commit
This commit is contained in:
@@ -0,0 +1,61 @@
|
|||||||
|
// FILE: b.kt
|
||||||
|
package MyPackage
|
||||||
|
//properties
|
||||||
|
val a: Int
|
||||||
|
val a1: Int = 1
|
||||||
|
abstract val a2: Int
|
||||||
|
abstract val a3: Int = 1
|
||||||
|
|
||||||
|
var b: Int private set
|
||||||
|
var b1: Int = 0; private set
|
||||||
|
abstract var b2: Int private set
|
||||||
|
abstract var b3: Int = 0; private set
|
||||||
|
|
||||||
|
var c: Int set(v: Int) { field = v }
|
||||||
|
var c1: Int = 0; set(v: Int) { field = v }
|
||||||
|
abstract var c2: Int set(v: Int) { field = v }
|
||||||
|
abstract var c3: Int = 0; set(v: Int) { field = v }
|
||||||
|
|
||||||
|
val e: Int get() = a
|
||||||
|
val e1: Int = 0; get() = a
|
||||||
|
abstract val e2: Int get() = a
|
||||||
|
abstract val e3: Int = 0; get() = a
|
||||||
|
|
||||||
|
//methods
|
||||||
|
fun f()
|
||||||
|
fun g() {}
|
||||||
|
abstract fun h()
|
||||||
|
abstract fun j() {}
|
||||||
|
|
||||||
|
//property accessors
|
||||||
|
var i: Int abstract get abstract set
|
||||||
|
var i1: Int = 0; abstract get abstract set
|
||||||
|
|
||||||
|
var j: Int get() = i; abstract set
|
||||||
|
var j1: Int = 0; get() = i; abstract set
|
||||||
|
|
||||||
|
var k: Int abstract set
|
||||||
|
var k1: Int = 0; abstract set
|
||||||
|
|
||||||
|
var l: Int abstract get abstract set
|
||||||
|
var l1: Int = 0; abstract get abstract set
|
||||||
|
|
||||||
|
var n: Int abstract get abstract set(v: Int) {}
|
||||||
|
|
||||||
|
// FILE: c.kt
|
||||||
|
//creating an instance
|
||||||
|
abstract class B1(
|
||||||
|
val i: Int,
|
||||||
|
val s: String
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
class B2() : B1(1, "r") {}
|
||||||
|
|
||||||
|
abstract class B3(i: Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo(c: B3) {
|
||||||
|
val a = B3(1)
|
||||||
|
val b = B1(2, "s")
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
abstract class My {
|
||||||
|
abstract var x: Int
|
||||||
|
public get
|
||||||
|
private set
|
||||||
|
|
||||||
|
abstract val y: Int
|
||||||
|
protected get
|
||||||
|
|
||||||
|
abstract protected var z: Int
|
||||||
|
internal get
|
||||||
|
private set
|
||||||
|
|
||||||
|
abstract internal val w: Int
|
||||||
|
protected get
|
||||||
|
|
||||||
|
abstract var u: Int
|
||||||
|
protected set
|
||||||
|
|
||||||
|
open var t: Int = 0
|
||||||
|
private set
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package abstract
|
||||||
|
|
||||||
|
abstract class MyAbstractClass() {
|
||||||
|
//properties
|
||||||
|
val a: Int
|
||||||
|
val a1: Int = 1
|
||||||
|
abstract val a2: Int
|
||||||
|
abstract val a3: Int = 1
|
||||||
|
|
||||||
|
var b: Int private set
|
||||||
|
var b1: Int = 0; private set
|
||||||
|
abstract var b2: Int private set
|
||||||
|
abstract var b3: Int = 0; private set
|
||||||
|
|
||||||
|
var c: Int set(v: Int) { field = v }
|
||||||
|
var c1: Int = 0; set(v: Int) { field = v }
|
||||||
|
abstract var c2: Int set(v: Int) { field = v }
|
||||||
|
abstract var c3: Int = 0; set(v: Int) { field = v }
|
||||||
|
|
||||||
|
val e: Int get() = a
|
||||||
|
val e1: Int = 0; get() = a
|
||||||
|
abstract val e2: Int get() = a
|
||||||
|
abstract val e3: Int = 0; get() = a
|
||||||
|
|
||||||
|
//methods
|
||||||
|
fun f()
|
||||||
|
fun g() {}
|
||||||
|
abstract fun h()
|
||||||
|
abstract fun j() {}
|
||||||
|
|
||||||
|
//property accessors
|
||||||
|
var i: Int abstract get abstract set
|
||||||
|
var i1: Int = 0; abstract get abstract set
|
||||||
|
|
||||||
|
var j: Int get() = i; abstract set
|
||||||
|
var j1: Int get() = i; abstract set
|
||||||
|
|
||||||
|
var k: Int abstract set
|
||||||
|
var k1: Int = 0; abstract set
|
||||||
|
|
||||||
|
var l: Int abstract get abstract set
|
||||||
|
var l1: Int = 0; abstract get abstract set
|
||||||
|
|
||||||
|
var n: Int abstract get abstract set(v: Int) {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package abstract
|
||||||
|
|
||||||
|
class MyClass() {
|
||||||
|
//properties
|
||||||
|
val a: Int
|
||||||
|
val a1: Int = 1
|
||||||
|
abstract val a2: Int
|
||||||
|
abstract val a3: Int = 1
|
||||||
|
|
||||||
|
var b: Int private set
|
||||||
|
var b1: Int = 0; private set
|
||||||
|
abstract var b2: Int private set
|
||||||
|
abstract var b3: Int = 0; private set
|
||||||
|
|
||||||
|
var c: Int set(v: Int) { field = v }
|
||||||
|
var c1: Int = 0; set(v: Int) { field = v }
|
||||||
|
abstract var c2: Int set(v: Int) { field = v }
|
||||||
|
abstract var c3: Int = 0; set(v: Int) { field = v }
|
||||||
|
|
||||||
|
val e: Int get() = a
|
||||||
|
val e1: Int = 0; get() = a
|
||||||
|
abstract val e2: Int get() = a
|
||||||
|
abstract val e3: Int = 0; get() = a
|
||||||
|
|
||||||
|
//methods
|
||||||
|
fun f()
|
||||||
|
fun g() {}
|
||||||
|
abstract fun h()
|
||||||
|
abstract fun j() {}
|
||||||
|
|
||||||
|
//property accessors
|
||||||
|
var i: Int abstract get abstract set
|
||||||
|
var i1: Int = 0; abstract get abstract set
|
||||||
|
|
||||||
|
var j: Int get() = i; abstract set
|
||||||
|
var j1: Int = 0; get() = i; abstract set
|
||||||
|
|
||||||
|
var k: Int abstract set
|
||||||
|
var k1: Int = 0; abstract set
|
||||||
|
|
||||||
|
var l: Int abstract get abstract set
|
||||||
|
var l1: Int = 0; abstract get abstract set
|
||||||
|
|
||||||
|
var n: Int abstract get abstract set(v: Int) {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package abstract
|
||||||
|
|
||||||
|
interface MyTrait {
|
||||||
|
//properties
|
||||||
|
val a: Int
|
||||||
|
val a1: Int = 1
|
||||||
|
abstract val a2: Int
|
||||||
|
abstract val a3: Int = 1
|
||||||
|
|
||||||
|
var b: Int private set
|
||||||
|
var b1: Int = 0; private set
|
||||||
|
abstract var b2: Int private set
|
||||||
|
abstract var b3: Int = 0; private set
|
||||||
|
|
||||||
|
var c: Int set(v: Int) { field = v }
|
||||||
|
var c1: Int = 0; set(v: Int) { field = v }
|
||||||
|
abstract var c2: Int set(v: Int) { field = v }
|
||||||
|
abstract var c3: Int = 0; set(v: Int) { field = v }
|
||||||
|
|
||||||
|
val e: Int get() = a
|
||||||
|
val e1: Int = 0; get() = a
|
||||||
|
abstract val e2: Int get() = a
|
||||||
|
abstract val e3: Int = 0; get() = a
|
||||||
|
|
||||||
|
//methods
|
||||||
|
fun f()
|
||||||
|
fun g() {}
|
||||||
|
abstract fun h()
|
||||||
|
abstract fun j() {}
|
||||||
|
|
||||||
|
//property accessors
|
||||||
|
var i: Int abstract get abstract set
|
||||||
|
var i1: Int = 0; abstract get abstract set
|
||||||
|
|
||||||
|
var j: Int get() = i; abstract set
|
||||||
|
var j1: Int = 0; get() = i; abstract set
|
||||||
|
|
||||||
|
var k: Int abstract set
|
||||||
|
var k1: Int = 0; abstract set
|
||||||
|
|
||||||
|
var l: Int abstract get abstract set
|
||||||
|
var l1: Int = 0; abstract get abstract set
|
||||||
|
|
||||||
|
var n: Int abstract get abstract set(v: Int) {}
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
// http://youtrack.jetbrains.net/issue/KT-419
|
||||||
|
|
||||||
|
class A(w: Int) {
|
||||||
|
var c = w
|
||||||
|
|
||||||
|
init {
|
||||||
|
c = 81
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
interface NoC {
|
||||||
|
init {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
val a : Int get() = 1
|
||||||
|
|
||||||
|
init {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class WithC() {
|
||||||
|
val x : Int = 1
|
||||||
|
init {
|
||||||
|
val b = x
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
val a : Int get() = 1
|
||||||
|
|
||||||
|
init {
|
||||||
|
val z = b
|
||||||
|
val zz = x
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
fun getArray(): Array<Int> = throw Exception()
|
||||||
|
fun getList(): MutableList<Int> = throw Exception()
|
||||||
|
fun fn() {
|
||||||
|
getArray()[1] = 2
|
||||||
|
getList()[1] = 2
|
||||||
|
getArray()[1]++
|
||||||
|
getList()[1]++
|
||||||
|
getArray()[1] += 2
|
||||||
|
getList()[1] += 2
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
fun text() {
|
||||||
|
"direct:a" to "mock:a"
|
||||||
|
"direct:a" on {it.body == "<hello/>"} to "mock:a"
|
||||||
|
"direct:a" on {it -> it.body == "<hello/>"} to "mock:a"
|
||||||
|
bar {1}
|
||||||
|
bar {<!UNRESOLVED_REFERENCE!>it<!> + 1}
|
||||||
|
bar {it, it1 -> it}
|
||||||
|
|
||||||
|
bar1 {1}
|
||||||
|
bar1 {it + 1}
|
||||||
|
|
||||||
|
bar2 {}
|
||||||
|
bar2 {1}
|
||||||
|
bar2 {<!UNRESOLVED_REFERENCE!>it<!>}
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>bar2<!> {it -> it}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(f : (Int, Int) -> Int) {}
|
||||||
|
fun bar1(f : (Int) -> Int) {}
|
||||||
|
fun bar2(f : () -> Int) {}
|
||||||
|
|
||||||
|
infix fun String.to(dest : String) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
infix fun String.on(predicate : (s : URI) -> Boolean) : URI {
|
||||||
|
return URI(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
class URI(val body : Any) {
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun to(dest : String) {}<!>
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER
|
||||||
|
// TODO Uncomment all the examples when there will be no problems with light classes
|
||||||
|
//package `foo.bar`
|
||||||
|
|
||||||
|
// TODO: Uncomment after fixing KT-9416
|
||||||
|
//import kotlin.Deprecated as `deprecate\entity`
|
||||||
|
|
||||||
|
//@`deprecate\entity`("") data class Pair(val x: Int, val y: Int)
|
||||||
|
|
||||||
|
// Names should not contains characters: '.', ';', '[', ']', '/', '<', '>', ':', '\\'
|
||||||
|
//class `class.name`
|
||||||
|
class `class;name`
|
||||||
|
class `class[name`
|
||||||
|
class `class]name`
|
||||||
|
//class `class/name`
|
||||||
|
class `class<name`
|
||||||
|
class `class>name`
|
||||||
|
class `class:name`
|
||||||
|
class `class\name`
|
||||||
|
|
||||||
|
class ` ` {}
|
||||||
|
class ` `
|
||||||
|
|
||||||
|
//val `val.X` = 10
|
||||||
|
val `val;X` = 10
|
||||||
|
val `val[X` = 10
|
||||||
|
val `val]X` = 10
|
||||||
|
//val `val/X` = 10
|
||||||
|
val `val<X` = 10
|
||||||
|
val `val>X` = 10
|
||||||
|
val `val:X` = 10
|
||||||
|
val `val\X` = 10
|
||||||
|
|
||||||
|
val `;` = 1
|
||||||
|
val `[` = 2
|
||||||
|
val `]` = 3
|
||||||
|
val `<` = 4
|
||||||
|
|
||||||
|
val `>` = 5
|
||||||
|
val `:` = 6
|
||||||
|
val `\` = 7
|
||||||
|
val `<>` = 8
|
||||||
|
|
||||||
|
val `[]` = 9
|
||||||
|
val `[;]` = 10
|
||||||
|
|
||||||
|
// TODO Uncomment when there will be no problems with light classes (Error: Invalid formal type parameter (must be a valid Java identifier))
|
||||||
|
//class AWithTypeParameter<`T:K`> {}
|
||||||
|
//fun <`T/K`> genericFun(x: `T/K`) {}
|
||||||
|
|
||||||
|
class B(val `a:b`: Int, val `c:d`: Int)
|
||||||
|
|
||||||
|
val ff: (`x:X`: Int) -> Unit = {}
|
||||||
|
val fg: ((`x:X`: Int) -> Unit) -> Unit = {}
|
||||||
|
val fh: ((Int) -> ((`x:X`: Int) -> Unit) -> Unit) = {{}}
|
||||||
|
|
||||||
|
fun f(x: Int, g: (Int) -> Unit) = g(x)
|
||||||
|
|
||||||
|
data class Data(val x: Int, val y: Int)
|
||||||
|
|
||||||
|
class A() {
|
||||||
|
init {
|
||||||
|
val `a:b` = 10
|
||||||
|
}
|
||||||
|
|
||||||
|
fun g(`x:y`: Int) {
|
||||||
|
val `s:` = 30
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun `foo:bar`(`\arg`: Int): Int {
|
||||||
|
val (`a:b`, c) = Data(10, 20)
|
||||||
|
val `a\b` = 10
|
||||||
|
|
||||||
|
fun localFun() {}
|
||||||
|
|
||||||
|
for (`x/y` in 0..10) {
|
||||||
|
}
|
||||||
|
|
||||||
|
f(10) {
|
||||||
|
`x:z`: Int -> localFun()
|
||||||
|
}
|
||||||
|
|
||||||
|
f(20, fun(`x:z`: Int): Unit {})
|
||||||
|
|
||||||
|
try {
|
||||||
|
val `a:` = 10
|
||||||
|
}
|
||||||
|
catch (`e:a`: Exception) {
|
||||||
|
val `b:` = 20
|
||||||
|
}
|
||||||
|
|
||||||
|
return `\arg`
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
fun foo(u : Unit) : Int = 1
|
||||||
|
|
||||||
|
fun test() : Int {
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>foo<!>(1)
|
||||||
|
val a : () -> Unit = {
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>foo<!>(1)
|
||||||
|
}
|
||||||
|
return 1 - "1"
|
||||||
|
}
|
||||||
|
|
||||||
|
class A() {
|
||||||
|
val x : Int = <!INAPPLICABLE_CANDIDATE!>foo1<!>(<!UNRESOLVED_REFERENCE!>xx<!>)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo1() {}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
class A() {
|
||||||
|
override fun equals(other : Any?) : Boolean = false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f(): Unit {
|
||||||
|
var x: Int? = 1
|
||||||
|
x = null
|
||||||
|
x + 1
|
||||||
|
x plus 1
|
||||||
|
x < 1
|
||||||
|
x += 1
|
||||||
|
|
||||||
|
x == 1
|
||||||
|
x != 1
|
||||||
|
|
||||||
|
A() == 1
|
||||||
|
|
||||||
|
x === "1"
|
||||||
|
x !== "1"
|
||||||
|
|
||||||
|
x === 1
|
||||||
|
x !== 1
|
||||||
|
|
||||||
|
x<!UNRESOLVED_REFERENCE!>..<!>2
|
||||||
|
x in 1..2
|
||||||
|
|
||||||
|
val y : Boolean? = true
|
||||||
|
false || y
|
||||||
|
y && true
|
||||||
|
y && 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
// FILE: a.kt
|
||||||
|
package boundsWithSubstitutors
|
||||||
|
open class A<T>
|
||||||
|
class B<X : A<X>>()
|
||||||
|
|
||||||
|
class C : A<C>()
|
||||||
|
|
||||||
|
val a = B<C>()
|
||||||
|
val a1 = B<Int>()
|
||||||
|
|
||||||
|
class X<A, B : A>()
|
||||||
|
|
||||||
|
val b = X<Any, X<A<C>, C>>()
|
||||||
|
val b0 = X<Any, Any?>()
|
||||||
|
val b1 = X<Any, X<A<C>, String>>()
|
||||||
|
|
||||||
|
// FILE: b.kt
|
||||||
|
open class A {}
|
||||||
|
open class B<T : A>()
|
||||||
|
|
||||||
|
class Pair<A, B>
|
||||||
|
|
||||||
|
abstract class C<T : B<Int>, X : (B<Char>) -> Pair<B<Any>, B<A>>>() : B<Any>() { // 2 errors
|
||||||
|
val a = B<Char>() // error
|
||||||
|
|
||||||
|
abstract val x : (B<Char>) -> B<Any>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
foo<Int?>()
|
||||||
|
foo<Int>()
|
||||||
|
bar<Int?>()
|
||||||
|
bar<Int>()
|
||||||
|
bar<Double?>()
|
||||||
|
bar<Double>()
|
||||||
|
1.<!INAPPLICABLE_CANDIDATE!>buzz<!><Double>()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T : Any> foo() {}
|
||||||
|
fun <T : Int?> bar() {}
|
||||||
|
fun <T : Int> Int.buzz() : Unit {}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
class C {
|
||||||
|
|
||||||
|
fun f (a : Boolean, b : Boolean) {
|
||||||
|
b@ while (true)
|
||||||
|
a@ {
|
||||||
|
break@f
|
||||||
|
break
|
||||||
|
break@b
|
||||||
|
break@a
|
||||||
|
}
|
||||||
|
|
||||||
|
continue
|
||||||
|
|
||||||
|
b@ while (true)
|
||||||
|
a@ {
|
||||||
|
continue@f
|
||||||
|
continue
|
||||||
|
continue@b
|
||||||
|
continue@a
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
|
||||||
|
continue@f
|
||||||
|
break@f
|
||||||
|
}
|
||||||
|
|
||||||
|
fun containsBreak(a: String?, b: String?) {
|
||||||
|
while (a == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
a.<!INAPPLICABLE_CANDIDATE!>compareTo<!>("2")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun notContainsBreak(a: String?, b: String?) {
|
||||||
|
while (a == null) {
|
||||||
|
while (b == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a.<!INAPPLICABLE_CANDIDATE!>compareTo<!>("2")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun containsBreakWithLabel(a: String?) {
|
||||||
|
loop@ while(a == null) {
|
||||||
|
break@loop
|
||||||
|
}
|
||||||
|
a?.compareTo("2")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun containsIllegalBreak(a: String?) {
|
||||||
|
loop@ while(a == null) {
|
||||||
|
break@label
|
||||||
|
}
|
||||||
|
a.<!INAPPLICABLE_CANDIDATE!>compareTo<!>("2")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun containsBreakToOuterLoop(a: String?, b: String?) {
|
||||||
|
loop@ while(b == null) {
|
||||||
|
while(a == null) {
|
||||||
|
break@loop
|
||||||
|
}
|
||||||
|
a.<!INAPPLICABLE_CANDIDATE!>compareTo<!>("2")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun containsBreakInsideLoopWithLabel(a: String?, array: Array<Int>) {
|
||||||
|
l@ while(a == null) {
|
||||||
|
for (el in array) {
|
||||||
|
break@l
|
||||||
|
}
|
||||||
|
}
|
||||||
|
a.<!INAPPLICABLE_CANDIDATE!>compareTo<!>("2")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun unresolvedBreak(a: String?, array: Array<Int>) {
|
||||||
|
while(a == null) {
|
||||||
|
l@ for (el in array) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if (true) break else break@l
|
||||||
|
}
|
||||||
|
a.<!INAPPLICABLE_CANDIDATE!>compareTo<!>("2")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun twoLabelsOnLoop() {
|
||||||
|
label1@ label2@ for (i in 1..100) {
|
||||||
|
if (i > 0) {
|
||||||
|
break@label1
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
break@label2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
// !LANGUAGE: +AllowBreakAndContinueInsideWhen
|
||||||
|
|
||||||
|
fun breakContinueInWhen(i: Int) {
|
||||||
|
for (y in 0..10) {
|
||||||
|
when(i) {
|
||||||
|
0 -> continue
|
||||||
|
1 -> break
|
||||||
|
2 -> {
|
||||||
|
for(z in 0..10) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
for(w in 0..10) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun breakContinueInWhenWithWhile(i: Int, j: Int) {
|
||||||
|
while (i > 0) {
|
||||||
|
when (i) {
|
||||||
|
0 -> continue
|
||||||
|
1 -> break
|
||||||
|
2 -> {
|
||||||
|
while (j > 0) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun breakContinueInWhenWithDoWhile(i: Int, j: Int) {
|
||||||
|
do {
|
||||||
|
when (i) {
|
||||||
|
0 -> continue
|
||||||
|
1 -> break
|
||||||
|
2 -> {
|
||||||
|
do {
|
||||||
|
if (j == 5) break
|
||||||
|
if (j == 10) continue
|
||||||
|
} while (j > 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (i > 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun labeledBreakContinue(i: Int) {
|
||||||
|
outer@ for (y in 0..10) {
|
||||||
|
when (i) {
|
||||||
|
0 -> continue@outer
|
||||||
|
1 -> break@outer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testBreakContinueInWhenInWhileCondition() {
|
||||||
|
var i = 0
|
||||||
|
while (
|
||||||
|
when (i) {
|
||||||
|
1 -> break
|
||||||
|
2 -> continue
|
||||||
|
else -> true
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
++i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testBreakContinueInWhenInDoWhileCondition() {
|
||||||
|
var i = 0
|
||||||
|
do {
|
||||||
|
++i
|
||||||
|
} while (
|
||||||
|
when (i) {
|
||||||
|
1 -> break
|
||||||
|
2 -> continue
|
||||||
|
else -> true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testBreakContinueInWhenInForIteratorExpression(xs: List<Any>, i: Int) {
|
||||||
|
for (x in when (i) {
|
||||||
|
1 -> break
|
||||||
|
2 -> continue
|
||||||
|
else -> xs
|
||||||
|
}) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
// !LANGUAGE: -AllowBreakAndContinueInsideWhen
|
||||||
|
|
||||||
|
fun breakContinueInWhen(i: Int) {
|
||||||
|
for (y in 0..10) {
|
||||||
|
when(i) {
|
||||||
|
0 -> continue
|
||||||
|
1 -> break
|
||||||
|
2 -> {
|
||||||
|
for(z in 0..10) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
for(w in 0..10) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun breakContinueInWhenWithWhile(i: Int, j: Int) {
|
||||||
|
while (i > 0) {
|
||||||
|
when (i) {
|
||||||
|
0 -> continue
|
||||||
|
1 -> break
|
||||||
|
2 -> {
|
||||||
|
while (j > 0) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun breakContinueInWhenWithDoWhile(i: Int, j: Int) {
|
||||||
|
do {
|
||||||
|
when (i) {
|
||||||
|
0 -> continue
|
||||||
|
1 -> break
|
||||||
|
2 -> {
|
||||||
|
do {
|
||||||
|
if (j == 5) break
|
||||||
|
if (j == 10) continue
|
||||||
|
} while (j > 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (i > 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun labeledBreakContinue(i: Int) {
|
||||||
|
outer@ for (y in 0..10) {
|
||||||
|
when (i) {
|
||||||
|
0 -> continue@outer
|
||||||
|
1 -> break@outer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+159
@@ -0,0 +1,159 @@
|
|||||||
|
// FILE: a.kt
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an example of a Type-Safe Groovy-style Builder
|
||||||
|
*
|
||||||
|
* Builders are good for declaratively describing data in your code.
|
||||||
|
* In this example we show how to describe an HTML page in Kotlin.
|
||||||
|
*
|
||||||
|
* See this page for details:
|
||||||
|
* http://confluence.jetbrains.net/display/Kotlin/Type-safe+Groovy-style+builders
|
||||||
|
*/
|
||||||
|
package html
|
||||||
|
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
fun main(args : Array<String>) {
|
||||||
|
val result =
|
||||||
|
html {
|
||||||
|
head {
|
||||||
|
title {+"XML encoding with Kotlin"}
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
h1 {+"XML encoding with Kotlin"}
|
||||||
|
p {+"this format can be used as an alternative markup to XML"}
|
||||||
|
|
||||||
|
// an element with attributes and text content
|
||||||
|
a(href = "https://jetbrains.com/kotlin") {+"Kotlin"}
|
||||||
|
|
||||||
|
// mixed content
|
||||||
|
p {
|
||||||
|
+"This is some"
|
||||||
|
b {+"mixed"}
|
||||||
|
+"text. For more see the"
|
||||||
|
a(href = "https://jetbrains.com/kotlin") {+"Kotlin"}
|
||||||
|
+"project"
|
||||||
|
}
|
||||||
|
p {+"some text"}
|
||||||
|
|
||||||
|
// content generated from command-line arguments
|
||||||
|
p {
|
||||||
|
+"Command line arguments were:"
|
||||||
|
ul {
|
||||||
|
for (arg in args)
|
||||||
|
li {+arg}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println(result)
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class Element {
|
||||||
|
abstract fun render(builder : StringBuilder, indent : String)
|
||||||
|
|
||||||
|
override fun toString() : String {
|
||||||
|
val builder = StringBuilder()
|
||||||
|
render(builder, "")
|
||||||
|
return builder.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TextElement(val text : String) : Element() {
|
||||||
|
override fun render(builder : StringBuilder, indent : String) {
|
||||||
|
builder.append("$indent$text\n")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class Tag(val name : String) : Element() {
|
||||||
|
val children = ArrayList<Element>()
|
||||||
|
val attributes = HashMap<String, String>()
|
||||||
|
|
||||||
|
protected fun <T : Element> initTag(tag : T, init : T.() -> Unit) : T {
|
||||||
|
tag.<!UNRESOLVED_REFERENCE!>init<!>()
|
||||||
|
children.add(tag)
|
||||||
|
return tag
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun render(builder : StringBuilder, indent : String) {
|
||||||
|
builder.append("$indent<$name${renderAttributes()}>\n")
|
||||||
|
for (c in children) {
|
||||||
|
c.render(builder, indent + " ")
|
||||||
|
}
|
||||||
|
builder.append("$indent</$name>\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun renderAttributes() : String? {
|
||||||
|
val builder = StringBuilder()
|
||||||
|
for (a in attributes.keys) {
|
||||||
|
builder.append(" $a=\"${attributes[a]}\"")
|
||||||
|
}
|
||||||
|
return builder.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class TagWithText(name : String) : Tag(name) {
|
||||||
|
operator fun String.unaryPlus() {
|
||||||
|
children.add(TextElement(this))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class HTML() : TagWithText("html") {
|
||||||
|
fun head(init : Head.() -> Unit) = initTag(Head(), init)
|
||||||
|
|
||||||
|
fun body(init : Body.() -> Unit) = initTag(Body(), init)
|
||||||
|
}
|
||||||
|
|
||||||
|
class Head() : TagWithText("head") {
|
||||||
|
fun title(init : Title.() -> Unit) = initTag(Title(), init)
|
||||||
|
}
|
||||||
|
|
||||||
|
class Title() : TagWithText("title")
|
||||||
|
|
||||||
|
abstract class BodyTag(name : String) : TagWithText(name) {
|
||||||
|
fun b(init : B.() -> Unit) = initTag(B(), init)
|
||||||
|
fun p(init : P.() -> Unit) = initTag(P(), init)
|
||||||
|
fun h1(init : H1.() -> Unit) = initTag(H1(), init)
|
||||||
|
fun ul(init : UL.() -> Unit) = initTag(UL(), init)
|
||||||
|
fun a(href : String, init : A.() -> Unit) {
|
||||||
|
val a = initTag(A(), init)
|
||||||
|
a.href = href
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Body() : BodyTag("body")
|
||||||
|
class UL() : BodyTag("ul") {
|
||||||
|
fun li(init : LI.() -> Unit) = initTag(LI(), init)
|
||||||
|
}
|
||||||
|
|
||||||
|
class B() : BodyTag("b")
|
||||||
|
class LI() : BodyTag("li")
|
||||||
|
class P() : BodyTag("p")
|
||||||
|
class H1() : BodyTag("h1")
|
||||||
|
class A() : BodyTag("a") {
|
||||||
|
public var href : String?
|
||||||
|
get() = attributes["href"]
|
||||||
|
set(value) {
|
||||||
|
if (value != null) {
|
||||||
|
attributes.put("href", value)
|
||||||
|
// attributes["href"] = value //doesn't work: KT-1355
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun html(init : HTML.() -> Unit) : HTML {
|
||||||
|
val html = HTML()
|
||||||
|
html.<!UNRESOLVED_REFERENCE!>init<!>()
|
||||||
|
return html
|
||||||
|
}
|
||||||
|
|
||||||
|
// An excerpt from the Standard Library
|
||||||
|
operator fun <K, V> MutableMap<K, V>.set(key : K, value : V) = this.put(key, value)
|
||||||
|
|
||||||
|
fun println(message : Any?) {
|
||||||
|
System.out.println(message)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun print(message : Any?) {
|
||||||
|
System.out.print(message)
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
|
fun test() : Unit {
|
||||||
|
var x : Int? = 0
|
||||||
|
var y : Int = 0
|
||||||
|
|
||||||
|
checkSubtype<Int?>(x)
|
||||||
|
checkSubtype<Int>(y)
|
||||||
|
checkSubtype<Int>(x as Int)
|
||||||
|
checkSubtype<Int>(y as Int)
|
||||||
|
checkSubtype<Int?>(x as Int?)
|
||||||
|
checkSubtype<Int?>(y as Int?)
|
||||||
|
checkSubtype<Int?>(x as? Int)
|
||||||
|
checkSubtype<Int?>(y as? Int)
|
||||||
|
checkSubtype<Int?>(x as? Int?)
|
||||||
|
checkSubtype<Int?>(y as? Int?)
|
||||||
|
|
||||||
|
val s = "" as Any
|
||||||
|
("" as String?)?.length
|
||||||
|
(data@("" as String?))?.length
|
||||||
|
(@MustBeDocumented()( "" as String?))?.length
|
||||||
|
Unit
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
fun test(c : Char) {
|
||||||
|
test(<!INFERENCE_ERROR!>''<!>)
|
||||||
|
test('a')
|
||||||
|
test(<!INFERENCE_ERROR!>'aa'<!>)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>test<!>(<!INFERENCE_ERROR!>'a)<!>
|
||||||
|
<!UNRESOLVED_REFERENCE!>test<!>(<!INFERENCE_ERROR!>'<!>
|
||||||
|
<!UNRESOLVED_REFERENCE!>test<!>(0<!INFERENCE_ERROR!><!SYNTAX!><!>'<!>
|
||||||
|
<!UNRESOLVED_REFERENCE!>test<!>('\n')
|
||||||
|
<!UNRESOLVED_REFERENCE!>test<!>('\\')
|
||||||
|
<!UNRESOLVED_REFERENCE!>test<!>(<!INFERENCE_ERROR!>''<!><!INFERENCE_ERROR!><!SYNTAX!><!>''<!>)
|
||||||
|
test('\'')
|
||||||
|
test('\"')
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
fun test() {
|
||||||
|
if (<!UNRESOLVED_REFERENCE!>x<!> > 0) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
|
fun varargByte(vararg v: Byte) = v
|
||||||
|
|
||||||
|
fun varargShort(vararg v: Short) = v
|
||||||
|
|
||||||
|
fun varargInt(vararg v: Int) = v
|
||||||
|
|
||||||
|
fun varargLong(vararg v: Long) = v
|
||||||
|
|
||||||
|
fun varargFloat(vararg v: Float) = v
|
||||||
|
|
||||||
|
fun varargDouble(vararg v: Double) = v
|
||||||
|
|
||||||
|
fun <T> testFun(p: T) {}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
checkSubtype<Byte>(1)
|
||||||
|
checkSubtype<Short>(1)
|
||||||
|
checkSubtype<Int>(1)
|
||||||
|
checkSubtype<Long>(1)
|
||||||
|
|
||||||
|
checkSubtype<Long>(0x001)
|
||||||
|
checkSubtype<Int>(0b001)
|
||||||
|
|
||||||
|
checkSubtype<Double>(0.1)
|
||||||
|
checkSubtype<Float>(0.1.toFloat())
|
||||||
|
|
||||||
|
checkSubtype<Double>(1e5)
|
||||||
|
checkSubtype<Float>(1e-5.toFloat())
|
||||||
|
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Double>(1)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Float>(1)
|
||||||
|
|
||||||
|
1 as Byte
|
||||||
|
1 as Int
|
||||||
|
0xff as Long
|
||||||
|
|
||||||
|
1.1 as Int
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Int>(1.1)
|
||||||
|
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>varargByte<!>(0x77, 1, 3, 200, 0b111)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>varargShort<!>(0x777, 1, 2, 3, 200000, 0b111)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>varargInt<!>(0x77777777, 0x7777777777, 1, 2, 3, 2000000000, 0b111)
|
||||||
|
varargLong(0x777777777777, 1, 2, 3, 200000, 0b111)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>varargFloat<!>(1, 1.0, -0.1, 1e4, 1e-4, -1e4)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>varargDouble<!>(1, 1.0, -0.1, 1e4, 1e-4, -1e4)
|
||||||
|
|
||||||
|
testFun(1.0)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>testFun<!><Float>(1.0)
|
||||||
|
testFun(1.0.toFloat())
|
||||||
|
testFun<Float>(1.0.toFloat())
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
open class NoC
|
||||||
|
class NoC1 : NoC
|
||||||
|
|
||||||
|
class WithC0() : NoC()
|
||||||
|
open class WithC1() : NoC
|
||||||
|
class NoC2 : WithC1
|
||||||
|
class NoC3 : WithC1()
|
||||||
|
class WithC2() : WithC1
|
||||||
|
|
||||||
|
class WithPC0() {
|
||||||
|
}
|
||||||
|
|
||||||
|
class WithPC1(a : Int) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class Foo() : WithPC0, <!SYNTAX!>this<!>() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class WithCPI_Dup(x : Int) {
|
||||||
|
var x : Int
|
||||||
|
}
|
||||||
|
|
||||||
|
class WithCPI(x : Int) {
|
||||||
|
val a = 1
|
||||||
|
val xy : Int = x
|
||||||
|
}
|
||||||
|
|
||||||
|
class NoCPI {
|
||||||
|
val a = 1
|
||||||
|
var ab = 1
|
||||||
|
get() = 1
|
||||||
|
set(v) {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
fun test() {
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>Double<!>()
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>Float<!>()
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>Long<!>()
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>Int<!>()
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>Short<!>()
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>Byte<!>()
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>Char<!>()
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>Boolean<!>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
interface A<H> {
|
||||||
|
fun foo() : Int = 1
|
||||||
|
fun foo2() : Int = 1
|
||||||
|
fun foo1() : Int = 1
|
||||||
|
val a : Int
|
||||||
|
val a1 : Int
|
||||||
|
val g : Iterator<H>
|
||||||
|
|
||||||
|
fun <T> g() : T
|
||||||
|
fun <T> g1() : T
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class B<H>() : A<H> {
|
||||||
|
override fun foo() {
|
||||||
|
}
|
||||||
|
override fun foo2() : Unit {
|
||||||
|
}
|
||||||
|
|
||||||
|
override val a : Double = 1.toDouble()
|
||||||
|
override val a1 = 1.toDouble()
|
||||||
|
|
||||||
|
abstract override fun <X> g() : Int
|
||||||
|
abstract override fun <X> g1() : List<X>
|
||||||
|
|
||||||
|
abstract override val g : Iterator<Int>
|
||||||
|
}
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||||
|
|
||||||
|
fun f(x: Int = 0) {}
|
||||||
|
|
||||||
|
val inVal: (x: Int = 0)->Unit = {}
|
||||||
|
|
||||||
|
fun inParam(fn: (x: Int = 0)->Unit) {}
|
||||||
|
|
||||||
|
fun inParamNested(fn1: (fn2: (n: Int = 0)->Unit)->Unit) {}
|
||||||
|
|
||||||
|
fun inReturn(): (x: Int = 0)->Unit = {}
|
||||||
|
|
||||||
|
class A : (Int)->Unit {
|
||||||
|
override fun invoke(p1: Int) {
|
||||||
|
var lambda: (x: Int = 0)->Unit = {}
|
||||||
|
}
|
||||||
|
|
||||||
|
val prop: (x: Int = 0)->Unit
|
||||||
|
get(): (x: Int = 0)->Unit = {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
interface Inter {
|
||||||
|
fun foo(x: Int = <!UNRESOLVED_REFERENCE!>y<!>, y: Int = x)
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class Abst {
|
||||||
|
abstract fun foo(x: Int = <!UNRESOLVED_REFERENCE!>y<!>, y: Int = x)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun extraDiagnostics(x: Int = <!UNRESOLVED_REFERENCE!>y<!>, y: Int)
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
val x = ""
|
||||||
|
|
||||||
|
fun bar(x : Int = "", y : Int = x, z : String = y) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// KT-371 Resolve default parameters for constructors
|
||||||
|
|
||||||
|
class A(x : Int = <!UNRESOLVED_REFERENCE!>y<!>, y : Int = x) { // None of the references is resolved, no types checked
|
||||||
|
fun foo(bool: Boolean, a: Int = <!UNRESOLVED_REFERENCE!>b<!>, b: String = a) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
val z = 3
|
||||||
|
|
||||||
|
fun foo(x: Int = <!UNRESOLVED_REFERENCE!>y<!>, y: Int = x, i : Int = z): Int = x + y
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// NI_EXPECTED_FILE
|
||||||
|
|
||||||
|
interface T {
|
||||||
|
val a = <!UNRESOLVED_REFERENCE!>Foo<!>.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||||
|
}
|
||||||
+53
@@ -0,0 +1,53 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
|
class CustomDelegate {
|
||||||
|
operator fun get(thisRef: Any?, prop: KProperty<*>): String = prop.name
|
||||||
|
operator fun set(thisRef: Any?, prop: KProperty<*>, value: String) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class OkDelegate {
|
||||||
|
operator fun getValue(thisRef: Any?, prop: KProperty<*>): String = prop.name
|
||||||
|
operator fun setValue(thisRef: Any?, prop: KProperty<*>, value: String) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CustomDelegate2 {
|
||||||
|
operator fun get(thisRef: Any?, prop: KProperty<*>): String = prop.name
|
||||||
|
operator fun set(thisRef: Any?, prop: KProperty<*>, value: String) {}
|
||||||
|
|
||||||
|
operator fun getValue(thisRef: Any?, prop: KProperty<*>): Int = 5
|
||||||
|
operator fun setValue(thisRef: Any?, prop: KProperty<*>, value: Int) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CustomDelegate3 {
|
||||||
|
operator fun get(thisRef: Any?, prop: KProperty<*>): String = prop.name
|
||||||
|
operator fun set(thisRef: Any?, prop: KProperty<*>, value: String) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun OkDelegate.get(thisRef: Any?, prop: KProperty<*>): Int = 4
|
||||||
|
operator fun OkDelegate.set(thisRef: Any?, prop: KProperty<*>, value: Int) {}
|
||||||
|
|
||||||
|
operator fun CustomDelegate3.getValue(thisRef: Any?, prop: KProperty<*>): Int = 4
|
||||||
|
operator fun CustomDelegate3.setValue(thisRef: Any?, prop: KProperty<*>, value: Int) {}
|
||||||
|
|
||||||
|
class Example {
|
||||||
|
|
||||||
|
var a by CustomDelegate()
|
||||||
|
val aval by CustomDelegate()
|
||||||
|
var b by OkDelegate()
|
||||||
|
var c by CustomDelegate2()
|
||||||
|
var d by CustomDelegate3()
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
requireString(a)
|
||||||
|
requireString(aval)
|
||||||
|
requireString(b)
|
||||||
|
requireInt(c)
|
||||||
|
requireInt(d)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun requireString(s: String) {}
|
||||||
|
fun requireInt(n: Int) {}
|
||||||
|
|
||||||
|
}
|
||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
class Example {
|
||||||
|
operator fun plus(): String = ""
|
||||||
|
operator fun unaryPlus(): Int = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
class ExampleDeprecated {
|
||||||
|
operator fun plus(): String = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun String.plus(): String = this
|
||||||
|
operator fun String.unaryPlus(): Int = 0
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
requireInt(+ "")
|
||||||
|
requireInt(+ Example())
|
||||||
|
requireString(<!INAPPLICABLE_CANDIDATE!>+<!> ExampleDeprecated())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun requireInt(n: Int) {}
|
||||||
|
fun requireString(s: String) {}
|
||||||
|
|
||||||
|
class Example2 {
|
||||||
|
operator fun plus() = this
|
||||||
|
operator fun minus() = this
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>+<!>this
|
||||||
|
<!UNRESOLVED_REFERENCE!>-<!>this
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
interface Base {
|
||||||
|
fun f() = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Left() : Base
|
||||||
|
|
||||||
|
interface Right : Base
|
||||||
|
|
||||||
|
class Diamond() : Left(), Right
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
interface Base<P> {
|
||||||
|
fun f() = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Left<P>() : Base<P>
|
||||||
|
|
||||||
|
interface Right<P> : Base<P>
|
||||||
|
|
||||||
|
class Diamond<P>() : Left<P>(), Right<P>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
interface Base {
|
||||||
|
var v : Int
|
||||||
|
get() = 1
|
||||||
|
set(v) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Left() : Base
|
||||||
|
|
||||||
|
interface Right : Base
|
||||||
|
|
||||||
|
class Diamond() : Left(), Right
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package dollar
|
||||||
|
|
||||||
|
open class `$$$$$`() {
|
||||||
|
}
|
||||||
|
open class `$`() {
|
||||||
|
}
|
||||||
|
open class `$$`(`$$$$` : `$$$$$`?) : `$`() {
|
||||||
|
val `$$$` : `$$$$$`? = `$$$$`
|
||||||
|
open public fun `$$$$$$`() : `$$$$$`? {
|
||||||
|
return `$$$`
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
enum class Color {
|
||||||
|
RED {
|
||||||
|
fun <T : RED> simpleName(): RED = null!!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyColor(val x: Color.RED, y: Color.RED) : Color.RED {
|
||||||
|
|
||||||
|
var z: Color.RED = Color.RED
|
||||||
|
set(arg: Color.RED) { z = arg }
|
||||||
|
|
||||||
|
fun foo(arg: Color.RED): Color.RED = arg
|
||||||
|
|
||||||
|
fun bar(): Color.RED {
|
||||||
|
class Local : Color.RED
|
||||||
|
fun local(arg: Color.RED): Color.RED = arg
|
||||||
|
val temp: Color.RED = Color.RED
|
||||||
|
temp as? Color.RED
|
||||||
|
if (temp is Color.RED) {
|
||||||
|
return temp as Color.RED
|
||||||
|
}
|
||||||
|
val obj = object : Color.RED {}
|
||||||
|
if (obj is Color.RED) {
|
||||||
|
return obj
|
||||||
|
}
|
||||||
|
return Color.RED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun create(): Array<Color.RED>? = null
|
||||||
|
|
||||||
|
interface Your<T : Color.RED>
|
||||||
|
|
||||||
|
class His : Your<Color.RED>
|
||||||
|
|
||||||
|
fun <T : Color.RED> otherCreate(): Array<T>? = null
|
||||||
|
|
||||||
|
typealias RedAlias = Color.RED
|
||||||
|
|
||||||
|
typealias ArrayOfEnumEntry = Array<Color.RED>
|
||||||
|
|
||||||
|
typealias ArrayOfEnumEntryAlias = Array<RedAlias>
|
||||||
|
|
||||||
|
fun <T> bar(a: Any): T = a as T
|
||||||
|
|
||||||
|
fun <T> foo() {
|
||||||
|
foo<Color.RED>()
|
||||||
|
foo<RedAlias>()
|
||||||
|
bar<Color.RED>(Color.RED)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Array<Color.RED>.foo(entries: Array<Color.RED>): Array<Color.RED> = null!!
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun bar(doIt: Int.() -> Int) {
|
||||||
|
1.<!UNRESOLVED_REFERENCE!>doIt<!>()
|
||||||
|
1?.<!UNRESOLVED_REFERENCE!>doIt<!>()
|
||||||
|
val i: Int? = 1
|
||||||
|
i.<!UNRESOLVED_REFERENCE!>doIt<!>()
|
||||||
|
i?.<!UNRESOLVED_REFERENCE!>doIt<!>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// See KT-13997
|
||||||
|
|
||||||
|
class Foo {
|
||||||
|
var bar: Int // Ok
|
||||||
|
external get
|
||||||
|
external set
|
||||||
|
}
|
||||||
|
|
||||||
|
class Bar {
|
||||||
|
val foo: Int // Ok
|
||||||
|
external get
|
||||||
|
|
||||||
|
var baz: Int
|
||||||
|
external get
|
||||||
|
|
||||||
|
var gav: Int
|
||||||
|
external set
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
abstract class A {
|
||||||
|
abstract val x : Int
|
||||||
|
external get
|
||||||
|
}
|
||||||
|
|
||||||
|
interface B {
|
||||||
|
val x: Int
|
||||||
|
external get
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
class NotRange1() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class NotRange2() {
|
||||||
|
abstract operator fun iterator() : Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class ImproperIterator1 {
|
||||||
|
abstract operator fun hasNext() : Boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class NotRange3() {
|
||||||
|
abstract operator fun iterator() : ImproperIterator1
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class ImproperIterator2 {
|
||||||
|
abstract operator fun next() : Boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class NotRange4() {
|
||||||
|
abstract operator fun iterator() : ImproperIterator2
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class ImproperIterator3 {
|
||||||
|
abstract operator fun hasNext() : Int
|
||||||
|
abstract operator fun next() : Int
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class NotRange5() {
|
||||||
|
abstract operator fun iterator() : ImproperIterator3
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class AmbiguousHasNextIterator {
|
||||||
|
abstract operator fun hasNext() : Boolean
|
||||||
|
val hasNext : Boolean get() = false
|
||||||
|
abstract operator fun next() : Int
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class NotRange6() {
|
||||||
|
abstract operator fun iterator() : AmbiguousHasNextIterator
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class ImproperIterator4 {
|
||||||
|
val hasNext : Int get() = 1
|
||||||
|
abstract operator fun next() : Int
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class NotRange7() {
|
||||||
|
abstract operator fun iterator() : ImproperIterator3
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class GoodIterator {
|
||||||
|
abstract operator fun hasNext() : Boolean
|
||||||
|
abstract operator fun next() : Int
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class Range0() {
|
||||||
|
abstract operator fun iterator() : GoodIterator
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class Range1() {
|
||||||
|
abstract operator fun iterator() : Iterator<Int>
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class ImproperIterator5 {
|
||||||
|
abstract val String.hasNext : Boolean
|
||||||
|
abstract operator fun next() : Int
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class NotRange8() {
|
||||||
|
abstract operator fun iterator() : ImproperIterator5
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun test(notRange1: NotRange1, notRange2: NotRange2, notRange3: NotRange3, notRange4: NotRange4, notRange5: NotRange5, notRange6: NotRange6, notRange7: NotRange7, notRange8: NotRange8, range0: Range0, range1: Range1) {
|
||||||
|
<!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>for (i in notRange1)<!>;
|
||||||
|
<!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>for (i in notRange2)<!>;
|
||||||
|
<!UNRESOLVED_REFERENCE!>for (i in notRange3)<!>;
|
||||||
|
<!UNRESOLVED_REFERENCE!>for (i in notRange4)<!>;
|
||||||
|
for (i in notRange5);
|
||||||
|
for (i in notRange6);
|
||||||
|
for (i in notRange7);
|
||||||
|
<!UNRESOLVED_REFERENCE!>for (i in notRange8)<!>;
|
||||||
|
for (i in range0);
|
||||||
|
for (i in range1);
|
||||||
|
|
||||||
|
for (i in (checkSubtype<List<Int>>(ArrayList<Int>())));
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
fun foo(a: (String) -> Unit) {
|
||||||
|
"".<!UNRESOLVED_REFERENCE!>a<!>()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
interface A : (String) -> Unit {}
|
||||||
|
|
||||||
|
fun foo(a: @ExtensionFunctionType A) {
|
||||||
|
// @Extension annotation on an unrelated type shouldn't have any effect on this diagnostic.
|
||||||
|
// Only kotlin.Function{n} type annotated with @Extension should
|
||||||
|
"".<!UNRESOLVED_REFERENCE!>a<!>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
|
package foo
|
||||||
|
|
||||||
|
fun Any.foo() : () -> Unit {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Any.foo1() : (i : Int) -> Unit {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo2() : (i : () -> Unit) -> Unit {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> fooT1(t : T) : () -> T {
|
||||||
|
return {t}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> fooT2() : (t : T) -> T {
|
||||||
|
return {it}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun main(args : Array<String>) {
|
||||||
|
args.foo()()
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>args.foo1()()<!>
|
||||||
|
<!INAPPLICABLE_CANDIDATE!><!UNRESOLVED_REFERENCE!>a<!>.foo1()()<!>
|
||||||
|
<!UNRESOLVED_REFERENCE!>a<!>.foo1()(<!UNRESOLVED_REFERENCE!>a<!>)
|
||||||
|
|
||||||
|
args.foo1()(1)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>args.foo1()("1")<!>
|
||||||
|
<!INAPPLICABLE_CANDIDATE!><!UNRESOLVED_REFERENCE!>a<!>.foo1()("1")<!>
|
||||||
|
<!UNRESOLVED_REFERENCE!>a<!>.foo1()(<!UNRESOLVED_REFERENCE!>a<!>)
|
||||||
|
|
||||||
|
foo2()({})
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>foo2<!>(){}
|
||||||
|
(foo2()){}
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>(foo2()){x -> }<!>
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>foo2()({x -> })<!>
|
||||||
|
|
||||||
|
val a = fooT1(1)()
|
||||||
|
checkSubtype<Int>(a)
|
||||||
|
|
||||||
|
val b = fooT2<Int>()(1)
|
||||||
|
checkSubtype<Int>(b)
|
||||||
|
fooT2()(1) // : Any?
|
||||||
|
|
||||||
|
<!UNRESOLVED_REFERENCE!>1()<!>
|
||||||
|
<!UNRESOLVED_REFERENCE!>1{}<!>
|
||||||
|
<!UNRESOLVED_REFERENCE!>1(){}<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f() : Int.() -> Unit = {}
|
||||||
|
|
||||||
|
fun main1() {
|
||||||
|
1.<!UNRESOLVED_REFERENCE!>(fun Int.() = 1)()<!>;
|
||||||
|
<!UNRESOLVED_REFERENCE!>{1}()<!>;
|
||||||
|
<!UNRESOLVED_REFERENCE!>(fun (x : Int) = x)(1)<!>
|
||||||
|
1.<!UNRESOLVED_REFERENCE!>(fun Int.(x : Int) = x)(1)<!>;
|
||||||
|
l@<!UNRESOLVED_REFERENCE!>{1}()<!>
|
||||||
|
1.<!UNRESOLVED_REFERENCE!>((fun Int.() = 1))()<!>
|
||||||
|
1.<!UNRESOLVED_REFERENCE!>(f())()<!>
|
||||||
|
1.<!UNRESOLVED_REFERENCE!>if(true){f()}else{f()}()<!>
|
||||||
|
1.<!UNRESOLVED_REFERENCE!>if(true)(fun Int.() {})else{f()}()<!>
|
||||||
|
|
||||||
|
1.<!UNRESOLVED_REFERENCE!>"sdf"()<!>
|
||||||
|
|
||||||
|
1."sdf"
|
||||||
|
1.{}
|
||||||
|
1.if (true) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
<!UNRESOLVED_REFERENCE!>{x : Int -> 1}()<!>;
|
||||||
|
<!UNRESOLVED_REFERENCE!>(fun Int.() = 1)()<!>
|
||||||
|
"sd".<!UNRESOLVED_REFERENCE!>(fun Int.() = 1)()<!>
|
||||||
|
val i : Int? = null
|
||||||
|
i.<!UNRESOLVED_REFERENCE!>(fun Int.() = 1)()<!>;
|
||||||
|
<!UNRESOLVED_REFERENCE!>{}<Int>()<!>
|
||||||
|
1?.<!UNRESOLVED_REFERENCE!>(fun Int.() = 1)()<!>
|
||||||
|
1.<!UNRESOLVED_REFERENCE!>{}()<!>
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER -UNUSED_VARIABLE
|
||||||
|
fun test(a) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class A(a<!SYNTAX!><!>)
|
||||||
|
|
||||||
|
val bar = fun(a){}
|
||||||
|
|
||||||
|
val la = { a -> }
|
||||||
|
val las = { a: Int -> }
|
||||||
@@ -0,0 +1,209 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
// !DIAGNOSTICS: -UNREACHABLE_CODE
|
||||||
|
|
||||||
|
fun none() {}
|
||||||
|
|
||||||
|
fun unitEmptyInfer() {}
|
||||||
|
fun unitEmpty() : Unit {}
|
||||||
|
fun unitEmptyReturn() : Unit {return}
|
||||||
|
fun unitIntReturn() : Unit {return 1}
|
||||||
|
fun unitUnitReturn() : Unit {return Unit}
|
||||||
|
fun test1() : Any = {return}
|
||||||
|
fun test2() : Any = a@ {return@a 1}
|
||||||
|
fun test3() : Any { return }
|
||||||
|
fun test4(): ()-> Unit = { return@test4 }
|
||||||
|
fun test5(): Any = l@{ return@l }
|
||||||
|
fun test6(): Any = {return 1}
|
||||||
|
|
||||||
|
fun bbb() {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo(expr: StringBuilder): Int {
|
||||||
|
val c = 'a'
|
||||||
|
when(c) {
|
||||||
|
0.toChar() -> throw Exception("zero")
|
||||||
|
else -> throw Exception("nonzero" + c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun unitShort() : Unit = Unit
|
||||||
|
fun unitShortConv() : Unit = 1
|
||||||
|
fun unitShortNull() : Unit = null
|
||||||
|
|
||||||
|
fun intEmpty() : Int {}
|
||||||
|
fun intShortInfer() = 1
|
||||||
|
fun intShort() : Int = 1
|
||||||
|
//fun intBlockInfer() {1}
|
||||||
|
fun intBlock() : Int {return 1}
|
||||||
|
fun intBlock1() : Int {1}
|
||||||
|
|
||||||
|
fun intString(): Int = "s"
|
||||||
|
fun intFunctionLiteral(): Int = { 10 }
|
||||||
|
|
||||||
|
fun blockReturnUnitMismatch() : Int {return}
|
||||||
|
fun blockReturnValueTypeMismatch() : Int {return 3.4}
|
||||||
|
fun blockReturnValueTypeMatch() : Int {return 1}
|
||||||
|
fun blockReturnValueTypeMismatchUnit() : Int {return Unit}
|
||||||
|
|
||||||
|
fun blockAndAndMismatch() : Int {
|
||||||
|
true && false
|
||||||
|
}
|
||||||
|
fun blockAndAndMismatch1() : Int {
|
||||||
|
return true && false
|
||||||
|
}
|
||||||
|
fun blockAndAndMismatch2() : Int {
|
||||||
|
(return true) && (return false)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun blockAndAndMismatch3() : Int {
|
||||||
|
true || false
|
||||||
|
}
|
||||||
|
fun blockAndAndMismatch4() : Int {
|
||||||
|
return true || false
|
||||||
|
}
|
||||||
|
fun blockAndAndMismatch5() : Int {
|
||||||
|
(return true) || (return false)
|
||||||
|
}
|
||||||
|
fun blockReturnValueTypeMatch1() : Int {
|
||||||
|
return if (1 > 2) 1.0 else 2.0
|
||||||
|
}
|
||||||
|
fun blockReturnValueTypeMatch2() : Int {
|
||||||
|
return if (1 > 2) 1
|
||||||
|
}
|
||||||
|
fun blockReturnValueTypeMatch3() : Int {
|
||||||
|
return if (1 > 2) else 1
|
||||||
|
}
|
||||||
|
fun blockReturnValueTypeMatch4() : Int {
|
||||||
|
if (1 > 2)
|
||||||
|
return 1.0
|
||||||
|
else return 2.0
|
||||||
|
}
|
||||||
|
fun blockReturnValueTypeMatch5() : Int {
|
||||||
|
if (1 > 2)
|
||||||
|
return 1.0
|
||||||
|
return 2.0
|
||||||
|
}
|
||||||
|
fun blockReturnValueTypeMatch6() : Int {
|
||||||
|
if (1 > 2)
|
||||||
|
else return 1.0
|
||||||
|
return 2.0
|
||||||
|
}
|
||||||
|
fun blockReturnValueTypeMatch7() : Int {
|
||||||
|
if (1 > 2)
|
||||||
|
1.0
|
||||||
|
else 2.0
|
||||||
|
}
|
||||||
|
fun blockReturnValueTypeMatch8() : Int {
|
||||||
|
if (1 > 2)
|
||||||
|
1.0
|
||||||
|
else 2.0
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
fun blockReturnValueTypeMatch9() : Int {
|
||||||
|
if (1 > 2)
|
||||||
|
1.0
|
||||||
|
}
|
||||||
|
fun blockReturnValueTypeMatch10() : Int {
|
||||||
|
return if (1 > 2)
|
||||||
|
1
|
||||||
|
}
|
||||||
|
fun blockReturnValueTypeMatch11() : Int {
|
||||||
|
if (1 > 2)
|
||||||
|
else 1.0
|
||||||
|
}
|
||||||
|
fun blockReturnValueTypeMatch12() : Int {
|
||||||
|
if (1 > 2)
|
||||||
|
return 1
|
||||||
|
else return 1.0
|
||||||
|
}
|
||||||
|
fun blockNoReturnIfValDeclaration(): Int {
|
||||||
|
val x = 1
|
||||||
|
}
|
||||||
|
fun blockNoReturnIfEmptyIf(): Int {
|
||||||
|
if (1 < 2) {} else {}
|
||||||
|
}
|
||||||
|
fun blockNoReturnIfUnitInOneBranch(): Int {
|
||||||
|
if (1 < 2) {
|
||||||
|
return 1
|
||||||
|
} else {
|
||||||
|
if (3 < 4) {
|
||||||
|
} else {
|
||||||
|
return 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fun nonBlockReturnIfEmptyIf(): Int = if (1 < 2) {} else {}
|
||||||
|
fun nonBlockNoReturnIfUnitInOneBranch(): Int = if (1 < 2) {} else 2
|
||||||
|
|
||||||
|
val a = return 1
|
||||||
|
|
||||||
|
class A() {
|
||||||
|
}
|
||||||
|
fun illegalConstantBody(): Int = "s"
|
||||||
|
fun illegalConstantBlock(): String {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
fun illegalIfBody(): Int =
|
||||||
|
if (1 < 2) 'a' else { 1.0 }
|
||||||
|
fun illegalIfBlock(): Boolean {
|
||||||
|
if (1 < 2)
|
||||||
|
return false
|
||||||
|
else { return 1 }
|
||||||
|
}
|
||||||
|
fun illegalReturnIf(): Char {
|
||||||
|
return if (1 < 2) 'a' else { 1 }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun returnNothing(): Nothing {
|
||||||
|
throw 1
|
||||||
|
}
|
||||||
|
fun f(): Int {
|
||||||
|
if (1 < 2) { return 1 } else returnNothing()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f1(): Int = if (1 < 2) 1 else returnNothing()
|
||||||
|
|
||||||
|
public fun f2() = 1
|
||||||
|
class B() {
|
||||||
|
protected fun f() = "ss"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testFunctionLiterals() {
|
||||||
|
val endsWithVarDeclaration : () -> Boolean = {
|
||||||
|
val x = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
val endsWithAssignment: () -> Int = {
|
||||||
|
var x = 1
|
||||||
|
x = 333
|
||||||
|
}
|
||||||
|
|
||||||
|
val endsWithReAssignment: () -> Int = {
|
||||||
|
var x = 1
|
||||||
|
x += 333
|
||||||
|
}
|
||||||
|
|
||||||
|
val endsWithFunDeclaration : () -> String = {
|
||||||
|
var x = 1
|
||||||
|
x = 333
|
||||||
|
fun meow() : Unit {}
|
||||||
|
}
|
||||||
|
|
||||||
|
val endsWithObjectDeclaration : () -> Int = {
|
||||||
|
var x = 1
|
||||||
|
x = 333
|
||||||
|
object A {}
|
||||||
|
}
|
||||||
|
|
||||||
|
val expectedUnitReturnType1: () -> Unit = {
|
||||||
|
val x = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
val expectedUnitReturnType2: () -> Unit = {
|
||||||
|
fun meow() : Unit {}
|
||||||
|
object A {}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
// FILE: b.kt
|
||||||
|
interface A<in T> {}
|
||||||
|
interface B<T> : A<Int> {}
|
||||||
|
interface C<T> : B<T>, A<T> {}
|
||||||
|
interface C1<T> : B<T>, A<Any> {}
|
||||||
|
interface D : C<Boolean>, B<Double>{}
|
||||||
|
|
||||||
|
interface A1<out T> {}
|
||||||
|
interface B1 : A1<Int> {}
|
||||||
|
interface B2 : A1<Any>, B1 {}
|
||||||
|
|
||||||
|
interface BA1<T> {}
|
||||||
|
interface BB1 : BA1<Int> {}
|
||||||
|
interface BB2 : BA1<Any>, BB1 {}
|
||||||
|
|
||||||
|
|
||||||
|
// FILE: b.kt
|
||||||
|
package x
|
||||||
|
interface AA1<out T> {}
|
||||||
|
interface AB1 : AA1<Int> {}
|
||||||
|
interface AB3 : AA1<Comparable<Int>> {}
|
||||||
|
interface AB2 : AA1<Number>, AB1, AB3 {}
|
||||||
|
|
||||||
|
// FILE: b.kt
|
||||||
|
package x2
|
||||||
|
interface AA1<out T> {}
|
||||||
|
interface AB1 : AA1<Any> {}
|
||||||
|
interface AB3 : AA1<Comparable<Int>> {}
|
||||||
|
interface AB2 : AA1<Number>, AB1, AB3 {}
|
||||||
|
|
||||||
|
// FILE: b.kt
|
||||||
|
package x3
|
||||||
|
interface AA1<in T> {}
|
||||||
|
interface AB1 : AA1<Any> {}
|
||||||
|
interface AB3 : AA1<Comparable<Int>> {}
|
||||||
|
interface AB2 : AA1<Number>, AB1, AB3 {}
|
||||||
|
|
||||||
|
// FILE: b.kt
|
||||||
|
package sx2
|
||||||
|
interface AA1<in T> {}
|
||||||
|
interface AB1 : AA1<Int> {}
|
||||||
|
interface AB3 : AA1<Comparable<Int>> {}
|
||||||
|
interface AB2 : AA1<Number>, AB1, AB3 {}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
|
// A generic funciton is always less specific than a non-generic one
|
||||||
|
fun <T> foo(t : T) : Unit {}
|
||||||
|
fun foo(i : Int) : Int = 1
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
checkSubtype<Int>(foo(1))
|
||||||
|
checkSubtype<Unit>(foo("s"))
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
val z: Boolean = true
|
||||||
|
val b: Byte = 0
|
||||||
|
val s: Short = 0
|
||||||
|
val i: Int = 0
|
||||||
|
val j: Long = 0L
|
||||||
|
val f: Float = 0.0f
|
||||||
|
val d: Double = 0.0
|
||||||
|
val c: Char = '0'
|
||||||
|
|
||||||
|
val nz: Boolean? = true
|
||||||
|
val nb: Byte? = 0
|
||||||
|
val ns: Short? = 0
|
||||||
|
val ni: Int? = 0
|
||||||
|
val nj: Long? = 0L
|
||||||
|
val nf: Float? = 0.0f
|
||||||
|
val nd: Double? = 0.0
|
||||||
|
val nc: Char? = '0'
|
||||||
|
|
||||||
|
val n: Number = 0
|
||||||
|
val nn: Number? = 0
|
||||||
|
val a: Any = 0
|
||||||
|
val na: Any? = 0
|
||||||
|
|
||||||
|
// Identity for primitive values of same type
|
||||||
|
val test_zz = z === z || z !== z
|
||||||
|
val test_bb = b === b || b !== b
|
||||||
|
val test_ss = s === s || s !== s
|
||||||
|
val test_ii = i === i || i !== i
|
||||||
|
val test_jj = j === j || j !== j
|
||||||
|
val test_ff = f === f || f !== f
|
||||||
|
val test_dd = d === d || d !== d
|
||||||
|
val test_cc = c === c || c !== c
|
||||||
|
|
||||||
|
// Identity for primitive values of different types (no extra error)
|
||||||
|
val test_zb = z === b || z !== b
|
||||||
|
|
||||||
|
// Primitive vs nullable
|
||||||
|
val test_znz = z === nz || nz === z || z !== nz || nz !== z
|
||||||
|
val test_bnb = b === nb || nb === b || b !== nb || nb !== b
|
||||||
|
val test_sns = s === ns || ns === s || s !== ns || ns !== s
|
||||||
|
val test_ini = i === ni || ni === i || i !== ni || ni !== i
|
||||||
|
val test_jnj = j === nj || nj === j || j !== nj || nj !== j
|
||||||
|
val test_fnf = f === nf || nf === f || f !== nf || nf !== f
|
||||||
|
val test_dnd = d === nd || nd === d || d !== nd || nd !== d
|
||||||
|
val test_cnc = c === nc || nc === c || c !== nc || nc !== c
|
||||||
|
|
||||||
|
// Primitive number vs Number
|
||||||
|
val test_bn = b === n || n === b || b !== n || n !== b
|
||||||
|
val test_sn = s === n || n === s || s !== n || n !== s
|
||||||
|
val test_in = i === n || n === i || i !== n || n !== i
|
||||||
|
val test_jn = j === n || n === j || j !== n || n !== j
|
||||||
|
val test_fn = f === n || n === f || f !== n || n !== f
|
||||||
|
val test_dn = d === n || n === d || d !== n || n !== d
|
||||||
|
|
||||||
|
// Primitive number vs Number?
|
||||||
|
val test_bnn = b === nn || nn === b || b !== nn || nn !== b
|
||||||
|
val test_snn = s === nn || nn === s || s !== nn || nn !== s
|
||||||
|
val test_inn = i === nn || nn === i || i !== nn || nn !== i
|
||||||
|
val test_jnn = j === nn || nn === j || j !== nn || nn !== j
|
||||||
|
val test_fnn = f === nn || nn === f || f !== nn || nn !== f
|
||||||
|
val test_dnn = d === nn || nn === d || d !== nn || nn !== d
|
||||||
|
|
||||||
|
// Primitive vs Any
|
||||||
|
val test_za = z === a || a === z || z !== a || a !== z
|
||||||
|
val test_ba = b === a || a === b || b !== a || a !== b
|
||||||
|
val test_sa = s === a || a === s || s !== a || a !== s
|
||||||
|
val test_ia = i === a || a === i || i !== a || a !== i
|
||||||
|
val test_ja = j === a || a === j || j !== a || a !== j
|
||||||
|
val test_fa = f === a || a === f || f !== a || a !== f
|
||||||
|
val test_da = d === a || a === d || d !== a || a !== d
|
||||||
|
val test_ca = c === a || a === c || c !== a || a !== c
|
||||||
|
|
||||||
|
// Primitive vs Any?
|
||||||
|
val test_zna = z === na || na === z || z !== na || na !== z
|
||||||
|
val test_bna = b === na || na === b || b !== na || na !== b
|
||||||
|
val test_sna = s === na || na === s || s !== na || na !== s
|
||||||
|
val test_ina = i === na || na === i || i !== na || na !== i
|
||||||
|
val test_jna = j === na || na === j || j !== na || na !== j
|
||||||
|
val test_fna = f === na || na === f || f !== na || na !== f
|
||||||
|
val test_dna = d === na || na === d || d !== na || na !== d
|
||||||
|
val test_cna = c === na || na === c || c !== na || na !== c
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
class IncDec() {
|
||||||
|
operator fun inc() : IncDec = this
|
||||||
|
operator fun dec() : IncDec = this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testIncDec() {
|
||||||
|
var x = IncDec()
|
||||||
|
x++
|
||||||
|
++x
|
||||||
|
x--
|
||||||
|
--x
|
||||||
|
x = x++
|
||||||
|
x = x--
|
||||||
|
x = ++x
|
||||||
|
x = --x
|
||||||
|
}
|
||||||
|
|
||||||
|
class WrongIncDec() {
|
||||||
|
operator fun inc() : Int = 1
|
||||||
|
operator fun dec() : Int = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testWrongIncDec() {
|
||||||
|
var x = WrongIncDec()
|
||||||
|
x++
|
||||||
|
<!AMBIGUITY!>++<!>x
|
||||||
|
x<!AMBIGUITY!>--<!>
|
||||||
|
<!AMBIGUITY!>--<!>x
|
||||||
|
}
|
||||||
|
|
||||||
|
class UnitIncDec() {
|
||||||
|
operator fun inc() : Unit {}
|
||||||
|
operator fun dec() : Unit {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testUnitIncDec() {
|
||||||
|
var x = UnitIncDec()
|
||||||
|
x++
|
||||||
|
++x
|
||||||
|
x--
|
||||||
|
--x
|
||||||
|
x = x++
|
||||||
|
x = x--
|
||||||
|
x = ++x
|
||||||
|
x = --x
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
// http://youtrack.jetbrains.net/issue/KT-451
|
||||||
|
// KT-451 Incorrect character literals cause assertion failures
|
||||||
|
|
||||||
|
fun ff() {
|
||||||
|
val b = <!INFERENCE_ERROR, INFERENCE_ERROR!>''<!>
|
||||||
|
val c = <!INFERENCE_ERROR, INFERENCE_ERROR!>'23'<!>
|
||||||
|
val d = <!INFERENCE_ERROR, INFERENCE_ERROR!>'a<!>
|
||||||
|
val e = <!INFERENCE_ERROR, INFERENCE_ERROR!>'ab<!>
|
||||||
|
val f = <!INFERENCE_ERROR, INFERENCE_ERROR!>'\'<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
'a'
|
||||||
|
'\n'
|
||||||
|
'\t'
|
||||||
|
'\b'
|
||||||
|
'\r'
|
||||||
|
'\"'
|
||||||
|
'\''
|
||||||
|
'\\'
|
||||||
|
'\$'
|
||||||
|
<!INFERENCE_ERROR!>'\x'<!>
|
||||||
|
<!INFERENCE_ERROR!>'\123'<!>
|
||||||
|
<!INFERENCE_ERROR!>'\ra'<!>
|
||||||
|
<!INFERENCE_ERROR!>'\000'<!>
|
||||||
|
<!INFERENCE_ERROR!>'\000'<!>
|
||||||
|
'\u0000'
|
||||||
|
'\u000a'
|
||||||
|
'\u000A'
|
||||||
|
<!INFERENCE_ERROR!>'\u'<!>
|
||||||
|
<!INFERENCE_ERROR!>'\u0'<!>
|
||||||
|
<!INFERENCE_ERROR!>'\u00'<!>
|
||||||
|
<!INFERENCE_ERROR!>'\u000'<!>
|
||||||
|
<!INFERENCE_ERROR!>'\u000z'<!>
|
||||||
|
<!INFERENCE_ERROR!>'\\u000'<!>
|
||||||
|
<!INFERENCE_ERROR, INFERENCE_ERROR!>'\'<!>
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
fun ff(a: String) = 1
|
||||||
|
|
||||||
|
fun gg() {
|
||||||
|
val a: String? = ""
|
||||||
|
|
||||||
|
if (a != null) {
|
||||||
|
ff(a)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
class Pair<out A, out B>(val first: A, val second: B)
|
||||||
|
|
||||||
|
class Example {
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun to(other: Example) = Pair(this, other)<!>
|
||||||
|
fun toNonInfix(other: Example) = Pair(this, other)
|
||||||
|
}
|
||||||
|
|
||||||
|
infix fun Example.toExt(other: Example) = Pair(this, other)
|
||||||
|
fun Example.toExtNonInfix(other: Example) = Pair(this, other)
|
||||||
|
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun Example.toExtWithExtraParams(other: Example, blah: Int = 0) = Pair(this, other)<!>
|
||||||
|
fun Example.toExtNonInfixWithExtraParams(other: Example, blah: Int = 0) = Pair(this, other)
|
||||||
|
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun Example.toExtDefaultValues(other: Example? = null, blah: Int = 0) = Pair(this, other)<!>
|
||||||
|
fun Example.toExtNonInfixDefaultValues(other: Example? = null, blah: Int = 0) = Pair(this, other)
|
||||||
|
|
||||||
|
fun Example.withLambda(f: () -> Unit) = Pair(this, f)
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
Example() to Example()
|
||||||
|
Example() toNonInfix Example()
|
||||||
|
Example().toNonInfix(Example())
|
||||||
|
|
||||||
|
val a = Example()
|
||||||
|
val b = Example()
|
||||||
|
|
||||||
|
a toExt b
|
||||||
|
a toExtNonInfix b
|
||||||
|
a.toExtNonInfix(b)
|
||||||
|
|
||||||
|
a toExtWithExtraParams b
|
||||||
|
a toExtNonInfixWithExtraParams b
|
||||||
|
|
||||||
|
a toExtDefaultValues b
|
||||||
|
a toExtNonInfixDefaultValues b
|
||||||
|
|
||||||
|
a withLambda { }
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
class Pair<A, B>(val a: A, val b: B)
|
||||||
|
infix fun <A, B> A.to(that: B): Pair<A, B> = Pair(this, that)
|
||||||
|
|
||||||
|
// OK
|
||||||
|
infix fun String.ok1(o: String) {}
|
||||||
|
class OkTest {
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun ok2(o: String) {}<!>
|
||||||
|
infix fun String.ok3(o: String) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Errors
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun String.e1(o: String, o2: String? = null) = o<!>
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun String.e2(o: String = "", o2: String? = null) = o<!>
|
||||||
|
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun e3() {}<!>
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun e4(s: String) {}<!>
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun String.e5() {}<!>
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun String.e6(a: Int, b: Int) {}<!>
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun e7(a: Int, b: Int) {}<!>
|
||||||
|
|
||||||
|
class Example {
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun e8(s: String, a: Int = 0) {}<!>
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun e9(s: String, a: Int) {}<!>
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun e10() {}<!>
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
// NI_EXPECTED_FILE
|
||||||
|
|
||||||
|
fun test() = 3
|
||||||
|
|
||||||
|
fun <T> proxy(t: T) = t
|
||||||
|
|
||||||
|
class A {
|
||||||
|
val test = test()
|
||||||
|
}
|
||||||
|
|
||||||
|
class B {
|
||||||
|
val test = proxy(test())
|
||||||
|
}
|
||||||
|
|
||||||
|
class C {
|
||||||
|
val bar = test()
|
||||||
|
val test = <!UNRESOLVED_REFERENCE!>bar<!>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
// FILE: KotlinFile.kt
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
if (1 is Int) {
|
||||||
|
if (1 is Boolean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
A.create() is A
|
||||||
|
A.create() is A?
|
||||||
|
|
||||||
|
<!UNRESOLVED_REFERENCE!>unresolved<!> is A
|
||||||
|
<!UNRESOLVED_REFERENCE!>unresolved<!> is A?
|
||||||
|
|
||||||
|
val x = foo()
|
||||||
|
x as String
|
||||||
|
x is String
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo(): Any = ""
|
||||||
|
|
||||||
|
// FILE: A.java
|
||||||
|
class A {
|
||||||
|
static A create() { return null; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
package lvalue_assignment
|
||||||
|
|
||||||
|
open class B() {
|
||||||
|
var b: Int = 2
|
||||||
|
val c: Int = 34
|
||||||
|
}
|
||||||
|
|
||||||
|
class C() : B() {
|
||||||
|
var x = 4
|
||||||
|
fun foo(c: C) {
|
||||||
|
this.x = 34
|
||||||
|
this.b = 123
|
||||||
|
super.b = 23
|
||||||
|
this.c = 34
|
||||||
|
super.c = 3535 //repeat for 'c'
|
||||||
|
|
||||||
|
getInt() = 12
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo1(c: C) {
|
||||||
|
super.c = 34
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar(c: C) {
|
||||||
|
this = c //should be an error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getInt() = 0
|
||||||
|
|
||||||
|
class D() {
|
||||||
|
inner class B() {
|
||||||
|
fun foo() {
|
||||||
|
this@D = D()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo(): Unit {}
|
||||||
|
|
||||||
|
fun cannotBe() {
|
||||||
|
var i: Int = 5
|
||||||
|
|
||||||
|
<!UNRESOLVED_REFERENCE!>z<!> = 30;
|
||||||
|
"" = "";
|
||||||
|
foo() = Unit;
|
||||||
|
|
||||||
|
(i as Int) = 34
|
||||||
|
(i is Int) = false
|
||||||
|
A() = A()
|
||||||
|
5 = 34
|
||||||
|
}
|
||||||
|
|
||||||
|
fun canBe(i0: Int, j: Int) {
|
||||||
|
var i = i0
|
||||||
|
(label@ i) = 34
|
||||||
|
|
||||||
|
(label@ j) = 34 //repeat for j
|
||||||
|
|
||||||
|
val a = A()
|
||||||
|
(l@ a.a) = 3894
|
||||||
|
}
|
||||||
|
|
||||||
|
fun canBe2(j: Int) {
|
||||||
|
(label@ j) = 34
|
||||||
|
}
|
||||||
|
|
||||||
|
class A() {
|
||||||
|
var a: Int = 3
|
||||||
|
}
|
||||||
|
|
||||||
|
class Test() {
|
||||||
|
fun testIllegalValues() {
|
||||||
|
<!VARIABLE_EXPECTED!>1<!> += 23
|
||||||
|
(l@ <!VARIABLE_EXPECTED!>1<!>) += 23
|
||||||
|
|
||||||
|
<!VARIABLE_EXPECTED!>getInt()<!> += 343
|
||||||
|
(f@ <!VARIABLE_EXPECTED!>getInt()<!>) += 343
|
||||||
|
|
||||||
|
1++
|
||||||
|
(r@ 1)++
|
||||||
|
|
||||||
|
getInt()++
|
||||||
|
(m@ getInt())++
|
||||||
|
|
||||||
|
this<!UNRESOLVED_REFERENCE!>++<!>
|
||||||
|
|
||||||
|
var s : String = "r"
|
||||||
|
s += "ss"
|
||||||
|
s += this
|
||||||
|
s += (a@ 2)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testIncompleteSyntax() {
|
||||||
|
val s = "s"
|
||||||
|
<!UNRESOLVED_REFERENCE!>++<!>s.<!SYNTAX!><!>
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testVariables() {
|
||||||
|
var a: Int = 34
|
||||||
|
val b: Int = 34
|
||||||
|
|
||||||
|
a += 34
|
||||||
|
(l@ a) += 34
|
||||||
|
|
||||||
|
<!VARIABLE_EXPECTED!>b<!> += 34
|
||||||
|
|
||||||
|
a++
|
||||||
|
(l@ a)++
|
||||||
|
(a)++
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testVariables1() {
|
||||||
|
val b: Int = 34
|
||||||
|
|
||||||
|
(l@ <!VARIABLE_EXPECTED!>b<!>) += 34
|
||||||
|
//repeat for b
|
||||||
|
(<!VARIABLE_EXPECTED!>b<!>) += 3
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testArrays(a: Array<Int>, ab: Ab) {
|
||||||
|
a[3] = 4
|
||||||
|
a[4]++
|
||||||
|
a[6] += 43
|
||||||
|
|
||||||
|
ab.getArray()[54] = 23
|
||||||
|
ab.getArray()[54]++
|
||||||
|
|
||||||
|
(f@ a)[3] = 4
|
||||||
|
|
||||||
|
<!UNRESOLVED_REFERENCE!>this[54] = 34<!>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Array<Int>.checkThis() {
|
||||||
|
this[45] = 34
|
||||||
|
this[352]++
|
||||||
|
this[35] += 234
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class Ab {
|
||||||
|
abstract fun getArray() : Array<Int>
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
// Here we want just to check return type
|
||||||
|
// Should be () -> Int
|
||||||
|
fun foo() = { 42 }
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
// FILE: A.kt
|
||||||
|
package foo.bar
|
||||||
|
|
||||||
|
class X
|
||||||
|
|
||||||
|
// FILE: B.kt
|
||||||
|
|
||||||
|
package foo
|
||||||
|
|
||||||
|
fun f() {
|
||||||
|
class Local1 {
|
||||||
|
fun g() : bar.X? = null
|
||||||
|
}
|
||||||
|
class Local2 {
|
||||||
|
fun g() : foo.bar.X? = null
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
fun box() : String {
|
||||||
|
val s = "abc"
|
||||||
|
val test1 = """$s"""
|
||||||
|
if (test1 != "abc") return "Fail 1: $test1"
|
||||||
|
|
||||||
|
val test2 = """${s}"""
|
||||||
|
if (test2 != "abc") return "Fail 2: $test2"
|
||||||
|
|
||||||
|
val test3 = """ "$s" """
|
||||||
|
if (test3 != " \"abc\" ") return "Fail 3: $test3"
|
||||||
|
|
||||||
|
val test4 = """ "${s}" """
|
||||||
|
if (test4 != " \"abc\" ") return "Fail 4: $test4"
|
||||||
|
|
||||||
|
val test5 =
|
||||||
|
"""
|
||||||
|
${s.length}
|
||||||
|
"""
|
||||||
|
if (test5 != "\n 3\n") return "Fail 5: $test5"
|
||||||
|
|
||||||
|
val test6 = """\n"""
|
||||||
|
if (test6 != "\\n") return "Fail 6: $test6"
|
||||||
|
|
||||||
|
val test7 = """\${'$'}foo"""
|
||||||
|
if (test7 != "\\\$foo") return "Fail 7: $test7"
|
||||||
|
|
||||||
|
val test8 = """$ foo"""
|
||||||
|
if (test8 != "$ foo") return "Fail 8: $test8"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun new() : String {
|
||||||
|
return """
|
||||||
|
sdfasdf
|
||||||
|
${<!UNRESOLVED_REFERENCE!>a<!>}
|
||||||
|
ds"asdfas
|
||||||
|
$<!UNRESOLVED_REFERENCE!>b<!>
|
||||||
|
asgfaf
|
||||||
|
"""
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package Jet87
|
||||||
|
|
||||||
|
open class A() {
|
||||||
|
fun foo() : Int = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
interface B {
|
||||||
|
fun bar() : Double = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface G<X> {
|
||||||
|
val <X> boo: Double where X : A, X : B
|
||||||
|
val <A> bal: Double where A : B
|
||||||
|
val <Y> bas: Double where Y : B, X : B
|
||||||
|
}
|
||||||
|
|
||||||
|
class C() : A(), B
|
||||||
|
|
||||||
|
class D() {
|
||||||
|
companion object : A(), B {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Test1<T>()
|
||||||
|
where
|
||||||
|
T : A,
|
||||||
|
T : B,
|
||||||
|
B : T // error
|
||||||
|
{
|
||||||
|
|
||||||
|
fun test(t : T) {
|
||||||
|
<!OTHER_ERROR!>T<!>.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||||
|
<!OTHER_ERROR!>T<!>.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||||
|
t.foo()
|
||||||
|
t.bar()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
Test1<B>()
|
||||||
|
Test1<A>()
|
||||||
|
Test1<C>()
|
||||||
|
}
|
||||||
|
|
||||||
|
class Foo() {}
|
||||||
|
|
||||||
|
class Bar<T : Foo>
|
||||||
|
|
||||||
|
class Buzz<T> where T : Bar<Int>, T : nioho
|
||||||
|
|
||||||
|
class X<T : Foo>
|
||||||
|
class Y<T> where T : Foo, T : Bar<Foo>
|
||||||
|
|
||||||
|
fun <T> test2(t : T)
|
||||||
|
where
|
||||||
|
T : A,
|
||||||
|
T : B,
|
||||||
|
B : T
|
||||||
|
{
|
||||||
|
<!OTHER_ERROR!>T<!>.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||||
|
<!OTHER_ERROR!>T<!>.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||||
|
t.foo()
|
||||||
|
t.bar()
|
||||||
|
}
|
||||||
|
|
||||||
|
val t1 = <!INAPPLICABLE_CANDIDATE!>test2<!><A>(A())
|
||||||
|
val t2 = <!INAPPLICABLE_CANDIDATE!>test2<!><B>(C())
|
||||||
|
val t3 = test2<C>(C())
|
||||||
|
|
||||||
|
val <T, B : T> x : Int = 0
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
abstract class A : Function1<Any, Unit>
|
||||||
|
|
||||||
|
abstract class B : (Int)->Unit
|
||||||
|
|
||||||
|
// Named parameter is prohibited because of possible inconsistency between
|
||||||
|
// type declaration and actual override
|
||||||
|
class C : (x: Int)->Unit {
|
||||||
|
override fun invoke(p1: Int): Unit {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,296 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
// FULL_JDK
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
val a : Int? = 0
|
||||||
|
if (a != null) {
|
||||||
|
a.plus(1)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
a?.plus(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
val out : java.io.PrintStream? = null
|
||||||
|
val ins : java.io.InputStream? = null
|
||||||
|
|
||||||
|
out?.println()
|
||||||
|
ins?.read()
|
||||||
|
|
||||||
|
if (ins != null) {
|
||||||
|
ins.read()
|
||||||
|
out?.println()
|
||||||
|
if (out != null) {
|
||||||
|
ins.read();
|
||||||
|
out.println();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (out != null && ins != null) {
|
||||||
|
ins.read();
|
||||||
|
out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (out == null) {
|
||||||
|
out?.println()
|
||||||
|
} else {
|
||||||
|
out.println()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (out != null && ins != null || out != null) {
|
||||||
|
ins?.read();
|
||||||
|
ins.<!INAPPLICABLE_CANDIDATE!>read<!>();
|
||||||
|
out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (out == null || out.println(0) == Unit) {
|
||||||
|
out?.println(1)
|
||||||
|
out.<!INAPPLICABLE_CANDIDATE!>println<!>(1)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
out.println(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (out != null && out.println() == Unit) {
|
||||||
|
out.println();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
out?.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (out == null || out.println() == Unit) {
|
||||||
|
out?.println();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (1 == 2 || out != null && out.println(1) == Unit) {
|
||||||
|
out?.println(2);
|
||||||
|
out.<!INAPPLICABLE_CANDIDATE!>println<!>(2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
out?.println(3)
|
||||||
|
out.<!INAPPLICABLE_CANDIDATE!>println<!>(3)
|
||||||
|
}
|
||||||
|
|
||||||
|
out?.println()
|
||||||
|
ins?.read()
|
||||||
|
|
||||||
|
if (ins != null) {
|
||||||
|
ins.read()
|
||||||
|
out?.println()
|
||||||
|
if (out != null) {
|
||||||
|
ins.read();
|
||||||
|
out.println();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (out != null && ins != null) {
|
||||||
|
ins.read();
|
||||||
|
out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (out == null) {
|
||||||
|
out?.println()
|
||||||
|
} else {
|
||||||
|
out.println()
|
||||||
|
}
|
||||||
|
|
||||||
|
if (out != null && ins != null || out != null) {
|
||||||
|
ins?.read();
|
||||||
|
out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (out == null || out.println(0) == Unit) {
|
||||||
|
out?.println(1)
|
||||||
|
out.<!INAPPLICABLE_CANDIDATE!>println<!>(1)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
out.println(2)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (out != null && out.println() == Unit) {
|
||||||
|
out.println();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
out?.println();
|
||||||
|
out.<!INAPPLICABLE_CANDIDATE!>println<!>();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (out == null || out.println() == Unit) {
|
||||||
|
out?.println();
|
||||||
|
out.<!INAPPLICABLE_CANDIDATE!>println<!>();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
out.println();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (1 == 2 || out != null && out.println(1) == Unit) {
|
||||||
|
out?.println(2);
|
||||||
|
out.<!INAPPLICABLE_CANDIDATE!>println<!>(2);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
out?.println(3)
|
||||||
|
out.<!INAPPLICABLE_CANDIDATE!>println<!>(3)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (1 > 2) {
|
||||||
|
if (out == null) return;
|
||||||
|
out.println();
|
||||||
|
}
|
||||||
|
out?.println();
|
||||||
|
|
||||||
|
while (out != null) {
|
||||||
|
out.println();
|
||||||
|
}
|
||||||
|
out?.println();
|
||||||
|
|
||||||
|
val out2 : java.io.PrintStream? = null
|
||||||
|
|
||||||
|
while (out2 == null) {
|
||||||
|
out2?.println();
|
||||||
|
out2.<!INAPPLICABLE_CANDIDATE!>println<!>();
|
||||||
|
}
|
||||||
|
out2.<!INAPPLICABLE_CANDIDATE!>println<!>()
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun f(out : String?) {
|
||||||
|
out?.get(0)
|
||||||
|
out.<!INAPPLICABLE_CANDIDATE!>get<!>(0)
|
||||||
|
if (out != null) else return;
|
||||||
|
out.get(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f1(out : String?) {
|
||||||
|
out?.get(0)
|
||||||
|
if (out != null) else {
|
||||||
|
1 + 2
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
out.get(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f2(out : String?) {
|
||||||
|
out?.get(0)
|
||||||
|
if (out == null) {
|
||||||
|
1 + 2
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
out.get(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f3(out : String?) {
|
||||||
|
out?.get(0)
|
||||||
|
if (out == null) {
|
||||||
|
1 + 2
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
1 + 2
|
||||||
|
}
|
||||||
|
out.get(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f4(s : String?) {
|
||||||
|
s?.get(0)
|
||||||
|
while (1 < 2 && s != null) {
|
||||||
|
s.get(0)
|
||||||
|
}
|
||||||
|
s?.get(0)
|
||||||
|
while (s == null || 1 < 2) {
|
||||||
|
s?.get(0)
|
||||||
|
}
|
||||||
|
s.get(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f5(s : String?) {
|
||||||
|
s?.get(0)
|
||||||
|
while (1 < 2 && s != null) {
|
||||||
|
s.get(0)
|
||||||
|
}
|
||||||
|
s?.get(0)
|
||||||
|
while (s == null || 1 < 2) {
|
||||||
|
if (1 > 2) break
|
||||||
|
s?.get(0)
|
||||||
|
}
|
||||||
|
s?.get(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f6(s : String?) {
|
||||||
|
s?.get(0)
|
||||||
|
do {
|
||||||
|
s?.get(0)
|
||||||
|
if (1 < 2) break;
|
||||||
|
} while (s == null)
|
||||||
|
s?.get(0)
|
||||||
|
do {
|
||||||
|
s?.get(0)
|
||||||
|
} while (s == null)
|
||||||
|
s.<!INAPPLICABLE_CANDIDATE!>get<!>(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f7(s : String?, t : String?) {
|
||||||
|
s?.get(0)
|
||||||
|
if (!(s == null)) {
|
||||||
|
s.get(0)
|
||||||
|
}
|
||||||
|
s?.get(0)
|
||||||
|
if (!(s != null)) {
|
||||||
|
s?.get(0)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
s.get(0)
|
||||||
|
}
|
||||||
|
s?.get(0)
|
||||||
|
if (!!(s != null)) {
|
||||||
|
s.get(0)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
s?.get(0)
|
||||||
|
}
|
||||||
|
s?.get(0)
|
||||||
|
t?.get(0)
|
||||||
|
if (!(s == null || t == null)) {
|
||||||
|
s.get(0)
|
||||||
|
t.get(0)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
s?.get(0)
|
||||||
|
t?.get(0)
|
||||||
|
}
|
||||||
|
s?.get(0)
|
||||||
|
t?.get(0)
|
||||||
|
if (!(s == null)) {
|
||||||
|
s.get(0)
|
||||||
|
t?.get(0)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
s?.get(0)
|
||||||
|
t?.get(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f8(b : String?, a : String) {
|
||||||
|
b?.get(0)
|
||||||
|
if (b == a) {
|
||||||
|
b.get(0);
|
||||||
|
}
|
||||||
|
b?.get(0)
|
||||||
|
if (a == b) {
|
||||||
|
b.get(0)
|
||||||
|
}
|
||||||
|
if (a != b) {
|
||||||
|
b?.get(0)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
b.<!INAPPLICABLE_CANDIDATE!>get<!>(0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f9(a : Int?) : Int {
|
||||||
|
if (a != null)
|
||||||
|
return a
|
||||||
|
return 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER -USELESS_CAST
|
||||||
|
|
||||||
|
infix fun Any?.foo(a: Any) {}
|
||||||
|
infix fun Any?.zoo(a: Any) {}
|
||||||
|
infix fun Any?.Loo(a: Any) {}
|
||||||
|
infix fun Any?.doo(a: Any) {}
|
||||||
|
infix fun Any?.ddoo(a: Any) {}
|
||||||
|
operator fun Any?.contains(a: Any): Boolean = true
|
||||||
|
|
||||||
|
fun test(a: Any) {
|
||||||
|
1f<!UNRESOLVED_REFERENCE!>oo<!> a
|
||||||
|
1ffoo a
|
||||||
|
1doo a
|
||||||
|
1ddoo a
|
||||||
|
1contains a
|
||||||
|
|
||||||
|
1Lfoo a
|
||||||
|
1L<!UNRESOLVED_REFERENCE!>oo<!> a
|
||||||
|
1LLoo a
|
||||||
|
|
||||||
|
0b1foo a
|
||||||
|
0b1Lfoo a
|
||||||
|
0b1L<!UNRESOLVED_REFERENCE!>oo<!> a
|
||||||
|
0b1LLoo a
|
||||||
|
|
||||||
|
0xf<!UNRESOLVED_REFERENCE!>oo<!> a
|
||||||
|
0xff<!UNRESOLVED_REFERENCE!>oo<!> a
|
||||||
|
0xfLLoo a
|
||||||
|
|
||||||
|
1.0f<!UNRESOLVED_REFERENCE!>oo<!> a
|
||||||
|
1.0ffoo a
|
||||||
|
1.0doo a
|
||||||
|
1.0ddoo a
|
||||||
|
|
||||||
|
.0f<!UNRESOLVED_REFERENCE!>oo<!> a
|
||||||
|
.0ffoo a
|
||||||
|
.0doo a
|
||||||
|
.0ddoo a
|
||||||
|
|
||||||
|
1in a
|
||||||
|
1.0in a
|
||||||
|
1.0fin a
|
||||||
|
1.0<!UNRESOLVED_REFERENCE!>din<!> a
|
||||||
|
.0in a
|
||||||
|
.0fin a
|
||||||
|
.0<!UNRESOLVED_REFERENCE!>din<!> a
|
||||||
|
|
||||||
|
1is Any
|
||||||
|
1as Any
|
||||||
|
1as? Any
|
||||||
|
|
||||||
|
1!is Any
|
||||||
|
1!in a
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
object A1() {
|
||||||
|
constructor(x: Int = "", y: Int) : this() {
|
||||||
|
x + y
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object A2 public constructor(private val prop: Int) {
|
||||||
|
constructor(x: Int = "", y: Int) : this(x * y) {
|
||||||
|
x + y
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val x = object (val prop: Int) {
|
||||||
|
<!CONSTRUCTOR_IN_OBJECT, CONSTRUCTOR_IN_OBJECT!>constructor()<!> : <!UNRESOLVED_REFERENCE!>this<!>(1) {
|
||||||
|
val x = 1
|
||||||
|
x * x
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class A3 {
|
||||||
|
companion object B(val prop: Int) {
|
||||||
|
public constructor() : this(2)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,219 @@
|
|||||||
|
// !DIAGNOSTICS: -EXTENSION_SHADOWED_BY_MEMBER
|
||||||
|
|
||||||
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
|
interface Example {
|
||||||
|
operator fun plus(o: Example): Example
|
||||||
|
operator fun div(o: Example): Example
|
||||||
|
operator fun plus(o: Example, s: String = ""): Example
|
||||||
|
operator fun minus(vararg o: Example): Example
|
||||||
|
operator fun plus(): Example
|
||||||
|
operator fun minus(): Example
|
||||||
|
|
||||||
|
operator fun unaryPlus(): Example
|
||||||
|
operator fun unaryMinus(): Example
|
||||||
|
|
||||||
|
operator fun unaryPlus(s: String = ""): Example
|
||||||
|
operator fun unaryMinus(o: Example)
|
||||||
|
|
||||||
|
operator fun inc(): Example
|
||||||
|
operator fun dec(): Example?
|
||||||
|
|
||||||
|
operator fun plusAssign(n: Int)
|
||||||
|
operator fun minusAssign(n: Int): String
|
||||||
|
operator fun divAssign(n: Int, a: String = "")
|
||||||
|
operator fun modAssign(vararg n: Int)
|
||||||
|
|
||||||
|
operator fun compareTo(other: Example): Int
|
||||||
|
|
||||||
|
override operator fun equals(other: Any?): Boolean
|
||||||
|
operator fun equals(a: String): Boolean
|
||||||
|
|
||||||
|
operator fun contains(n: Int): Boolean
|
||||||
|
operator fun contains(n: Int, s: String = ""): Boolean
|
||||||
|
|
||||||
|
operator fun invoke()
|
||||||
|
|
||||||
|
operator fun get(n: Int)
|
||||||
|
operator fun get(n: Int, n2: Int)
|
||||||
|
operator fun get()
|
||||||
|
|
||||||
|
operator fun set(n: Int, v: Int)
|
||||||
|
operator fun set(n: Int, n2: Int, v: Int)
|
||||||
|
operator fun set(v: Int)
|
||||||
|
|
||||||
|
operator fun rangeTo(o: Int)
|
||||||
|
operator fun rangeTo(o: Int, o2: Int)
|
||||||
|
operator fun rangeTo(vararg o: String)
|
||||||
|
|
||||||
|
operator fun component1(): Int
|
||||||
|
operator fun component1(n: Int): Int
|
||||||
|
operator fun componentN(): Int
|
||||||
|
|
||||||
|
operator fun iterator(): String
|
||||||
|
operator fun iterator(n: Int): String
|
||||||
|
|
||||||
|
operator fun next(): String
|
||||||
|
operator fun next(n: Int): String
|
||||||
|
|
||||||
|
operator fun hasNext(): Boolean
|
||||||
|
operator fun hasNext(n: Int): String
|
||||||
|
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun i1(n: Int)<!>
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun i1(n: Int, n2: Int)<!>
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun i1(vararg n: Int)<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
class OkDelegates {
|
||||||
|
operator fun getValue(thisRef: Any?, prop: KProperty<*>): String = ""
|
||||||
|
operator fun setValue(thisRef: Any?, prop: KProperty<*>, s: String): String = ""
|
||||||
|
operator fun setValue(thisRef: Any?, prop: Any, n: Int) {}
|
||||||
|
operator fun setValue(thisRef: Any?, prop: Any?, s: String) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DelegatesWithErrors {
|
||||||
|
operator fun getValue(thisRef: Any?, prop: String): String = ""
|
||||||
|
operator fun setValue(thisRef: Any?, prop: String, value: String) {}
|
||||||
|
|
||||||
|
operator fun setValue(thisRef: Any?, prop: KProperty<*>, vararg n: Int) {}
|
||||||
|
operator fun setValue(thisRef: Any?, prop: KProperty<*>, f: Float = 0.0f) {}
|
||||||
|
|
||||||
|
operator fun getValue(prop: KProperty<*>): String = ""
|
||||||
|
operator fun setValue(prop: KProperty<*>, value: String) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Example2 {
|
||||||
|
operator fun inc(s: String): Example
|
||||||
|
operator fun dec()
|
||||||
|
operator fun compareTo(vararg other: Example): Int
|
||||||
|
operator fun contains(vararg n: Int): Boolean
|
||||||
|
operator fun hasNext(): Int
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Example3 {
|
||||||
|
operator fun compareTo(other: Example, s: String = ""): Int
|
||||||
|
operator fun contains(n: Int)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
operator fun Example.plus(o: Any): Example {}
|
||||||
|
operator fun Example.div(o: Example): Example {}
|
||||||
|
operator fun Example.plus(o: Example, s: String = ""): Example {}
|
||||||
|
operator fun Example.minus(vararg o: Example): Example {}
|
||||||
|
operator fun Example.plus(): Example {}
|
||||||
|
operator fun Example.minus(): Example {}
|
||||||
|
|
||||||
|
operator fun Example.unaryPlus(): Example {}
|
||||||
|
operator fun Example.unaryMinus(): Example {}
|
||||||
|
|
||||||
|
operator fun Example.unaryPlus(s: String = ""): Example {}
|
||||||
|
operator fun Example.unaryMinus(o: Example) {}
|
||||||
|
|
||||||
|
operator fun Example.inc(): Example {}
|
||||||
|
operator fun Example.dec(): Example? {}
|
||||||
|
|
||||||
|
operator fun Example.plusAssign(n: Int) {}
|
||||||
|
operator fun Example.minusAssign(n: Int): String {}
|
||||||
|
operator fun Example.divAssign(n: Int, a: String = "") {}
|
||||||
|
operator fun Example.modAssign(vararg n: Int) {}
|
||||||
|
|
||||||
|
operator fun Example.compareTo(other: Example): Int {}
|
||||||
|
|
||||||
|
operator fun Example.equals(a: String): Boolean {}
|
||||||
|
|
||||||
|
operator fun Example.contains(n: Int): Boolean {}
|
||||||
|
operator fun Example.contains(n: Int, s: String = ""): Boolean {}
|
||||||
|
|
||||||
|
operator fun Example.invoke() {}
|
||||||
|
|
||||||
|
operator fun Example.get(n: Int) {}
|
||||||
|
operator fun Example.get(n: Int, n2: Int) {}
|
||||||
|
operator fun Example.get() {}
|
||||||
|
|
||||||
|
operator fun Example.set(n: Int, v: Int) {}
|
||||||
|
operator fun Example.set(n: Int, n2: Int, v: Int) {}
|
||||||
|
operator fun Example.set(v: Int) {}
|
||||||
|
|
||||||
|
operator fun Example.rangeTo(o: Int) {}
|
||||||
|
operator fun Example.rangeTo(o: Int, o2: Int) {}
|
||||||
|
operator fun Example.rangeTo(vararg o: String) {}
|
||||||
|
|
||||||
|
operator fun Example.component1(): Int {}
|
||||||
|
operator fun Example.component1(n: Int): Int {}
|
||||||
|
operator fun Example.componentN(): Int {}
|
||||||
|
|
||||||
|
operator fun Example.iterator(): String {}
|
||||||
|
operator fun Example.iterator(n: Int): String {}
|
||||||
|
|
||||||
|
operator fun Example.next(): String {}
|
||||||
|
operator fun Example.next(n: Int): String {}
|
||||||
|
|
||||||
|
operator fun Example.hasNext(): Boolean {}
|
||||||
|
operator fun Example.hasNext(n: Int): String {}
|
||||||
|
|
||||||
|
infix fun Example.i1(n: Int) {}
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun Example.i1(n: Int, n2: Int) {}<!>
|
||||||
|
infix fun Example.i1(vararg n: Int) {}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
operator fun plus(o: String): Example {}
|
||||||
|
operator fun div(o: Example): Example {}
|
||||||
|
operator fun plus(o: Example, s: String = ""): Example {}
|
||||||
|
operator fun minus(vararg o: Example): Example {}
|
||||||
|
|
||||||
|
operator fun unaryPlus(): Example {}
|
||||||
|
operator fun unaryMinus(): Example {}
|
||||||
|
|
||||||
|
operator fun unaryPlus(s: String = ""): Example {}
|
||||||
|
operator fun unaryMinus(o: Example) {}
|
||||||
|
|
||||||
|
operator fun inc(): Example {}
|
||||||
|
operator fun dec(): Example? {}
|
||||||
|
|
||||||
|
operator fun plusAssign(n: Int) {}
|
||||||
|
operator fun minusAssign(n: Int): String {}
|
||||||
|
operator fun divAssign(n: Int, a: String = "") {}
|
||||||
|
operator fun modAssign(vararg n: Int) {}
|
||||||
|
|
||||||
|
operator fun compareTo(other: Example): Int {}
|
||||||
|
|
||||||
|
operator fun equals(a: String): Boolean {}
|
||||||
|
|
||||||
|
operator fun contains(n: Int): Boolean {}
|
||||||
|
operator fun contains(n: Int, s: String = ""): Boolean {}
|
||||||
|
|
||||||
|
operator fun invoke() {}
|
||||||
|
|
||||||
|
operator fun get(n: Int) {}
|
||||||
|
operator fun get(n: Int, n2: Int) {}
|
||||||
|
operator fun get() {}
|
||||||
|
|
||||||
|
operator fun set(n: Int, v: Int) {}
|
||||||
|
operator fun set(n: Int, n2: Int, v: Int) {}
|
||||||
|
operator fun set(v: Int) {}
|
||||||
|
|
||||||
|
operator fun rangeTo(o: Int) {}
|
||||||
|
operator fun rangeTo(o: Int, o2: Int) {}
|
||||||
|
operator fun rangeTo(vararg o: String) {}
|
||||||
|
|
||||||
|
operator fun component1(): Int {}
|
||||||
|
operator fun component1(n: Int): Int {}
|
||||||
|
operator fun componentN(): Int {}
|
||||||
|
|
||||||
|
operator fun iterator(): String {}
|
||||||
|
operator fun iterator(n: Int): String {}
|
||||||
|
|
||||||
|
operator fun next(): String {}
|
||||||
|
operator fun next(n: Int): String {}
|
||||||
|
|
||||||
|
operator fun hasNext(): Boolean {}
|
||||||
|
operator fun hasNext(n: Int): String {}
|
||||||
|
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun i1(n: Int) {}<!>
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun i1(n: Int, n2: Int) {}<!>
|
||||||
|
<!INAPPLICABLE_INFIX_MODIFIER!>infix fun i1(vararg n: Int) {}<!>
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
class Example {
|
||||||
|
public fun plus(o: Example) = o
|
||||||
|
public operator fun minus(o: Example) = o
|
||||||
|
|
||||||
|
public fun get(i: Int) = ""
|
||||||
|
public operator fun get(s: String) = ""
|
||||||
|
|
||||||
|
public fun set(i: Int, v: String) {}
|
||||||
|
public operator fun set(s: String, v: String) {}
|
||||||
|
|
||||||
|
public fun not() = false
|
||||||
|
|
||||||
|
public fun rangeTo(o: Example) = o
|
||||||
|
public fun contains(o: Example) = false
|
||||||
|
public fun compareTo(o: Example) = 0
|
||||||
|
|
||||||
|
public fun inc() = this
|
||||||
|
public fun dec() = this
|
||||||
|
|
||||||
|
public fun invoke() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Example2 {
|
||||||
|
public operator fun not() = true
|
||||||
|
|
||||||
|
public fun plusAssign(o: Example2) {}
|
||||||
|
public operator fun minusAssign(o: Example2) {}
|
||||||
|
|
||||||
|
public operator fun rangeTo(o: Example2) = o
|
||||||
|
public operator fun contains(o: Example2) = false
|
||||||
|
public operator fun compareTo(o: Example2) = 0
|
||||||
|
|
||||||
|
public operator fun inc() = this
|
||||||
|
public operator fun dec() = this
|
||||||
|
|
||||||
|
public operator fun invoke() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
var a = Example()
|
||||||
|
var b = Example()
|
||||||
|
var c = Example2()
|
||||||
|
var d = Example2()
|
||||||
|
|
||||||
|
Example() == Example()
|
||||||
|
|
||||||
|
a == b
|
||||||
|
c != d
|
||||||
|
|
||||||
|
Example() + Example()
|
||||||
|
|
||||||
|
a + b
|
||||||
|
a - b
|
||||||
|
a[1]
|
||||||
|
a["str"]
|
||||||
|
|
||||||
|
a[1] = "A"
|
||||||
|
a["str"] = "str"
|
||||||
|
|
||||||
|
a.plus(b)
|
||||||
|
a.minus(b)
|
||||||
|
a.get(1)
|
||||||
|
a.get("str")
|
||||||
|
|
||||||
|
c += d
|
||||||
|
c -= d
|
||||||
|
|
||||||
|
a..b
|
||||||
|
c..d
|
||||||
|
|
||||||
|
Example()..Example()
|
||||||
|
Example2()..Example2()
|
||||||
|
|
||||||
|
a < b
|
||||||
|
a >= b
|
||||||
|
c > d
|
||||||
|
|
||||||
|
a in b
|
||||||
|
c in d
|
||||||
|
|
||||||
|
a++
|
||||||
|
a--
|
||||||
|
c++
|
||||||
|
c--
|
||||||
|
|
||||||
|
!a
|
||||||
|
!c
|
||||||
|
|
||||||
|
a()
|
||||||
|
c()
|
||||||
|
|
||||||
|
Example()()
|
||||||
|
Example2()()
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class Base {
|
||||||
|
abstract operator fun plus(o: Base): Base
|
||||||
|
abstract fun minus(o: Base): Base
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Anc : Base() {
|
||||||
|
override fun plus(o: Base) = o
|
||||||
|
override fun minus(o: Base) = o
|
||||||
|
}
|
||||||
|
|
||||||
|
class Anc2 : Anc()
|
||||||
|
|
||||||
|
fun test2() {
|
||||||
|
Anc() + Anc()
|
||||||
|
Anc() - Anc()
|
||||||
|
Anc2() + Anc2()
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
class A {
|
||||||
|
operator fun A.minus(o: A) = o
|
||||||
|
|
||||||
|
operator fun A.add(o: A) = o
|
||||||
|
operator fun A.get(o: A) = o
|
||||||
|
operator fun A.invokee() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun A.plus(o: A) = o
|
||||||
|
operator fun A.component1() = 1
|
||||||
|
operator fun A.componentN() = 1
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
abstract class B() {
|
||||||
|
abstract fun foo2(arg: Int = 239) : Int
|
||||||
|
}
|
||||||
|
|
||||||
|
class C() : B() {
|
||||||
|
override fun foo2(arg: Int) : Int = arg
|
||||||
|
}
|
||||||
|
|
||||||
|
fun invokeIt() {
|
||||||
|
C().foo2()
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
interface Aaa<T> {
|
||||||
|
fun zzz(value: T): Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
class Bbb<T>() : Aaa<T> {
|
||||||
|
override fun zzz(value: T) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
var a = Bbb<Double>()
|
||||||
|
a.zzz(10.0)
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
public interface ITest {
|
||||||
|
public var prop : Int
|
||||||
|
get() = 12
|
||||||
|
set(value) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class ATest {
|
||||||
|
protected open var prop2 : Int
|
||||||
|
get() = 13
|
||||||
|
set(value) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Test: ATest(), ITest {
|
||||||
|
override var prop : Int
|
||||||
|
get() = 12
|
||||||
|
private set(value) {}
|
||||||
|
|
||||||
|
override var prop2 : Int
|
||||||
|
get() = 14
|
||||||
|
internal set(value) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val test = Test()
|
||||||
|
test.prop = 12
|
||||||
|
|
||||||
|
val itest: ITest = test
|
||||||
|
itest.prop = 12 // No error here
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
open class Var() {
|
||||||
|
open var v : Int = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
interface VarT {
|
||||||
|
var v : Int
|
||||||
|
}
|
||||||
|
|
||||||
|
class Val() : Var(), VarT {
|
||||||
|
override val v : Int = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
class Var2() : Var() {
|
||||||
|
override var v : Int = 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
class X {}
|
||||||
|
|
||||||
|
val s = java
|
||||||
|
val ss = System
|
||||||
|
val sss = X
|
||||||
|
val x = "${System}"
|
||||||
|
val xs = java.lang
|
||||||
|
val xss = java.<!UNRESOLVED_REFERENCE!>lang<!>.<!UNRESOLVED_REFERENCE!>System<!>
|
||||||
|
val xsss = foo.X
|
||||||
|
val xssss = foo
|
||||||
|
val f = { System }
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
java = null
|
||||||
|
System = null
|
||||||
|
System!!
|
||||||
|
java.lang.System = null
|
||||||
|
java.lang.System!!
|
||||||
|
System is Int
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>System<!>()
|
||||||
|
(System)
|
||||||
|
foo@ System
|
||||||
|
null <!UNRESOLVED_REFERENCE!>in<!> System
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
// FILE: a.kt
|
||||||
|
|
||||||
|
package foo
|
||||||
|
|
||||||
|
// FILE: b.kt
|
||||||
|
|
||||||
|
@foo fun bar(p: foo): foo = null!!
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
// FILE: b.kt
|
||||||
|
|
||||||
|
|
||||||
|
package foobar.a
|
||||||
|
import java.*
|
||||||
|
|
||||||
|
val a : java.util.List<Int>? = null
|
||||||
|
val a2 : util.List<Int>? = null
|
||||||
|
val a3 : LinkedList<Int>? = null
|
||||||
|
|
||||||
|
// FILE: b.kt
|
||||||
|
package foobar
|
||||||
|
|
||||||
|
abstract class Foo<T>() {
|
||||||
|
abstract val x : T<Int>
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: b.kt
|
||||||
|
package foobar.a
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
val b : List<Int>? = a
|
||||||
|
val b1 : util.List<Int>? = a
|
||||||
|
|
||||||
|
// FILE: b.kt
|
||||||
|
package foobar
|
||||||
|
val x1 = <!UNRESOLVED_REFERENCE!>a<!>.<!UNRESOLVED_REFERENCE!>a<!>
|
||||||
|
val x2 = foobar.a.a
|
||||||
|
|
||||||
|
val y1 = foobar.a.b
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
fun <O> done(result : O) : Iteratee<Any?, O> = StrangeIterateeImpl<Any?, O>(result)
|
||||||
|
|
||||||
|
abstract class Iteratee<in I, out O> {
|
||||||
|
abstract fun process(item : I) : Iteratee<I, O>
|
||||||
|
abstract val isDone : Boolean
|
||||||
|
abstract val result : O
|
||||||
|
abstract fun done() : O
|
||||||
|
}
|
||||||
|
|
||||||
|
class StrangeIterateeImpl<in I, out O>(val obj: O) : Iteratee<I, O>() {
|
||||||
|
override fun process(item: I): Iteratee<I, O> = StrangeIterateeImpl<I, O>(obj)
|
||||||
|
override val isDone = true
|
||||||
|
override val result = obj
|
||||||
|
override fun done() = obj
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class Sum() : Iteratee<Int, Int>() {
|
||||||
|
override fun process(item : Int) : Iteratee<Int, Int> {
|
||||||
|
return foobar.done<Int>(item);
|
||||||
|
}
|
||||||
|
abstract override val isDone : Boolean
|
||||||
|
abstract override val result : Int
|
||||||
|
abstract override fun done() : Int
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class Collection<E> : Iterable<E> {
|
||||||
|
fun <O> iterate(iteratee : Iteratee<E, O>) : O {
|
||||||
|
var current = iteratee
|
||||||
|
for (x in this) {
|
||||||
|
val it = current.process(x)
|
||||||
|
if (it.isDone) return it.result
|
||||||
|
current = it
|
||||||
|
}
|
||||||
|
return current.done()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
class X {
|
||||||
|
val x : Int
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Y() {
|
||||||
|
val x : Int = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
class Y1 {
|
||||||
|
val x : Int get() = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
class Z : Y() {
|
||||||
|
}
|
||||||
|
|
||||||
|
//KT-650 Prohibit creating class without constructor.
|
||||||
|
|
||||||
|
class MyIterable<T> : Iterable<T>
|
||||||
|
{
|
||||||
|
override fun iterator(): Iterator<T> = MyIterator()
|
||||||
|
|
||||||
|
inner class MyIterator : Iterator<T>
|
||||||
|
{
|
||||||
|
override fun hasNext(): Boolean = false
|
||||||
|
override fun next(): T {
|
||||||
|
throw UnsupportedOperationException()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// FILE: a.kt
|
||||||
|
package outer
|
||||||
|
|
||||||
|
private fun a() {}
|
||||||
|
private class B
|
||||||
|
|
||||||
|
// FILE: b.kt
|
||||||
|
package outer.p1
|
||||||
|
|
||||||
|
import outer.a
|
||||||
|
|
||||||
|
fun use() {
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>a<!>()
|
||||||
|
outer.<!INAPPLICABLE_CANDIDATE!>B<!>()
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: c.kt
|
||||||
|
package outer.p1.p2
|
||||||
|
|
||||||
|
import outer.a
|
||||||
|
|
||||||
|
fun use() {
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>a<!>()
|
||||||
|
outer.<!INAPPLICABLE_CANDIDATE!>B<!>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
// See KT-10325: private setters are allowed for overridden properties in final class
|
||||||
|
|
||||||
|
interface A {
|
||||||
|
val a: Int
|
||||||
|
|
||||||
|
var b: Int
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class AA {
|
||||||
|
abstract val c: Int
|
||||||
|
|
||||||
|
abstract var d: Int
|
||||||
|
}
|
||||||
|
|
||||||
|
class B : A, AA() {
|
||||||
|
override var a: Int = 0
|
||||||
|
// Ok
|
||||||
|
private set
|
||||||
|
|
||||||
|
override var b: Int = 1
|
||||||
|
private set
|
||||||
|
|
||||||
|
override var c: Int = 2
|
||||||
|
// Ok
|
||||||
|
private set
|
||||||
|
|
||||||
|
override var d: Int = 3
|
||||||
|
private set
|
||||||
|
}
|
||||||
|
|
||||||
|
open class C : A, AA() {
|
||||||
|
override var a: Int = 0
|
||||||
|
// Errors here and below
|
||||||
|
private set
|
||||||
|
|
||||||
|
override var b: Int = 1
|
||||||
|
private set
|
||||||
|
|
||||||
|
override var c: Int = 2
|
||||||
|
private set
|
||||||
|
|
||||||
|
override var d: Int = 3
|
||||||
|
private set
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class D : A, AA() {
|
||||||
|
override var a: Int = 0
|
||||||
|
// Errors here and below
|
||||||
|
private set
|
||||||
|
|
||||||
|
override var b: Int = 1
|
||||||
|
private set
|
||||||
|
|
||||||
|
override var c: Int = 2
|
||||||
|
private set
|
||||||
|
|
||||||
|
override var d: Int = 3
|
||||||
|
private set
|
||||||
|
}
|
||||||
|
|
||||||
|
interface E : A {
|
||||||
|
override var a: Int
|
||||||
|
get() = 0
|
||||||
|
// Errors here and below
|
||||||
|
private set(arg) {}
|
||||||
|
|
||||||
|
override var b: Int
|
||||||
|
get() = 0
|
||||||
|
private set(arg) {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import<!SYNTAX!><!>
|
||||||
|
|
||||||
|
fun firstFun() {}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun test() {
|
||||||
|
fun <T> foo(){}
|
||||||
|
foo<in Int>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
interface A<T> {}
|
||||||
|
interface B<T> {}
|
||||||
|
interface C<T> {}
|
||||||
|
interface D<T> {}
|
||||||
|
|
||||||
|
interface Test : A<in Int>, B<out Int>, C<*>???, D<Int> {}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
var x : Int = 1 + x
|
||||||
|
get() : Int = 1
|
||||||
|
set(value : Long) {
|
||||||
|
field = value.toInt()
|
||||||
|
field = 1.toLong()
|
||||||
|
}
|
||||||
|
|
||||||
|
val xx : Int = 1 + x
|
||||||
|
get() : Int = 1
|
||||||
|
set(value : Long) {}
|
||||||
|
|
||||||
|
val p : Int = 1
|
||||||
|
get() = 1
|
||||||
|
|
||||||
|
class Test() {
|
||||||
|
var a : Int = 111
|
||||||
|
var b : Int = 222
|
||||||
|
get() = field
|
||||||
|
set(x) {a = x; field = x}
|
||||||
|
|
||||||
|
public val i = 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
class Foo(val a: Int, b: Int) {
|
||||||
|
val c = a + b
|
||||||
|
|
||||||
|
val d: Int
|
||||||
|
get() = a
|
||||||
|
|
||||||
|
val e: Int
|
||||||
|
get() = b
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
package qualified_expressions
|
||||||
|
|
||||||
|
fun test(s: IntRange?) {
|
||||||
|
val a: Int = s?.start
|
||||||
|
val b: Int? = s?.start
|
||||||
|
val c: Int = s?.start ?: -11
|
||||||
|
val d: Int = s?.start ?: "empty"
|
||||||
|
val e: String = s?.start ?: "empty"
|
||||||
|
val f: Int = s?.endInclusive ?: b ?: 1
|
||||||
|
val g: Boolean? = e.startsWith("s")//?.length
|
||||||
|
}
|
||||||
|
|
||||||
|
fun String.startsWith(s: String): Boolean = true
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
class Test(foo: Any?, bar: Any?) {
|
||||||
|
val foo = foo ?: this
|
||||||
|
private val bar = bar ?: this
|
||||||
|
private val bas = bas()
|
||||||
|
val bas2 = bas2()
|
||||||
|
|
||||||
|
private fun bas(): Int = null!!
|
||||||
|
private fun bas2(): Int = null!!
|
||||||
|
|
||||||
|
fun bar() = bar(1)
|
||||||
|
fun bar(i: Int) = 2
|
||||||
|
private fun bar2() = bar2(1)
|
||||||
|
private fun bar2(i: Int) = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
// KT-6413 Typechecker recursive problem when class have non-invariant generic parameters
|
||||||
|
class Test2<A, B, C>(foo: Any?, bar: Any?) {
|
||||||
|
val foo = foo ?: this
|
||||||
|
private val bar = bar ?: this
|
||||||
|
private val bas = bas()
|
||||||
|
val bas2 = bas2()
|
||||||
|
|
||||||
|
private fun bas(): Int = null!!
|
||||||
|
private fun bas2(): Int = null!!
|
||||||
|
|
||||||
|
fun bar() = bar(1)
|
||||||
|
fun bar(i: Int) = 2
|
||||||
|
private fun bar2() = bar2(1)
|
||||||
|
private fun bar2(i: Int) = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
class Test3<in A, B, C>(foo: Any?, bar: Any?) {
|
||||||
|
val foo = foo ?: this
|
||||||
|
private val bar = bar ?: this
|
||||||
|
private val bas = bas()
|
||||||
|
val bas2 = bas2()
|
||||||
|
|
||||||
|
private fun bas(): Int = null!!
|
||||||
|
private fun bas2(): Int = null!!
|
||||||
|
|
||||||
|
fun bar() = bar(1)
|
||||||
|
fun bar(i: Int) = 2
|
||||||
|
private fun bar2() = bar2(1)
|
||||||
|
private fun bar2(i: Int) = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
class Test4<A, out B, C>(foo: Any?, bar: Any?) {
|
||||||
|
val foo = foo ?: this
|
||||||
|
private val bar = bar ?: this
|
||||||
|
private val bas = bas()
|
||||||
|
val bas2 = bas2()
|
||||||
|
|
||||||
|
private fun bas(): Int = null!!
|
||||||
|
private fun bas2(): Int = null!!
|
||||||
|
|
||||||
|
fun bar() = bar(1)
|
||||||
|
fun bar(i: Int) = 2
|
||||||
|
private fun bar2() = bar2(1)
|
||||||
|
private fun bar2(i: Int) = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
class Test5<A, out B, C>(foo: Any?, bar: Any?) {
|
||||||
|
val foo = foo ?: this
|
||||||
|
private val bar = bar ?: this
|
||||||
|
private val bas: Int = bas()
|
||||||
|
val bas2 = bas2()
|
||||||
|
|
||||||
|
private fun bas(): Int = null!!
|
||||||
|
private fun bas2(): Int = null!!
|
||||||
|
|
||||||
|
fun bar() = bar(1)
|
||||||
|
fun bar(i: Int) = 2
|
||||||
|
private fun bar2(): Int = bar2(1)
|
||||||
|
private fun bar2(i: Int) = 2
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
// NI_EXPECTED_FILE
|
||||||
|
|
||||||
|
// FILE: f.kt
|
||||||
|
package a
|
||||||
|
val foo = bar()
|
||||||
|
|
||||||
|
fun bar() = foo
|
||||||
|
|
||||||
|
// FILE: f.kt
|
||||||
|
package b
|
||||||
|
fun foo() = bar()
|
||||||
|
|
||||||
|
fun bar() = foo()
|
||||||
|
|
||||||
|
// FILE: f.kt
|
||||||
|
package c
|
||||||
|
fun bazz() = bar()
|
||||||
|
|
||||||
|
fun foo() = bazz()
|
||||||
|
|
||||||
|
fun bar() = foo()
|
||||||
|
|
||||||
|
// FILE: f.kt
|
||||||
|
|
||||||
|
package ok.a
|
||||||
|
val foo = bar()
|
||||||
|
|
||||||
|
fun bar() : Int = foo
|
||||||
|
|
||||||
|
// FILE: f.kt
|
||||||
|
package ok.b
|
||||||
|
fun foo() : Int = bar()
|
||||||
|
|
||||||
|
fun bar() = foo()
|
||||||
|
|
||||||
|
// FILE: f.kt
|
||||||
|
package ok.c
|
||||||
|
fun bazz() = bar()
|
||||||
|
|
||||||
|
fun foo() : Int = bazz()
|
||||||
|
|
||||||
|
fun bar() = foo()
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION -UNREACHABLE_CODE -UNUSED_VARIABLE
|
||||||
|
|
||||||
|
// FILE: 1.kt
|
||||||
|
package p1.yield
|
||||||
|
|
||||||
|
import p1.yield.yield
|
||||||
|
import p1.yield.foo
|
||||||
|
|
||||||
|
val yield = 5
|
||||||
|
fun foo(){}
|
||||||
|
|
||||||
|
fun bar(yield: Int = 4) {}
|
||||||
|
|
||||||
|
fun yield(yield: Int) {
|
||||||
|
"$yield"
|
||||||
|
"${yield}"
|
||||||
|
|
||||||
|
yield
|
||||||
|
val foo = yield + yield
|
||||||
|
val foo2 = yield
|
||||||
|
|
||||||
|
bar(yield = 5)
|
||||||
|
|
||||||
|
yield(4)
|
||||||
|
yield {}
|
||||||
|
|
||||||
|
class yield<T: yield<T>>
|
||||||
|
|
||||||
|
return@yield
|
||||||
|
return@yield Unit
|
||||||
|
|
||||||
|
val foo5: yield<*>
|
||||||
|
}
|
||||||
|
|
||||||
|
fun yield(i: (Int) -> Unit) {}
|
||||||
|
|
||||||
|
// FILE: 2.kt
|
||||||
|
|
||||||
|
package p2.yield
|
||||||
|
|
||||||
|
import p2.yield.yield
|
||||||
|
import p2.yield.foo
|
||||||
|
|
||||||
|
val yield = 5
|
||||||
|
fun foo(){}
|
||||||
|
|
||||||
|
fun bar(yield: Int = 4) {}
|
||||||
|
|
||||||
|
fun yield(yield: Int) {
|
||||||
|
"$`yield`"
|
||||||
|
"${`yield`}"
|
||||||
|
|
||||||
|
`yield`
|
||||||
|
val foo = `yield` + `yield`
|
||||||
|
val foo2 = `yield`
|
||||||
|
|
||||||
|
bar(`yield` = 5)
|
||||||
|
|
||||||
|
`yield`(4)
|
||||||
|
`yield` {}
|
||||||
|
|
||||||
|
class `yield`<T: `yield`<T>>
|
||||||
|
|
||||||
|
return@`yield`
|
||||||
|
return@`yield` Unit
|
||||||
|
|
||||||
|
val foo5: `yield`<*>
|
||||||
|
}
|
||||||
|
|
||||||
|
fun yield(i: (Int) -> Unit) {}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER -UNUSED_EXPRESSION -UNREACHABLE_CODE -UNUSED_VARIABLE -WRONG_ANNOTATION_TARGET -UNUSED_LAMBDA_EXPRESSION
|
||||||
|
|
||||||
|
// FILE: 1.kt
|
||||||
|
|
||||||
|
annotation class yield
|
||||||
|
|
||||||
|
fun bar(p: Int) {
|
||||||
|
yield@ p
|
||||||
|
`yield`@ p
|
||||||
|
|
||||||
|
@yield() p
|
||||||
|
@`yield`() p
|
||||||
|
|
||||||
|
for (yield in 1..5) {
|
||||||
|
|
||||||
|
}
|
||||||
|
{ yield: Int -> }
|
||||||
|
|
||||||
|
val (yield) = listOf(4)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> listOf(vararg e: T): List<T> = null!!
|
||||||
|
operator fun <T> List<T>.component1() = get(0)
|
||||||
|
|
||||||
|
// FILE: 2.kt
|
||||||
|
package p3
|
||||||
|
|
||||||
|
enum class yield {
|
||||||
|
yield
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f1(yield: Int, foo: Int = yield) {}
|
||||||
|
|
||||||
|
fun f2(foo: yield) {}
|
||||||
|
|
||||||
|
// FILE: 3.kt
|
||||||
|
package p4
|
||||||
|
|
||||||
|
typealias yield = Number
|
||||||
|
|
||||||
|
fun <yield: Number> f1() {}
|
||||||
|
fun <y: yield> f2() {}
|
||||||
|
|
||||||
|
// FILE: 4.kt
|
||||||
|
object X {
|
||||||
|
fun yield() {}
|
||||||
|
|
||||||
|
fun test3(yield: Int) {
|
||||||
|
X::yield
|
||||||
|
|
||||||
|
yield::toInt
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
// Fixpoint generic in Java: Enum<T extends Enum<T>>
|
||||||
|
fun test(a : java.lang.annotation.RetentionPolicy) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
java.util.Collections.emptyList()
|
||||||
|
val a : Collection<String>? = java.util.Collections.emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test(a : java.lang.Comparable<Int>) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test(a : java.util.ArrayList<Int>) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test(a : java.lang.Class<Int>) {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
// !CHECK_TYPE
|
||||||
|
// JAVAC_SKIP
|
||||||
|
// FULL_JDK
|
||||||
|
|
||||||
|
// FILE: f.kt
|
||||||
|
|
||||||
|
import java.*
|
||||||
|
import java.util.*
|
||||||
|
import utils.*
|
||||||
|
|
||||||
|
import java.io.PrintStream
|
||||||
|
import java.lang.Comparable as Com
|
||||||
|
|
||||||
|
val l : MutableList<in Int> = ArrayList<Int>()
|
||||||
|
|
||||||
|
fun test(l : java.util.List<Int>) {
|
||||||
|
val x : java.List
|
||||||
|
val y : java.util.List<Int>
|
||||||
|
val b : java.lang.Object
|
||||||
|
val z : java.utils.List<Int>
|
||||||
|
|
||||||
|
val f : java.io.File? = null
|
||||||
|
|
||||||
|
Collections.<!UNRESOLVED_REFERENCE!>emptyList<!>
|
||||||
|
Collections.<!UNRESOLVED_REFERENCE!>emptyList<!><Int>
|
||||||
|
Collections.emptyList<Int>()
|
||||||
|
Collections.emptyList()
|
||||||
|
|
||||||
|
checkSubtype<Set<Int>?>(Collections.singleton<Int>(1))
|
||||||
|
Collections.<!INAPPLICABLE_CANDIDATE!>singleton<!><Int>(1.0)
|
||||||
|
|
||||||
|
List<Int>
|
||||||
|
|
||||||
|
|
||||||
|
val o = "sdf" as Object
|
||||||
|
|
||||||
|
try {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
catch(e: Exception) {
|
||||||
|
System.out.println(e.message)
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintStream("sdf")
|
||||||
|
|
||||||
|
val c : Com<Int>? = null
|
||||||
|
|
||||||
|
checkSubtype<java.lang.Comparable<Int>?>(c)
|
||||||
|
|
||||||
|
// Collections.sort<Integer>(ArrayList<Integer>())
|
||||||
|
xxx.<!UNRESOLVED_REFERENCE!>Class<!>()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FILE: f.kt
|
||||||
|
package xxx
|
||||||
|
import java.lang.Class;
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package <!SYNTAX!>return<!>
|
||||||
|
|
||||||
|
class A {
|
||||||
|
fun outer() {
|
||||||
|
fun inner() {
|
||||||
|
if (1 < 2)
|
||||||
|
return@inner
|
||||||
|
else
|
||||||
|
return@outer
|
||||||
|
}
|
||||||
|
if (1 < 2)
|
||||||
|
return@A
|
||||||
|
else if (2 < 3)
|
||||||
|
return@inner
|
||||||
|
return@outer
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun foo1(): () -> String = return { "some long expression "}
|
||||||
|
fun foo2(): () -> String = return@label { "some long expression "}
|
||||||
|
fun foo3(): () -> String = return<!SYNTAX!>@<!> { "some long expression "}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
class Rule(val apply:() -> Unit)
|
||||||
|
|
||||||
|
fun bar() {}
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
val rule: Rule? = Rule { bar() }
|
||||||
|
|
||||||
|
// this compiles and works
|
||||||
|
val apply = rule?.apply
|
||||||
|
if (apply != null) apply()
|
||||||
|
|
||||||
|
// this compiles and works
|
||||||
|
rule?.apply?.invoke()
|
||||||
|
|
||||||
|
// this should be an error
|
||||||
|
rule?.apply()
|
||||||
|
|
||||||
|
// these both also ok (with smart cast / unnecessary safe call)
|
||||||
|
if (rule != null) {
|
||||||
|
rule.apply()
|
||||||
|
rule?.apply()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// http://youtrack.jetbrains.net/issue/KT-418
|
||||||
|
|
||||||
|
fun ff() {
|
||||||
|
val i: Int = 1
|
||||||
|
val a: Int = i?.plus(2)
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
fun Int.gg() = null
|
||||||
|
|
||||||
|
fun ff() {
|
||||||
|
val a: Int = 1
|
||||||
|
val b: Int = a?.gg()
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// FILE: Test.java
|
||||||
|
public class Test {
|
||||||
|
public static final String FOO = "test";
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: anotherTest.kt
|
||||||
|
package foo
|
||||||
|
|
||||||
|
val s: String = "test"
|
||||||
|
|
||||||
|
// FILE: test.kt
|
||||||
|
fun ff() {
|
||||||
|
val a = Test?.FOO
|
||||||
|
val b = foo?.s
|
||||||
|
System?.out.println(a + b)
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
// http://youtrack.jetbrains.net/issue/KT-413
|
||||||
|
|
||||||
|
open class A {
|
||||||
|
fun f() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class B : A() {
|
||||||
|
fun g() {
|
||||||
|
super?.f()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
fun use(s: java.io.Serializable) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun useList(s: List<java.io.Serializable>) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testPrimitives(b: Byte, ss: Short, i: Int, l: Long, d: Double, s: String, f: Float, bool: Boolean) {
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(b)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(ss)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(i)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(l)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(s)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(f)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(d)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(bool)
|
||||||
|
}
|
||||||
|
|
||||||
|
class N
|
||||||
|
class S: java.io.Serializable
|
||||||
|
|
||||||
|
fun testArrays(ia: IntArray, ai: Array<Int>, an: Array<N>, a: Array<S>) {
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(ia)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(ai)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(an)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(a)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testLiterals() {
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(1)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(1.0)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(11111111111111)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>("Asdsd")
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testNotSerializable(l: List<Int>) {
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(l)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(N())
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class C {
|
||||||
|
E, E2
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testEnums(a: Enum<*>) {
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(C.E)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(C.E2)
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>use<!>(a)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testLists(a: List<Int>) {
|
||||||
|
<!INAPPLICABLE_CANDIDATE!>useList<!>(a)
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
class My {
|
||||||
|
var x: Int = 0
|
||||||
|
// Ok
|
||||||
|
private set
|
||||||
|
|
||||||
|
private var y: Int = 1
|
||||||
|
// Error: better
|
||||||
|
public set
|
||||||
|
|
||||||
|
protected var z: Int = 2
|
||||||
|
// Ok
|
||||||
|
private set
|
||||||
|
|
||||||
|
protected var w: Int = 3
|
||||||
|
// Error: incompatible
|
||||||
|
internal set
|
||||||
|
|
||||||
|
internal var v: Int = 4
|
||||||
|
// Error: incompatible
|
||||||
|
protected set
|
||||||
|
|
||||||
|
internal var t: Int = 5
|
||||||
|
// Error: better
|
||||||
|
public set
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
// FILE: f.kt
|
||||||
|
class A {
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: f.kt
|
||||||
|
package n
|
||||||
|
class B
|
||||||
|
// FILE: f.kt
|
||||||
|
abstract class XXX() {
|
||||||
|
abstract val a : Int
|
||||||
|
abstract val a2 : n.B
|
||||||
|
abstract val a3 : (A)
|
||||||
|
abstract val a31 : (n.B)
|
||||||
|
abstract val a4 : A?
|
||||||
|
abstract val a5 : (A)?
|
||||||
|
abstract val a6 : (A?)
|
||||||
|
abstract val a7 : (A) -> n.B
|
||||||
|
abstract val a8 : (A, n.B) -> n.B
|
||||||
|
|
||||||
|
//val a9 : (A, B)
|
||||||
|
//val a10 : (B)? -> B
|
||||||
|
|
||||||
|
val a11 : ((Int) -> Int)? = null
|
||||||
|
val a12 : ((Int) -> (Int))? = null
|
||||||
|
abstract val a13 : Int.(Int) -> Int
|
||||||
|
abstract val a14 : n.B.(Int) -> Int
|
||||||
|
abstract val a15 : Int? .(Int) -> Int
|
||||||
|
abstract val a152 : (Int?).(Int) -> Int
|
||||||
|
// abstract val a151 : Int?.(Int) -> Int
|
||||||
|
abstract val a16 : (Int) -> (Int) -> Int
|
||||||
|
abstract val a17 : ((Int) -> Int).(Int) -> Int
|
||||||
|
abstract val a18 : (Int) -> ((Int) -> Int)
|
||||||
|
abstract val a19 : ((Int) -> Int) -> Int
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class YYY() {
|
||||||
|
abstract val a7 : (a : A) -> n.B
|
||||||
|
abstract val a8 : (a : A, b : n.B) -> n.B
|
||||||
|
//val a9 : (A, B)
|
||||||
|
//val a10 : (B)? -> B
|
||||||
|
val a11 : ((a : Int) -> Int)? = null
|
||||||
|
val a12 : ((a : Int) -> (Int))? = null
|
||||||
|
abstract val a13 : Int.(a : Int) -> Int
|
||||||
|
abstract val a14 : n.B.(a : Int) -> Int
|
||||||
|
abstract val a15 : Int? .(a : Int) -> Int
|
||||||
|
abstract val a152 : (Int?).(a : Int) -> Int
|
||||||
|
//abstract val a151 : Int?.(a : Int) -> Int
|
||||||
|
abstract val a16 : (a : Int) -> (a : Int) -> Int
|
||||||
|
abstract val a17 : ((a : Int) -> Int).(a : Int) -> Int
|
||||||
|
abstract val a18 : (a : Int) -> ((a : Int) -> Int)
|
||||||
|
abstract val a19 : (b : (a : Int) -> Int) -> Int
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// !LANGUAGE: -SingleUnderscoreForParameterName
|
||||||
|
|
||||||
|
data class A(val x: Int, val y: Int)
|
||||||
|
|
||||||
|
fun foo(a: Array<A>) {
|
||||||
|
val (_, y) = A(1, 2)
|
||||||
|
y.hashCode()
|
||||||
|
|
||||||
|
val q1: (Int, String) -> Unit = {
|
||||||
|
_, s -> s.hashCode()
|
||||||
|
}
|
||||||
|
q1(1, "")
|
||||||
|
|
||||||
|
val q2: (Int, String) -> Unit = fun(_: Int, s: String) {
|
||||||
|
s.hashCode()
|
||||||
|
}
|
||||||
|
q2(1, "")
|
||||||
|
|
||||||
|
val q3: (A) -> Unit = {
|
||||||
|
(_, y) -> y.hashCode()
|
||||||
|
}
|
||||||
|
q3(A(2, 3))
|
||||||
|
|
||||||
|
for ((_, z) in a) {
|
||||||
|
z.hashCode()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
|
||||||
|
fun <T> getT() {}
|
||||||
|
fun <A, B> getTT() {}
|
||||||
|
fun <A, B, C> getTTT(x : Any) {}
|
||||||
|
fun foo(a : Any?) {}
|
||||||
|
|
||||||
|
public fun main() {
|
||||||
|
getT<*>()
|
||||||
|
<!UNRESOLVED_REFERENCE!>ggetT<!><*>()
|
||||||
|
getTT<*, *>()
|
||||||
|
getTT<*, Int>()
|
||||||
|
getTT<Int, *>()
|
||||||
|
foo(getTTT<Int, *, Int>(1))
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
|
infix fun Any?.foo(a: Any) {}
|
||||||
|
operator fun Any?.contains(a: Any): Boolean = true
|
||||||
|
|
||||||
|
fun test(a: Any) {
|
||||||
|
|
||||||
|
a foo""
|
||||||
|
a foo"asd"
|
||||||
|
a foo"$a"
|
||||||
|
a foo"asd${a}sfsa"
|
||||||
|
a foo"""sdf"""
|
||||||
|
a foo'd'
|
||||||
|
a foo<!INFERENCE_ERROR!>''<!>
|
||||||
|
|
||||||
|
a foo""foo a
|
||||||
|
a foo"asd"foo a
|
||||||
|
a foo"$a"foo a
|
||||||
|
a foo"asd${a}sfsa"foo a
|
||||||
|
a foo"""sdf"""foo a
|
||||||
|
a foo'd'foo a
|
||||||
|
a foo<!INFERENCE_ERROR!>''<!>foo a
|
||||||
|
|
||||||
|
a in"foo"
|
||||||
|
a in"""foo"""
|
||||||
|
a in's'
|
||||||
|
a in<!INFERENCE_ERROR!>''<!>
|
||||||
|
|
||||||
|
a !in"foo"
|
||||||
|
a !in"""foo"""
|
||||||
|
a !in's'
|
||||||
|
a !in<!INFERENCE_ERROR!>''<!>
|
||||||
|
|
||||||
|
if("s"is Any) {}
|
||||||
|
if("s"is Any) {}
|
||||||
|
test("s"as Any)
|
||||||
|
|
||||||
|
a foo""<!SYNTAX!>1<!>
|
||||||
|
a foo""<!SYNTAX!>1.0<!>
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user