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))
modifierList.add(Modifier.OVERRIDE);
if (!myModifiers.contains(Modifier.OVERRIDE) && !myModifiers.contains(Modifier.FINAL))
modifierList.add(Modifier.OPEN);
modifierList.add(accessModifier());
if (modifierList.size() > 0)
@@ -123,7 +123,7 @@ public class JavaToKotlinConverterTest extends LightDaemonAnalyzerTestCase {
protected String statementToKotlin(String text) throws Exception {
String result = methodToKotlin("void main() {" + text + "}");
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);
}
@@ -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 {
fun main() : Unit {
open fun main() : Unit {
Library.ourOut?.print()
}
}
@@ -1,15 +1,15 @@
namespace {
open class Library {
class object {
fun call() : Unit {
open fun call() : Unit {
}
fun getString() : String? {
open fun getString() : String? {
return ""
}
}
}
open class User {
fun main() : Unit {
open fun main() : Unit {
Library.call()
Library.getString()?.isEmpty()
}
@@ -1,13 +1,13 @@
namespace {
open class Library {
fun call() : Unit {
open fun call() : Unit {
}
fun getString() : String? {
open fun getString() : String? {
return ""
}
}
open class User {
fun main() : Unit {
open fun main() : Unit {
var lib : Library? = Library()
lib?.call()
lib?.getString()?.isEmpty()
@@ -3,7 +3,7 @@ open class Library {
public val myString : String?
}
open class User {
fun main() : Unit {
open fun main() : Unit {
Library.myString?.isEmpty()
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
abstract open class A {
abstract fun callme() : Unit
fun callmetoo() : Unit {
abstract open fun callme() : Unit
open fun callmetoo() : Unit {
print("This is a concrete method.")
}
}
@@ -1,10 +1,10 @@
abstract open class Shape {
public var color : String?
public fun setColor(c : String?) : Unit {
open public fun setColor(c : String?) : Unit {
color = c
}
public fun getColor() : String? {
open public fun getColor() : String? {
return color
}
abstract public fun area() : Double
abstract open public fun area() : Double
}
@@ -1,8 +1,8 @@
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 {
var myI : Int = 10
}
fun sB() : Boolean {
open fun sB() : Boolean {
return true
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
class S {
class object {
fun staticF() : Boolean {
open fun staticF() : Boolean {
return true
}
}
@@ -1,10 +1,10 @@
class S {
class object {
fun sI() : Int {
open fun sI() : Int {
return 1
}
}
fun sB() : Boolean {
open fun sB() : Boolean {
return true
}
}
+2 -2
View File
@@ -1,9 +1,9 @@
class S {
class object {
fun sB() : Boolean {
open fun sB() : Boolean {
return true
}
fun sI() : Int {
open fun sI() : Int {
return 1
}
}
@@ -5,10 +5,10 @@ RED(23)
YELLOW(24)
BLUE(25)
private var code : Int
private (c : Int) {
open private (c : Int) {
code = c
}
public fun getCode() : Int {
open public fun getCode() : Int {
return code
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
namespace {
open class A {
fun a() : Unit {
open fun a() : Unit {
}
}
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
}
+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 User {
fun main() : Unit {
open fun main() : Unit {
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 {
fun call() : Unit {
open fun call() : Unit {
}
}
open class A : B {
@@ -1,10 +1,10 @@
namespace {
open class Base {
fun foo() : Unit
open fun foo() : Unit
}
open class A : Base {
open class C {
fun test() : Unit {
open fun test() : Unit {
super@A.foo()
}
}
@@ -1,11 +1,11 @@
namespace {
open class Base {
fun foo() : Unit {
open fun foo() : Unit {
}
}
open class A : Base {
open class C {
fun test() : Unit {
open fun test() : Unit {
this@A.foo()
}
}
@@ -1,4 +1,4 @@
trait INode {
fun getTag() : Tag?
fun toKotlin() : String?
open fun getTag() : Tag?
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 {
}