TEST: primary/secondary constructor fields initialization
This commit is contained in:
committed by
vvlevchenko
parent
62917fd171
commit
48ee81548e
@@ -219,6 +219,10 @@ task fields(type: UnitKonanTest) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
task fields1(type: UnitKonanTest) {
|
||||||
|
source = "codegen/object/fields1.kt"
|
||||||
|
}
|
||||||
|
|
||||||
task constructor(type: UnitKonanTest) {
|
task constructor(type: UnitKonanTest) {
|
||||||
source = "codegen/object/constructor.kt"
|
source = "codegen/object/constructor.kt"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
extern void *resolve_symbol(const char*);
|
||||||
|
|
||||||
|
int
|
||||||
|
run_test() {
|
||||||
|
int (*primary_constructor)(int, int) = resolve_symbol("kfun:primaryConstructorCall(Int;Int)");
|
||||||
|
int (*secondary_constructor)(int) = resolve_symbol("kfun:secondaryConstructorCall(Int)");
|
||||||
|
|
||||||
|
if (primary_constructor(0xdeadbeef, 41) != 42) return 1;
|
||||||
|
|
||||||
|
if (secondary_constructor(41) != 42) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
class B(val a:Int, b:Int) {
|
||||||
|
constructor(pos:Int):this(1, pos) {}
|
||||||
|
val pos = b + 1
|
||||||
|
}
|
||||||
|
|
||||||
|
fun primaryConstructorCall(a:Int, b:Int) = B(a, b).pos
|
||||||
|
|
||||||
|
fun secondaryConstructorCall(a:Int) = B(a).pos
|
||||||
Reference in New Issue
Block a user