nullable safe calls supported (for methods and instances)

This commit is contained in:
Sergey Ignatov
2011-11-07 15:58:32 +04:00
parent 8f1727882a
commit 510fb25e80
10 changed files with 108 additions and 8 deletions
@@ -0,0 +1,12 @@
class Library {
static void call() {}
static String getString() { return ""; }
}
class User {
void main() {
Library.call();
Library.getString().isEmpty();
}
}
@@ -0,0 +1,17 @@
namespace {
open class Library {
class object {
fun call() : Unit {
}
fun getString() : String? {
return ""
}
}
}
open class User {
fun main() : Unit {
Library.call()
Library.getString()?.isEmpty()
}
}
}
@@ -0,0 +1,16 @@
class Library {
void call() {}
String getString() { return ""; }
}
class User {
void main() {
Library lib = new Library();
lib.call();
lib.getString().isEmpty();
new Library().call();
new Library().getString().isEmpty();
}
}
@@ -0,0 +1,18 @@
namespace {
open class Library {
fun call() : Unit {
}
fun getString() : String? {
return ""
}
}
open class User {
fun main() : Unit {
var lib : Library? = Library()
lib?.call()
lib?.getString()?.isEmpty()
Library().call()
Library().getString()?.isEmpty()
}
}
}
@@ -0,0 +1,9 @@
class Library {
final public String myString;
}
class User {
void main() {
Library.myString.isEmpty();
}
}
@@ -0,0 +1,10 @@
namespace {
open class Library {
public val myString : String?
}
open class User {
fun main() : Unit {
Library.myString?.isEmpty()
}
}
}