Support for secondary constructors in j2k

This commit is contained in:
Valentin Kipyatkov
2015-03-06 19:21:30 +01:00
parent b44dbe6ca2
commit 569e4a68ae
33 changed files with 367 additions and 589 deletions
@@ -1,34 +1,30 @@
// ERROR: 'public fun <T> Identifier(name: T, isNullable: kotlin.Boolean): Identifier<T>' is already defined in root package
// ERROR: 'public constructor Identifier<T>(name: T, myHasDollar: kotlin.Boolean)' is already defined in root package
// ERROR: Cannot choose among the following candidates without completing type inference: public fun <T> Identifier(name: T, isNullable: kotlin.Boolean): Identifier<T> defined in root package public constructor Identifier<T>(name: T, myHasDollar: kotlin.Boolean) defined in Identifier
// ERROR: Cannot choose among the following candidates without completing type inference: public fun <T> Identifier(name: T, isNullable: kotlin.Boolean): Identifier<T> defined in root package public constructor Identifier<T>(name: T, myHasDollar: kotlin.Boolean) defined in Identifier
// ERROR: Cannot choose among the following candidates without completing type inference: public fun <T> Identifier(name: T, isNullable: kotlin.Boolean): Identifier<T> defined in root package public constructor Identifier<T>(name: T, myHasDollar: kotlin.Boolean) defined in Identifier
// ERROR: Overload resolution ambiguity: public fun <T> Identifier(name: kotlin.String, isNullable: kotlin.Boolean): Identifier<kotlin.String> defined in root package public constructor Identifier<T>(name: kotlin.String, myHasDollar: kotlin.Boolean) defined in Identifier
public fun <T> Identifier(name: T): Identifier<T> {
return Identifier(name, false)
}
public fun <T> Identifier(name: T, isNullable: Boolean): Identifier<T> {
val __ = Identifier(name, false)
__.myNullable = isNullable
return __
}
public fun <T> Identifier(name: T, hasDollar: Boolean, isNullable: Boolean): Identifier<T> {
val __ = Identifier(name, hasDollar)
__.myNullable = isNullable
return __
}
public class Identifier<T>(public val name: T, private val myHasDollar: Boolean) {
// ERROR: Property must be initialized or be abstract
public class Identifier<T> {
public val name: T
private val myHasDollar: Boolean
private var myNullable = true
public constructor(name: T) {
this.name = name
}
public constructor(name: T, isNullable: Boolean) {
this.name = name
myNullable = isNullable
}
public constructor(name: T, hasDollar: Boolean, isNullable: Boolean) {
this.name = name
myHasDollar = hasDollar
myNullable = isNullable
}
}
public class User {
default object {
public fun main() {
val i1 = Identifier("name", false, true)
val i2 = Identifier<String>("name", false)
val i2 = Identifier("name", false)
val i3 = Identifier("name")
}
}