Merge remote branch 'origin'
This commit is contained in:
@@ -84,6 +84,7 @@ fun foo(a : Boolean, b : Int) : Unit {}
|
||||
---------------------
|
||||
l0:
|
||||
<START>
|
||||
read (Unit)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
@@ -94,6 +95,7 @@ fun genfun<T>() : Unit {}
|
||||
---------------------
|
||||
l0:
|
||||
<START>
|
||||
read (Unit)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
@@ -104,6 +106,7 @@ fun flfun(f : fun () : Any) : Unit {}
|
||||
---------------------
|
||||
l0:
|
||||
<START>
|
||||
read (Unit)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
|
||||
@@ -3,6 +3,7 @@ fun empty() {}
|
||||
---------------------
|
||||
l0:
|
||||
<START>
|
||||
read (Unit)
|
||||
l1:
|
||||
<END>
|
||||
error:
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
namespace abstract
|
||||
|
||||
class MyClass() {
|
||||
//properties
|
||||
val <error>a</error>: Int
|
||||
val a1: Int = 1
|
||||
<error>abstract</error> val a2: Int
|
||||
<error>abstract</error> val a3: Int = 1
|
||||
|
||||
var <error>b</error>: Int private set
|
||||
var b1: Int = 0; private set
|
||||
<error>abstract</error> var b2: Int private set
|
||||
<error>abstract</error> var b3: Int = 0; private set
|
||||
|
||||
var <error>c</error>: Int set(v: Int) { $c = v }
|
||||
var c1: Int = 0; set(v: Int) { $c1 = v }
|
||||
<error>abstract</error> var c2: Int set(v: Int) { $c2 = v }
|
||||
<error>abstract</error> var c3: Int = 0; set(v: Int) { $c3 = v }
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <error>0</error>; get() = a
|
||||
<error>abstract</error> val e2: Int get() = a
|
||||
<error>abstract</error> val e3: Int = 0; get() = a
|
||||
|
||||
//methods
|
||||
fun <error>f</error>()
|
||||
fun g() {}
|
||||
<error>abstract</error> fun h()
|
||||
<error><error>abstract</error></error> fun j() {}
|
||||
}
|
||||
|
||||
abstract class MyAbstractClass() {
|
||||
//properties
|
||||
val <error>a</error>: Int
|
||||
val a1: Int = 1
|
||||
abstract val a2: Int
|
||||
abstract val a3: Int = <error>1</error>
|
||||
|
||||
var <error>b</error>: Int private set
|
||||
var b1: Int = 0; private set
|
||||
abstract var b2: Int private set
|
||||
abstract var b3: Int = <error>0</error>; private set
|
||||
|
||||
var <error>c</error>: Int set(v: Int) { $c = v }
|
||||
var c1: Int = 0; set(v: Int) { $c1 = v }
|
||||
abstract var c2: Int <error>set(v: Int) { $c2 = v }</error>
|
||||
abstract var c3: Int = <error>0</error>; <error>set(v: Int) { $c3 = v }</error>
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <error>0</error>; get() = a
|
||||
abstract val e2: Int <error>get() = a</error>
|
||||
abstract val e3: Int = <error>0</error>; <error>get() = a</error>
|
||||
|
||||
//methods
|
||||
fun <error>f</error>()
|
||||
fun g() {}
|
||||
abstract fun h()
|
||||
<error>abstract</error> fun j() {}
|
||||
}
|
||||
|
||||
trait MyTrait {
|
||||
//properties
|
||||
val a: Int
|
||||
val a1: Int = <error>1</error>
|
||||
<warning>abstract</warning> val a2: Int
|
||||
<warning>abstract</warning> val a3: Int = <error>1</error>
|
||||
|
||||
var b: Int private set
|
||||
var b1: Int = <error>0</error>; private set
|
||||
<warning>abstract</warning> var b2: Int private set
|
||||
<warning>abstract</warning> var b3: Int = <error>0</error>; private set
|
||||
|
||||
var <error>c</error>: Int set(v: Int) { $c = v }
|
||||
var <error>c1</error>: Int = <error>0</error>; set(v: Int) { $c1 = v }
|
||||
<warning>abstract</warning> var c2: Int <error>set(v: Int) { $c2 = v }</error>
|
||||
<warning>abstract</warning> var c3: Int = <error>0</error>; <error>set(v: Int) { $c3 = v }</error>
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <error>0</error>; get() = a
|
||||
<warning>abstract</warning> val e2: Int <error>get() = a</error>
|
||||
<warning>abstract</warning> val e3: Int = <error>0</error>; <error>get() = a</error>
|
||||
|
||||
//methods
|
||||
fun f()
|
||||
fun g() {}
|
||||
<warning>abstract</warning> fun h()
|
||||
<error>abstract</error> fun j() {}
|
||||
}
|
||||
|
||||
enum class MyEnum() {
|
||||
//properties
|
||||
val <error>a</error>: Int
|
||||
val a1: Int = 1
|
||||
abstract val a2: Int
|
||||
abstract val a3: Int = <error>1</error>
|
||||
|
||||
var <error>b</error>: Int private set
|
||||
var b1: Int = 0; private set
|
||||
abstract var b2: Int private set
|
||||
abstract var b3: Int = <error>0</error>; private set
|
||||
|
||||
var <error>c</error>: Int set(v: Int) { $c = v }
|
||||
var c1: Int = 0; set(v: Int) { $c1 = v }
|
||||
abstract var c2: Int <error>set(v: Int) { $c2 = v }</error>
|
||||
abstract var c3: Int = <error>0</error>; <error>set(v: Int) { $c3 = v }</error>
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <error>0</error>; get() = a
|
||||
abstract val e2: Int <error>get() = a</error>
|
||||
abstract val e3: Int = <error>0</error>; <error>get() = a</error>
|
||||
|
||||
//methods
|
||||
fun <error>f</error>()
|
||||
fun g() {}
|
||||
abstract fun h()
|
||||
<error>abstract</error> fun j() {}
|
||||
}
|
||||
|
||||
abstract enum class MyAbstractEnum() {}
|
||||
|
||||
namespace MyNamespace {
|
||||
//properties
|
||||
val <error>a</error>: Int
|
||||
val a1: Int = 1
|
||||
<error>abstract</error> val a2: Int
|
||||
<error>abstract</error> val a3: Int = 1
|
||||
|
||||
var <error>b</error>: Int private set
|
||||
var b1: Int = 0; private set
|
||||
<error>abstract</error> var b2: Int private set
|
||||
<error>abstract</error> var b3: Int = 0; private set
|
||||
|
||||
var <error>c</error>: Int set(v: Int) { $c = v }
|
||||
var c1: Int = 0; set(v: Int) { $c1 = v }
|
||||
<error>abstract</error> var c2: Int set(v: Int) { $c2 = v }
|
||||
<error>abstract</error> var c3: Int = 0; set(v: Int) { $c3 = v }
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <error>0</error>; get() = a
|
||||
<error>abstract</error> val e2: Int get() = a
|
||||
<error>abstract</error> val e3: Int = 0; get() = a
|
||||
|
||||
//methods
|
||||
fun <error>f</error>()
|
||||
fun g() {}
|
||||
<error>abstract</error> fun h()
|
||||
<error>abstract</error> fun j() {}
|
||||
}
|
||||
|
||||
//creating an instance
|
||||
abstract class B1(
|
||||
val i: Int,
|
||||
val s: String
|
||||
) {
|
||||
}
|
||||
|
||||
class B2() : B1(1, "r") {}
|
||||
|
||||
abstract class B3(i: Int) {
|
||||
this(): this(1)
|
||||
}
|
||||
|
||||
fun foo(a: B3) {
|
||||
val a = <error>B3()</error>
|
||||
val b = <error>B1(2, "s")</error>
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
class A() {
|
||||
fun equals(a : Any?) : Boolean
|
||||
fun equals(a : Any?) : Boolean = false
|
||||
}
|
||||
|
||||
class B() {
|
||||
fun equals(a : Any?) : Boolean?
|
||||
fun equals(a : Any?) : Boolean? = false
|
||||
}
|
||||
|
||||
class C() {
|
||||
fun equals(a : Any?) : Int
|
||||
fun equals(a : Any?) : Int = 0
|
||||
}
|
||||
|
||||
fun f(): Unit {
|
||||
@@ -32,7 +32,7 @@ fun f(): Unit {
|
||||
x !== 1
|
||||
|
||||
x<error>..</error>2
|
||||
x <error>in</error> 1..2
|
||||
<error>x</error> in 1..2
|
||||
|
||||
val y : Boolean? = true
|
||||
false || <error>y</error>
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace boundsWithSubstitutors {
|
||||
open class A {}
|
||||
open class B<T : A>()
|
||||
|
||||
class C<T : B<<error>Int</error>>, X : fun (B<<error>Char</error>>) : (B<<error>Any</error>>, B<A>)>() : B<<error>Any</error>>() { // 2 errors
|
||||
abstract class C<T : B<<error>Int</error>>, X : fun (B<<error>Char</error>>) : (B<<error>Any</error>>, B<A>)>() : B<<error>Any</error>>() { // 2 errors
|
||||
val a = B<<error>Char</error>>() // error
|
||||
|
||||
val x : fun (B<<error>Char</error>>) : B<<error>Any</error>>
|
||||
abstract val x : fun (B<<error>Char</error>>) : B<<error>Any</error>>
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
import java.util.*
|
||||
|
||||
namespace html {
|
||||
|
||||
abstract class Factory<T> {
|
||||
abstract fun create() : T
|
||||
}
|
||||
|
||||
abstract class Element
|
||||
|
||||
class TextElement(val text : String) : Element
|
||||
|
||||
abstract class Tag(val name : String) : Element {
|
||||
val children = ArrayList<Element>()
|
||||
val attributes = HashMap<String, String>()
|
||||
|
||||
protected fun initTag<T : Element>(init : fun T.() : Unit) : T
|
||||
where class object T : Factory<T>{
|
||||
val tag = T.create()
|
||||
tag.init()
|
||||
children.add(tag)
|
||||
return tag
|
||||
}
|
||||
}
|
||||
|
||||
abstract class TagWithText(name : String) : Tag(name) {
|
||||
fun String.plus() {
|
||||
children.add(TextElement(this))
|
||||
}
|
||||
}
|
||||
|
||||
class HTML() : TagWithText("html") {
|
||||
class object : Factory<HTML> {
|
||||
override fun create() = HTML()
|
||||
}
|
||||
|
||||
fun head(init : fun Head.() : Unit) = initTag<Head>(init)
|
||||
|
||||
fun body(init : fun Body.() : Unit) = initTag<Body>(init)
|
||||
}
|
||||
|
||||
class Head() : TagWithText("head") {
|
||||
class object : Factory<Head> {
|
||||
override fun create() = Head()
|
||||
}
|
||||
|
||||
fun title(init : fun Title.() : Unit) = initTag<Title>(init)
|
||||
}
|
||||
|
||||
class Title() : TagWithText("title")
|
||||
|
||||
abstract class BodyTag(name : String) : TagWithText(name) {
|
||||
}
|
||||
|
||||
class Body() : BodyTag("body") {
|
||||
class object : Factory<Body> {
|
||||
override fun create() = Body()
|
||||
}
|
||||
|
||||
fun b(init : fun B.() : Unit) = initTag<B>(init)
|
||||
fun p(init : fun P.() : Unit) = initTag<P>(init)
|
||||
fun h1(init : fun H1.() : Unit) = initTag<H1>(init)
|
||||
fun a(href : String, init : fun A.() : Unit) {
|
||||
val a = initTag<A>(init)
|
||||
a.href = href
|
||||
}
|
||||
}
|
||||
|
||||
class B() : BodyTag("b")
|
||||
class P() : BodyTag("p")
|
||||
class H1() : BodyTag("h1")
|
||||
class A() : BodyTag("a") {
|
||||
var href : String
|
||||
get() = attributes["href"]
|
||||
set(value) { attributes["href"] = value }
|
||||
}
|
||||
|
||||
fun Map<String, String>.set(key : String, value : String) = this.put(key, value)
|
||||
|
||||
fun html(init : fun HTML.() : Unit) : HTML {
|
||||
val html = HTML()
|
||||
html.init()
|
||||
return html
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace foo {
|
||||
|
||||
import html.*
|
||||
|
||||
fun result(args : Array<String>) =
|
||||
html {
|
||||
head {
|
||||
title {+"XML encoding with Groovy"}
|
||||
}
|
||||
body {
|
||||
h1 {+"XML encoding with Groovy"}
|
||||
p {+"this format can be used as an alternative markup to XML"}
|
||||
|
||||
// an element with attributes and text content
|
||||
a(href = "http://groovy.codehaus.org") {+"Groovy"}
|
||||
|
||||
// mixed content
|
||||
p {
|
||||
+"This is some"
|
||||
b {+"mixed"}
|
||||
+"text. For more see the"
|
||||
a(href = "http://groovy.codehaus.org") {+"Groovy"}
|
||||
+"project"
|
||||
}
|
||||
p {+"some text"}
|
||||
|
||||
// content generated by
|
||||
p {
|
||||
for (arg in args)
|
||||
+arg
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fun test() {
|
||||
1 : Byte
|
||||
1 : Int
|
||||
<error>1</error> : Double
|
||||
1 <warning>as</warning> Byte
|
||||
1 <warning>as</warning> Int
|
||||
<error>1</error> <warning>as</warning> Double
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
class NoC
|
||||
open class NoC
|
||||
class NoC1 : NoC
|
||||
|
||||
class WithC0() : NoC<error>()</error>
|
||||
class WithC1() : NoC
|
||||
open class WithC1() : NoC
|
||||
class NoC2 : <error>WithC1</error>
|
||||
class NoC3 : WithC1<error>()</error>
|
||||
class WithC2() : <error>WithC1</error>
|
||||
@@ -23,7 +23,7 @@ class WithPC1(a : Int) {
|
||||
|
||||
this(s : String) : this(1) {}
|
||||
|
||||
this(b : Char) : this<error>("", 2)</error> {}
|
||||
this(b : Char) : <error>this("", 2)</error> {}
|
||||
|
||||
this(b : Byte) : this(""), <error>this(1)</error> {}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ class Foo() : <error>WithPC0</error>, <error>this</error>() {
|
||||
|
||||
}
|
||||
|
||||
class WithCPI_Dup(<error>x</error> : Int) {
|
||||
class WithCPI_Dup(x : Int) {
|
||||
var <error>x</error> : Int
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
trait A {
|
||||
fun foo() {}
|
||||
}
|
||||
trait B : A, <error>E</error> {}
|
||||
trait C : B {}
|
||||
trait D : <error>B</error> {}
|
||||
trait E : <error>F</error> {}
|
||||
trait F : <error>D</error>, C {}
|
||||
trait G : F {}
|
||||
trait H : F {}
|
||||
|
||||
val a : A? = null
|
||||
val b : B? = null
|
||||
val c : C? = null
|
||||
val d : D? = null
|
||||
val e : E? = null
|
||||
val f : F? = null
|
||||
val g : G? = null
|
||||
val h : H? = null
|
||||
|
||||
fun test() {
|
||||
a?.foo()
|
||||
b?.foo()
|
||||
c?.foo()
|
||||
d?.foo()
|
||||
e?.<error>foo</error>()
|
||||
f?.foo()
|
||||
g?.foo()
|
||||
h?.foo()
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fun Int?.optint() : Unit
|
||||
val Int?.optval : Unit
|
||||
fun Int?.optint() : Unit {}
|
||||
val Int?.optval : Unit = ()
|
||||
|
||||
fun <T, E> T.foo(x : E, y : A) : T {
|
||||
y.plus(1)
|
||||
@@ -16,7 +16,7 @@ class A
|
||||
fun A.plus(a : Any) {
|
||||
|
||||
1.foo()
|
||||
true.foo<error>()</error>
|
||||
true.<error>foo()</error>
|
||||
|
||||
1
|
||||
}
|
||||
@@ -33,7 +33,7 @@ fun test() {
|
||||
val Int.abs : Int
|
||||
get() = if (this > 0) this else -this;
|
||||
|
||||
val <T> T.foo : T
|
||||
val <T> T.<error>foo</error> : T
|
||||
|
||||
fun Int.foo() = this
|
||||
|
||||
@@ -42,11 +42,12 @@ namespace null_safety {
|
||||
fun parse(cmd: String): Command? { return null }
|
||||
class Command() {
|
||||
// fun equals(other : Any?) : Boolean
|
||||
val foo : Int
|
||||
val foo : Int = 0
|
||||
}
|
||||
|
||||
fun Any.equals(other : Any?) : Boolean
|
||||
fun Any?.equals1(other : Any?) : Boolean
|
||||
fun Any.equals(other : Any?) : Boolean = true
|
||||
fun Any?.equals1(other : Any?) : Boolean = true
|
||||
fun Any.equals2(other : Any?) : Boolean = true
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
@@ -56,13 +57,13 @@ namespace null_safety {
|
||||
|
||||
command<error>.</error>foo
|
||||
|
||||
command<error>.</error>equals(null)
|
||||
command?.equals(null)
|
||||
command.equals(null)
|
||||
command<warning>?.</warning>equals(null)
|
||||
command.equals1(null)
|
||||
command<warning>?.</warning>equals1(null)
|
||||
|
||||
val c = Command()
|
||||
c<warning>?.</warning>equals(null)
|
||||
c<warning>?.</warning>equals2(null)
|
||||
|
||||
if (command == null) 1
|
||||
}
|
||||
|
||||
@@ -4,77 +4,77 @@ class NotRange1() {
|
||||
|
||||
}
|
||||
|
||||
class NotRange2() {
|
||||
fun iterator() : Unit
|
||||
abstract class NotRange2() {
|
||||
abstract fun iterator() : Unit
|
||||
}
|
||||
|
||||
class ImproperIterator1 {
|
||||
fun hasNext() : Boolean
|
||||
abstract class ImproperIterator1 {
|
||||
abstract fun hasNext() : Boolean
|
||||
}
|
||||
|
||||
class NotRange3() {
|
||||
fun iterator() : ImproperIterator1
|
||||
abstract class NotRange3() {
|
||||
abstract fun iterator() : ImproperIterator1
|
||||
}
|
||||
|
||||
class ImproperIterator2 {
|
||||
fun next() : Boolean
|
||||
abstract class ImproperIterator2 {
|
||||
abstract fun next() : Boolean
|
||||
}
|
||||
|
||||
class NotRange4() {
|
||||
fun iterator() : ImproperIterator2
|
||||
abstract class NotRange4() {
|
||||
abstract fun iterator() : ImproperIterator2
|
||||
}
|
||||
|
||||
class ImproperIterator3 {
|
||||
fun hasNext() : Int
|
||||
fun next() : Int
|
||||
abstract class ImproperIterator3 {
|
||||
abstract fun hasNext() : Int
|
||||
abstract fun next() : Int
|
||||
}
|
||||
|
||||
class NotRange5() {
|
||||
fun iterator() : ImproperIterator3
|
||||
abstract class NotRange5() {
|
||||
abstract fun iterator() : ImproperIterator3
|
||||
}
|
||||
|
||||
class AmbiguousHasNextIterator {
|
||||
fun hasNext() : Boolean
|
||||
abstract class AmbiguousHasNextIterator {
|
||||
abstract fun hasNext() : Boolean
|
||||
val hasNext : Boolean get() = false
|
||||
fun next() : Int
|
||||
abstract fun next() : Int
|
||||
}
|
||||
|
||||
class NotRange6() {
|
||||
fun iterator() : AmbiguousHasNextIterator
|
||||
abstract class NotRange6() {
|
||||
abstract fun iterator() : AmbiguousHasNextIterator
|
||||
}
|
||||
|
||||
class ImproperIterator4 {
|
||||
abstract class ImproperIterator4 {
|
||||
val hasNext : Int get() = 1
|
||||
fun next() : Int
|
||||
abstract fun next() : Int
|
||||
}
|
||||
|
||||
class NotRange7() {
|
||||
fun iterator() : ImproperIterator3
|
||||
abstract class NotRange7() {
|
||||
abstract fun iterator() : ImproperIterator3
|
||||
}
|
||||
|
||||
class GoodIterator {
|
||||
fun hasNext() : Boolean
|
||||
fun next() : Int
|
||||
abstract class GoodIterator {
|
||||
abstract fun hasNext() : Boolean
|
||||
abstract fun next() : Int
|
||||
}
|
||||
|
||||
class Range0() {
|
||||
fun iterator() : GoodIterator
|
||||
abstract class Range0() {
|
||||
abstract fun iterator() : GoodIterator
|
||||
}
|
||||
|
||||
class Range1() {
|
||||
fun iterator() : Iterator<Int>
|
||||
abstract class Range1() {
|
||||
abstract fun iterator() : Iterator<Int>
|
||||
}
|
||||
|
||||
fun test() {
|
||||
for (i in <error>NotRange1()</error>);
|
||||
for (i in <error>NotRange2()</error>);
|
||||
for (i in <error>NotRange3()</error>);
|
||||
for (i in <error>NotRange4()</error>);
|
||||
for (i in <error>NotRange5()</error>);
|
||||
for (i in <error>NotRange6()</error>);
|
||||
for (i in <error>NotRange7()</error>);
|
||||
for (i in Range0());
|
||||
for (i in Range1());
|
||||
fun test(notRange1: NotRange1, notRange2: NotRange2, notRange3: NotRange3, notRange4: NotRange4, notRange5: NotRange5, notRange6: NotRange6, notRange7: NotRange7, range0: Range0, range1: Range1) {
|
||||
for (i in <error>notRange1</error>);
|
||||
for (i in <error>notRange2</error>);
|
||||
for (i in <error>notRange3</error>);
|
||||
for (i in <error>notRange4</error>);
|
||||
for (i in <error>notRange5</error>);
|
||||
for (i in <error>notRange6</error>);
|
||||
for (i in <error>notRange7</error>);
|
||||
for (i in range0);
|
||||
for (i in range1);
|
||||
|
||||
for (i in (ArrayList<Int>() : List<Int>));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
fun none()
|
||||
fun none() {}
|
||||
|
||||
fun unitEmptyInfer() {}
|
||||
fun unitEmpty() : Unit {}
|
||||
@@ -128,6 +128,8 @@ fun blockNoReturnIfUnitInOneBranch(): Int {
|
||||
}
|
||||
}
|
||||
}
|
||||
fun nonBlockReturnIfEmptyIf(): Int = if (1 < 2) <error>{}</error> else <error>{}</error>
|
||||
fun nonBlockNoReturnIfUnitInOneBranch(): Int = if (1 < 2) <error>{}</error> else 2
|
||||
|
||||
val a = <error>return 1</error>
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
trait A<in T> {}
|
||||
trait B<T> : A<Int> {}
|
||||
trait C<T> : <error>B<T>, A<T></error> {}
|
||||
trait C1<T> : B<T>, A<Any> {}
|
||||
trait D : <error>C<Boolean>, B<Double></error>{}
|
||||
|
||||
trait A1<out T> {}
|
||||
trait B1 : A1<Int> {}
|
||||
trait B2 : A1<Any>, B1 {}
|
||||
|
||||
trait BA1<T> {}
|
||||
trait BB1 : BA1<Int> {}
|
||||
trait BB2 : <error>BA1<Any>, BB1</error> {}
|
||||
|
||||
|
||||
namespace x {
|
||||
trait AA1<out T> {}
|
||||
trait AB1 : AA1<Int> {}
|
||||
trait AB3 : AA1<Comparable<Int>> {}
|
||||
trait AB2 : AA1<Number>, AB1, AB3 {}
|
||||
}
|
||||
|
||||
namespace x2 {
|
||||
trait AA1<out T> {}
|
||||
trait AB1 : AA1<Any> {}
|
||||
trait AB3 : AA1<Comparable<Int>> {}
|
||||
trait AB2 : <error>AA1<Number>, AB1, AB3</error> {}
|
||||
}
|
||||
|
||||
namespace x3 {
|
||||
trait AA1<in T> {}
|
||||
trait AB1 : AA1<Any> {}
|
||||
trait AB3 : AA1<Comparable<Int>> {}
|
||||
trait AB2 : AA1<Number>, AB1, AB3 {}
|
||||
}
|
||||
|
||||
namespace sx2 {
|
||||
trait AA1<in T> {}
|
||||
trait AB1 : AA1<Int> {}
|
||||
trait AB3 : AA1<Comparable<Int>> {}
|
||||
trait AB2 : <error>AA1<Number>, AB1, AB3</error> {}
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
namespace Jet87
|
||||
|
||||
open class A() {
|
||||
fun foo() : Int
|
||||
fun foo() : Int = 1
|
||||
}
|
||||
|
||||
open class B() {
|
||||
fun bar() : Double;
|
||||
trait B {
|
||||
fun bar() : Double = 1.0;
|
||||
}
|
||||
|
||||
class C() : A(), B()
|
||||
class C() : A(), B
|
||||
|
||||
class D() {
|
||||
class object : A(), B () {}
|
||||
class object : A(), B {}
|
||||
}
|
||||
|
||||
class Test1<T : A>()
|
||||
@@ -60,13 +60,13 @@ fun <T : A> test2(t : T)
|
||||
t.bar()
|
||||
}
|
||||
|
||||
val test1 = test2<<error>A</error>>(A())
|
||||
val test2 = test2<<error>B</error>>(B())
|
||||
val test3 = test2<C>(C())
|
||||
val t1 = test2<<error>A</error>>(A())
|
||||
val t2 = test2<<error>B</error>>(C())
|
||||
val t3 = test2<C>(C())
|
||||
|
||||
class Test<<error>T</error>>
|
||||
where
|
||||
class object T : <error>Foo</error>,
|
||||
class object T : A {}
|
||||
|
||||
val <T, B : T> x : Int
|
||||
val <T, B : T> x : Int = 0
|
||||
|
||||
@@ -8,6 +8,10 @@ namespace a {
|
||||
|
||||
}
|
||||
|
||||
abstract class Foo<T>() {
|
||||
abstract val x : T<Int>
|
||||
}
|
||||
|
||||
namespace a {
|
||||
import java.util.*
|
||||
|
||||
@@ -22,25 +26,32 @@ val y1 = a.b
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun done<O>(result : O) : Iteratee<Any?, O>
|
||||
fun done<O>(result : O) : Iteratee<Any?, O> = StrangeIterateeImpl<Any?, O>(result)
|
||||
|
||||
class Iteratee<in I, out O> {
|
||||
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 Sum() : Iteratee<Int, Int> {
|
||||
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);
|
||||
}
|
||||
override val isDone : Boolean
|
||||
override val result : Int
|
||||
override fun done() : Int
|
||||
abstract override val isDone : Boolean
|
||||
abstract override val result : Int
|
||||
abstract override fun done() : Int
|
||||
}
|
||||
|
||||
class Collection<E> : Iterable<E> {
|
||||
abstract class Collection<E> : Iterable<E> {
|
||||
fun iterate<O>(iteratee : Iteratee<E, O>) : O {
|
||||
for (x in this) {
|
||||
val it = iteratee.process(x)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace toplevelObjectDeclarations {
|
||||
class Foo(y : Int) {
|
||||
virtual fun foo() : Int = 1
|
||||
open class Foo(y : Int) {
|
||||
open fun foo() : Int = 1
|
||||
}
|
||||
|
||||
class T : <error>Foo</error> {}
|
||||
@@ -60,11 +60,11 @@ namespace nestedObejcts {
|
||||
|
||||
namespace localObjects {
|
||||
object A {
|
||||
val x : Int
|
||||
val x : Int = 0
|
||||
}
|
||||
|
||||
class Foo {
|
||||
fun foo() : Int
|
||||
open class Foo {
|
||||
fun foo() : Int = 1
|
||||
}
|
||||
|
||||
fun test() {
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
namespace override
|
||||
|
||||
namespace normal {
|
||||
trait MyTrait {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
abstract class MyAbstractClass {
|
||||
abstract fun bar()
|
||||
}
|
||||
|
||||
open class MyClass : MyTrait, MyAbstractClass {
|
||||
override fun foo() {}
|
||||
override fun bar() {}
|
||||
}
|
||||
|
||||
class MyChildClass : MyClass {}
|
||||
|
||||
class <error>MyIllegalClass</error> : MyTrait, MyAbstractClass {}
|
||||
|
||||
class <error>MyIllegalClass2</error> : MyTrait, MyAbstractClass {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
class <error>MyIllegalClass3</error> : MyTrait, MyAbstractClass {
|
||||
override fun bar() {}
|
||||
}
|
||||
|
||||
class <error>MyIllegalClass4</error> : MyTrait, MyAbstractClass {
|
||||
fun <error>foo</error>() {}
|
||||
<error>override</error> fun other() {}
|
||||
}
|
||||
|
||||
class MyChildClass1 : MyClass {
|
||||
fun <error>foo</error>() {}
|
||||
override fun bar() {}
|
||||
}
|
||||
}
|
||||
|
||||
namespace generics {
|
||||
trait MyTrait<T> {
|
||||
fun foo(t: T) : T
|
||||
}
|
||||
|
||||
abstract class MyAbstractClass<T> {
|
||||
abstract fun bar(t: T) : T
|
||||
}
|
||||
|
||||
open class MyGenericClass<T> : MyTrait<T>, MyAbstractClass<T> {
|
||||
override fun foo(t: T) = t
|
||||
override fun bar(t: T) = t
|
||||
}
|
||||
|
||||
class MyChildClass : MyGenericClass<Int> {}
|
||||
class MyChildClass1<T> : MyGenericClass<T> {}
|
||||
class MyChildClass2<T> : MyGenericClass<T> {
|
||||
fun <error>foo</error>(t: T) = t
|
||||
override fun bar(t: T) = t
|
||||
}
|
||||
|
||||
open class MyClass : MyTrait<Int>, MyAbstractClass<String> {
|
||||
override fun foo(i: Int) = i
|
||||
override fun bar(s: String) = s
|
||||
}
|
||||
|
||||
class <error>MyIllegalGenericClass1</error><T> : MyTrait<T>, MyAbstractClass<T> {}
|
||||
class <error>MyIllegalGenericClass2</error><T, R> : MyTrait<T>, MyAbstractClass<R> {
|
||||
<error>override</error> fun foo(r: R) = r
|
||||
}
|
||||
class <error>MyIllegalClass1</error> : MyTrait<Int>, MyAbstractClass<String> {}
|
||||
|
||||
class <error>MyIllegalClass2</error><T> : MyTrait<Int>, MyAbstractClass<Int> {
|
||||
fun foo(t: T) = t
|
||||
fun bar(t: T) = t
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
class <error>X</error> {
|
||||
val x : Int
|
||||
val <error>x</error> : Int
|
||||
}
|
||||
|
||||
class Y() {
|
||||
val x : Int
|
||||
open class Y() {
|
||||
val x : Int = 2
|
||||
}
|
||||
|
||||
class Y1 {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
trait A<T> {}
|
||||
trait B<T> {}
|
||||
trait C<T> {}
|
||||
trait D<T> {}
|
||||
|
||||
trait Test : A<<error>in</error> Int>, B<<error>out</error> Int>, C<<error>*</error>><error>?</error><error>?</error><error>?</error>, D<Int> {}
|
||||
@@ -7,13 +7,13 @@
|
||||
|
||||
val xx : Int = <error>1 + x</error>
|
||||
get() : Int = 1
|
||||
<error>set(ref value : Long) {$x = value}</error>
|
||||
<error>set(value : Long) {}</error>
|
||||
|
||||
val p : Int = <error>1</error>
|
||||
get() = 1
|
||||
|
||||
class Test() {
|
||||
var a : Int
|
||||
var a : Int = 111
|
||||
var b : Int get() = <error>$a</error>; set(x) {a = x; <error>$a</error> = x}
|
||||
|
||||
this(i : Int) : this() {
|
||||
|
||||
@@ -16,7 +16,7 @@ class A() {
|
||||
val z = foo()
|
||||
}
|
||||
|
||||
fun foo() : Unit {
|
||||
fun foo1() : Unit {
|
||||
<error>this</error>
|
||||
this<error>@a</error>
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace a {
|
||||
val foo = bar()
|
||||
val foo = <error>bar()</error>
|
||||
|
||||
fun bar() = <error>foo</error>
|
||||
fun bar() = foo
|
||||
}
|
||||
|
||||
namespace b {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace redeclarations {
|
||||
object <error>A</error> {
|
||||
val x : Int
|
||||
val x : Int = 0
|
||||
|
||||
val A = 1
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ fun test(l : java.util.List<Int>) {
|
||||
Collections.<error>emptyList</error>
|
||||
Collections.emptyList<Int>
|
||||
Collections.emptyList<Int>()
|
||||
Collections.emptyList<error>()</error>
|
||||
Collections.emptyList()
|
||||
|
||||
Collections.singleton<Int>(1) : Set<Int>?
|
||||
Collections.singleton<Int><error>(1.0)</error>
|
||||
Collections.singleton<Int>(<error>1.0</error>)
|
||||
|
||||
<error>List</error><Int>
|
||||
|
||||
@@ -43,7 +43,7 @@ fun test(l : java.util.List<Int>) {
|
||||
c : java.lang.Comparable<Int>?
|
||||
|
||||
// Collections.sort<Integer>(ArrayList<Integer>())
|
||||
xxx.Class<error>()</error>
|
||||
xxx.<error>Class</error>()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
// KT-286 Check supertype lists
|
||||
|
||||
/*
|
||||
In a supertype list:
|
||||
Same type should not be mentioned twice
|
||||
Same type should not be indirectly mentioned with incoherent type arguments
|
||||
Every trait's required dependencies should be satisfied
|
||||
No final types should appear
|
||||
Only one class is allowed
|
||||
*/
|
||||
|
||||
class C1()
|
||||
|
||||
open class OC1()
|
||||
|
||||
open class C2 {}
|
||||
|
||||
open class C3 {}
|
||||
|
||||
trait T1 {}
|
||||
|
||||
trait T2<T> {}
|
||||
|
||||
trait Test<error>()</error> {
|
||||
<error>this</error>(x : Int) {}
|
||||
}
|
||||
|
||||
trait Test1 : C2<error>()</error> {}
|
||||
|
||||
trait Test2 : C2 {}
|
||||
|
||||
trait Test3 : C2, <error>C3</error> {}
|
||||
|
||||
trait Test4 : T1 {}
|
||||
|
||||
trait Test5 : T1, <error>T1</error> {}
|
||||
|
||||
trait Test6 : <error>C1</error> {}
|
||||
|
||||
class CTest1() : OC1() {}
|
||||
|
||||
class CTest2 : C2 {}
|
||||
|
||||
class CTest3 : C2, <error>C3</error> {}
|
||||
|
||||
class CTest4 : T1 {}
|
||||
|
||||
class CTest5 : T1, <error>T1</error> {}
|
||||
|
||||
class CTest6 : <error>C1</error> {}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
open class bar()
|
||||
|
||||
trait Foo<error>()</error> : bar<error>()</error>, <error>bar</error>, <error>bar</error> {
|
||||
<error>this</error>(x : Int) {}
|
||||
}
|
||||
|
||||
trait Foo2 : bar, Foo {
|
||||
}
|
||||
|
||||
open class Foo1() : bar(), <error>bar</error>, Foo, <error>Foo</error><error>()</error> {}
|
||||
open class Foo12 : bar<error>()</error>, <error>bar</error> {}
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace variance
|
||||
|
||||
abstract class Consumer<in T> {}
|
||||
|
||||
abstract class Producer<out T> {}
|
||||
|
||||
abstract class Usual<T> {}
|
||||
|
||||
fun foo(c: Consumer<Int>, p: Producer<Int>, u: Usual<Int>) {
|
||||
val c1: Consumer<Any> = <error>c</error>
|
||||
val c2: Consumer<Int> = c1
|
||||
|
||||
val p1: Producer<Any> = p
|
||||
val p2: Producer<Int> = <error>p1</error>
|
||||
|
||||
val u1: Usual<Any> = <error>u</error>
|
||||
val u2: Usual<Int> = <error>u1</error>
|
||||
}
|
||||
|
||||
//Arrays copy example
|
||||
class Array<T>(val length : Int) {
|
||||
fun get(index : Int) : T { return null }
|
||||
fun set(index : Int, value : T) { /* ... */ }
|
||||
}
|
||||
|
||||
fun copy1(from : Array<Any>, to : Array<Any>) {}
|
||||
|
||||
fun copy2(from : Array<out Any>, to : Array<in Any>) {}
|
||||
|
||||
fun <T> copy3(from : Array<out T>, to : Array<in T>) {}
|
||||
|
||||
fun copy4(from : Array<out Number>, to : Array<in Int>) {}
|
||||
|
||||
fun f(ints: Array<Int>, any: Array<Any>, numbers: Array<Number>) {
|
||||
copy1(<error>ints</error>, any)
|
||||
copy2(ints, any) //ok
|
||||
copy2(ints, <error>numbers</error>)
|
||||
copy3<Int>(ints, numbers)
|
||||
copy4(ints, numbers) //ok
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
class A() {
|
||||
<info>open</info> class A() {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
@@ -215,4 +215,41 @@ fun returnFunctionLiteral(a: Any?): Function0<Int> =
|
||||
|
||||
fun illegalTupleReturnType(a: Any): (Any, String) = (a, <error>a</error>)
|
||||
|
||||
fun declarationInsidePattern(x: (Any, Any)): String = when(x) { is (val a is String, *) => <info descr="Automatically cast to String">a</info>; else => "something" }
|
||||
fun declarationInsidePattern(x: (Any, Any)): String = when(x) { is (val a is String, *) => <info descr="Automatically cast to String">a</info>; else => "something" }
|
||||
|
||||
fun mergeAutocasts(a: Any?) {
|
||||
if (a is String || a is Int) {
|
||||
a.<error>compareTo</error>("")
|
||||
a.toString()
|
||||
}
|
||||
if (a is Int || a is String) {
|
||||
a.<error>compareTo</error>("")
|
||||
}
|
||||
when (a) {
|
||||
is String, is Any => a.<error>compareTo</error>("")
|
||||
}
|
||||
if (a is String && a is Any) {
|
||||
val i: Int = <info descr="Automatically cast to String">a</info>.compareTo("")
|
||||
}
|
||||
if (a is String && <info descr="Automatically cast to String">a</info>.compareTo("") == 0) {}
|
||||
if (a is String || a.<error>compareTo</error>("") == 0) {}
|
||||
}
|
||||
|
||||
//mutability
|
||||
fun f(): String {
|
||||
var a: Any = 11
|
||||
if (a is String) {
|
||||
val i: String = <error>a</error>
|
||||
<error>a</error>.compareTo("f")
|
||||
val f: Function0<String> = { <error>a</error> }
|
||||
return <error>a</error>
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
fun foo(var a: Any): Int {
|
||||
if (a is Int) {
|
||||
return <error>a</error>
|
||||
}
|
||||
return 1
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
class Test() {
|
||||
<info>abstract</info> class Test() {
|
||||
<info>abstract</info> val x : Int
|
||||
<info>abstract</info> val x1 : Int <info>get</info>
|
||||
<info>abstract</info> val x2 : Int <info>get</info>() = 1
|
||||
<info>abstract</info> val x2 : Int <error><info>get</info>() = 1</error>
|
||||
|
||||
val <info>a</info> : Int
|
||||
val <info>b</info> : Int <info>get</info>
|
||||
val <error>a</error> : Int
|
||||
val <error>b</error> : Int <info>get</info>
|
||||
val <info>c</info> = 1
|
||||
|
||||
val <info>c1</info> = 1
|
||||
@@ -15,35 +15,36 @@ class Test() {
|
||||
<info>get</info>() { return 1 }
|
||||
val c4 : Int
|
||||
<info>get</info>() = 1
|
||||
val <info>c5</info> : Int
|
||||
val <error>c5</error> : Int
|
||||
<info>get</info>() = $c5 + 1
|
||||
|
||||
<info>abstract</info> var y : Int
|
||||
<info>abstract</info> var y1 : Int <info>get</info>
|
||||
<info>abstract</info> var y2 : Int <info>set</info>
|
||||
<info>abstract</info> var y3 : Int <info>set</info> <info>get</info>
|
||||
<info>abstract</info> var y4 : Int <info>set</info> <info>get</info>() = 1
|
||||
<info>abstract</info> var y5 : Int <info>set</info>(x) {} <info>get</info>() = 1
|
||||
<info>abstract</info> var y4 : Int <info>set</info> <error><info>get</info>() = 1</error>
|
||||
<info>abstract</info> var y5 : Int <error><info>set</info>(x) {}</error> <error><info>get</info>() = 1</error>
|
||||
<info>abstract</info> var y6 : Int <error><info>set</info>(x) {}</error>
|
||||
|
||||
var <info>v</info> : Int
|
||||
var <info>v1</info> : Int <info>get</info>
|
||||
var <info>v2</info> : Int <info>get</info> <info>set</info>
|
||||
var <info>v3</info> : Int <info>get</info>() = 1; <info>set</info>
|
||||
var <error>v</error> : Int
|
||||
var <error>v1</error> : Int <info>get</info>
|
||||
var <error>v2</error> : Int <info>get</info> <info>set</info>
|
||||
var <error>v3</error> : Int <info>get</info>() = 1; <info>set</info>
|
||||
var v4 : Int <info>get</info>() = 1; <info>set</info>(x){}
|
||||
|
||||
var <info>v5</info> : Int <info>get</info>() = 1; <info>set</info>(x){$v5 = x}
|
||||
var <info>v6</info> : Int <info>get</info>() = $v6 + 1; <info>set</info>(x){}
|
||||
var <error>v5</error> : Int <info>get</info>() = 1; <info>set</info>(x){$v5 = x}
|
||||
var <error>v6</error> : Int <info>get</info>() = $v6 + 1; <info>set</info>(x){}
|
||||
|
||||
val v7 : Int <info>abstract</info> <info>get</info>
|
||||
var v8 : Int <info>abstract</info> <info>get</info> <info>abstract</info> <info>set</info>
|
||||
var <info>v9</info> : Int <info>abstract</info> <info>set</info>
|
||||
var <info>v10</info> : Int <info>abstract</info> <info>get</info>
|
||||
<info>abstract</info> val v7 : Int <info>abstract</info> <info>get</info>
|
||||
<info>abstract</info> var v8 : Int <info>abstract</info> <info>get</info> <info>abstract</info> <info>set</info>
|
||||
var <error>v9</error> : Int <info>set</info>
|
||||
var <error>v10</error> : Int <info>get</info>
|
||||
|
||||
}
|
||||
|
||||
<info>open</info> class Super(i : Int)
|
||||
|
||||
class TestPCParameters(w : Int, <info>x</info> : Int, val <info>y</info> : Int, var <info>z</info> : Int) : Super(w) {
|
||||
class TestPCParameters(w : Int, x : Int, val <info>y</info> : Int, var <info>z</info> : Int) : Super(w) {
|
||||
|
||||
val <info>xx</info> = w
|
||||
|
||||
@@ -51,6 +52,6 @@ class TestPCParameters(w : Int, <info>x</info> : Int, val <info>y</info> : Int,
|
||||
w + 1
|
||||
}
|
||||
|
||||
fun foo() = x
|
||||
fun foo() = <error>x</error>
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// One of the two passes is making a scope and turning vals into functions
|
||||
// See KT-76
|
||||
|
||||
namespace x
|
||||
|
||||
val b : Foo = Foo()
|
||||
val a1 = b.compareTo(2)
|
||||
|
||||
class Foo() {
|
||||
fun compareTo(other : Byte) : Int = 0
|
||||
fun compareTo(other : Char) : Int = 0
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fun foo(u : Unit) : Int = 1
|
||||
|
||||
fun test() : Int {
|
||||
foo(<error>1</error>)
|
||||
val a : fun() : Unit = {
|
||||
foo(<error>1</error>)
|
||||
}
|
||||
return 1
|
||||
}
|
||||
@@ -11,8 +11,8 @@ fun takeFirst(expr: StringBuilder): Char {
|
||||
|
||||
fun evaluateArg(expr: AbstractStringBuilder, numbers: ArrayList<Int>): Int {
|
||||
if (expr.length() == 0) throw Exception("Syntax error: Character expected");
|
||||
val c = takeFirst<error>(expr)</error>
|
||||
if (c <error>>=</error> '0' && c <error><=</error> '9') {
|
||||
val c = takeFirst(<error>expr</error>)
|
||||
if (c >= '0' && c <= '9') {
|
||||
val n = c - '0'
|
||||
if (!numbers.contains(n)) throw Exception("You used incorrect number: " + n)
|
||||
numbers.remove(n)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// JET-11 Redeclaration & Forward reference for classes cause an exception
|
||||
class <error>NoC</error>
|
||||
open class <error>NoC</error>
|
||||
class NoC1 : NoC
|
||||
class <error>NoC</error>
|
||||
open class <error>NoC</error>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
fun foo1() : fun (Int) : Int
|
||||
fun foo1() : fun (Int) : Int = { (x: Int) => x }
|
||||
|
||||
fun foo() {
|
||||
val h : fun (Int) : Int = foo1();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
enum class ProtocolState {
|
||||
abstract enum class ProtocolState {
|
||||
WAITING {
|
||||
override fun signal() = ProtocolState.TALKING
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
enum class ProtocolState {
|
||||
abstract enum class ProtocolState {
|
||||
WAITING {
|
||||
override fun signal() = ProtocolState.TALKING
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class XXX {
|
||||
val a : Int abstract get
|
||||
abstract class XXX {
|
||||
abstract val a : Int abstract get
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
class Item(val room: Object) {
|
||||
val name : String
|
||||
abstract class Item(val room: Object) {
|
||||
abstract val name : String
|
||||
}
|
||||
|
||||
val items: ArrayList<Item> = ArrayList<Item>
|
||||
|
||||
@@ -14,9 +14,9 @@ val a = object {
|
||||
{
|
||||
b + 1
|
||||
}
|
||||
val x = <error>b</error>
|
||||
val x = b
|
||||
val y = 1
|
||||
}
|
||||
|
||||
val b = a.x
|
||||
val b = <error>a</error>.x
|
||||
val c = a.y
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
fun box() {
|
||||
val a : C
|
||||
a.foo()
|
||||
}
|
||||
|
||||
open class A {
|
||||
open fun foo() {}
|
||||
}
|
||||
|
||||
open class B : A {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
open class C : B {
|
||||
override fun foo() {}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fun Any.equals(other : Any?) : Boolean = true
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
val command : Any = 1
|
||||
|
||||
command<warning>?.</warning>equals(null)
|
||||
command.equals(null)
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
open class Foo {}
|
||||
open class Bar {}
|
||||
|
||||
fun <T : Bar, T1> foo(x : Int) {}
|
||||
fun <T1, T : Foo> foo(x : Long) {}
|
||||
|
||||
fun f(): Unit {
|
||||
foo<<error>Int</error>, Int>(1)
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
class A() {
|
||||
var x: Int = 0
|
||||
get() = <error>"s"</error>
|
||||
set(value: <error>String</error>) {
|
||||
$x = <error>value</error>
|
||||
}
|
||||
val y: Int
|
||||
get(): <error>String</error> = "s"
|
||||
val z: Int
|
||||
get() {
|
||||
return <error>"s"</error>
|
||||
}
|
||||
|
||||
var a: Any = 1
|
||||
set(v: <error>String</error>) {
|
||||
$a = v
|
||||
}
|
||||
val b: Int
|
||||
get(): <error>Any</error> = "s"
|
||||
val c: Int
|
||||
get() {
|
||||
return 1
|
||||
}
|
||||
val d = 1
|
||||
get() {
|
||||
return $d
|
||||
}
|
||||
val e = 1
|
||||
get(): <error>String</error> {
|
||||
return <error>$e</error>
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// KT-303 Stack overflow on a cyclic class hierarchy
|
||||
|
||||
open class Foo() : <error>Bar</error>() {
|
||||
val a : Int = 1
|
||||
}
|
||||
|
||||
open class Bar() : <error>Foo</error>() {
|
||||
|
||||
}
|
||||
|
||||
val x : Int = <error>Foo()</error>
|
||||
@@ -0,0 +1,15 @@
|
||||
fun foo(u : Unit) : Int = 1
|
||||
|
||||
fun test() : Int {
|
||||
foo(1)
|
||||
val a : fun() : Unit = {
|
||||
foo(1)
|
||||
}
|
||||
return 1 - "1"
|
||||
}
|
||||
|
||||
class A() {
|
||||
val x : Int = foo1(xx)
|
||||
}
|
||||
|
||||
fun foo1() {}
|
||||
@@ -0,0 +1,241 @@
|
||||
namespace abstract
|
||||
|
||||
class MyClass() {
|
||||
//properties
|
||||
val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>a<!>: Int
|
||||
val a1: Int = 1
|
||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> val a2: Int
|
||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> val a3: Int = 1
|
||||
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>b<!>: Int private set
|
||||
var b1: Int = 0; private set
|
||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> var b2: Int private set
|
||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> var b3: Int = 0; private set
|
||||
|
||||
var <!MUST_BE_INITIALIZED!>c<!>: Int set(v: Int) { $c = v }
|
||||
var c1: Int = 0; set(v: Int) { $c1 = v }
|
||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> var c2: Int set(v: Int) { $c2 = v }
|
||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> var c3: Int = 0; set(v: Int) { $c3 = v }
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = a
|
||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> val e2: Int get() = a
|
||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> val e3: Int = 0; get() = a
|
||||
|
||||
//methods
|
||||
fun <!NON_ABSTRACT_FUNCTION_WITH_NO_BODY!>f<!>()
|
||||
fun g() {}
|
||||
<!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> fun h()
|
||||
<!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> fun j() {}
|
||||
|
||||
//property accessors
|
||||
var i: Int <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
var i1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var j: Int get() = i; <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
var j1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = i; <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>k<!>: Int <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
var k1: Int = 0; <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var l: Int <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
var l1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var n: Int <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, ABSTRACT_FUNCTION_WITH_BODY, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set(v: Int) {}
|
||||
}
|
||||
|
||||
abstract class MyAbstractClass() {
|
||||
//properties
|
||||
val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>a<!>: Int
|
||||
val a1: Int = 1
|
||||
abstract val a2: Int
|
||||
abstract val a3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>1<!>
|
||||
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>b<!>: Int private set
|
||||
var b1: Int = 0; private set
|
||||
abstract var b2: Int private set
|
||||
abstract var b3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; private set
|
||||
|
||||
var <!MUST_BE_INITIALIZED!>c<!>: Int set(v: Int) { $c = v }
|
||||
var c1: Int = 0; set(v: Int) { $c1 = v }
|
||||
abstract var c2: Int <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { $c2 = v }<!>
|
||||
abstract var c3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { $c3 = v }<!>
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = a
|
||||
abstract val e2: Int <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
|
||||
abstract val e3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
|
||||
|
||||
//methods
|
||||
fun <!NON_ABSTRACT_FUNCTION_WITH_NO_BODY!>f<!>()
|
||||
fun g() {}
|
||||
abstract fun h()
|
||||
<!ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> fun j() {}
|
||||
|
||||
//property accessors
|
||||
var i: Int <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
var i1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var j: Int get() = i; <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
var j1: Int get() = i; <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>k<!>: Int <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
var k1: Int = 0; <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var l: Int <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
var l1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var n: Int <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!ABSTRACT_FUNCTION_WITH_BODY, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set(v: Int) {}
|
||||
}
|
||||
|
||||
trait MyTrait {
|
||||
//properties
|
||||
val a: Int
|
||||
val a1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>1<!>
|
||||
<!REDUNDANT_MODIFIER_IN_TRAIT!>abstract<!> val a2: Int
|
||||
<!REDUNDANT_MODIFIER_IN_TRAIT!>abstract<!> val a3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>1<!>
|
||||
|
||||
var b: Int private set
|
||||
var b1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; private set
|
||||
<!REDUNDANT_MODIFIER_IN_TRAIT!>abstract<!> var b2: Int private set
|
||||
<!REDUNDANT_MODIFIER_IN_TRAIT!>abstract<!> var b3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; private set
|
||||
|
||||
var <!BACKING_FIELD_IN_TRAIT!>c<!>: Int set(v: Int) { $c = v }
|
||||
var <!BACKING_FIELD_IN_TRAIT!>c1<!>: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; set(v: Int) { $c1 = v }
|
||||
<!REDUNDANT_MODIFIER_IN_TRAIT!>abstract<!> var c2: Int <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { $c2 = v }<!>
|
||||
<!REDUNDANT_MODIFIER_IN_TRAIT!>abstract<!> var c3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { $c3 = v }<!>
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; get() = a
|
||||
<!REDUNDANT_MODIFIER_IN_TRAIT!>abstract<!> val e2: Int <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
|
||||
<!REDUNDANT_MODIFIER_IN_TRAIT!>abstract<!> val e3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
|
||||
|
||||
//methods
|
||||
fun f()
|
||||
fun g() {}
|
||||
<!REDUNDANT_MODIFIER_IN_TRAIT!>abstract<!> fun h()
|
||||
<!REDUNDANT_MODIFIER_IN_TRAIT, ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> fun j() {}
|
||||
|
||||
//property accessors
|
||||
var i: Int abstract get abstract set
|
||||
var i1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var j: Int get() = i; <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
var j1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; get() = i; <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var k: Int abstract set
|
||||
var k1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var l: Int abstract get abstract set
|
||||
var l1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var n: Int <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!ABSTRACT_FUNCTION_WITH_BODY, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set(v: Int) {}
|
||||
}
|
||||
|
||||
enum class MyEnum() {
|
||||
//properties
|
||||
val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>a<!>: Int
|
||||
val a1: Int = 1
|
||||
abstract val a2: Int
|
||||
abstract val a3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>1<!>
|
||||
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>b<!>: Int private set
|
||||
var b1: Int = 0; private set
|
||||
abstract var b2: Int private set
|
||||
abstract var b3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; private set
|
||||
|
||||
var <!MUST_BE_INITIALIZED!>c<!>: Int set(v: Int) { $c = v }
|
||||
var c1: Int = 0; set(v: Int) { $c1 = v }
|
||||
abstract var c2: Int <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { $c2 = v }<!>
|
||||
abstract var c3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { $c3 = v }<!>
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = a
|
||||
abstract val e2: Int <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
|
||||
abstract val e3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
|
||||
|
||||
//methods
|
||||
fun <!NON_ABSTRACT_FUNCTION_WITH_NO_BODY!>f<!>()
|
||||
fun g() {}
|
||||
abstract fun h()
|
||||
<!ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> fun j() {}
|
||||
|
||||
//property accessors
|
||||
var i: Int <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
var i1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var j: Int get() = i; <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
var j1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = i; <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>k<!>: Int <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
var k1: Int = 0; <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var l: Int <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
var l1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var n: Int <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!ABSTRACT_FUNCTION_WITH_BODY, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set(v: Int) {}
|
||||
}
|
||||
|
||||
abstract enum class MyAbstractEnum() {}
|
||||
|
||||
namespace MyNamespace {
|
||||
//properties
|
||||
val <!MUST_BE_INITIALIZED!>a<!>: Int
|
||||
val a1: Int = 1
|
||||
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> val a2: Int
|
||||
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> val a3: Int = 1
|
||||
|
||||
var <!MUST_BE_INITIALIZED!>b<!>: Int private set
|
||||
var b1: Int = 0; private set
|
||||
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> var b2: Int private set
|
||||
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> var b3: Int = 0; private set
|
||||
|
||||
var <!MUST_BE_INITIALIZED!>c<!>: Int set(v: Int) { $c = v }
|
||||
var c1: Int = 0; set(v: Int) { $c1 = v }
|
||||
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> var c2: Int set(v: Int) { $c2 = v }
|
||||
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> var c3: Int = 0; set(v: Int) { $c3 = v }
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = a
|
||||
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> val e2: Int get() = a
|
||||
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> val e3: Int = 0; get() = a
|
||||
|
||||
//methods
|
||||
fun <!NON_MEMBER_FUNCTION_NO_BODY!>f<!>()
|
||||
fun g() {}
|
||||
<!NON_MEMBER_ABSTRACT_FUNCTION!>abstract<!> fun h()
|
||||
<!NON_MEMBER_ABSTRACT_FUNCTION!>abstract<!> fun j() {}
|
||||
|
||||
//property accessors
|
||||
var i: Int <!NON_MEMBER_ABSTRACT_ACCESSOR, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!NON_MEMBER_ABSTRACT_ACCESSOR, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
var i1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; <!NON_MEMBER_ABSTRACT_ACCESSOR, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!NON_MEMBER_ABSTRACT_ACCESSOR, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var j: Int get() = i; <!NON_MEMBER_ABSTRACT_ACCESSOR, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
var j1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = i; <!NON_MEMBER_ABSTRACT_ACCESSOR, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var <!MUST_BE_INITIALIZED!>k<!>: Int <!NON_MEMBER_ABSTRACT_ACCESSOR, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
var k1: Int = 0; <!NON_MEMBER_ABSTRACT_ACCESSOR, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var l: Int <!NON_MEMBER_ABSTRACT_ACCESSOR, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!NON_MEMBER_ABSTRACT_ACCESSOR, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
var l1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; <!NON_MEMBER_ABSTRACT_ACCESSOR, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!NON_MEMBER_ABSTRACT_ACCESSOR, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
|
||||
var n: Int <!NON_MEMBER_ABSTRACT_ACCESSOR, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get <!NON_MEMBER_ABSTRACT_ACCESSOR, ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set(v: Int) {}
|
||||
}
|
||||
|
||||
//creating an instance
|
||||
abstract class B1(
|
||||
val i: Int,
|
||||
val s: String
|
||||
) {
|
||||
}
|
||||
|
||||
class B2() : B1(1, "r") {}
|
||||
|
||||
abstract class B3(i: Int) {
|
||||
this(): this(1)
|
||||
}
|
||||
|
||||
fun foo(a: B3) {
|
||||
val a = <!CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS!>B3()<!>
|
||||
val b = <!CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS!>B1(2, "s")<!>
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
class NoC {
|
||||
<!ANONYMOUS_INITIALIZER_WITHOUT_CONSTRUCTOR!>{
|
||||
|
||||
}<!>
|
||||
|
||||
val a : Int get() = 1
|
||||
|
||||
<!ANONYMOUS_INITIALIZER_WITHOUT_CONSTRUCTOR!>{
|
||||
|
||||
}<!>
|
||||
}
|
||||
|
||||
class WithC() {
|
||||
val x : Int
|
||||
{
|
||||
$x = 1
|
||||
<!UNRESOLVED_REFERENCE!>$y<!> = 2
|
||||
val b = x
|
||||
|
||||
}
|
||||
|
||||
val a : Int get() = 1
|
||||
|
||||
{
|
||||
val z = <!UNRESOLVED_REFERENCE!>b<!>
|
||||
val zz = x
|
||||
val zzz = <!NO_BACKING_FIELD!>$a<!>
|
||||
}
|
||||
|
||||
this(a : Int) : this() {
|
||||
val b = x
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
class A() {
|
||||
fun equals(a : Any?) : Boolean = false
|
||||
}
|
||||
|
||||
class B() {
|
||||
fun equals(a : Any?) : Boolean? = false
|
||||
}
|
||||
|
||||
class C() {
|
||||
fun equals(a : Any?) : Int = 0
|
||||
}
|
||||
|
||||
fun f(): Unit {
|
||||
var x: Int? = 1
|
||||
x = 1
|
||||
x <!UNSAFE_INFIX_CALL!>+<!> 1
|
||||
x <!UNSAFE_INFIX_CALL!>plus<!> 1
|
||||
x <!UNSAFE_INFIX_CALL!><<!> 1
|
||||
x <!UNSAFE_INFIX_CALL!>+=<!> 1
|
||||
|
||||
x == 1
|
||||
x != 1
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE!>A() == 1<!>
|
||||
B() <!RESULT_TYPE_MISMATCH!>==<!> 1
|
||||
C() <!RESULT_TYPE_MISMATCH!>==<!> 1
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE!>x === "1"<!>
|
||||
<!EQUALITY_NOT_APPLICABLE!>x !== "1"<!>
|
||||
|
||||
x === 1
|
||||
x !== 1
|
||||
|
||||
x<!UNSAFE_INFIX_CALL!>..<!>2
|
||||
<!TYPE_MISMATCH!>x<!> in 1..2
|
||||
|
||||
val y : Boolean? = true
|
||||
false || <!TYPE_MISMATCH!>y<!>
|
||||
<!TYPE_MISMATCH!>y<!> && true
|
||||
<!TYPE_MISMATCH!>y<!> && <!TYPE_MISMATCH!>1<!>
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace boundsWithSubstitutors {
|
||||
open class A<T>
|
||||
class B<X : A<X>>()
|
||||
|
||||
class C : A<C>
|
||||
|
||||
val a = B<C>()
|
||||
val a1 = B<<!UPPER_BOUND_VIOLATED!>Int<!>>()
|
||||
|
||||
class X<A, B : A>()
|
||||
|
||||
val b = X<Any, X<A<C>, C>>
|
||||
val b0 = X<Any, <!UPPER_BOUND_VIOLATED!>Any?<!>>
|
||||
val b1 = X<Any, X<A<C>, <!UPPER_BOUND_VIOLATED!>String<!>>>
|
||||
|
||||
}
|
||||
|
||||
open class A {}
|
||||
open class B<T : A>()
|
||||
|
||||
abstract class C<T : B<<!UPPER_BOUND_VIOLATED!>Int<!>>, X : fun (B<<!UPPER_BOUND_VIOLATED!>Char<!>>) : (B<<!UPPER_BOUND_VIOLATED!>Any<!>>, B<A>)>() : B<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any<!>>() { // 2 errors
|
||||
val a = B<<!UPPER_BOUND_VIOLATED!>Char<!>>() // error
|
||||
|
||||
abstract val x : fun (B<<!UPPER_BOUND_VIOLATED!>Char<!>>) : B<<!UPPER_BOUND_VIOLATED!>Any<!>>
|
||||
}
|
||||
|
||||
|
||||
fun test() {
|
||||
foo<<!UPPER_BOUND_VIOLATED!>Int?<!>>()
|
||||
foo<Int>()
|
||||
bar<Int?>()
|
||||
bar<Int>()
|
||||
bar<<!UPPER_BOUND_VIOLATED!>Double?<!>>()
|
||||
bar<<!UPPER_BOUND_VIOLATED!>Double<!>>()
|
||||
1.buzz<<!UPPER_BOUND_VIOLATED!>Double<!>>()
|
||||
}
|
||||
|
||||
fun foo<T : Any>() {}
|
||||
fun bar<T : Int?>() {}
|
||||
fun <T : <!FINAL_UPPER_BOUND!>Int<!>> Int.buzz() : Unit {}
|
||||
@@ -0,0 +1,28 @@
|
||||
class C {
|
||||
|
||||
fun f (a : Boolean, b : Boolean) {
|
||||
@b (while (true)
|
||||
@a {
|
||||
<!NOT_A_LOOP_LABEL!>break@f<!>
|
||||
break
|
||||
break@b
|
||||
<!NOT_A_LOOP_LABEL!>break@a<!>
|
||||
})
|
||||
|
||||
<!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>continue<!>
|
||||
|
||||
@b (while (true)
|
||||
@a {
|
||||
<!NOT_A_LOOP_LABEL!>continue@f<!>
|
||||
continue
|
||||
continue@b
|
||||
<!NOT_A_LOOP_LABEL!>continue@a<!>
|
||||
})
|
||||
|
||||
<!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>break<!>
|
||||
|
||||
<!NOT_A_LOOP_LABEL!>continue@f<!>
|
||||
<!NOT_A_LOOP_LABEL!>break@f<!>
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
import java.util.*
|
||||
|
||||
namespace html {
|
||||
|
||||
abstract class Factory<T> {
|
||||
abstract fun create() : T
|
||||
}
|
||||
|
||||
abstract class Element
|
||||
|
||||
class TextElement(val text : String) : Element
|
||||
|
||||
abstract class Tag(val name : String) : Element {
|
||||
val children = ArrayList<Element>()
|
||||
val attributes = HashMap<String, String>()
|
||||
|
||||
protected fun initTag<T : Element>(init : fun T.() : Unit) : T
|
||||
where class object T : Factory<T>{
|
||||
val tag = T.create()
|
||||
tag.init()
|
||||
children.add(tag)
|
||||
return tag
|
||||
}
|
||||
}
|
||||
|
||||
abstract class TagWithText(name : String) : Tag(name) {
|
||||
fun String.plus() {
|
||||
children.add(TextElement(this))
|
||||
}
|
||||
}
|
||||
|
||||
class HTML() : TagWithText("html") {
|
||||
class object : Factory<HTML> {
|
||||
override fun create() = HTML()
|
||||
}
|
||||
|
||||
fun head(init : fun Head.() : Unit) = initTag<Head>(init)
|
||||
|
||||
fun body(init : fun Body.() : Unit) = initTag<Body>(init)
|
||||
}
|
||||
|
||||
class Head() : TagWithText("head") {
|
||||
class object : Factory<Head> {
|
||||
override fun create() = Head()
|
||||
}
|
||||
|
||||
fun title(init : fun Title.() : Unit) = initTag<Title>(init)
|
||||
}
|
||||
|
||||
class Title() : TagWithText("title")
|
||||
|
||||
abstract class BodyTag(name : String) : TagWithText(name) {
|
||||
}
|
||||
|
||||
class Body() : BodyTag("body") {
|
||||
class object : Factory<Body> {
|
||||
override fun create() = Body()
|
||||
}
|
||||
|
||||
fun b(init : fun B.() : Unit) = initTag<B>(init)
|
||||
fun p(init : fun P.() : Unit) = initTag<P>(init)
|
||||
fun h1(init : fun H1.() : Unit) = initTag<H1>(init)
|
||||
fun a(href : String, init : fun A.() : Unit) {
|
||||
val a = initTag<A>(init)
|
||||
a.href = href
|
||||
}
|
||||
}
|
||||
|
||||
class B() : BodyTag("b")
|
||||
class P() : BodyTag("p")
|
||||
class H1() : BodyTag("h1")
|
||||
class A() : BodyTag("a") {
|
||||
var href : String
|
||||
get() = attributes["href"]
|
||||
set(value) { attributes["href"] = value }
|
||||
}
|
||||
|
||||
fun Map<String, String>.set(key : String, value : String) = this.put(key, value)
|
||||
|
||||
fun html(init : fun HTML.() : Unit) : HTML {
|
||||
val html = HTML()
|
||||
html.init()
|
||||
return html
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace foo {
|
||||
|
||||
import html.*
|
||||
|
||||
fun result(args : Array<String>) =
|
||||
html {
|
||||
head {
|
||||
title {+"XML encoding with Groovy"}
|
||||
}
|
||||
body {
|
||||
h1 {+"XML encoding with Groovy"}
|
||||
p {+"this format can be used as an alternative markup to XML"}
|
||||
|
||||
// an element with attributes and text content
|
||||
a(href = "http://groovy.codehaus.org") {+"Groovy"}
|
||||
|
||||
// mixed content
|
||||
p {
|
||||
+"This is some"
|
||||
b {+"mixed"}
|
||||
+"text. For more see the"
|
||||
a(href = "http://groovy.codehaus.org") {+"Groovy"}
|
||||
+"project"
|
||||
}
|
||||
p {+"some text"}
|
||||
|
||||
// content generated by
|
||||
p {
|
||||
for (arg in args)
|
||||
+arg
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fun test() : Unit {
|
||||
var x : Int? = 0
|
||||
var y : Int = 0
|
||||
|
||||
x : Int?
|
||||
y : Int
|
||||
x as Int : Int
|
||||
y <!USELESS_CAST!>as<!> Int : Int
|
||||
x <!USELESS_CAST!>as<!> Int? : Int?
|
||||
y <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as<!> Int? : Int?
|
||||
x as? Int : Int?
|
||||
y <!USELESS_CAST!>as?<!> Int : Int?
|
||||
x <!USELESS_CAST!>as?<!> Int? : Int?
|
||||
y <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as?<!> Int? : Int?
|
||||
()
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace Jet86
|
||||
|
||||
class A {
|
||||
class object {
|
||||
val x = 1
|
||||
}
|
||||
<!MANY_CLASS_OBJECTS!>class object { // error
|
||||
val x = 1
|
||||
}<!>
|
||||
}
|
||||
|
||||
class B() {
|
||||
val x = 12
|
||||
}
|
||||
|
||||
object b {
|
||||
<!CLASS_OBJECT_NOT_ALLOWED!>class object {
|
||||
val x = 1
|
||||
}<!> // error
|
||||
}
|
||||
|
||||
val a = A.x
|
||||
val c = <!NO_CLASS_OBJECT!>B<!>.x
|
||||
val d = b.<!UNRESOLVED_REFERENCE!>x<!>
|
||||
|
||||
val s = <!NO_CLASS_OBJECT!>System<!> // error
|
||||
fun test() {
|
||||
System.out?.println()
|
||||
java.lang.System.out?.println()
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fun test() {
|
||||
1 : Byte
|
||||
1 : Int
|
||||
<!TYPE_MISMATCH, TYPE_MISMATCH!>1<!> : Double
|
||||
1 <!USELESS_CAST!>as<!> Byte
|
||||
1 <!USELESS_CAST!>as<!> Int
|
||||
<!ERROR_COMPILE_TIME_VALUE!>1<!> <!CAST_NEVER_SUCCEEDS!>as<!> Double
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
open class NoC
|
||||
class NoC1 : NoC
|
||||
|
||||
class WithC0() : NoC<!NO_CONSTRUCTOR!>()<!>
|
||||
open class WithC1() : NoC
|
||||
class NoC2 : <!SUPERTYPE_NOT_INITIALIZED!>WithC1<!>
|
||||
class NoC3 : WithC1<!PRIMARY_CONSTRUCTOR_MISSING_SUPER_CONSTRUCTOR_CALL!>()<!>
|
||||
class WithC2() : <!SUPERTYPE_NOT_INITIALIZED!>WithC1<!>
|
||||
|
||||
class NoPC {
|
||||
<!SECONDARY_CONSTRUCTOR_BUT_NO_PRIMARY!>this<!>() {}
|
||||
}
|
||||
|
||||
class WithPC0() {
|
||||
this(a : Int) : this() {}
|
||||
}
|
||||
|
||||
class WithPC1(a : Int) {
|
||||
<!SECONDARY_CONSTRUCTOR_NO_INITIALIZER_LIST!>this<!>() {}
|
||||
|
||||
this(b : Long) : this("") {}
|
||||
|
||||
this(s : String) : this(1) {}
|
||||
|
||||
this(b : Char) : <!NONE_APPLICABLE!>this("", 2)<!> {}
|
||||
|
||||
this(b : Byte) : this(""), <!MANY_CALLS_TO_THIS!>this(1)<!> {}
|
||||
}
|
||||
|
||||
|
||||
class Foo() : <!SUPERTYPE_NOT_INITIALIZED, FINAL_SUPERTYPE!>WithPC0<!>, <!MANY_CLASSES_IN_SUPERTYPE_LIST!>this<!>() {
|
||||
|
||||
}
|
||||
|
||||
class WithCPI_Dup(x : Int) {
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>x<!> : Int
|
||||
}
|
||||
|
||||
class WithCPI(x : Int) {
|
||||
val a = 1
|
||||
val b : Int = $a
|
||||
val xy : Int = x
|
||||
}
|
||||
|
||||
class <!PRIMARY_CONSTRUCTOR_MISSING_STATEFUL_PROPERTY!>NoCPI<!> {
|
||||
val a = <!PROPERTY_INITIALIZER_NO_PRIMARY_CONSTRUCTOR!>1<!>
|
||||
var ab = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>1<!>
|
||||
get() = 1
|
||||
set(v) {}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
trait A {
|
||||
fun foo() : Int = 1
|
||||
fun foo1() : Int = 1
|
||||
val a : Int
|
||||
val a1 : Int
|
||||
val <T> g : Iterator<T>
|
||||
|
||||
fun <T> g() : T
|
||||
fun <T> g1() : T
|
||||
}
|
||||
|
||||
abstract class B() : A {
|
||||
override fun <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>foo<!>() {
|
||||
}
|
||||
override fun foo() : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Unit<!> {
|
||||
}
|
||||
|
||||
override val a : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Double<!> = 1.dbl
|
||||
override val <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>a1<!> = 1.dbl
|
||||
|
||||
abstract override fun <X> g() : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Int<!>
|
||||
abstract override fun <X> g1() : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>java.util.List<X><!>
|
||||
|
||||
abstract override val <X> g : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Iterator<Int><!>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
trait A {
|
||||
fun foo() {}
|
||||
}
|
||||
trait B : A, <!CYCLIC_INHERITANCE_HIERARCHY!>E<!> {}
|
||||
trait C : B {}
|
||||
trait D : <!CYCLIC_INHERITANCE_HIERARCHY!>B<!> {}
|
||||
trait E : <!CYCLIC_INHERITANCE_HIERARCHY!>F<!> {}
|
||||
trait F : <!CYCLIC_INHERITANCE_HIERARCHY!>D<!>, C {}
|
||||
trait G : F {}
|
||||
trait H : F {}
|
||||
|
||||
val a : A? = null
|
||||
val b : B? = null
|
||||
val c : C? = null
|
||||
val d : D? = null
|
||||
val e : E? = null
|
||||
val f : F? = null
|
||||
val g : G? = null
|
||||
val h : H? = null
|
||||
|
||||
fun test() {
|
||||
a?.foo()
|
||||
b?.foo()
|
||||
c?.foo()
|
||||
d?.foo()
|
||||
e?.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
f?.foo()
|
||||
g?.foo()
|
||||
h?.foo()
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
enum class List<out T>(val size : Int) {
|
||||
Nil : List<Nothing>(0) {
|
||||
val a = 1
|
||||
}
|
||||
Cons<out T>(val head : T, val tail : List<T>) : List<T>(tail.size + 1)
|
||||
|
||||
}
|
||||
|
||||
val foo = List.Nil
|
||||
val foo1 = foo.a
|
||||
@@ -0,0 +1,71 @@
|
||||
fun Int?.optint() : Unit {}
|
||||
val Int?.optval : Unit = ()
|
||||
|
||||
fun <T, E> T.foo(x : E, y : A) : T {
|
||||
y.plus(1)
|
||||
y plus 1
|
||||
y + 1.0
|
||||
|
||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>minus<T>(this)
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
class A
|
||||
|
||||
fun A.plus(a : Any) {
|
||||
|
||||
1.foo()
|
||||
true.<!NONE_APPLICABLE!>foo()<!>
|
||||
|
||||
1
|
||||
}
|
||||
|
||||
fun A.plus(a : Int) {
|
||||
1
|
||||
}
|
||||
|
||||
fun <T> T.minus(t : T) : Int = 1
|
||||
|
||||
fun test() {
|
||||
val y = 1.abs
|
||||
}
|
||||
val Int.abs : Int
|
||||
get() = if (this > 0) this else -this;
|
||||
|
||||
val <T> T.<!MUST_BE_INITIALIZED!>foo<!> : T
|
||||
|
||||
fun Int.foo() = this
|
||||
|
||||
namespace null_safety {
|
||||
|
||||
fun parse(cmd: String): Command? { return null }
|
||||
class Command() {
|
||||
// fun equals(other : Any?) : Boolean
|
||||
val foo : Int = 0
|
||||
}
|
||||
|
||||
fun Any.equals(other : Any?) : Boolean = true
|
||||
fun Any?.equals1(other : Any?) : Boolean = true
|
||||
fun Any.equals2(other : Any?) : Boolean = true
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
System.out?.print(1)
|
||||
|
||||
val command = parse("")
|
||||
|
||||
command<!UNSAFE_CALL!>.<!>foo
|
||||
|
||||
command.equals(null)
|
||||
command<!UNNECESSARY_SAFE_CALL!>?.<!>equals(null)
|
||||
command.equals1(null)
|
||||
command<!UNNECESSARY_SAFE_CALL!>?.<!>equals1(null)
|
||||
|
||||
val c = Command()
|
||||
c<!UNNECESSARY_SAFE_CALL!>?.<!>equals2(null)
|
||||
|
||||
if (command == null) 1
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
import java.util.*;
|
||||
|
||||
class NotRange1() {
|
||||
|
||||
}
|
||||
|
||||
abstract class NotRange2() {
|
||||
abstract fun iterator() : Unit
|
||||
}
|
||||
|
||||
abstract class ImproperIterator1 {
|
||||
abstract fun hasNext() : Boolean
|
||||
}
|
||||
|
||||
abstract class NotRange3() {
|
||||
abstract fun iterator() : ImproperIterator1
|
||||
}
|
||||
|
||||
abstract class ImproperIterator2 {
|
||||
abstract fun next() : Boolean
|
||||
}
|
||||
|
||||
abstract class NotRange4() {
|
||||
abstract fun iterator() : ImproperIterator2
|
||||
}
|
||||
|
||||
abstract class ImproperIterator3 {
|
||||
abstract fun hasNext() : Int
|
||||
abstract fun next() : Int
|
||||
}
|
||||
|
||||
abstract class NotRange5() {
|
||||
abstract fun iterator() : ImproperIterator3
|
||||
}
|
||||
|
||||
abstract class AmbiguousHasNextIterator {
|
||||
abstract fun hasNext() : Boolean
|
||||
val hasNext : Boolean get() = false
|
||||
abstract fun next() : Int
|
||||
}
|
||||
|
||||
abstract class NotRange6() {
|
||||
abstract fun iterator() : AmbiguousHasNextIterator
|
||||
}
|
||||
|
||||
abstract class ImproperIterator4 {
|
||||
val hasNext : Int get() = 1
|
||||
abstract fun next() : Int
|
||||
}
|
||||
|
||||
abstract class NotRange7() {
|
||||
abstract fun iterator() : ImproperIterator3
|
||||
}
|
||||
|
||||
abstract class GoodIterator {
|
||||
abstract fun hasNext() : Boolean
|
||||
abstract fun next() : Int
|
||||
}
|
||||
|
||||
abstract class Range0() {
|
||||
abstract fun iterator() : GoodIterator
|
||||
}
|
||||
|
||||
abstract class Range1() {
|
||||
abstract fun iterator() : Iterator<Int>
|
||||
}
|
||||
|
||||
fun test(notRange1: NotRange1, notRange2: NotRange2, notRange3: NotRange3, notRange4: NotRange4, notRange5: NotRange5, notRange6: NotRange6, notRange7: NotRange7, range0: Range0, range1: Range1) {
|
||||
for (i in <!ITERATOR_MISSING!>notRange1<!>);
|
||||
for (i in <!HAS_NEXT_MISSING, NEXT_MISSING!>notRange2<!>);
|
||||
for (i in <!NEXT_MISSING!>notRange3<!>);
|
||||
for (i in <!HAS_NEXT_MISSING!>notRange4<!>);
|
||||
for (i in <!HAS_NEXT_FUNCTION_TYPE_MISMATCH!>notRange5<!>);
|
||||
for (i in <!HAS_NEXT_PROPERTY_AND_FUNCTION_AMBIGUITY!>notRange6<!>);
|
||||
for (i in <!HAS_NEXT_FUNCTION_TYPE_MISMATCH!>notRange7<!>);
|
||||
for (i in range0);
|
||||
for (i in range1);
|
||||
|
||||
for (i in (ArrayList<Int>() : List<Int>));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
fun none() {}
|
||||
|
||||
fun unitEmptyInfer() {}
|
||||
fun unitEmpty() : Unit {}
|
||||
fun unitEmptyReturn() : Unit {return}
|
||||
fun unitIntReturn() : Unit {return <!TYPE_MISMATCH!>1<!>}
|
||||
fun unitUnitReturn() : Unit {return ()}
|
||||
fun test1() : Any = {<!RETURN_NOT_ALLOWED, RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY!>return<!>}
|
||||
fun test2() : Any = @a {return@a 1}
|
||||
fun test3() : Any { <!RETURN_TYPE_MISMATCH!>return<!> }
|
||||
|
||||
fun bbb() {
|
||||
return <!TYPE_MISMATCH!>1<!>
|
||||
}
|
||||
|
||||
fun foo(expr: StringBuilder): Int {
|
||||
val c = 'a'
|
||||
when(c) {
|
||||
0.chr => throw Exception("zero")
|
||||
else => throw Exception("nonzero" + c)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun unitShort() : Unit = ()
|
||||
fun unitShortConv() : Unit = <!TYPE_MISMATCH!>1<!>
|
||||
fun unitShortNull() : Unit = <!TYPE_MISMATCH!>null<!>
|
||||
|
||||
fun intEmpty() : Int <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{}<!>
|
||||
fun intShortInfer() = 1
|
||||
fun intShort() : Int = 1
|
||||
//fun intBlockInfer() {1}
|
||||
fun intBlock() : Int {return 1}
|
||||
fun intBlock() : Int {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1<!>}
|
||||
|
||||
fun intString(): Int = <!TYPE_MISMATCH!>"s"<!>
|
||||
fun intFunctionLiteral(): Int = <!TYPE_MISMATCH!>{ 10 }<!>
|
||||
|
||||
fun blockReturnUnitMismatch() : Int {<!RETURN_TYPE_MISMATCH!>return<!>}
|
||||
fun blockReturnValueTypeMismatch() : Int {return <!ERROR_COMPILE_TIME_VALUE!>3.4<!>}
|
||||
fun blockReturnValueTypeMatch() : Int {return 1}
|
||||
fun blockReturnValueTypeMismatchUnit() : Int {return <!TYPE_MISMATCH!>()<!>}
|
||||
|
||||
fun blockAndAndMismatch() : Int {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>true && false<!>
|
||||
}
|
||||
fun blockAndAndMismatch() : Int {
|
||||
return <!TYPE_MISMATCH!>true && false<!>
|
||||
}
|
||||
fun blockAndAndMismatch() : Int {
|
||||
<!UNREACHABLE_CODE!>(return <!ERROR_COMPILE_TIME_VALUE!>true<!>) && (return <!ERROR_COMPILE_TIME_VALUE!>false<!>)<!>
|
||||
}
|
||||
|
||||
fun blockAndAndMismatch() : Int {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>true || false<!>
|
||||
}
|
||||
fun blockAndAndMismatch() : Int {
|
||||
return <!TYPE_MISMATCH!>true || false<!>
|
||||
}
|
||||
fun blockAndAndMismatch() : Int {
|
||||
<!UNREACHABLE_CODE!>(return <!ERROR_COMPILE_TIME_VALUE!>true<!>) || (return <!ERROR_COMPILE_TIME_VALUE!>false<!>)<!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
return if (1 > 2) <!ERROR_COMPILE_TIME_VALUE!>1.0<!> else <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
return <!TYPE_MISMATCH!>if (1 > 2) 1<!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
return <!TYPE_MISMATCH!>if (1 > 2) else 1<!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
if (1 > 2)
|
||||
return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
|
||||
else return <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
if (1 > 2)
|
||||
return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
|
||||
return <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
if (1 > 2)
|
||||
else return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
|
||||
return <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
if (1 > 2)
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1.0<!>
|
||||
else <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>2.0<!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
if (1 > 2)
|
||||
1.0
|
||||
else 2.0
|
||||
return 1
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>if (1 > 2)
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1.0<!><!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
return <!TYPE_MISMATCH!>if (1 > 2)
|
||||
1<!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>if (1 > 2)
|
||||
else <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1.0<!><!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
if (1 > 2)
|
||||
return 1
|
||||
else return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
|
||||
}
|
||||
fun blockNoReturnIfValDeclaration(): Int {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>val x = 1<!>
|
||||
}
|
||||
fun blockNoReturnIfEmptyIf(): Int {
|
||||
if (1 < 2) <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{}<!> else <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{}<!>
|
||||
}
|
||||
fun blockNoReturnIfUnitInOneBranch(): Int {
|
||||
if (1 < 2) {
|
||||
return 1
|
||||
} else {
|
||||
if (3 < 4) <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{
|
||||
}<!> else {
|
||||
return 2
|
||||
}
|
||||
}
|
||||
}
|
||||
fun nonBlockReturnIfEmptyIf(): Int = if (1 < 2) <!TYPE_MISMATCH!>{}<!> else <!TYPE_MISMATCH!>{}<!>
|
||||
fun nonBlockNoReturnIfUnitInOneBranch(): Int = if (1 < 2) <!TYPE_MISMATCH!>{}<!> else 2
|
||||
|
||||
val a = <!RETURN_NOT_ALLOWED!>return 1<!>
|
||||
|
||||
class A() {
|
||||
this(a : Int) : this() {
|
||||
if (a == 1)
|
||||
return
|
||||
return <!TYPE_MISMATCH!>1<!>
|
||||
}
|
||||
|
||||
}
|
||||
fun illegalConstantBody(): Int = <!TYPE_MISMATCH!>"s"<!>
|
||||
fun illegalConstantBlock(): String {
|
||||
return <!ERROR_COMPILE_TIME_VALUE!>1<!>
|
||||
}
|
||||
fun illegalIfBody(): Int =
|
||||
if (1 < 2) <!ERROR_COMPILE_TIME_VALUE!>'a'<!> else { <!ERROR_COMPILE_TIME_VALUE!>1.0<!> }
|
||||
fun illegalIfBlock(): Boolean {
|
||||
if (1 < 2)
|
||||
return false
|
||||
else { return <!ERROR_COMPILE_TIME_VALUE!>1<!> }
|
||||
}
|
||||
fun illegalReturnIf(): Char {
|
||||
return if (1 < 2) 'a' else { <!ERROR_COMPILE_TIME_VALUE!>1<!> }
|
||||
}
|
||||
|
||||
fun returnNothing(): Nothing {
|
||||
throw 1
|
||||
}
|
||||
fun f(): Int {
|
||||
if (1 < 2) { return 1 } else returnNothing()
|
||||
}
|
||||
|
||||
fun f(): Int = if (1 < 2) 1 else returnNothing()
|
||||
@@ -0,0 +1,42 @@
|
||||
trait A<in T> {}
|
||||
trait B<T> : A<Int> {}
|
||||
trait C<T> : <!INCONSISTENT_TYPE_PARAMETER_VALUES!>B<T>, A<T><!> {}
|
||||
trait C1<T> : B<T>, A<Any> {}
|
||||
trait D : <!INCONSISTENT_TYPE_PARAMETER_VALUES, INCONSISTENT_TYPE_PARAMETER_VALUES!>C<Boolean>, B<Double><!>{}
|
||||
|
||||
trait A1<out T> {}
|
||||
trait B1 : A1<Int> {}
|
||||
trait B2 : A1<Any>, B1 {}
|
||||
|
||||
trait BA1<T> {}
|
||||
trait BB1 : BA1<Int> {}
|
||||
trait BB2 : <!INCONSISTENT_TYPE_PARAMETER_VALUES!>BA1<Any>, BB1<!> {}
|
||||
|
||||
|
||||
namespace x {
|
||||
trait AA1<out T> {}
|
||||
trait AB1 : AA1<Int> {}
|
||||
trait AB3 : AA1<Comparable<Int>> {}
|
||||
trait AB2 : AA1<Number>, AB1, AB3 {}
|
||||
}
|
||||
|
||||
namespace x2 {
|
||||
trait AA1<out T> {}
|
||||
trait AB1 : AA1<Any> {}
|
||||
trait AB3 : AA1<Comparable<Int>> {}
|
||||
trait AB2 : <!INCONSISTENT_TYPE_PARAMETER_VALUES!>AA1<Number>, AB1, AB3<!> {}
|
||||
}
|
||||
|
||||
namespace x3 {
|
||||
trait AA1<in T> {}
|
||||
trait AB1 : AA1<Any> {}
|
||||
trait AB3 : AA1<Comparable<Int>> {}
|
||||
trait AB2 : AA1<Number>, AB1, AB3 {}
|
||||
}
|
||||
|
||||
namespace sx2 {
|
||||
trait AA1<in T> {}
|
||||
trait AB1 : AA1<Int> {}
|
||||
trait AB3 : AA1<Comparable<Int>> {}
|
||||
trait AB2 : <!INCONSISTENT_TYPE_PARAMETER_VALUES!>AA1<Number>, AB1, AB3<!> {}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
namespace illegal_modifiers
|
||||
|
||||
abstract class A() {
|
||||
<!INCOMPATIBLE_MODIFIERS!>abstract<!> <!INCOMPATIBLE_MODIFIERS!>final<!> fun f()
|
||||
abstract <!REDUNDANT_MODIFIER!>open<!> fun g()
|
||||
<!INCOMPATIBLE_MODIFIERS!>final<!> <!INCOMPATIBLE_MODIFIERS!>open<!> fun h() {}
|
||||
|
||||
open var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>r<!>: String
|
||||
get
|
||||
<!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> protected set
|
||||
}
|
||||
|
||||
<!TRAIT_CAN_NOT_BE_FINAL!>final<!> trait T {}
|
||||
|
||||
class FinalClass() {
|
||||
<!NON_FINAL_MEMBER_IN_FINAL_CLASS!>open<!> fun foo() {}
|
||||
val i: Int = 1
|
||||
<!NON_FINAL_ACCESSOR_OF_FINAL_PROPERTY!>open<!> get(): Int = $i
|
||||
var j: Int = 1
|
||||
<!NON_FINAL_ACCESSOR_OF_FINAL_PROPERTY!>open<!> set(v: Int) {}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
class IncDec() {
|
||||
fun inc() : IncDec = this
|
||||
fun dec() : IncDec = this
|
||||
}
|
||||
|
||||
fun testIncDec() {
|
||||
var x = IncDec()
|
||||
x++
|
||||
++x
|
||||
x--
|
||||
--x
|
||||
x = x++
|
||||
x = x--
|
||||
x = ++x
|
||||
x = --x
|
||||
}
|
||||
|
||||
class WrongIncDec() {
|
||||
fun inc() : Int = 1
|
||||
fun dec() : Int = 1
|
||||
}
|
||||
|
||||
fun testWrongIncDec() {
|
||||
var x = WrongIncDec()
|
||||
x<!RESULT_TYPE_MISMATCH!>++<!>
|
||||
<!RESULT_TYPE_MISMATCH!>++<!>x
|
||||
x<!RESULT_TYPE_MISMATCH!>--<!>
|
||||
<!RESULT_TYPE_MISMATCH!>--<!>x
|
||||
}
|
||||
|
||||
class UnitIncDec() {
|
||||
fun inc() : Unit {}
|
||||
fun dec() : Unit {}
|
||||
}
|
||||
|
||||
fun testUnitIncDec() {
|
||||
var x = UnitIncDec()
|
||||
x++
|
||||
++x
|
||||
x--
|
||||
--x
|
||||
x = <!TYPE_MISMATCH!>x++<!>
|
||||
x = <!TYPE_MISMATCH!>x--<!>
|
||||
x = <!TYPE_MISMATCH!>++x<!>
|
||||
x = <!TYPE_MISMATCH!>--x<!>
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fun test() {
|
||||
if (1 is Int) {
|
||||
if (1 is <!INCOMPATIBLE_TYPES!>Boolean<!>) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
namespace Jet87
|
||||
|
||||
open class A() {
|
||||
fun foo() : Int = 1
|
||||
}
|
||||
|
||||
trait B {
|
||||
fun bar() : Double = 1.0;
|
||||
}
|
||||
|
||||
class C() : A(), B
|
||||
|
||||
class D() {
|
||||
class object : A(), B {}
|
||||
}
|
||||
|
||||
class Test1<T : A>()
|
||||
where
|
||||
T : B,
|
||||
<!NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER!>B<!> : T, // error
|
||||
class object T : A,
|
||||
class object T : B,
|
||||
class object <!NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER!>B<!> : T
|
||||
{
|
||||
|
||||
fun test(t : T) {
|
||||
T.foo()
|
||||
T.bar()
|
||||
t.foo()
|
||||
t.bar()
|
||||
}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
Test1<<!UPPER_BOUND_VIOLATED!>B<!>>()
|
||||
Test1<<!UPPER_BOUND_VIOLATED!>A<!>>()
|
||||
Test1<C>()
|
||||
}
|
||||
|
||||
class Foo() {}
|
||||
|
||||
class Bar<T : <!FINAL_UPPER_BOUND!>Foo<!>>
|
||||
|
||||
class Buzz<T> where T : <!FINAL_UPPER_BOUND!>Bar<<!UPPER_BOUND_VIOLATED!>Int<!>><!>, T : <!UNRESOLVED_REFERENCE!>nioho<!>
|
||||
|
||||
class X<T : <!FINAL_UPPER_BOUND!>Foo<!>>
|
||||
class Y<<!CONFLICTING_UPPER_BOUNDS!>T<!> : <!FINAL_UPPER_BOUND!>Foo<!>> where T : <!FINAL_UPPER_BOUND!>Bar<Foo><!>
|
||||
|
||||
fun <T : A> test2(t : T)
|
||||
where
|
||||
T : B,
|
||||
<!NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER!>B<!> : T,
|
||||
class object <!NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER!>B<!> : T,
|
||||
class object T : B,
|
||||
class object T : A
|
||||
{
|
||||
T.foo()
|
||||
T.bar()
|
||||
t.foo()
|
||||
t.bar()
|
||||
}
|
||||
|
||||
val t1 = test2<<!UPPER_BOUND_VIOLATED!>A<!>>(A())
|
||||
val t2 = test2<<!UPPER_BOUND_VIOLATED!>B<!>>(C())
|
||||
val t3 = test2<C>(C())
|
||||
|
||||
class Test<<!CONFLICTING_CLASS_OBJECT_UPPER_BOUNDS!>T<!>>
|
||||
where
|
||||
class object T : <!FINAL_CLASS_OBJECT_UPPER_BOUND!>Foo<!>,
|
||||
class object T : A {}
|
||||
|
||||
val <T, B : T> x : Int = 0
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace root
|
||||
|
||||
namespace a {
|
||||
|
||||
}
|
||||
|
||||
val x = <!EXPRESSION_EXPECTED_NAMESPACE_FOUND, UNRESOLVED_REFERENCE!>a<!>
|
||||
val y2 = <!NAMESPACE_IS_NOT_AN_EXPRESSION!>namespace<!>
|
||||
@@ -0,0 +1,63 @@
|
||||
namespace foobar
|
||||
|
||||
namespace a {
|
||||
import java.*
|
||||
|
||||
val a : util.List<Int>? = null
|
||||
val a1 : <!UNRESOLVED_REFERENCE!>List<!><Int>? = null
|
||||
|
||||
}
|
||||
|
||||
abstract class Foo<T>() {
|
||||
abstract val x : T<Int>
|
||||
}
|
||||
|
||||
namespace a {
|
||||
import java.util.*
|
||||
|
||||
val b : List<Int>? = a
|
||||
val b1 : <!UNRESOLVED_REFERENCE!>util<!>.List<Int>? = a
|
||||
}
|
||||
|
||||
val x1 = a.a
|
||||
|
||||
val y1 = a.b
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun done<O>(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 iterate<O>(iteratee : Iteratee<E, O>) : O {
|
||||
for (x in this) {
|
||||
val it = iteratee.process(x)
|
||||
if (it.isDone) return it.result
|
||||
iteratee = it
|
||||
}
|
||||
return iteratee.done()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
fun test() {
|
||||
val a : Int? = 0
|
||||
if (a != null) {
|
||||
a.plus(1)
|
||||
}
|
||||
else {
|
||||
a?.plus(1)
|
||||
}
|
||||
|
||||
val out : java.io.PrintStream? = null//= System.out
|
||||
val ins = System.`in`
|
||||
|
||||
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) == ()) {
|
||||
out?.println(1)
|
||||
}
|
||||
else {
|
||||
out.println(2)
|
||||
}
|
||||
|
||||
if (out != null && out.println() == ()) {
|
||||
out.println();
|
||||
}
|
||||
else {
|
||||
out?.println();
|
||||
}
|
||||
|
||||
if (out == null || out != null && out.println() == ()) {
|
||||
out?.println();
|
||||
}
|
||||
else {
|
||||
out.println();
|
||||
}
|
||||
|
||||
if (1 == 2 || out != null && out.println(1) == ()) {
|
||||
out?.println(2);
|
||||
}
|
||||
else {
|
||||
out?.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) == ()) {
|
||||
out?.println(1)
|
||||
}
|
||||
else {
|
||||
out.println(2)
|
||||
}
|
||||
|
||||
if (out != null && out.println() == ()) {
|
||||
out.println();
|
||||
}
|
||||
else {
|
||||
out?.println();
|
||||
}
|
||||
|
||||
if (out == null || out != null && out.println() == ()) {
|
||||
out?.println();
|
||||
}
|
||||
else {
|
||||
out.println();
|
||||
}
|
||||
|
||||
if (1 == 2 || out != null && out.println(1) == ()) {
|
||||
out?.println(2);
|
||||
}
|
||||
else {
|
||||
out?.println(3)
|
||||
}
|
||||
|
||||
if (1 > 2) {
|
||||
if (out == null) return;
|
||||
out.println();
|
||||
}
|
||||
out?.println();
|
||||
|
||||
while (out != null) {
|
||||
out.println();
|
||||
}
|
||||
out?.println();
|
||||
|
||||
while (out == null) {
|
||||
out?.println();
|
||||
}
|
||||
out.println()
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun f(out : String?) {
|
||||
out?.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.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 == 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.get(0)
|
||||
}
|
||||
}
|
||||
|
||||
fun f9(a : Int?) : Int {
|
||||
if (a != null)
|
||||
return a
|
||||
return 1
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
namespace toplevelObjectDeclarations {
|
||||
open class Foo(y : Int) {
|
||||
open fun foo() : Int = 1
|
||||
}
|
||||
|
||||
class T : <!SUPERTYPE_NOT_INITIALIZED!>Foo<!> {}
|
||||
|
||||
object A : <!SUPERTYPE_NOT_INITIALIZED!>Foo<!> {
|
||||
val x : Int = 2
|
||||
|
||||
fun test() : Int {
|
||||
return x + foo()
|
||||
}
|
||||
}
|
||||
|
||||
object B : <!UNRESOLVED_REFERENCE!>A<!> {}
|
||||
|
||||
val x = A.foo()
|
||||
|
||||
val y = object : Foo(x) {
|
||||
{
|
||||
x + 12
|
||||
}
|
||||
|
||||
override fun foo() : Int = 1
|
||||
}
|
||||
|
||||
val z = y.foo()
|
||||
}
|
||||
|
||||
namespace nestedObejcts {
|
||||
object A {
|
||||
val b = B
|
||||
val d = A.B.A
|
||||
|
||||
object B {
|
||||
val a = A
|
||||
val e = B.A
|
||||
|
||||
object A {
|
||||
val a = A
|
||||
val b = B
|
||||
val x = nestedObejcts.A.B.A
|
||||
val y = this<!AMBIGUOUS_LABEL!>@A<!>
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
object B {
|
||||
val b = B
|
||||
val c = A.B
|
||||
}
|
||||
|
||||
val a = A
|
||||
val b = B
|
||||
val c = A.B
|
||||
val d = A.B.A
|
||||
val e = B.<!UNRESOLVED_REFERENCE!>A<!>.B
|
||||
}
|
||||
|
||||
namespace localObjects {
|
||||
object A {
|
||||
val x : Int = 0
|
||||
}
|
||||
|
||||
open class Foo {
|
||||
fun foo() : Int = 1
|
||||
}
|
||||
|
||||
fun test() {
|
||||
A.x
|
||||
val b = object : Foo {
|
||||
}
|
||||
b.foo()
|
||||
|
||||
object B {
|
||||
fun foo() {}
|
||||
}
|
||||
B.foo()
|
||||
}
|
||||
|
||||
val bb = <!UNRESOLVED_REFERENCE!>B<!>.foo()
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class <!PRIMARY_CONSTRUCTOR_MISSING_STATEFUL_PROPERTY!>X<!> {
|
||||
val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>x<!> : Int
|
||||
}
|
||||
|
||||
open class Y() {
|
||||
val x : Int = 2
|
||||
}
|
||||
|
||||
class Y1 {
|
||||
val x : Int get() = 1
|
||||
}
|
||||
|
||||
class Z : Y<!PRIMARY_CONSTRUCTOR_MISSING_SUPER_CONSTRUCTOR_CALL!>()<!> {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
trait A<T> {}
|
||||
trait B<T> {}
|
||||
trait C<T> {}
|
||||
trait D<T> {}
|
||||
|
||||
trait Test : A<<!PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE!>in<!> Int>, B<<!PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE!>out<!> Int>, C<<!PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE!>*<!>><!NULLABLE_SUPERTYPE!>?<!><!NULLABLE_SUPERTYPE!>?<!><!NULLABLE_SUPERTYPE!>?<!>, D<Int> {}
|
||||
@@ -0,0 +1,28 @@
|
||||
var x : Int = 1 + x
|
||||
get() : Int = 1
|
||||
set(<!REF_SETTER_PARAMETER!>ref<!> value : <!WRONG_SETTER_PARAMETER_TYPE!>Long<!>) {
|
||||
$x = value.int
|
||||
$x = <!TYPE_MISMATCH!>1.lng<!>
|
||||
}
|
||||
|
||||
val xx : Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>1 + x<!>
|
||||
get() : Int = 1
|
||||
<!VAL_WITH_SETTER!>set(value : Long) {}<!>
|
||||
|
||||
val p : Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>1<!>
|
||||
get() = 1
|
||||
|
||||
class Test() {
|
||||
var a : Int = 111
|
||||
var b : Int get() = <!UNRESOLVED_REFERENCE!>$a<!>; set(x) {a = x; <!UNRESOLVED_REFERENCE!>$a<!> = x}
|
||||
|
||||
this(i : Int) : this() {
|
||||
<!NO_BACKING_FIELD!>$b<!> = $a
|
||||
$a = <!NO_BACKING_FIELD!>$b<!>
|
||||
a = <!NO_BACKING_FIELD!>$b<!>
|
||||
}
|
||||
fun f() {
|
||||
<!UNRESOLVED_REFERENCE!>$b<!> = <!UNRESOLVED_REFERENCE!>$a<!>
|
||||
a = <!UNRESOLVED_REFERENCE!>$b<!>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace qualified_expressions
|
||||
|
||||
fun test(s: String?) {
|
||||
val a: Int = <!TYPE_MISMATCH!>s?.length<!>
|
||||
val b: Int? = s?.length
|
||||
val c: Int = s?.length ?: -11
|
||||
val d: Int = s?.length ?: <!TYPE_MISMATCH!>"empty"<!>
|
||||
val e: String = <!TYPE_MISMATCH!>s?.length<!> ?: "empty"
|
||||
val f: Int = s?.length ?: b ?: 1
|
||||
val g: Int? = e? startsWith("s")?.length
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
class Dup {
|
||||
fun Dup() : Unit {
|
||||
this<!AMBIGUOUS_LABEL!>@Dup<!>
|
||||
}
|
||||
}
|
||||
|
||||
class A() {
|
||||
fun foo() : Unit {
|
||||
this@A
|
||||
this<!UNRESOLVED_REFERENCE!>@a<!>
|
||||
this
|
||||
}
|
||||
|
||||
val x = this@A.foo()
|
||||
val y = this.foo()
|
||||
val z = foo()
|
||||
}
|
||||
|
||||
fun foo1() : Unit {
|
||||
<!NO_THIS!>this<!>
|
||||
this<!UNRESOLVED_REFERENCE!>@a<!>
|
||||
}
|
||||
|
||||
namespace closures {
|
||||
class A(val a:Int) {
|
||||
|
||||
class B() {
|
||||
val x = this@B : B
|
||||
val y = this@A : A
|
||||
val z = this : B
|
||||
val Int.xx = this : Int
|
||||
fun Char.xx() : Any {
|
||||
this : Char
|
||||
val a = {Double.() => this : Double + this@xx : Char}
|
||||
val b = @a{Double.() => this@a : Double + this@xx : Char}
|
||||
val c = @a{() => <!NO_THIS!>this@a<!> + this@xx : Char}
|
||||
return (@a{Double.() => this@a : Double + this@xx : Char})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
namespace a {
|
||||
val foo = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>bar()<!>
|
||||
|
||||
fun bar() = foo
|
||||
}
|
||||
|
||||
namespace b {
|
||||
fun foo() = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>bar()<!>
|
||||
|
||||
fun bar() = foo()
|
||||
}
|
||||
|
||||
namespace c {
|
||||
fun bazz() = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>bar()<!>
|
||||
|
||||
fun foo() = bazz()
|
||||
|
||||
fun bar() = foo()
|
||||
}
|
||||
|
||||
namespace ok {
|
||||
|
||||
namespace a {
|
||||
val foo = bar()
|
||||
|
||||
fun bar() : Int = foo
|
||||
}
|
||||
|
||||
namespace b {
|
||||
fun foo() : Int = bar()
|
||||
|
||||
fun bar() = foo()
|
||||
}
|
||||
|
||||
namespace c {
|
||||
fun bazz() = bar()
|
||||
|
||||
fun foo() : Int = bazz()
|
||||
|
||||
fun bar() = foo()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace redeclarations {
|
||||
object <!REDECLARATION, REDECLARATION!>A<!> {
|
||||
val x : Int = 0
|
||||
|
||||
val A = 1
|
||||
}
|
||||
|
||||
namespace <!REDECLARATION!>A<!> {
|
||||
class A {}
|
||||
}
|
||||
|
||||
class <!REDECLARATION, REDECLARATION!>A<!> {}
|
||||
|
||||
val <!REDECLARATION!>A<!> = 1
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import java.*
|
||||
import util.*
|
||||
import <!UNRESOLVED_REFERENCE!>utils<!>.*
|
||||
|
||||
import java.io.PrintStream
|
||||
import java.lang.Comparable as Com
|
||||
|
||||
val l : List<in Int> = ArrayList<Int>()
|
||||
|
||||
fun test(l : java.util.List<Int>) {
|
||||
val x : java.<!UNRESOLVED_REFERENCE!>List<!>
|
||||
val y : java.util.List<Int>
|
||||
val b : java.lang.Object
|
||||
val a : util.List<Int>
|
||||
val z : java.<!UNRESOLVED_REFERENCE!>utils<!>.List<Int>
|
||||
|
||||
val f : java.io.File? = null
|
||||
|
||||
Collections.<!UNRESOLVED_REFERENCE!>emptyList<!>
|
||||
Collections.emptyList<Int>
|
||||
Collections.emptyList<Int>()
|
||||
Collections.emptyList()
|
||||
|
||||
Collections.singleton<Int>(1) : Set<Int>?
|
||||
Collections.singleton<Int>(<!ERROR_COMPILE_TIME_VALUE!>1.0<!>)
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>List<!><Int>
|
||||
|
||||
|
||||
val o = "sdf" <!CAST_NEVER_SUCCEEDS!>as<!> Object
|
||||
|
||||
try {
|
||||
// ...
|
||||
}
|
||||
catch(e: Exception) {
|
||||
System.out?.println(e.getMessage())
|
||||
}
|
||||
|
||||
PrintStream("sdf")
|
||||
|
||||
val c : Com<Int>? = null
|
||||
|
||||
c : java.lang.Comparable<Int>?
|
||||
|
||||
// Collections.sort<Integer>(ArrayList<Integer>())
|
||||
xxx.<!UNRESOLVED_REFERENCE!>Class<!>()
|
||||
}
|
||||
|
||||
|
||||
namespace xxx {
|
||||
import java.lang.Class;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
fun demo() {
|
||||
val abc = 1
|
||||
val a = ""
|
||||
val asd = 1
|
||||
val bar = 5
|
||||
fun map(f : fun () : Any?) : Int = 1
|
||||
fun buzz(f : fun () : Any?) : Int = 1
|
||||
val sdf = 1
|
||||
val foo = 3;
|
||||
"$abc"
|
||||
"$"
|
||||
"$.$.asdf$\t"
|
||||
"asd\$"
|
||||
"asd$a<!ILLEGAL_ESCAPE_SEQUENCE!>\x<!>"
|
||||
"asd$a$asd$ $<!UNRESOLVED_REFERENCE!>xxx<!>"
|
||||
"fosdfasdo${1 + bar + 100}}sdsdfgdsfsdf"
|
||||
"foo${bar + map {foo}}sdfsdf"
|
||||
"foo${bar + map { "foo" }}sdfsdf"
|
||||
"foo${bar + map {
|
||||
"foo$sdf${ buzz{}}" }}sdfsdf"
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// KT-286 Check supertype lists
|
||||
|
||||
/*
|
||||
In a supertype list:
|
||||
Same type should not be mentioned twice
|
||||
Same type should not be indirectly mentioned with incoherent type arguments
|
||||
Every trait's required dependencies should be satisfied
|
||||
No final types should appear
|
||||
Only one class is allowed
|
||||
*/
|
||||
|
||||
class C1()
|
||||
|
||||
open class OC1()
|
||||
|
||||
open class C2 {}
|
||||
|
||||
open class C3 {}
|
||||
|
||||
trait T1 {}
|
||||
|
||||
trait T2<T> {}
|
||||
|
||||
trait Test<!CONSTRUCTOR_IN_TRAIT!>()<!> {
|
||||
<!CONSTRUCTOR_IN_TRAIT, SECONDARY_CONSTRUCTOR_NO_INITIALIZER_LIST!>this<!>(x : Int) {}
|
||||
}
|
||||
|
||||
trait Test1 : C2<!SUPERTYPE_INITIALIZED_IN_TRAIT!>()<!> {}
|
||||
|
||||
trait Test2 : C2 {}
|
||||
|
||||
trait Test3 : C2, <!MANY_CLASSES_IN_SUPERTYPE_LIST!>C3<!> {}
|
||||
|
||||
trait Test4 : T1 {}
|
||||
|
||||
trait Test5 : T1, <!SUPERTYPE_APPEARS_TWICE!>T1<!> {}
|
||||
|
||||
trait Test6 : <!FINAL_SUPERTYPE!>C1<!> {}
|
||||
|
||||
class CTest1() : OC1() {}
|
||||
|
||||
class CTest2 : C2 {}
|
||||
|
||||
class CTest3 : C2, <!MANY_CLASSES_IN_SUPERTYPE_LIST!>C3<!> {}
|
||||
|
||||
class CTest4 : T1 {}
|
||||
|
||||
class CTest5 : T1, <!SUPERTYPE_APPEARS_TWICE!>T1<!> {}
|
||||
|
||||
class CTest6 : <!SUPERTYPE_NOT_INITIALIZED, FINAL_SUPERTYPE!>C1<!> {}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
open class bar()
|
||||
|
||||
trait Foo<!CONSTRUCTOR_IN_TRAIT!>()<!> : bar<!SUPERTYPE_INITIALIZED_IN_TRAIT!>()<!>, <!MANY_CLASSES_IN_SUPERTYPE_LIST, SUPERTYPE_APPEARS_TWICE!>bar<!>, <!MANY_CLASSES_IN_SUPERTYPE_LIST, SUPERTYPE_APPEARS_TWICE!>bar<!> {
|
||||
<!CONSTRUCTOR_IN_TRAIT, SECONDARY_CONSTRUCTOR_NO_INITIALIZER_LIST!>this<!>(x : Int) {}
|
||||
}
|
||||
|
||||
trait Foo2 : bar, Foo {
|
||||
}
|
||||
|
||||
open class Foo1() : bar(), <!SUPERTYPE_NOT_INITIALIZED, MANY_CLASSES_IN_SUPERTYPE_LIST, SUPERTYPE_APPEARS_TWICE!>bar<!>, Foo, <!SUPERTYPE_APPEARS_TWICE!>Foo<!><!CONSTRUCTOR_IN_TRAIT!>()<!> {}
|
||||
open class Foo12 : bar<!PRIMARY_CONSTRUCTOR_MISSING_SUPER_CONSTRUCTOR_CALL!>()<!>, <!SUPERTYPE_NOT_INITIALIZED, MANY_CLASSES_IN_SUPERTYPE_LIST, SUPERTYPE_APPEARS_TWICE!>bar<!> {}
|
||||
@@ -0,0 +1,161 @@
|
||||
fun t1() : Int{
|
||||
return 0
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
}
|
||||
|
||||
fun t1a() : Int {
|
||||
<!RETURN_TYPE_MISMATCH!>return<!>
|
||||
<!UNREACHABLE_CODE!>return 1<!>
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
}
|
||||
|
||||
fun t1b() : Int {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>return 1<!>
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
}
|
||||
|
||||
fun t1c() : Int {
|
||||
return 1
|
||||
<!RETURN_TYPE_MISMATCH, UNREACHABLE_CODE!>return<!>
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
}
|
||||
|
||||
fun t2() : Int {
|
||||
if (1 > 2)
|
||||
return 1
|
||||
else return 1
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
}
|
||||
|
||||
fun t2a() : Int {
|
||||
if (1 > 2) {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
} else { return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
}
|
||||
|
||||
fun t3() : Any {
|
||||
if (1 > 2)
|
||||
return 2
|
||||
else return ""
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
}
|
||||
|
||||
fun t4(a : Boolean) : Int {
|
||||
do {
|
||||
return 1
|
||||
}
|
||||
while (<!UNREACHABLE_CODE!>a<!>)
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
}
|
||||
|
||||
fun t4break(a : Boolean) : Int {
|
||||
do {
|
||||
break
|
||||
}
|
||||
while (<!UNREACHABLE_CODE!>a<!>)
|
||||
return 1
|
||||
}
|
||||
|
||||
fun t5() : Int {
|
||||
do {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
while (<!UNREACHABLE_CODE!>1 > 2<!>)
|
||||
<!UNREACHABLE_CODE!>return 1<!>
|
||||
}
|
||||
|
||||
fun t6() : Int {
|
||||
while (1 > 2) {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
fun t6break() : Int {
|
||||
while (1 > 2) {
|
||||
break
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
fun t7(b : Int) : Int {
|
||||
for (i in 1..b) {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
fun t7break(b : Int) : Int {
|
||||
for (i in 1..b) {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
fun t7() : Int {
|
||||
try {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
catch (e : Any) {
|
||||
2
|
||||
}
|
||||
return 1 // this is OK, like in Java
|
||||
}
|
||||
|
||||
fun t8() : Int {
|
||||
try {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
catch (e : Any) {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
<!UNREACHABLE_CODE!>return 1<!>
|
||||
}
|
||||
|
||||
fun blockAndAndMismatch() : Boolean {
|
||||
<!UNREACHABLE_CODE!>(return true) || (return false)<!>
|
||||
<!UNREACHABLE_CODE!>return true<!>
|
||||
}
|
||||
|
||||
fun tf() : Int {
|
||||
try {<!UNREACHABLE_CODE!>return 1<!>} finally{return 1}
|
||||
<!UNREACHABLE_CODE!>return 1<!>
|
||||
}
|
||||
|
||||
fun failtest(a : Int) : Int {
|
||||
<!UNREACHABLE_BECAUSE_OF_NOTHING!>if (fail() || true) {
|
||||
|
||||
}<!>
|
||||
<!UNREACHABLE_BECAUSE_OF_NOTHING!>return 1<!>
|
||||
}
|
||||
|
||||
fun foo(a : Nothing) : Unit {
|
||||
1
|
||||
a
|
||||
<!UNREACHABLE_BECAUSE_OF_NOTHING!>2<!>
|
||||
}
|
||||
|
||||
fun fail() : Nothing {
|
||||
throw java.lang.RuntimeException()
|
||||
}
|
||||
|
||||
fun nullIsNotNothing() : Unit {
|
||||
val x : Int? = 1
|
||||
if (x != null) {
|
||||
return
|
||||
}
|
||||
fail()
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace unresolved
|
||||
|
||||
fun testGenericArgumentsCount() {
|
||||
val p1: Tuple2<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!> = (2, 2)
|
||||
val p2: <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Tuple2<!> = (2, 2)
|
||||
}
|
||||
|
||||
fun testUnresolved() {
|
||||
if (<!UNRESOLVED_REFERENCE!>a<!> is String) {
|
||||
val s = <!UNRESOLVED_REFERENCE!>a<!>
|
||||
}
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>(<!UNRESOLVED_REFERENCE!>a<!>)
|
||||
val s = "s"
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>(s)
|
||||
foo1(<!UNRESOLVED_REFERENCE!>i<!>)
|
||||
s.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
|
||||
when(<!UNRESOLVED_REFERENCE!>a<!>) {
|
||||
is Int => <!UNRESOLVED_REFERENCE!>a<!>
|
||||
is String => <!UNRESOLVED_REFERENCE!>a<!>
|
||||
}
|
||||
|
||||
//TODO
|
||||
for (j in <!UNRESOLVED_REFERENCE!>collection<!>) {
|
||||
val i: Int = j
|
||||
j += 1
|
||||
}
|
||||
}
|
||||
|
||||
fun foo1(i: Int) {}
|
||||
@@ -0,0 +1,8 @@
|
||||
class Foo1() : java.util.ArrayList<Int>()
|
||||
|
||||
open class Bar() {
|
||||
fun v() : Int = 1
|
||||
val v : Int = 1
|
||||
}
|
||||
|
||||
class Barr() : Bar() {}
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace variance
|
||||
|
||||
abstract class Consumer<in T> {}
|
||||
|
||||
abstract class Producer<out T> {}
|
||||
|
||||
abstract class Usual<T> {}
|
||||
|
||||
fun foo(c: Consumer<Int>, p: Producer<Int>, u: Usual<Int>) {
|
||||
val c1: Consumer<Any> = <!TYPE_MISMATCH!>c<!>
|
||||
val c2: Consumer<Int> = c1
|
||||
|
||||
val p1: Producer<Any> = p
|
||||
val p2: Producer<Int> = <!TYPE_MISMATCH!>p1<!>
|
||||
|
||||
val u1: Usual<Any> = <!TYPE_MISMATCH!>u<!>
|
||||
val u2: Usual<Int> = <!TYPE_MISMATCH!>u1<!>
|
||||
}
|
||||
|
||||
//Arrays copy example
|
||||
class Array<T>(val length : Int) {
|
||||
fun get(index : Int) : T { return null }
|
||||
fun set(index : Int, value : T) { /* ... */ }
|
||||
}
|
||||
|
||||
fun copy1(from : Array<Any>, to : Array<Any>) {}
|
||||
|
||||
fun copy2(from : Array<out Any>, to : Array<in Any>) {}
|
||||
|
||||
fun <T> copy3(from : Array<out T>, to : Array<in T>) {}
|
||||
|
||||
fun copy4(from : Array<out Number>, to : Array<in Int>) {}
|
||||
|
||||
fun f(ints: Array<Int>, any: Array<Any>, numbers: Array<Number>) {
|
||||
copy1(<!TYPE_MISMATCH!>ints<!>, any)
|
||||
copy2(ints, any) //ok
|
||||
copy2(ints, <!TYPE_MISMATCH!>numbers<!>)
|
||||
copy3<Int>(ints, numbers)
|
||||
copy4(ints, numbers) //ok
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
fun foo() : Int {
|
||||
val s = ""
|
||||
val x = 1
|
||||
when (x) {
|
||||
is * => 1
|
||||
is <!INCOMPATIBLE_TYPES!>String<!> => 1
|
||||
!is Int => 1
|
||||
is Any? => 1
|
||||
<!INCOMPATIBLE_TYPES!>s<!> => 1
|
||||
1 => 1
|
||||
1 + <!UNRESOLVED_REFERENCE!>a<!> => 1
|
||||
in 1..<!UNRESOLVED_REFERENCE!>a<!> => 1
|
||||
!in 1..<!UNRESOLVED_REFERENCE!>a<!> => 1
|
||||
.<!UNRESOLVED_REFERENCE!>a<!> => 1
|
||||
.equals(1).<!UNRESOLVED_REFERENCE!>a<!> => 1
|
||||
<!UNNECESSARY_SAFE_CALL!>?.<!>equals(1) => 1
|
||||
else => 1
|
||||
}
|
||||
return when (<!USELESS_ELVIS!>x<!>?:null) {
|
||||
<!UNSAFE_CALL!>.<!>equals(1) => 1
|
||||
?.equals(1).equals(2) => 1
|
||||
}
|
||||
}
|
||||
|
||||
val _type_test : Int = foo() // this is needed to ensure the inferred return type of foo()
|
||||
|
||||
fun test() {
|
||||
val x = 1;
|
||||
val s = "";
|
||||
|
||||
when (x) {
|
||||
<!INCOMPATIBLE_TYPES!>s<!> => 1
|
||||
is <!INCOMPATIBLE_TYPES!>""<!> => 1
|
||||
x => 1
|
||||
is 1 => 1
|
||||
is <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>(1, 1)<!> => 1
|
||||
}
|
||||
|
||||
val z = (1, 1)
|
||||
|
||||
when (z) {
|
||||
is (*, *) => 1
|
||||
is (*, 1) => 1
|
||||
is (1, 1) => 1
|
||||
is (1, <!INCOMPATIBLE_TYPES!>"1"<!>) => 1
|
||||
is <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>(1, "1", *)<!> => 1
|
||||
is boo @ (1, <!INCOMPATIBLE_TYPES!>"a"<!>, *) => 1
|
||||
is boo @ <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>(1, *)<!> => 1
|
||||
}
|
||||
|
||||
when (z) {
|
||||
<!ELSE_MISPLACED_IN_WHEN!>else => 1<!>
|
||||
(1, 1) => 2
|
||||
}
|
||||
|
||||
when (z) {
|
||||
else => 1
|
||||
}
|
||||
}
|
||||
|
||||
val (Int, Int).boo : (Int, Int, Int) = (1, 1, 1)
|
||||
@@ -0,0 +1,255 @@
|
||||
open class A() {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
class B() : A() {
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
fun f9() {
|
||||
val a : A?
|
||||
a?.foo()
|
||||
a?.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
if (a is B) {
|
||||
a.bar()
|
||||
a.foo()
|
||||
}
|
||||
a?.foo()
|
||||
a?.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
if (!(a is B)) {
|
||||
a?.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
a?.foo()
|
||||
}
|
||||
if (!(a is B) || a.bar() == ()) {
|
||||
a?.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
}
|
||||
if (!(a is B)) {
|
||||
return;
|
||||
}
|
||||
a.bar()
|
||||
a.foo()
|
||||
}
|
||||
|
||||
fun f10() {
|
||||
val a : A?
|
||||
if (!(a is B)) {
|
||||
return;
|
||||
}
|
||||
if (!(a is B)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
class C() : A() {
|
||||
fun bar() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun f10(a : A?) {
|
||||
if (a is B) {
|
||||
if (a is C) {
|
||||
a.bar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun f11(a : A?) {
|
||||
when (a) {
|
||||
is B => a.bar()
|
||||
is A => a.foo()
|
||||
is Any => a.foo()
|
||||
is Any? => a.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
else => a?.foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun f12(a : A?) {
|
||||
when (a) {
|
||||
is B => a.bar()
|
||||
is A => a.foo()
|
||||
is Any => a.foo();
|
||||
is Any? => a.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
is val c : <!TYPE_MISMATCH_IN_BINDING_PATTERN!>B<!> => c.foo()
|
||||
is val c is C => c.bar()
|
||||
is val c is C => a.bar()
|
||||
else => a?.foo()
|
||||
}
|
||||
|
||||
if (a is val b) {
|
||||
a?.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
b?.foo()
|
||||
}
|
||||
if (a is val b is B) {
|
||||
b.foo()
|
||||
a.bar()
|
||||
b.bar()
|
||||
}
|
||||
}
|
||||
|
||||
fun f13(a : A?) {
|
||||
if (a is val c is B) {
|
||||
c.foo()
|
||||
c.bar()
|
||||
}
|
||||
else {
|
||||
a?.foo()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.bar()
|
||||
}
|
||||
|
||||
a?.foo()
|
||||
if (!(a is val c is B)) {
|
||||
a?.foo()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.bar()
|
||||
}
|
||||
else {
|
||||
a.foo()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.bar()
|
||||
}
|
||||
|
||||
a?.foo()
|
||||
if (a is val c is B && a.foo() == () && c.bar() == ()) {
|
||||
c.foo()
|
||||
c.bar()
|
||||
}
|
||||
else {
|
||||
a?.foo()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.bar()
|
||||
}
|
||||
|
||||
if (!(a is val c is B) || !(a is val x is C)) {
|
||||
<!UNRESOLVED_REFERENCE!>x<!>
|
||||
<!UNRESOLVED_REFERENCE!>c<!>
|
||||
}
|
||||
else {
|
||||
<!UNRESOLVED_REFERENCE!>x<!>
|
||||
<!UNRESOLVED_REFERENCE!>c<!>
|
||||
}
|
||||
|
||||
if (!(a is val c is B) || !(a is val c is C)) {
|
||||
}
|
||||
|
||||
if (!(a is val c is B)) return
|
||||
a.bar()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.foo()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.bar()
|
||||
}
|
||||
|
||||
fun f14(a : A?) {
|
||||
while (!(a is val c is B)) {
|
||||
}
|
||||
a.bar()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.bar()
|
||||
}
|
||||
fun f15(a : A?) {
|
||||
do {
|
||||
} while (!(a is val c is B))
|
||||
a.bar()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.bar()
|
||||
}
|
||||
|
||||
fun getStringLength(obj : Any) : Char? {
|
||||
if (obj !is String)
|
||||
return null
|
||||
return obj.get(0) // no cast to String is needed
|
||||
}
|
||||
|
||||
fun toInt(i: Int?): Int = if (i != null) i else 0
|
||||
fun illegalWhenBody(a: Any): Int = when(a) {
|
||||
is Int => a
|
||||
is String => <!TYPE_MISMATCH!>a<!>
|
||||
}
|
||||
fun illegalWhenBlock(a: Any): Int {
|
||||
when(a) {
|
||||
is Int => return a
|
||||
is String => return <!TYPE_MISMATCH!>a<!>
|
||||
}
|
||||
}
|
||||
fun declarations(a: Any?) {
|
||||
if (a is String) {
|
||||
val p4: (Int, String) = (2, a)
|
||||
}
|
||||
if (a is String?) {
|
||||
if (a != null) {
|
||||
val s: String = a
|
||||
}
|
||||
}
|
||||
if (a != null) {
|
||||
if (a is String?) {
|
||||
val s: String = a
|
||||
}
|
||||
}
|
||||
}
|
||||
fun vars(a: Any?) {
|
||||
var b: Int = 0
|
||||
if (a is Int) {
|
||||
b = a
|
||||
}
|
||||
}
|
||||
fun tuples(a: Any?) {
|
||||
if (a != null) {
|
||||
val s: (Any, String) = (a, <!TYPE_MISMATCH!>a<!>)
|
||||
}
|
||||
if (a is String) {
|
||||
val s: (Any, String) = (a, a)
|
||||
}
|
||||
fun illegalTupleReturnType(): (Any, String) = (<!TYPE_MISMATCH!>a<!>, <!TYPE_MISMATCH!>a<!>)
|
||||
if (a is String) {
|
||||
fun legalTupleReturnType(): (Any, String) = (a, a)
|
||||
}
|
||||
val illegalFunctionLiteral: Function0<Int> = <!TYPE_MISMATCH!>{ <!TYPE_MISMATCH!>a<!> }<!>
|
||||
val illegalReturnValueInFunctionLiteral: Function0<Int> = { (): Int => <!TYPE_MISMATCH!>a<!> }
|
||||
|
||||
if (a is Int) {
|
||||
val legalFunctionLiteral: Function0<Int> = { a }
|
||||
val alsoLegalFunctionLiteral: Function0<Int> = { (): Int => a }
|
||||
}
|
||||
}
|
||||
fun returnFunctionLiteralBlock(a: Any?): Function0<Int> {
|
||||
if (a is Int) return { a }
|
||||
else return { 1 }
|
||||
}
|
||||
fun returnFunctionLiteral(a: Any?): Function0<Int> =
|
||||
if (a is Int) { (): Int => a }
|
||||
else { () => 1 }
|
||||
|
||||
fun illegalTupleReturnType(a: Any): (Any, String) = (a, <!TYPE_MISMATCH!>a<!>)
|
||||
|
||||
fun declarationInsidePattern(x: (Any, Any)): String = when(x) { is (val a is String, *) => a; else => "something" }
|
||||
|
||||
fun mergeAutocasts(a: Any?) {
|
||||
if (a is String || a is Int) {
|
||||
a.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
|
||||
a.toString()
|
||||
}
|
||||
if (a is Int || a is String) {
|
||||
a.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
|
||||
}
|
||||
when (a) {
|
||||
is String, is Any => a.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
|
||||
}
|
||||
if (a is String && a is Any) {
|
||||
val i: Int = a.compareTo("")
|
||||
}
|
||||
if (a is String && a.compareTo("") == 0) {}
|
||||
if (a is String || a.<!UNRESOLVED_REFERENCE!>compareTo<!>("") == 0) {}
|
||||
}
|
||||
|
||||
//mutability
|
||||
fun f(): String {
|
||||
var a: Any = 11
|
||||
if (a is String) {
|
||||
val i: String = <!AUTOCAST_IMPOSSIBLE!>a<!>
|
||||
<!AUTOCAST_IMPOSSIBLE!>a<!>.compareTo("f")
|
||||
val f: Function0<String> = { <!AUTOCAST_IMPOSSIBLE!>a<!> }
|
||||
return <!AUTOCAST_IMPOSSIBLE!>a<!>
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
fun foo(var a: Any): Int {
|
||||
if (a is Int) {
|
||||
return <!AUTOCAST_IMPOSSIBLE!>a<!>
|
||||
}
|
||||
return 1
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
abstract class Test() {
|
||||
abstract val x : Int
|
||||
abstract val x1 : Int get
|
||||
abstract val x2 : Int <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = 1<!>
|
||||
|
||||
val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>a<!> : Int
|
||||
val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>b<!> : Int get
|
||||
val c = 1
|
||||
|
||||
val c1 = 1
|
||||
get
|
||||
val c2 : Int
|
||||
get() = 1
|
||||
val c3 : Int
|
||||
get() { return 1 }
|
||||
val c4 : Int
|
||||
get() = 1
|
||||
val <!MUST_BE_INITIALIZED!>c5<!> : Int
|
||||
get() = $c5 + 1
|
||||
|
||||
abstract var y : Int
|
||||
abstract var y1 : Int get
|
||||
abstract var y2 : Int set
|
||||
abstract var y3 : Int set get
|
||||
abstract var y4 : Int set <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = 1<!>
|
||||
abstract var y5 : Int <!ABSTRACT_PROPERTY_WITH_SETTER!>set(x) {}<!> <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = 1<!>
|
||||
abstract var y6 : Int <!ABSTRACT_PROPERTY_WITH_SETTER!>set(x) {}<!>
|
||||
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>v<!> : Int
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>v1<!> : Int get
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>v2<!> : Int get set
|
||||
var <!MUST_BE_INITIALIZED!>v3<!> : Int get() = 1; set
|
||||
var v4 : Int get() = 1; set(x){}
|
||||
|
||||
var <!MUST_BE_INITIALIZED!>v5<!> : Int get() = 1; set(x){$v5 = x}
|
||||
var <!MUST_BE_INITIALIZED!>v6<!> : Int get() = $v6 + 1; set(x){}
|
||||
|
||||
abstract val v7 : Int abstract get
|
||||
abstract var v8 : Int abstract get abstract set
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>v9<!> : Int <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> set
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>v10<!> : Int <!ABSTRACT_ACCESSOR_OF_NON_ABSTRACT_PROPERTY!>abstract<!> get
|
||||
|
||||
}
|
||||
|
||||
open class Super(i : Int)
|
||||
|
||||
class TestPCParameters(w : Int, x : Int, val y : Int, var z : Int) : Super(w) {
|
||||
|
||||
val xx = w
|
||||
|
||||
{
|
||||
w + 1
|
||||
}
|
||||
|
||||
fun foo() = <!UNRESOLVED_REFERENCE!>x<!>
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// One of the two passes is making a scope and turning vals into functions
|
||||
// See KT-76
|
||||
|
||||
namespace x
|
||||
|
||||
val b : Foo = Foo()
|
||||
val a1 = b.compareTo(2)
|
||||
|
||||
class Foo() {
|
||||
fun compareTo(other : Byte) : Int = 0
|
||||
fun compareTo(other : Char) : Int = 0
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
fun test() {
|
||||
val a : Any? = null
|
||||
if (a is Any) else a = null;
|
||||
while (a is Any) a = null
|
||||
while (true) a = null
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fun foo(u : Unit) : Int = 1
|
||||
|
||||
fun test() : Int {
|
||||
foo(<!TYPE_MISMATCH!>1<!>)
|
||||
val a : fun() : Unit = {
|
||||
foo(<!TYPE_MISMATCH!>1<!>)
|
||||
}
|
||||
return 1
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import java.*
|
||||
import util.*
|
||||
|
||||
import java.io.*
|
||||
|
||||
fun takeFirst(expr: StringBuilder): Char {
|
||||
val c = expr.charAt(0)
|
||||
expr.deleteCharAt(0)
|
||||
return c
|
||||
}
|
||||
|
||||
fun evaluateArg(expr: AbstractStringBuilder, numbers: ArrayList<Int>): Int {
|
||||
if (expr.length() == 0) throw Exception("Syntax error: Character expected");
|
||||
val c = takeFirst(<!TYPE_MISMATCH!>expr<!>)
|
||||
if (c >= '0' && c <= '9') {
|
||||
val n = c - '0'
|
||||
if (!numbers.contains(n)) throw Exception("You used incorrect number: " + n)
|
||||
numbers.remove(n)
|
||||
return n
|
||||
}
|
||||
throw Exception("Syntax error: Unrecognized character " + c)
|
||||
}
|
||||
|
||||
fun evaluateAdd(expr: StringBuilder, numbers: ArrayList<Int>): Int {
|
||||
val lhs = evaluateArg(expr, numbers)
|
||||
if (expr.length() > 0) {
|
||||
|
||||
}
|
||||
return lhs
|
||||
}
|
||||
|
||||
fun evaluate(expr: StringBuilder, numbers: ArrayList<Int>): Int {
|
||||
val lhs = evaluateAdd(expr, numbers)
|
||||
if (expr.length() > 0) {
|
||||
val c = expr.charAt(0)
|
||||
expr.deleteCharAt(0)
|
||||
}
|
||||
return lhs
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
System.out?.println("24 game")
|
||||
val numbers = ArrayList<Int>(4)
|
||||
val rnd = Random();
|
||||
val prompt = StringBuilder()
|
||||
for(val i in 0..3) {
|
||||
val n = rnd.nextInt(9) + 1
|
||||
numbers.add(n)
|
||||
if (i > 0) prompt.append(" ");
|
||||
prompt.append(n)
|
||||
}
|
||||
System.out?.println("Your numbers: " + prompt)
|
||||
System.out?.println("Enter your expression:")
|
||||
val reader = BufferedReader(InputStreamReader(System.`in`))
|
||||
val expr = StringBuilder(reader.readLine())
|
||||
try {
|
||||
val result = evaluate(expr, numbers)
|
||||
if (result != 24)
|
||||
System.out?.println("Sorry, that's " + result)
|
||||
else
|
||||
System.out?.println("You won!");
|
||||
}
|
||||
catch(e: Throwable) {
|
||||
System.out?.println(e.getMessage())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// JET-11 Redeclaration & Forward reference for classes cause an exception
|
||||
open class <!REDECLARATION!>NoC<!>
|
||||
class NoC1 : NoC
|
||||
open class <!REDECLARATION!>NoC<!>
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace jet121 {
|
||||
fun box() : String {
|
||||
val answer = apply("OK") { String.() : Int =>
|
||||
get(0)
|
||||
length
|
||||
}
|
||||
|
||||
return if (answer == 2) "OK" else "FAIL"
|
||||
}
|
||||
|
||||
fun apply(arg:String, f : fun String.() : Int) : Int {
|
||||
return arg.f()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fun foo1() : fun (Int) : Int = { (x: Int) => x }
|
||||
|
||||
fun foo() {
|
||||
val h : fun (Int) : Int = foo1();
|
||||
h(1)
|
||||
val m : fun (Int) : Int = {(a : Int) => 1}//foo1()
|
||||
m(1)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fun set(key : String, value : String) {
|
||||
val a : String? = ""
|
||||
when (a) {
|
||||
"" => a<!UNSAFE_CALL!>.<!>get(0)
|
||||
is String, is Any => a.compareTo("")
|
||||
else => a.toString()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// JET-17 Do not infer property types by the initializer before the containing scope is ready
|
||||
|
||||
class WithC() {
|
||||
val a = 1
|
||||
val b = $a // error here, but must not be
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
abstract enum class ProtocolState {
|
||||
WAITING {
|
||||
override fun signal() = ProtocolState.TALKING
|
||||
}
|
||||
|
||||
TALKING {
|
||||
override fun signal() = ProtocolState.WAITING
|
||||
}
|
||||
|
||||
abstract fun signal() : ProtocolState
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val x: ProtocolState = ProtocolState.WAITING
|
||||
x = x.signal()
|
||||
if (x != ProtocolState.TALKING) return "fail 1"
|
||||
x = x.signal()
|
||||
if (x != ProtocolState.WAITING) return "fail 2"
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
abstract enum class ProtocolState {
|
||||
WAITING {
|
||||
override fun signal() = ProtocolState.TALKING
|
||||
}
|
||||
|
||||
TALKING {
|
||||
override fun signal() = ProtocolState.WAITING
|
||||
}
|
||||
|
||||
abstract fun signal() : ProtocolState
|
||||
}
|
||||
|
||||
enum class Foo<T> {
|
||||
<!NO_GENERICS_IN_SUPERTYPE_SPECIFIER!>X<!>
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun box() {
|
||||
val x: ProtocolState = ProtocolState.WAITING
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import java.util.Collections
|
||||
import java.util.List
|
||||
|
||||
val ab = Collections.emptyList<Int>() : List<Int>?
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user