separate compiler and plugin tests
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
~A~class A {
|
||||
~B~class B {
|
||||
~B()~this() {}
|
||||
}
|
||||
|
||||
~foo~fun foo(~foo.a~a : `std::Char`Char) = `foo.a`a`:std::Char`
|
||||
~fooB~fun fooB() = `foo`foo('1')`:std::Char`
|
||||
~foo.1~fun foo() : Int = (1.`std::Int.plus(Int)`plus(1))`:std::Int`
|
||||
~foo1~fun foo1() : `B`B = `B()`B()`:B`
|
||||
~A.a~val a : `std::Int`Int
|
||||
}
|
||||
|
||||
~C~class C : `A`A {
|
||||
~C.B~class B : `C`C {
|
||||
|
||||
}
|
||||
|
||||
val x : `C.B`B
|
||||
}
|
||||
|
||||
fun test() : Unit {
|
||||
for (~i~i in 1..2) {
|
||||
`i`i`:std::Int`
|
||||
}
|
||||
for (val ~j~j in 1..2) {
|
||||
`j`j`:std::Int`
|
||||
}
|
||||
for (val ~k~k : Int in 1..2) {
|
||||
`k`k`:std::Int`
|
||||
}
|
||||
for (~l~l : Int in 1..2) {
|
||||
`l`l`:std::Int`
|
||||
while (true) {
|
||||
`l`l
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Jet86
|
||||
|
||||
~A~class A {
|
||||
class object {
|
||||
~A.x~val x = 1
|
||||
}
|
||||
}
|
||||
|
||||
~B~class B() {
|
||||
~B.x~val x = 12
|
||||
}
|
||||
|
||||
val a = `A`A.`A.x`x
|
||||
val c = `B`B.`!error`x
|
||||
val d = B().`B.x`x
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace qualified_this {
|
||||
~qtA~class A(val a:Int) {
|
||||
|
||||
~qtB~class B() {
|
||||
val x = `qtB`this`qtB`@B
|
||||
val y = `qtA`this`qtA`@A
|
||||
val z = `qtB`this
|
||||
~xx~val Int.xx = `xx`this : Int
|
||||
~xx()~fun Int.xx() {
|
||||
`xx()`this : Int
|
||||
val a = {Int.() => `xx()`this`xx()`@xx + this}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class A<~T~T, ~E~E> {
|
||||
val a : `T`T
|
||||
val x : A<`T`T, `E`E>
|
||||
|
||||
class X<~X.T~T> : A<`X.T`T, `E`E> {
|
||||
val a : `X.T`T
|
||||
val b : `X.E`E
|
||||
|
||||
~X.E~class E {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
class Z(a : Int) {
|
||||
~c1~this() : `c2`this(1, true) {}
|
||||
|
||||
~c2~this(x : Int, y : Boolean) : `c1`this() {}
|
||||
}
|
||||
|
||||
~Z1.c()~class Z1() : Z {
|
||||
|
||||
this(x : Int, y : Boolean) : `Z1.c()`this() {}
|
||||
}
|
||||
|
||||
class Foo
|
||||
@@ -0,0 +1,3 @@
|
||||
class C(x : `std::Int`Int) : NotFound {
|
||||
val xx : `std::Int`Int
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
fun <~T~T, ~E~E> `T`T.foo(x : `E`E, y : `A`A) : `T`T {
|
||||
y.`+`plus(1)
|
||||
y `+`plus 1
|
||||
y `+1`+ 1.0
|
||||
|
||||
this?.`-`minus<T>(this)
|
||||
|
||||
this
|
||||
}
|
||||
|
||||
~A~class A
|
||||
|
||||
~+1~fun `A`A.plus(a : Any) {
|
||||
|
||||
1.`foo`foo()
|
||||
true.`!null`foo()
|
||||
|
||||
1
|
||||
}
|
||||
|
||||
~+~fun `A`A.plus(a : Int) {
|
||||
1
|
||||
}
|
||||
|
||||
~-~fun <T> T.minus(t : T) : Int = 1
|
||||
|
||||
fun test() {
|
||||
val y = 1.`abs`abs
|
||||
}
|
||||
~abs~val Int.abs : Int
|
||||
get() = if (this`:std::Int` > 0) this else -this`:std::Int`;
|
||||
|
||||
val <~TT~T> `TT`T.foo : `TT`T
|
||||
|
||||
~foo~fun Int.foo() = this`:std::Int`
|
||||
@@ -0,0 +1,3 @@
|
||||
fun invoker(~gen~gen : fun () : Int) : Int {
|
||||
return `gen`gen() // Says it cannot resolve 'gen' here
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace localObjects {
|
||||
object ~A~A {
|
||||
~x~val x : Int
|
||||
}
|
||||
|
||||
class Foo {
|
||||
~foo()~fun foo() : Int
|
||||
}
|
||||
|
||||
fun test() {
|
||||
`A`A.`x`x
|
||||
val b = object : Foo {
|
||||
}
|
||||
b.`foo()`foo()
|
||||
|
||||
object ~B~B {
|
||||
~B.foo()~fun foo() {}
|
||||
}
|
||||
`B`B.`B.foo()`foo()
|
||||
}
|
||||
|
||||
val bb = `!`B.foo()
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace root
|
||||
|
||||
~a~namespace a {
|
||||
import java.*
|
||||
|
||||
~a.a~val a : util.List<Int>? = null
|
||||
|
||||
val y : Any? = `a.b`b
|
||||
|
||||
}
|
||||
|
||||
namespace a {
|
||||
import java.util.*
|
||||
|
||||
~a.b~val b : List<Int>? = null
|
||||
|
||||
val x = `a.a`a
|
||||
}
|
||||
|
||||
val x = `a`a.`a.a`a
|
||||
|
||||
val y = `a`a.`a.b`b
|
||||
@@ -0,0 +1,28 @@
|
||||
~ns~namespace nestedObjects {
|
||||
object ~A~A {
|
||||
val b = `A.B`B
|
||||
val d = `A`A.`A.B`B.`A.B.A`A
|
||||
|
||||
object ~A.B~B {
|
||||
val a = `A.B.A`A
|
||||
val e = `A.B`B.`A.B.A`A
|
||||
|
||||
object ~A.B.A~A {
|
||||
val a = `A.B.A`A
|
||||
val b = `A.B`B
|
||||
val x = `ns`nestedObjects.`A`A.`A.B`B.`A.B.A`A
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
object ~B~B {
|
||||
val b = `B`B
|
||||
val c = `A`A.`A.B`B
|
||||
}
|
||||
|
||||
val a = `A`A
|
||||
val b = `B`B
|
||||
val c = `A`A.`A.B`B
|
||||
val d = A.B.`A.B.A`A
|
||||
val e = B.`!`A.B
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace toplevelObjectDeclarations {
|
||||
class Foo(y : Int) {
|
||||
~foo()~open fun foo() : Int = 1
|
||||
}
|
||||
|
||||
object ~A~A : Foo(0) {
|
||||
~x~val x : Int = 2
|
||||
|
||||
fun test() {
|
||||
return `x`x + `foo()`foo()
|
||||
}
|
||||
}
|
||||
|
||||
object B : `!`A {}
|
||||
|
||||
~ns.x~val x = `A`A.`foo()`foo()
|
||||
|
||||
~y~val y = object : Foo(`ns.x`x) {
|
||||
{
|
||||
`ns.x`x + 12
|
||||
}
|
||||
|
||||
~y.foo()~override fun foo() : Int = 1
|
||||
}
|
||||
|
||||
val z = `y`y.`y.foo()`foo()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
class C(~x~x : Int, ~y~val y : Int) : Base(`x`x /*parameter*/), Base1 by Base1(`x`x) {
|
||||
var z = `x`x // parameter
|
||||
get() = `$x`x // property
|
||||
|
||||
{
|
||||
val z = `x`x // parameter
|
||||
}
|
||||
|
||||
val foo = `$y`y
|
||||
|
||||
this() : this(1, 2) {
|
||||
val z = x // inaccessible
|
||||
val zz = `$y`y // property
|
||||
}
|
||||
|
||||
fun f() : Int {
|
||||
return `$x`x // property
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
class A(~a~val a : Int) {
|
||||
this() {`$a`a}
|
||||
~b~val b = `$a`a
|
||||
~f~fun f() = `$a`a
|
||||
}
|
||||
|
||||
fun test() {
|
||||
~va~val a = A()
|
||||
`va`a.`$a`a`:std::Int`
|
||||
a.`b`b`:std::Int`
|
||||
a.`f`f()`:std::Int`
|
||||
}
|
||||
|
||||
namespace Jet65 {
|
||||
|
||||
class Foo(~bar~var bar : Int, ~barr~barr : Int, ~barrr~val barrr : Int) {
|
||||
{
|
||||
`$bar`bar = 1
|
||||
`barr`barr = 1
|
||||
`$barrr`barrr = 1
|
||||
}
|
||||
|
||||
this(~s.bar~val bar : Int) : this(1, 1, 1) {
|
||||
`s.bar`bar = 1
|
||||
this.`$bar`bar
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
class In<in T>() {
|
||||
~In.f:T->Unit~fun f(t : T) : Unit {}
|
||||
~In.f:Int->Int~fun f(t : Int) : Int {}
|
||||
~In.f1~fun f1(t : T) : Unit {}
|
||||
}
|
||||
|
||||
class Out<out T>() {
|
||||
~Out.f~fun f() : T {}
|
||||
~Out.f(a)~fun f(a : Int) : Int {a}
|
||||
}
|
||||
|
||||
class Inv<T>() {
|
||||
~Inv.f~fun f(t : T) : T {t}
|
||||
~Inv.inf~fun inf(t : T) : Unit {}
|
||||
~Inv.outf~fun outf() : T {}
|
||||
}
|
||||
|
||||
fun testInOut() {
|
||||
In<String>().`In.f:T->Unit`f("1");
|
||||
(return : In<in String>).`In.f:T->Unit`f("1");
|
||||
(return : In<out String>).`In.f:Int->Int`f("1")
|
||||
(return : In<*>).`In.f:Int->Int`f("1");
|
||||
|
||||
In<String>().`In.f:Int->Int`f(1);
|
||||
(return : In<in String>).`In.f:Int->Int`f(1);
|
||||
(return : In<out String>).`In.f:Int->Int`f(1)
|
||||
(return : In<out String>).`!`f1(1)
|
||||
(return : In<*>).`In.f:Int->Int`f(1);
|
||||
|
||||
Out<Int>().`Out.f(a)`f(1)
|
||||
(return : Out<out Int>).`Out.f(a)`f(1)
|
||||
(return : Out<in Int>).`Out.f(a)`f(1)
|
||||
(return : Out<*>).`Out.f(a)`f(1)
|
||||
|
||||
Out<Int>().`Out.f`f()
|
||||
(return : Out<out Int>).`Out.f`f()
|
||||
(return : Out<in Int>).`Out.f`f()
|
||||
(return : Out<*>).`Out.f`f()
|
||||
|
||||
Inv<Int>().`Inv.f`f(1)
|
||||
(return : Inv<in Int>).`Inv.f`f(1)
|
||||
(return : Inv<out Int>).`!`f(1)
|
||||
(return : Inv<*>).`!`f(1)
|
||||
|
||||
Inv<Int>().`Inv.inf`inf(1)
|
||||
(return : Inv<in Int>).`Inv.inf`inf(1)
|
||||
(return : Inv<out Int>).`!`inf(1)
|
||||
(return : Inv<*>).`!`inf(1)
|
||||
|
||||
Inv<Int>().`Inv.outf`outf()
|
||||
((return : Inv<in Int>).`Inv.outf`outf())`:std::Any`
|
||||
(return : Inv<out Int>).`Inv.outf`outf()
|
||||
(return : Inv<*>).`Inv.outf`outf()
|
||||
|
||||
Inv<Int>().`Inv.outf`outf(1)
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
import java.*
|
||||
import util.*
|
||||
|
||||
fun f_plus(): Int {
|
||||
var x: Int = 1
|
||||
x = x `std::Int.plus(Int)`+ 1
|
||||
return x
|
||||
}
|
||||
|
||||
~X~class X<~T~T> {
|
||||
~X()~this() {}
|
||||
fun foo(a : `T`T) : `X`X<`T`T>{}
|
||||
~plus~fun plus(t : `T`T) : Int {}
|
||||
~minus~fun minus(t : String) : Int {}
|
||||
~times~fun times(t : String) : Int {}
|
||||
~div~fun div(t : String) : Int {}
|
||||
~mod~fun mod(t : String) : Int {}
|
||||
~rangeTo~fun rangeTo(t : String) : Int {}
|
||||
~==~fun equals(a : Any?) : Boolean {}
|
||||
~contains~fun contains(a : Any?) : Boolean {}
|
||||
}
|
||||
|
||||
~t~fun <~t.T~T> t(~t.t~t : `t.T`T) : `t.T`T {
|
||||
`t`t<Int>(1)`:std::Int`
|
||||
`t`t<`t.T`T>(`t.t`t)`:t.T`
|
||||
`X()`X<`t.T`T>()
|
||||
1 `std::Int.plus(Int)`+ 1
|
||||
1 `std::Int.plus(Int)`+= 1
|
||||
X<String>() `plus`+ "1"
|
||||
X<String>() `plus`plus "sadfas"
|
||||
X<String>().`plus`plus("")
|
||||
val x = X<String>()
|
||||
x `minus`- ""
|
||||
x `times`* ""
|
||||
x `div`/ ""
|
||||
x `mod`% ""
|
||||
x `rangeTo`.. ""
|
||||
x `==`== ""
|
||||
x `==`!= 1
|
||||
1 `contains`in x
|
||||
1 `contains`!in x
|
||||
}
|
||||
|
||||
~Foo~class Foo {
|
||||
~set1~fun set(i : Int, val1 : String) {}
|
||||
~get1~fun get(i : Int) : Int {}
|
||||
~get2~fun get(i : Int, j : Int) : String {}
|
||||
~get3~fun get(i : Object) : Any {return i }
|
||||
~+=~fun plusAssign(a : Any?) : Unit {}
|
||||
}
|
||||
|
||||
~Bar~class Bar : Foo {
|
||||
~Bar()~this() {}
|
||||
~not~fun not() : String {}
|
||||
~inc~fun inc() : Bar
|
||||
~dec~fun dec() : Bar
|
||||
~-~fun minus() : Bar
|
||||
~+~fun plus() : Bar
|
||||
}
|
||||
|
||||
fun <T> tt(t : T) : T {
|
||||
val x : List<Int> = 0
|
||||
x`java::java.util.List.get()`[1]
|
||||
val foo = `Bar()`Bar()
|
||||
foo`!!`[null, 1]
|
||||
foo`get2`[1, 1]
|
||||
foo`get1`[1]
|
||||
foo`set1`[1] = ""
|
||||
foo`set1`[1, 2] = ""
|
||||
x`java::java.util.List.set()`[1] = null
|
||||
(x`java::java.util.List.set()`[1]) = null
|
||||
x`java::java.util.List.set()`[null] = null
|
||||
(x`java::java.util.List.set()`[null, 2]) = null
|
||||
(`not`!foo)[1]`:std::Char`
|
||||
val y = Bar()
|
||||
y`inc`++
|
||||
`inc`++y
|
||||
`dec`--y
|
||||
y`dec`--
|
||||
y `+=`+= 1
|
||||
`+`+y
|
||||
`-`-y
|
||||
1 `std::Int.compareTo(Double)`> 2.0
|
||||
1 `std::Int.compareTo(Double)`< 2.0
|
||||
1 `std::Int.compareTo(Double)`>= 2.0
|
||||
1 `std::Int.compareTo(Double)`<= 2.0
|
||||
}
|
||||
|
||||
|
||||
class UnitIncDec() {
|
||||
~uinc~fun inc() : Unit
|
||||
~udec~fun dec() : Unit
|
||||
}
|
||||
|
||||
fun testUnitIncDec() {
|
||||
var x = UnitIncDec()
|
||||
x`uinc`++
|
||||
x`udec`--
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import `java::java`java.*
|
||||
import `java::java.util`util.*
|
||||
|
||||
fun foo(~a~a : `std::Array`Array<`std::Int`Int>) : `java::java.util.List`List {
|
||||
`a`a.`std::Array.get(Int)`get(1)
|
||||
`a`a.`std::Array.set(Int, Int)`set(1, 1)
|
||||
}
|
||||
|
||||
fun foo(o : `java::java.lang.Object`Object, l : `java::java.util`util.`java::java.util.List`List) : `java::java.util.List`List {}
|
||||
|
||||
~A~class A() {
|
||||
fun f(a : `java::java.util`util.`java::java.util.List`List) {}
|
||||
fun f(a : `java::java.util.List`List) {}
|
||||
|
||||
}
|
||||
|
||||
class B : `java::java.lang.Object`Object {
|
||||
fun bar(~o~o : `java::java.lang.Object`Object) {
|
||||
`java::java.lang.System`System.`java::java.lang.System.out`out.`java::java.io.PrintStream.print(Object)`print(`o`o)`:std::Unit`
|
||||
}
|
||||
|
||||
fun f(a : `java::java.util`util.`java::java.util.List`List) {}
|
||||
fun f(a : `java::java.util.List`List) {}
|
||||
|
||||
|
||||
~foo~fun foo(abc : `A`A) : `A`A {
|
||||
`java::java`java.`java::java.lang`lang.`java::java.lang.System`System.`java::java.lang.System.out`out.`java::java.io.PrintStream.print(Int)`print(1)
|
||||
`java::java.util`util.`java::java.util.Collections`Collections.`java::java.util.Collections.emptyList()`emptyList()
|
||||
`java::java`java.`!`Foo
|
||||
`java::java.util.Collections`Collections.`java::java.util.Collections.emptyList()`emptyList()
|
||||
}
|
||||
|
||||
fun barrr() : `std::Int`Int {
|
||||
`foo`foo(`A`A())
|
||||
}
|
||||
}
|
||||
|
||||
~c~fun c(~x~x : java.lang.`java::java.lang.Number`Number) {
|
||||
`x`x.`java::java.lang.Number.intValue()`intValue()
|
||||
}
|
||||
|
||||
fun <T> t(t : T) : T {
|
||||
`c`c(java.lang.Integer(1))
|
||||
System.out.`java::java.io.PrintStream.print(Object)`print(t)
|
||||
System.out.`java::java.io.PrintStream.print(char[])`print(null : CharArray?)
|
||||
System.out.`java::java.io.PrintStream.print(Object)`print(null : Object?)
|
||||
System.out.`java::java.io.PrintStream.print(Int)`print(1)
|
||||
System.out.`java::java.io.PrintStream.print(Double)`print(1.0)
|
||||
}
|
||||
|
||||
fun typeTransform() {
|
||||
Integer.getInteger("", 239)`:std::Int`
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
var xxxx = 1
|
||||
|
||||
~SimpleClass~class SimpleClass(x : Int) {
|
||||
fun foo() = x
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
`SimpleClass`SimpleClass(1).`!`xxxx
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
fun demo() {
|
||||
~abc~val abc = 1
|
||||
~a~val a = ""
|
||||
~asd~val asd = 1
|
||||
~bar~val bar = 5
|
||||
~map~fun map(f : fun () : Any?) : Int = 1
|
||||
~buzz~fun buzz(f : fun () : Any?) : Int = 1
|
||||
~sdf~val sdf = 1
|
||||
~foo~val foo = 3;
|
||||
"$`abc`abc"
|
||||
"$"
|
||||
"$.$.asdf$\t"
|
||||
"asd\$"
|
||||
"asd$`a`a"
|
||||
"asd$`a`a$`asd`asd$"
|
||||
"fosdfasdo${1 + `bar`bar + 100}}sdsdfgdsfsdf"
|
||||
"foo${`bar`bar + `map`map {`foo`foo}}sdfsdf"
|
||||
"foo${`bar`bar + `map`map { "foo" }}sdfsdf"
|
||||
"foo${`bar`bar + `map`map {
|
||||
"foo$`sdf`sdf${ `buzz`buzz{}}" }}sdfsdf"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
fun test() {
|
||||
~x~val x = 1
|
||||
try {
|
||||
~y~val y = `x`x
|
||||
}
|
||||
catch (~e1~e : Exception) {
|
||||
val z = `e1`e
|
||||
val zz = `!`y
|
||||
val zzz = `x`x
|
||||
}
|
||||
catch (~e2~e : Exception) {
|
||||
val z = `e2`e
|
||||
val zz = `!`y
|
||||
val zzz = `x`x
|
||||
}
|
||||
finally {
|
||||
val z = `!`e
|
||||
val zz = `!`y
|
||||
val zzz = `x`x
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// KT-300 Overload ambiguity while accessing range
|
||||
|
||||
class MyRange() : Range<Int> {
|
||||
~in~override fun contains(item: Int) = true
|
||||
}
|
||||
|
||||
fun foo(x: Int?, range: MyRange) {
|
||||
x `in`in range // Int? found, but Int expected
|
||||
}
|
||||
Reference in New Issue
Block a user