example with customer builder added,

initial support for constructors added
This commit is contained in:
Sergey Ignatov
2011-11-08 14:23:30 +04:00
parent 33f3350bb0
commit 39112d6327
50 changed files with 259 additions and 73 deletions
@@ -1,10 +1,10 @@
namespace {
open class Library {
open class Library() {
class object {
val ourOut : PrintStream?
}
}
open class User {
open class User() {
open fun main() : Unit {
Library.ourOut?.print()
}
@@ -1,5 +1,5 @@
namespace {
open class Library {
open class Library() {
class object {
open fun call() : Unit {
}
@@ -8,7 +8,7 @@ return ""
}
}
}
open class User {
open class User() {
open fun main() : Unit {
Library.call()
Library.getString()?.isEmpty()
@@ -1,12 +1,12 @@
namespace {
open class Library {
open class Library() {
open fun call() : Unit {
}
open fun getString() : String? {
return ""
}
}
open class User {
open class User() {
open fun main() : Unit {
var lib : Library? = Library()
lib?.call()
@@ -1,8 +1,8 @@
namespace {
open class Library {
open class Library() {
public val myString : String?
}
open class User {
open class User() {
open fun main() : Unit {
Library.myString?.isEmpty()
}
+1 -1
View File
@@ -1,4 +1,4 @@
abstract open class A {
abstract open class A() {
abstract open fun callme() : Unit
open fun callmetoo() : Unit {
print("This is a concrete method.")
@@ -1,5 +1,7 @@
abstract open class Shape {
abstract open class Shape() {
public var color : String?
{
}
open public fun setColor(c : String?) : Unit {
color = c
}
+1 -1
View File
@@ -1,2 +1,2 @@
open class Test {
open class Test() {
}
@@ -1,4 +1,4 @@
class T {
class T() {
open fun main() : Unit {
}
open fun i() : Int {
+1 -1
View File
@@ -1,4 +1,4 @@
class T {
class T() {
var a : String? = "abc"
var b : Int = 10
}
@@ -1,4 +1,4 @@
class T {
class T() {
var a : String?
var b : String?
var c : String? = "abc"
+1 -1
View File
@@ -1,2 +1,2 @@
class A {
class A() {
}
@@ -1,2 +1,2 @@
class A : Base, I {
class A() : Base, I {
}
@@ -1,2 +1,2 @@
class A : Base, I0, I1, I2 {
class A() : Base, I0, I1, I2 {
}
+1 -1
View File
@@ -1,2 +1,2 @@
class Test {
class Test() {
}
+1 -1
View File
@@ -1,2 +1,2 @@
class Entry<K, V> {
class Entry<K, V>() {
}
+2 -2
View File
@@ -1,4 +1,4 @@
class A {
class B {
class A() {
class B() {
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
class S {
class S() {
class object {
open class Inner {
open class Inner() {
}
}
}
+1 -1
View File
@@ -1,2 +1,2 @@
open class Test {
open class Test() {
}
@@ -1,4 +1,4 @@
class S {
class S() {
class object {
var myI : Int = 10
}
+1 -1
View File
@@ -1,4 +1,4 @@
class S {
class S() {
class object {
open fun staticF() : Boolean {
return true
@@ -1,4 +1,4 @@
class S {
class S() {
class object {
open fun sI() : Int {
return 1
+1 -1
View File
@@ -1,2 +1,2 @@
private open class Test {
private open class Test() {
}
+1 -1
View File
@@ -1,2 +1,2 @@
protected open class Test {
protected open class Test() {
}
+1 -1
View File
@@ -1,2 +1,2 @@
public open class Test {
public open class Test() {
}
@@ -1,2 +1,2 @@
class A : Base {
class A() : Base {
}
+1 -1
View File
@@ -1,4 +1,4 @@
class S {
class S() {
class object {
open fun sB() : Boolean {
return true
+1 -1
View File
@@ -1,5 +1,5 @@
namespace {
public open class MyClass {
public open class MyClass() {
open private fun init(arg1 : Int, arg2 : Int, arg3 : Int) : Unit {
}
}
@@ -0,0 +1,54 @@
package org.test.customer
class Customer {
public final String _firstName;
public final String _lastName;
Customer(String first, String last) {
doSmthBefore();
_firstName = first;
_lastName = last;
doSmthAfter();
}
public String getFirstName() {
return _firstName;
}
public String getLastName() {
return _lastName;
}
private void doSmthBefore() {}
private void doSmthAfter() {}
}
class CustomerBuilder {
public String _firstName = "Homer";
public String _lastName = "Simpson";
public CustomerBuilder WithFirstName(String firstName) {
_firstName = firstName;
return this;
}
public CustomerBuilder WithLastName(String lastName) {
_lastName = lastName;
return this;
}
public Customer Build() {
return new Customer(_firstName, _lastName);
}
}
public class User {
public static void main(Array[String] args) {
Customer customer = new CustomerBuilder()
.WithFirstName("Homer")
.WithLastName("Simpson")
.Build();
System.out.println(customer.getFirstName());
System.out.println(customer.getLastName());
}
}
@@ -0,0 +1,46 @@
namespace org.test.customer {
open class Customer(first : String?, last : String?) {
public val _firstName : String?
public val _lastName : String?
{
doSmthBefore()
$_firstName = first
$_lastName = last
doSmthAfter()
}
open public fun getFirstName() : String? {
return _firstName
}
open public fun getLastName() : String? {
return _lastName
}
open private fun doSmthBefore() : Unit {
}
open private fun doSmthAfter() : Unit {
}
}
open class CustomerBuilder() {
public var _firstName : String? = "Homer"
public var _lastName : String? = "Simpson"
open public fun WithFirstName(firstName : String?) : CustomerBuilder? {
_firstName = firstName
return this
}
open public fun WithLastName(lastName : String?) : CustomerBuilder? {
_lastName = lastName
return this
}
open public fun Build() : Customer? {
return org.test.customer.Customer(_firstName, _lastName)
}
}
public open class User() {
class object {
open public fun main() : Unit {
var customer : Customer? = org.test.customer.CustomerBuilder().WithFirstName("Homer")?.WithLastName("Simpson")?.Build()
System.`out`?.println(customer?.getFirstName())
System.`out`?.println(customer?.getLastName())
}
}
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
namespace test {
class C {
class C() {
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
namespace {
class A {
class A() {
}
class B {
class B() {
}
}
@@ -1,4 +1,4 @@
namespace test {
open class C {
open class C() {
}
}
+2 -2
View File
@@ -1,9 +1,9 @@
namespace {
open class A {
open class A() {
open fun a() : Unit {
}
}
class B : A {
class B() : A {
override fun a() : Unit {
}
}
@@ -1,13 +1,13 @@
namespace {
open class A {
open class A() {
open fun foo() : Unit {
}
}
open class B : A {
open class B() : A {
override fun foo() : Unit {
}
}
open class C : B {
open class C() : B {
override fun foo() : Unit {
}
}
@@ -1,7 +1,7 @@
namespace org.test {
open class Library {
open class Library() {
}
open class User {
open class User() {
open fun main() : Unit {
var lib : Library? = org.test.Library()
}
@@ -1,8 +1,11 @@
open class B {
open class B() {
open fun call() : Unit {
}
}
open class A : B {
open class A() : B {
{
super()
}
override fun call() : Unit {
return super.call()
}
@@ -1,9 +1,9 @@
namespace {
open class Base {
open class Base() {
open fun foo() : Unit
}
open class A : Base {
open class C {
open class A() : Base {
open class C() {
open fun test() : Unit {
super@A.foo()
}
@@ -1,10 +1,10 @@
namespace {
open class Base {
open class Base() {
open fun foo() : Unit {
}
}
open class A : Base {
open class C {
open class A() : Base {
open class C() {
open fun test() : Unit {
this@A.foo()
}
@@ -1,2 +1,2 @@
class CC<T : INode?, K : Node?> : A where T : Comparable<in T?>?, K : Collection<in K?>? {
class CC<T : INode?, K : Node?>() : A where T : Comparable<in T?>?, K : Collection<in K?>? {
}
@@ -1,2 +1,2 @@
class C<T : INode?> where T : Comparable<in T?>? {
class C<T : INode?>() where T : Comparable<in T?>? {
}
@@ -1,2 +1,2 @@
class C<T : INode?> : A where T : Comparable<in T?>? {
class C<T : INode?>() : A where T : Comparable<in T?>? {
}
@@ -1,2 +1,2 @@
class Comparable<T> {
class Comparable<T>() {
}