open modifier for functions added

This commit is contained in:
Sergey Ignatov
2011-11-07 19:35:49 +04:00
parent fd7fde1058
commit 12b03042ea
47 changed files with 91 additions and 55 deletions
@@ -57,6 +57,9 @@ public class Function extends Member {
if (myModifiers.contains(Modifier.OVERRIDE)) if (myModifiers.contains(Modifier.OVERRIDE))
modifierList.add(Modifier.OVERRIDE); modifierList.add(Modifier.OVERRIDE);
if (!myModifiers.contains(Modifier.OVERRIDE) && !myModifiers.contains(Modifier.FINAL))
modifierList.add(Modifier.OPEN);
modifierList.add(accessModifier()); modifierList.add(accessModifier());
if (modifierList.size() > 0) if (modifierList.size() > 0)
@@ -123,7 +123,7 @@ public class JavaToKotlinConverterTest extends LightDaemonAnalyzerTestCase {
protected String statementToKotlin(String text) throws Exception { protected String statementToKotlin(String text) throws Exception {
String result = methodToKotlin("void main() {" + text + "}"); String result = methodToKotlin("void main() {" + text + "}");
int pos = result.lastIndexOf("}"); int pos = result.lastIndexOf("}");
result = result.substring(0, pos).replaceFirst("fun main\\(\\) : Unit \\{", ""); result = result.substring(0, pos).replaceFirst("open fun main\\(\\) : Unit \\{", "");
return prettify(result); return prettify(result);
} }
@@ -1,2 +1,2 @@
fun fromArrayToCollection(a : Array<Foo?>?) : Unit { open fun fromArrayToCollection(a : Array<Foo?>?) : Unit {
} }
@@ -5,7 +5,7 @@ val ourOut : PrintStream?
} }
} }
open class User { open class User {
fun main() : Unit { open fun main() : Unit {
Library.ourOut?.print() Library.ourOut?.print()
} }
} }
@@ -1,15 +1,15 @@
namespace { namespace {
open class Library { open class Library {
class object { class object {
fun call() : Unit { open fun call() : Unit {
} }
fun getString() : String? { open fun getString() : String? {
return "" return ""
} }
} }
} }
open class User { open class User {
fun main() : Unit { open fun main() : Unit {
Library.call() Library.call()
Library.getString()?.isEmpty() Library.getString()?.isEmpty()
} }
@@ -1,13 +1,13 @@
namespace { namespace {
open class Library { open class Library {
fun call() : Unit { open fun call() : Unit {
} }
fun getString() : String? { open fun getString() : String? {
return "" return ""
} }
} }
open class User { open class User {
fun main() : Unit { open fun main() : Unit {
var lib : Library? = Library() var lib : Library? = Library()
lib?.call() lib?.call()
lib?.getString()?.isEmpty() lib?.getString()?.isEmpty()
@@ -3,7 +3,7 @@ open class Library {
public val myString : String? public val myString : String?
} }
open class User { open class User {
fun main() : Unit { open fun main() : Unit {
Library.myString?.isEmpty() Library.myString?.isEmpty()
} }
} }
+2 -2
View File
@@ -1,6 +1,6 @@
abstract open class A { abstract open class A {
abstract fun callme() : Unit abstract open fun callme() : Unit
fun callmetoo() : Unit { open fun callmetoo() : Unit {
print("This is a concrete method.") print("This is a concrete method.")
} }
} }
@@ -1,10 +1,10 @@
abstract open class Shape { abstract open class Shape {
public var color : String? public var color : String?
public fun setColor(c : String?) : Unit { open public fun setColor(c : String?) : Unit {
color = c color = c
} }
public fun getColor() : String? { open public fun getColor() : String? {
return color return color
} }
abstract public fun area() : Double abstract open public fun area() : Double
} }
@@ -1,8 +1,8 @@
class T { class T {
fun main() : Unit { open fun main() : Unit {
} }
fun i() : Int { open fun i() : Int {
} }
fun s() : String? { open fun s() : String? {
} }
} }
@@ -2,7 +2,7 @@ class S {
class object { class object {
var myI : Int = 10 var myI : Int = 10
} }
fun sB() : Boolean { open fun sB() : Boolean {
return true return true
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
class S { class S {
class object { class object {
fun staticF() : Boolean { open fun staticF() : Boolean {
return true return true
} }
} }
@@ -1,10 +1,10 @@
class S { class S {
class object { class object {
fun sI() : Int { open fun sI() : Int {
return 1 return 1
} }
} }
fun sB() : Boolean { open fun sB() : Boolean {
return true return true
} }
} }
+2 -2
View File
@@ -1,9 +1,9 @@
class S { class S {
class object { class object {
fun sB() : Boolean { open fun sB() : Boolean {
return true return true
} }
fun sI() : Int { open fun sI() : Int {
return 1 return 1
} }
} }
@@ -5,10 +5,10 @@ RED(23)
YELLOW(24) YELLOW(24)
BLUE(25) BLUE(25)
private var code : Int private var code : Int
private (c : Int) { open private (c : Int) {
code = c code = c
} }
public fun getCode() : Int { open public fun getCode() : Int {
return code return code
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
namespace { namespace {
open class A { open class A {
fun a() : Unit { open fun a() : Unit {
} }
} }
class B : A { class B : A {
@@ -0,0 +1,11 @@
class A {
void foo() {}
}
class B extends A {
void foo() {}
}
class C extends B {
void foo() {}
}
@@ -0,0 +1,14 @@
namespace {
open class A {
open fun foo() : Unit {
}
}
open class B : A {
override fun foo() : Unit {
}
}
open class C : B {
override fun foo() : Unit {
}
}
}
@@ -1 +1 @@
abstract fun getNoofGears() : Int abstract open fun getNoofGears() : Int
@@ -1,2 +1,2 @@
fun getT() : T? { open fun getT() : T? {
} }
@@ -1,2 +1,2 @@
fun main() : Unit { open fun main() : Unit {
} }
+1
View File
@@ -0,0 +1 @@
final String getString() { return ""; }
+3
View File
@@ -0,0 +1,3 @@
fun getString() : String? {
return ""
}
+1 -1
View File
@@ -1,2 +1,2 @@
fun test() : Unit { open fun test() : Unit {
} }
@@ -1,2 +1,2 @@
fun main() : String? { open fun main() : String? {
} }
@@ -1,2 +1,2 @@
fun main() : Int { open fun main() : Int {
} }
@@ -1,2 +1,2 @@
fun main() : Boolean { open fun main() : Boolean {
} }
@@ -1,3 +1,3 @@
fun isTrue() : Boolean { open fun isTrue() : Boolean {
return true return true
} }
+1
View File
@@ -0,0 +1 @@
String getString() { return ""; }
+3
View File
@@ -0,0 +1,3 @@
open fun getString() : String? {
return ""
}
@@ -1,2 +1,2 @@
fun putU<U>(u : U?) : Unit { open fun putU<U>(u : U?) : Unit {
} }
@@ -1,2 +1,2 @@
fun putUVW<U, V, W>(u : U?, v : V?, w : W?) : Unit { open fun putUVW<U, V, W>(u : U?, v : V?, w : W?) : Unit {
} }
+1 -1
View File
@@ -1,2 +1,2 @@
private fun test() : Unit { open private fun test() : Unit {
} }
+1 -1
View File
@@ -1,2 +1,2 @@
protected fun test() : Unit { open protected fun test() : Unit {
} }
+1 -1
View File
@@ -1,2 +1,2 @@
public fun test() : Unit { open public fun test() : Unit {
} }
@@ -1,2 +1,2 @@
fun popAll(dst : Collection<in E?>?) : Unit { open fun popAll(dst : Collection<in E?>?) : Unit {
} }
@@ -2,7 +2,7 @@ namespace org.test {
open class Library { open class Library {
} }
open class User { open class User {
fun main() : Unit { open fun main() : Unit {
var lib : Library? = org.test.Library() var lib : Library? = org.test.Library()
} }
} }
@@ -1,2 +1,2 @@
fun pushAll(src : Collection<out E?>?) : Unit { open fun pushAll(src : Collection<out E?>?) : Unit {
} }
@@ -1,2 +1,2 @@
fun wtf(w : Collection<*>?) : Unit { open fun wtf(w : Collection<*>?) : Unit {
} }
@@ -1,5 +1,5 @@
open class B { open class B {
fun call() : Unit { open fun call() : Unit {
} }
} }
open class A : B { open class A : B {
@@ -1,10 +1,10 @@
namespace { namespace {
open class Base { open class Base {
fun foo() : Unit open fun foo() : Unit
} }
open class A : Base { open class A : Base {
open class C { open class C {
fun test() : Unit { open fun test() : Unit {
super@A.foo() super@A.foo()
} }
} }
@@ -1,11 +1,11 @@
namespace { namespace {
open class Base { open class Base {
fun foo() : Unit { open fun foo() : Unit {
} }
} }
open class A : Base { open class A : Base {
open class C { open class C {
fun test() : Unit { open fun test() : Unit {
this@A.foo() this@A.foo()
} }
} }
@@ -1,4 +1,4 @@
trait INode { trait INode {
fun getTag() : Tag? open fun getTag() : Tag?
fun toKotlin() : String? open fun toKotlin() : String?
} }
@@ -1,2 +1,2 @@
fun max<T : Any?, K : Node?>(coll : Collection<out T?>?) : T? where T : Comparable<in T?>?, K : Collection<in K?>? { open fun max<T : Any?, K : Node?>(coll : Collection<out T?>?) : T? where T : Comparable<in T?>?, K : Collection<in K?>? {
} }
+1 -1
View File
@@ -1,2 +1,2 @@
fun max<T : Any?>(coll : Collection<out T?>?) : T? where T : Comparable<in T?>? { open fun max<T : Any?>(coll : Collection<out T?>?) : T? where T : Comparable<in T?>? {
} }
@@ -1 +1 @@
fun format(pattern : String?, vararg arguments : Any?) : String? open fun format(pattern : String?, vararg arguments : Any?) : String?
@@ -1,2 +1,2 @@
fun pushAll(vararg objs : Any?) : Unit { open fun pushAll(vararg objs : Any?) : Unit {
} }