partial support for 'abstract' modifier added

This commit is contained in:
svtk
2011-09-06 14:57:42 +04:00
41 changed files with 354 additions and 113 deletions
+50
View File
@@ -0,0 +1,50 @@
namespace abstract
class A1() {
fun <error>foo</error>(): Int
<error>abstract</error> fun f(): Int
}
abstract class A2() {
abstract fun f(): Int
}
class A3() {
val <error>i</error>: Int
val <error>j</error>: Int?
var <error>k</error>: String
var <error>l</error>: Int?
}
class <error>A4</error> {
val <error>i</error>: Int?
}
class <error>A5</error> {
var <error>i</error>: Int?
}
class A6 {
<error>abstract</error> val i: Int
}
abstract class A7 {
abstract val i: Int //ok
}
class A8() {
val i = 11
}
class A9() {
<error>abstract</error> val i = 23
}
abstract class <error>A10</error> {
val <error>i</error>: Int
}
<error>abstract</error> val i: Int
<error>abstract</error> fun foo(): fun(Int): Int
val <error>j</error>: Int
fun <error>foo1</error>(): fun(Int): Int
@@ -1,13 +1,13 @@
class A() {
fun equals(a : Any?) : Boolean
abstract class A() {
abstract fun equals(a : Any?) : Boolean
}
class B() {
fun equals(a : Any?) : Boolean?
abstract class B() {
abstract fun equals(a : Any?) : Boolean?
}
class C() {
fun equals(a : Any?) : Int
abstract class C() {
abstract fun equals(a : Any?) : Int
}
fun f(): Unit {
+2 -2
View File
@@ -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>>
}
+1 -1
View File
@@ -3,7 +3,7 @@ import java.util.*
namespace html {
abstract class Factory<T> {
fun create() : T
abstract fun create() : T
}
abstract class Element
+8 -8
View File
@@ -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)
@@ -33,21 +33,21 @@ 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
namespace null_safety {
fun parse(cmd: String): Command? { return null }
class Command() {
abstract class Command() {
// fun equals(other : Any?) : Boolean
val foo : Int
abstract val foo : Int
}
fun Any.equals(other : Any?) : Boolean
fun Any?.equals1(other : Any?) : Boolean
fun Any.equals2(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>) {
+31 -31
View File
@@ -4,65 +4,65 @@ 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() {
@@ -1,4 +1,4 @@
fun none()
fun none() {}
fun unitEmptyInfer() {}
fun unitEmpty() : Unit {}
+3 -3
View File
@@ -1,11 +1,11 @@
namespace Jet87
open class A() {
fun foo() : Int
fun foo() : Int = 1
}
open class B() {
fun bar() : Double;
fun bar() : Double = 1.0;
}
class C() : A(), B()
@@ -69,4 +69,4 @@ class Test<<error>T</error>>
class object T : <error>Foo</error>,
class object T : A {}
val <T, B : T> x : Int
val <T, B : T> x : Int = 0
+15 -8
View File
@@ -8,8 +8,8 @@ namespace a {
}
class Foo<T>() {
val x : T<Int>
abstract class Foo<T>() {
abstract val x : T<Int>
}
namespace a {
@@ -26,22 +26,29 @@ 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 val 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> {
+2 -2
View File
@@ -60,11 +60,11 @@ namespace nestedObejcts {
namespace localObjects {
object A {
val x : Int
val x : Int = 0
}
class Foo {
fun foo() : Int
fun foo() : Int = 1
}
fun test() {
@@ -1,9 +1,9 @@
class <error>X</error> {
val x : Int
val <error>x</error> : Int
}
class Y() {
val x : Int
val x : Int = 2
}
class Y1 {
+1 -1
View File
@@ -13,7 +13,7 @@
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() {
+1 -1
View File
@@ -1,6 +1,6 @@
namespace redeclarations {
object <error>A</error> {
val x : Int
val x : Int = 0
val A = 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,29 +15,30 @@ 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>
var <error>v9</error> : Int <info>abstract</info> <info>set</info>
var <error>v10</error> : Int <info>abstract</info> <info>get</info>
}
@@ -3,10 +3,10 @@
namespace x
val b : Foo
val b : Foo = Foo()
val a1 = b.compareTo(2)
class Foo() {
fun compareTo(other : Byte) : Int
fun compareTo(other : Char) : Int
fun compareTo(other : Byte) : Int = 0
fun compareTo(other : Char) : Int = 0
}
+1 -1
View File
@@ -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 -1
View File
@@ -1,4 +1,4 @@
enum class ProtocolState {
abstract enum class ProtocolState {
WAITING {
override fun signal() = ProtocolState.TALKING
}
+2 -2
View File
@@ -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>
@@ -4,13 +4,13 @@ fun box() {
}
open class A {
fun foo()
fun foo() {}
}
open class B : A {
fun foo()
fun foo() {}
}
open class C : B {
fun foo()
fun foo() {}
}
@@ -1,4 +1,4 @@
fun Any.equals(other : Any?) : Boolean
fun Any.equals(other : Any?) : Boolean = true
fun main(args: Array<String>) {