Control flow changes for secondary constructors

This commit is contained in:
Denis Zharkov
2015-03-10 19:42:45 +03:00
parent 61ae694be4
commit 7f20c4a237
39 changed files with 1785 additions and 30 deletions
@@ -39,10 +39,7 @@ import org.jetbrains.kotlin.lexer.JetTokens;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilPackage;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.BindingContextUtils;
import org.jetbrains.kotlin.resolve.BindingTrace;
import org.jetbrains.kotlin.resolve.CompileTimeConstantUtils;
import org.jetbrains.kotlin.resolve.*;
import org.jetbrains.kotlin.resolve.calls.model.*;
import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant;
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
@@ -80,7 +77,7 @@ public class JetControlFlowProcessor {
private Pseudocode generate(@NotNull JetElement subroutine) {
builder.enterSubroutine(subroutine);
CFPVisitor cfpVisitor = new CFPVisitor(builder);
if (subroutine instanceof JetDeclarationWithBody) {
if (subroutine instanceof JetDeclarationWithBody && !(subroutine instanceof JetSecondaryConstructor)) {
JetDeclarationWithBody declarationWithBody = (JetDeclarationWithBody) subroutine;
List<JetParameter> valueParameters = declarationWithBody.getValueParameters();
for (JetParameter valueParameter : valueParameters) {
@@ -1358,7 +1355,9 @@ public class JetControlFlowProcessor {
@Override
public void visitObjectDeclaration(@NotNull JetObjectDeclaration objectDeclaration) {
visitClassOrObject(objectDeclaration);
generateHeaderDelegationSpecifiers(objectDeclaration);
generateClassOrObjectInitializers(objectDeclaration);
generateDeclarationForLocalClassOrObjectIfNeeded(objectDeclaration);
}
@Override
@@ -1386,19 +1385,14 @@ public class JetControlFlowProcessor {
generateInstructions(classInitializer.getBody());
}
private void visitClassOrObject(JetClassOrObject classOrObject) {
private void generateHeaderDelegationSpecifiers(@NotNull JetClassOrObject classOrObject) {
for (JetDelegationSpecifier specifier : classOrObject.getDelegationSpecifiers()) {
generateInstructions(specifier);
}
List<JetDeclaration> declarations = classOrObject.getDeclarations();
if (classOrObject.isLocal()) {
for (JetDeclaration declaration : declarations) {
generateInstructions(declaration);
}
return;
}
//For top-level and inner classes and objects functions are collected and checked separately.
for (JetDeclaration declaration : declarations) {
}
private void generateClassOrObjectInitializers(@NotNull JetClassOrObject classOrObject) {
for (JetDeclaration declaration : classOrObject.getDeclarations()) {
if (declaration instanceof JetProperty || declaration instanceof JetClassInitializer) {
generateInstructions(declaration);
}
@@ -1407,15 +1401,61 @@ public class JetControlFlowProcessor {
@Override
public void visitClass(@NotNull JetClass klass) {
List<JetParameter> parameters = klass.getPrimaryConstructorParameters();
if (klass.hasPrimaryConstructor()) {
processParameters(klass.getPrimaryConstructorParameters());
// delegation specifiers of primary constructor, anonymous class and property initializers
generateHeaderDelegationSpecifiers(klass);
generateClassOrObjectInitializers(klass);
}
generateDeclarationForLocalClassOrObjectIfNeeded(klass);
}
private void generateDeclarationForLocalClassOrObjectIfNeeded(@NotNull JetClassOrObject classOrObject) {
if (classOrObject.isLocal()) {
for (JetDeclaration declaration : classOrObject.getDeclarations()) {
if (declaration instanceof JetSecondaryConstructor ||
declaration instanceof JetProperty ||
declaration instanceof JetClassInitializer) {
continue;
}
generateInstructions(declaration);
}
}
}
private void processParameters(@NotNull List<JetParameter> parameters) {
for (JetParameter parameter : parameters) {
generateInstructions(parameter);
}
visitClassOrObject(klass);
}
@Override
public void visitSecondaryConstructor(@NotNull JetSecondaryConstructor constructor) {
JetClassOrObject classOrObject = PsiTreeUtil.getParentOfType(constructor, JetClassOrObject.class);
assert classOrObject != null : "Guaranteed by parsing contract";
processParameters(constructor.getValueParameters());
generateCallOrMarkUnresolved(constructor.getDelegationCall());
if (constructor.getDelegationCall() != null &&
constructor.getDelegationCall().getCalleeExpression() != null &&
!constructor.getDelegationCall().getCalleeExpression().isThis()
) {
generateClassOrObjectInitializers(classOrObject);
}
generateInstructions(constructor.getBodyExpression());
}
@Override
public void visitDelegationToSuperCallSpecifier(@NotNull JetDelegatorToSuperCall call) {
generateCallOrMarkUnresolved(call);
}
private void generateCallOrMarkUnresolved(@Nullable JetCallElement call) {
if (call == null) return;
if (!generateCall(call)) {
List<JetExpression> arguments = KotlinPackage.map(
call.getValueArguments(),
@@ -577,8 +577,8 @@ public class JetFlowInformationProvider {
for (VariableDescriptor variable : declaredVariables) {
if (variable instanceof PropertyDescriptor) {
PseudocodeVariablesData.VariableInitState variableInitState = initializers.getIncoming().get(variable);
if (variableInitState == null) return;
trace.record(BindingContext.IS_INITIALIZED, (PropertyDescriptor) variable, variableInitState.isInitialized);
if (variableInitState != null && variableInitState.isInitialized) continue;
trace.record(BindingContext.IS_UNINITIALIZED, (PropertyDescriptor) variable);
}
}
}
@@ -70,7 +70,7 @@ public class JetConstructorDelegationCall extends JetElementImplStub<KotlinPlace
@Nullable
@Override
public JetExpression getCalleeExpression() {
return findChildByClass(JetExpression.class);
public JetConstructorDelegationReferenceExpression getCalleeExpression() {
return findChildByClass(JetConstructorDelegationReferenceExpression.class);
}
}
@@ -112,6 +112,12 @@ public class JetSecondaryConstructor extends JetDeclarationStub<KotlinPlaceHolde
return false;
}
@Override
@NotNull
public String getName() {
return "<init>";
}
@Nullable
@Override
public JetTypeParameterList getTypeParameterList() {
@@ -139,7 +145,7 @@ public class JetSecondaryConstructor extends JetDeclarationStub<KotlinPlaceHolde
@NotNull
@Override
public Name getNameAsSafeName() {
return Name.special("<init>");
return Name.special(getName());
}
@Nullable
@@ -185,7 +185,7 @@ public interface BindingContext {
return backingFieldRequired;
}
};
WritableSlice<PropertyDescriptor, Boolean> IS_INITIALIZED = Slices.createSimpleSetSlice();
WritableSlice<PropertyDescriptor, Boolean> IS_UNINITIALIZED = Slices.createSimpleSetSlice();
WritableSlice<JetFunctionLiteralExpression, Boolean> BLOCK = new Slices.SetSlice<JetFunctionLiteralExpression>(DO_NOTHING) {
@Override
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.cfg.JetFlowInformationProvider;
import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor;
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
@@ -45,6 +46,9 @@ public class ControlFlowAnalyzer {
for (JetClassOrObject aClass : c.getDeclaredClasses().keySet()) {
checkDeclarationContainer(c, aClass);
}
for (JetSecondaryConstructor constructor : c.getSecondaryConstructors().keySet()) {
checkSecondaryConstructor(constructor);
}
for (Map.Entry<JetNamedFunction, SimpleFunctionDescriptor> entry : c.getFunctions().entrySet()) {
JetNamedFunction function = entry.getKey();
SimpleFunctionDescriptor functionDescriptor = entry.getValue();
@@ -60,6 +64,12 @@ public class ControlFlowAnalyzer {
}
}
private void checkSecondaryConstructor(@NotNull JetSecondaryConstructor constructor) {
JetFlowInformationProvider flowInformationProvider = new JetFlowInformationProvider(constructor, trace);
flowInformationProvider.checkDeclaration();
flowInformationProvider.checkFunction(KotlinBuiltIns.getInstance().getUnitType());
}
private void checkDeclarationContainer(@NotNull BodiesResolveContext c, JetDeclarationContainer declarationContainer) {
// A pseudocode of class/object initialization corresponds to a class/object
// or initialization of properties corresponds to a package declared in a file
@@ -456,7 +456,7 @@ public class DeclarationsChecker {
if (initializer == null && delegate == null) {
boolean error = false;
if (backingFieldRequired && !inTrait &&
Boolean.FALSE.equals(trace.getBindingContext().get(BindingContext.IS_INITIALIZED, propertyDescriptor))) {
Boolean.TRUE.equals(trace.getBindingContext().get(BindingContext.IS_UNINITIALIZED, propertyDescriptor))) {
if (!(containingDeclaration instanceof ClassDescriptor) || hasAccessorImplementation) {
error = true;
trace.report(MUST_BE_INITIALIZED.on(property));
@@ -0,0 +1,115 @@
== A ==
class A(val w: Char) {
val x: Int
var y: Int
val z: Int
val v = -1
constructor(): this('a') {
y = 2
}
// anonymous
init {
x = w
z = 8
}
constructor(a: Int, b: Int = 3): this(b.toChar()) {
y = x
}
// anonymous
init {
y = 9
}
}
---------------------
L0:
1 <START>
v(val w: Char)
magic[FAKE_INITIALIZER](val w: Char) -> <v0>
w(w|<v0>)
v(val x: Int)
v(var y: Int)
v(val z: Int)
v(val v = -1)
r(1) -> <v1>
mark(-1)
call(-1, minus|<v1>) -> <v2>
w(v|<v2>)
2 mark({ x = w z = 8 })
magic[IMPLICIT_RECEIVER](x) -> <v3>
magic[IMPLICIT_RECEIVER](w) -> <v4>
r(w|<v4>) -> <v5>
w(x|<v3>, <v5>)
magic[IMPLICIT_RECEIVER](z) -> <v6>
r(8) -> <v7>
w(z|<v6>, <v7>)
mark({ y = 9 })
magic[IMPLICIT_RECEIVER](y) -> <v9>
r(9) -> <v10>
w(y|<v9>, <v10>)
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== <init> ==
constructor(): this('a') {
y = 2
}
---------------------
L0:
1 <START>
r('a') -> <v0>
mark(this('a'))
call(this('a'), <init>|<v0>) -> <v1>
2 mark({ y = 2 })
magic[IMPLICIT_RECEIVER](y) -> <v2>
r(2) -> <v3>
w(y|<v2>, <v3>)
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== <init> ==
constructor(a: Int, b: Int = 3): this(b.toChar()) {
y = x
}
---------------------
L0:
1 <START>
v(a: Int)
magic[FAKE_INITIALIZER](a: Int) -> <v0>
w(a|<v0>)
v(b: Int = 3)
jmp?(L2) NEXT:[magic[FAKE_INITIALIZER](b: Int = 3) -> <v2>, r(3) -> <v1>]
r(3) -> <v1>
L2 [after default value for parameter b]:
magic[FAKE_INITIALIZER](b: Int = 3) -> <v2> PREV:[jmp?(L2), r(3) -> <v1>]
merge(b: Int = 3|<v1>, <v2>) -> <v3>
w(b|<v3>)
mark(b.toChar())
r(b) -> <v4>
mark(toChar())
call(toChar(), toChar|<v4>) -> <v5>
mark(this(b.toChar()))
call(this(b.toChar()), <init>|<v5>) -> <v6>
2 mark({ y = x })
magic[IMPLICIT_RECEIVER](y) -> <v7>
magic[IMPLICIT_RECEIVER](x) -> <v8>
r(x|<v8>) -> <v9>
w(y|<v7>, <v9>)
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
@@ -0,0 +1,25 @@
class A(val w: Char) {
val x: Int
var y: Int
val z: Int
val v = -1
constructor(): this('a') {
y = 2
}
// anonymous
init {
x = w
z = 8
}
constructor(a: Int, b: Int = 3): this(b.toChar()) {
y = x
}
// anonymous
init {
y = 9
}
}
@@ -0,0 +1,73 @@
== A ==
class A(val w: Char) {
val x: Int
var y: Int
val z: Int
val v = -1
constructor(): this('a') {
y = 2
}
// anonymous
init {
x = w
z = 8
}
constructor(a: Int, b: Int = 3): this(b.toChar()) {
y = x
}
// anonymous
init {
y = 9
}
}
---------------------
<v0>: Char NEW: magic[FAKE_INITIALIZER](val w: Char) -> <v0>
<v3>: A NEW: magic[IMPLICIT_RECEIVER](x) -> <v3>
<v4>: A NEW: magic[IMPLICIT_RECEIVER](w) -> <v4>
<v6>: A NEW: magic[IMPLICIT_RECEIVER](z) -> <v6>
<v9>: A NEW: magic[IMPLICIT_RECEIVER](y) -> <v9>
1 <v1>: Int NEW: r(1) -> <v1>
-1 <v2>: Int NEW: call(-1, minus|<v1>) -> <v2>
w <v5>: Int NEW: r(w|<v4>) -> <v5>
8 <v7>: Int NEW: r(8) -> <v7>
z = 8 !<v8>: *
{ x = w z = 8 } !<v8>: * COPY
9 <v10>: Int NEW: r(9) -> <v10>
y = 9 !<v11>: *
{ y = 9 } !<v11>: * COPY
=====================
== <init> ==
constructor(): this('a') {
y = 2
}
---------------------
<v2>: A NEW: magic[IMPLICIT_RECEIVER](y) -> <v2>
'a' <v0>: Char NEW: r('a') -> <v0>
this('a') <v1>: * NEW: call(this('a'), <init>|<v0>) -> <v1>
2 <v3>: Int NEW: r(2) -> <v3>
y = 2 !<v4>: *
{ y = 2 } !<v4>: * COPY
=====================
== <init> ==
constructor(a: Int, b: Int = 3): this(b.toChar()) {
y = x
}
---------------------
<v0>: Int NEW: magic[FAKE_INITIALIZER](a: Int) -> <v0>
<v2>: Int NEW: magic[FAKE_INITIALIZER](b: Int = 3) -> <v2>
<v7>: A NEW: magic[IMPLICIT_RECEIVER](y) -> <v7>
<v8>: A NEW: magic[IMPLICIT_RECEIVER](x) -> <v8>
3 <v1>: Int NEW: r(3) -> <v1>
b: Int = 3 <v3>: Int NEW: merge(b: Int = 3|<v1>, <v2>) -> <v3>
b <v4>: {<: Number} NEW: r(b) -> <v4>
toChar() <v5>: Char NEW: call(toChar(), toChar|<v4>) -> <v5>
b.toChar() <v5>: Char COPY
this(b.toChar()) <v6>: * NEW: call(this(b.toChar()), <init>|<v5>) -> <v6>
x <v9>: Int NEW: r(x|<v8>) -> <v9>
y = x !<v10>: *
{ y = x } !<v10>: * COPY
=====================
@@ -0,0 +1,146 @@
== B ==
open class B(x: Int)
---------------------
L0:
1 <START>
v(x: Int)
magic[FAKE_INITIALIZER](x: Int) -> <v0>
w(x|<v0>)
L1:
<END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== A ==
class A(val w: Char, u: Int = 2) : B(w.toInt() + u) {
val x: Int
var y: Int
val z: Int
val v = -1
constructor(): this('a') {
y = 2
}
// anonymous
init {
x = w
z = 8
}
constructor(a: Int, b: Int = 3): this(b.toChar()) {
y = x
}
// anonymous
init {
y = 9
}
}
---------------------
L0:
1 <START>
v(val w: Char)
magic[FAKE_INITIALIZER](val w: Char) -> <v0>
w(w|<v0>)
v(u: Int = 2)
jmp?(L2) NEXT:[magic[FAKE_INITIALIZER](u: Int = 2) -> <v2>, r(2) -> <v1>]
r(2) -> <v1>
L2 [after default value for parameter u]:
magic[FAKE_INITIALIZER](u: Int = 2) -> <v2> PREV:[jmp?(L2), r(2) -> <v1>]
merge(u: Int = 2|<v1>, <v2>) -> <v3>
w(u|<v3>)
mark(w.toInt())
r(w) -> <v4>
mark(toInt())
call(toInt(), toInt|<v4>) -> <v5>
r(u) -> <v6>
mark(w.toInt() + u)
call(w.toInt() + u, plus|<v5>, <v6>) -> <v7>
mark(B(w.toInt() + u))
call(B(w.toInt() + u), <init>|<v7>) -> <v8>
v(val x: Int)
v(var y: Int)
v(val z: Int)
v(val v = -1)
r(1) -> <v9>
mark(-1)
call(-1, minus|<v9>) -> <v10>
w(v|<v10>)
2 mark({ x = w z = 8 })
magic[IMPLICIT_RECEIVER](x) -> <v11>
magic[IMPLICIT_RECEIVER](w) -> <v12>
r(w|<v12>) -> <v13>
w(x|<v11>, <v13>)
magic[IMPLICIT_RECEIVER](z) -> <v14>
r(8) -> <v15>
w(z|<v14>, <v15>)
mark({ y = 9 })
magic[IMPLICIT_RECEIVER](y) -> <v17>
r(9) -> <v18>
w(y|<v17>, <v18>)
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== <init> ==
constructor(): this('a') {
y = 2
}
---------------------
L0:
1 <START>
r('a') -> <v0>
mark(this('a'))
call(this('a'), <init>|<v0>) -> <v1>
2 mark({ y = 2 })
magic[IMPLICIT_RECEIVER](y) -> <v2>
r(2) -> <v3>
w(y|<v2>, <v3>)
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== <init> ==
constructor(a: Int, b: Int = 3): this(b.toChar()) {
y = x
}
---------------------
L0:
1 <START>
v(a: Int)
magic[FAKE_INITIALIZER](a: Int) -> <v0>
w(a|<v0>)
v(b: Int = 3)
jmp?(L2) NEXT:[magic[FAKE_INITIALIZER](b: Int = 3) -> <v2>, r(3) -> <v1>]
r(3) -> <v1>
L2 [after default value for parameter b]:
magic[FAKE_INITIALIZER](b: Int = 3) -> <v2> PREV:[jmp?(L2), r(3) -> <v1>]
merge(b: Int = 3|<v1>, <v2>) -> <v3>
w(b|<v3>)
mark(b.toChar())
r(b) -> <v4>
mark(toChar())
call(toChar(), toChar|<v4>) -> <v5>
mark(this(b.toChar()))
call(this(b.toChar()), <init>|<v5>) -> <v6>
2 mark({ y = x })
magic[IMPLICIT_RECEIVER](y) -> <v7>
magic[IMPLICIT_RECEIVER](x) -> <v8>
r(x|<v8>) -> <v9>
w(y|<v7>, <v9>)
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
@@ -0,0 +1,26 @@
open class B(x: Int)
class A(val w: Char, u: Int = 2) : B(w.toInt() + u) {
val x: Int
var y: Int
val z: Int
val v = -1
constructor(): this('a') {
y = 2
}
// anonymous
init {
x = w
z = 8
}
constructor(a: Int, b: Int = 3): this(b.toChar()) {
y = x
}
// anonymous
init {
y = 9
}
}
@@ -0,0 +1,87 @@
== B ==
open class B(x: Int)
---------------------
<v0>: Int NEW: magic[FAKE_INITIALIZER](x: Int) -> <v0>
=====================
== A ==
class A(val w: Char, u: Int = 2) : B(w.toInt() + u) {
val x: Int
var y: Int
val z: Int
val v = -1
constructor(): this('a') {
y = 2
}
// anonymous
init {
x = w
z = 8
}
constructor(a: Int, b: Int = 3): this(b.toChar()) {
y = x
}
// anonymous
init {
y = 9
}
}
---------------------
<v0>: Char NEW: magic[FAKE_INITIALIZER](val w: Char) -> <v0>
<v11>: A NEW: magic[IMPLICIT_RECEIVER](x) -> <v11>
<v12>: A NEW: magic[IMPLICIT_RECEIVER](w) -> <v12>
<v14>: A NEW: magic[IMPLICIT_RECEIVER](z) -> <v14>
<v17>: A NEW: magic[IMPLICIT_RECEIVER](y) -> <v17>
<v2>: Int NEW: magic[FAKE_INITIALIZER](u: Int = 2) -> <v2>
2 <v1>: Int NEW: r(2) -> <v1>
u: Int = 2 <v3>: Int NEW: merge(u: Int = 2|<v1>, <v2>) -> <v3>
w <v4>: Char NEW: r(w) -> <v4>
toInt() <v5>: Int NEW: call(toInt(), toInt|<v4>) -> <v5>
w.toInt() <v5>: Int COPY
u <v6>: Int NEW: r(u) -> <v6>
w.toInt() + u <v7>: Int NEW: call(w.toInt() + u, plus|<v5>, <v6>) -> <v7>
B(w.toInt() + u) <v8>: * NEW: call(B(w.toInt() + u), <init>|<v7>) -> <v8>
1 <v9>: Int NEW: r(1) -> <v9>
-1 <v10>: Int NEW: call(-1, minus|<v9>) -> <v10>
w <v13>: Int NEW: r(w|<v12>) -> <v13>
8 <v15>: Int NEW: r(8) -> <v15>
z = 8 !<v16>: *
{ x = w z = 8 } !<v16>: * COPY
9 <v18>: Int NEW: r(9) -> <v18>
y = 9 !<v19>: *
{ y = 9 } !<v19>: * COPY
=====================
== <init> ==
constructor(): this('a') {
y = 2
}
---------------------
<v2>: A NEW: magic[IMPLICIT_RECEIVER](y) -> <v2>
'a' <v0>: Char NEW: r('a') -> <v0>
this('a') <v1>: * NEW: call(this('a'), <init>|<v0>) -> <v1>
2 <v3>: Int NEW: r(2) -> <v3>
y = 2 !<v4>: *
{ y = 2 } !<v4>: * COPY
=====================
== <init> ==
constructor(a: Int, b: Int = 3): this(b.toChar()) {
y = x
}
---------------------
<v0>: Int NEW: magic[FAKE_INITIALIZER](a: Int) -> <v0>
<v2>: Int NEW: magic[FAKE_INITIALIZER](b: Int = 3) -> <v2>
<v7>: A NEW: magic[IMPLICIT_RECEIVER](y) -> <v7>
<v8>: A NEW: magic[IMPLICIT_RECEIVER](x) -> <v8>
3 <v1>: Int NEW: r(3) -> <v1>
b: Int = 3 <v3>: Int NEW: merge(b: Int = 3|<v1>, <v2>) -> <v3>
b <v4>: {<: Number} NEW: r(b) -> <v4>
toChar() <v5>: Char NEW: call(toChar(), toChar|<v4>) -> <v5>
b.toChar() <v5>: Char COPY
this(b.toChar()) <v6>: * NEW: call(this(b.toChar()), <init>|<v5>) -> <v6>
x <v9>: Int NEW: r(x|<v8>) -> <v9>
y = x !<v10>: *
{ y = x } !<v10>: * COPY
=====================
@@ -0,0 +1,61 @@
== A ==
class A {
val x: Int
constructor() {
if (1 == 1) {
return
}
else null!!
x = 1
}
}
---------------------
L0:
1 <START>
L1:
<END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== <init> ==
constructor() {
if (1 == 1) {
return
}
else null!!
x = 1
}
---------------------
L0:
1 <START>
mark()
call(, <init>) -> <v0>
v(val x: Int)
2 mark({ if (1 == 1) { return } else null!! x = 1 })
mark(if (1 == 1) { return } else null!!)
r(1) -> <v1>
r(1) -> <v2>
mark(1 == 1)
call(1 == 1, equals|<v1>, <v2>) -> <v3>
jf(L2|<v3>) NEXT:[r(null) -> <v5>, mark({ return })]
3 mark({ return })
ret L1 NEXT:[<END>]
- 2 jmp(L3) NEXT:[merge(if (1 == 1) { return } else null!!|!<v4>, <v6>) -> <v7>] PREV:[]
L2 [else branch]:
r(null) -> <v5> PREV:[jf(L2|<v3>)]
magic[NOT_NULL_ASSERTION](null!!|<v5>) -> <v6>
jmp(error) NEXT:[<ERROR>]
L3 ['if' expression result]:
- merge(if (1 == 1) { return } else null!!|!<v4>, <v6>) -> <v7> PREV:[]
- magic[IMPLICIT_RECEIVER](x) -> <v8> PREV:[]
- r(1) -> <v9> PREV:[]
- w(x|<v8>, <v9>) PREV:[]
L1:
1 <END> NEXT:[<SINK>] PREV:[ret L1]
error:
<ERROR> PREV:[jmp(error)]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
@@ -0,0 +1,10 @@
class A {
val x: Int
constructor() {
if (1 == 1) {
return
}
else null!!
x = 1
}
}
@@ -0,0 +1,35 @@
== A ==
class A {
val x: Int
constructor() {
if (1 == 1) {
return
}
else null!!
x = 1
}
}
---------------------
=====================
== <init> ==
constructor() {
if (1 == 1) {
return
}
else null!!
x = 1
}
---------------------
<v0>: * NEW: call(, <init>) -> <v0>
1 <v1>: OR{*, *} NEW: r(1) -> <v1>
1 <v2>: * NEW: r(1) -> <v2>
1 == 1 <v3>: Boolean NEW: call(1 == 1, equals|<v1>, <v2>) -> <v3>
return !<v4>: *
{ return } !<v4>: * COPY
null <v5>: * NEW: r(null) -> <v5>
null!! <v6>: * NEW: magic[NOT_NULL_ASSERTION](null!!|<v5>) -> <v6>
if (1 == 1) { return } else null!! <v7>: * NEW: merge(if (1 == 1) { return } else null!!|!<v4>, <v6>) -> <v7>
1 <v9>: Int NEW: r(1) -> <v9>
x = 1 !<v10>: *
{ if (1 == 1) { return } else null!! x = 1 } !<v10>: * COPY
=====================
@@ -0,0 +1,198 @@
== A ==
class A {
val x: Int
var y: Int
val z: Int
val v = -1
constructor() {
x = 1
y = 2
}
constructor(a: Int, b: Int = 3) {
x = a
y = x
}
//anonymous
init {
z = 8
}
constructor(a: String, b: Int = 4): this() {
y = 5
}
constructor(a: Double, b: Int = 6): this(a.toInt()) {
y = 7
}
// anonymous
init {
y = 9
}
}
---------------------
L0:
1 <START>
L1:
<END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== <init> ==
constructor() {
x = 1
y = 2
}
---------------------
L0:
1 <START>
mark()
call(, <init>) -> <v0>
v(val x: Int)
v(var y: Int)
v(val z: Int)
v(val v = -1)
r(1) -> <v1>
mark(-1)
call(-1, minus|<v1>) -> <v2>
w(v|<v2>)
2 mark({ z = 8 })
magic[IMPLICIT_RECEIVER](z) -> <v3>
r(8) -> <v4>
w(z|<v3>, <v4>)
mark({ y = 9 })
magic[IMPLICIT_RECEIVER](y) -> <v6>
r(9) -> <v7>
w(y|<v6>, <v7>)
mark({ x = 1 y = 2 })
magic[IMPLICIT_RECEIVER](x) -> <v9>
r(1) -> <v10>
w(x|<v9>, <v10>)
magic[IMPLICIT_RECEIVER](y) -> <v11>
r(2) -> <v12>
w(y|<v11>, <v12>)
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== <init> ==
constructor(a: Int, b: Int = 3) {
x = a
y = x
}
---------------------
L0:
1 <START>
v(a: Int)
magic[FAKE_INITIALIZER](a: Int) -> <v0>
w(a|<v0>)
v(b: Int = 3)
jmp?(L2) NEXT:[magic[FAKE_INITIALIZER](b: Int = 3) -> <v2>, r(3) -> <v1>]
r(3) -> <v1>
L2 [after default value for parameter b]:
magic[FAKE_INITIALIZER](b: Int = 3) -> <v2> PREV:[jmp?(L2), r(3) -> <v1>]
merge(b: Int = 3|<v1>, <v2>) -> <v3>
w(b|<v3>)
mark()
call(, <init>) -> <v4>
v(val x: Int)
v(var y: Int)
v(val z: Int)
v(val v = -1)
r(1) -> <v5>
mark(-1)
call(-1, minus|<v5>) -> <v6>
w(v|<v6>)
2 mark({ z = 8 })
magic[IMPLICIT_RECEIVER](z) -> <v7>
r(8) -> <v8>
w(z|<v7>, <v8>)
mark({ y = 9 })
magic[IMPLICIT_RECEIVER](y) -> <v10>
r(9) -> <v11>
w(y|<v10>, <v11>)
mark({ x = a y = x })
magic[IMPLICIT_RECEIVER](x) -> <v13>
r(a) -> <v14>
w(x|<v13>, <v14>)
magic[IMPLICIT_RECEIVER](y) -> <v15>
magic[IMPLICIT_RECEIVER](x) -> <v16>
r(x|<v16>) -> <v17>
w(y|<v15>, <v17>)
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== <init> ==
constructor(a: String, b: Int = 4): this() {
y = 5
}
---------------------
L0:
1 <START>
v(a: String)
magic[FAKE_INITIALIZER](a: String) -> <v0>
w(a|<v0>)
v(b: Int = 4)
jmp?(L2) NEXT:[magic[FAKE_INITIALIZER](b: Int = 4) -> <v2>, r(4) -> <v1>]
r(4) -> <v1>
L2 [after default value for parameter b]:
magic[FAKE_INITIALIZER](b: Int = 4) -> <v2> PREV:[jmp?(L2), r(4) -> <v1>]
merge(b: Int = 4|<v1>, <v2>) -> <v3>
w(b|<v3>)
mark(this())
call(this(), <init>) -> <v4>
2 mark({ y = 5 })
magic[IMPLICIT_RECEIVER](y) -> <v5>
r(5) -> <v6>
w(y|<v5>, <v6>)
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== <init> ==
constructor(a: Double, b: Int = 6): this(a.toInt()) {
y = 7
}
---------------------
L0:
1 <START>
v(a: Double)
magic[FAKE_INITIALIZER](a: Double) -> <v0>
w(a|<v0>)
v(b: Int = 6)
jmp?(L2) NEXT:[magic[FAKE_INITIALIZER](b: Int = 6) -> <v2>, r(6) -> <v1>]
r(6) -> <v1>
L2 [after default value for parameter b]:
magic[FAKE_INITIALIZER](b: Int = 6) -> <v2> PREV:[jmp?(L2), r(6) -> <v1>]
merge(b: Int = 6|<v1>, <v2>) -> <v3>
w(b|<v3>)
mark(a.toInt())
r(a) -> <v4>
mark(toInt())
call(toInt(), toInt|<v4>) -> <v5>
mark(this(a.toInt()))
call(this(a.toInt()), <init>|<v5>) -> <v6>
2 mark({ y = 7 })
magic[IMPLICIT_RECEIVER](y) -> <v7>
r(7) -> <v8>
w(y|<v7>, <v8>)
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
@@ -0,0 +1,32 @@
class A {
val x: Int
var y: Int
val z: Int
val v = -1
constructor() {
x = 1
y = 2
}
constructor(a: Int, b: Int = 3) {
x = a
y = x
}
//anonymous
init {
z = 8
}
constructor(a: String, b: Int = 4): this() {
y = 5
}
constructor(a: Double, b: Int = 6): this(a.toInt()) {
y = 7
}
// anonymous
init {
y = 9
}
}
@@ -0,0 +1,105 @@
== A ==
class A {
val x: Int
var y: Int
val z: Int
val v = -1
constructor() {
x = 1
y = 2
}
constructor(a: Int, b: Int = 3) {
x = a
y = x
}
//anonymous
init {
z = 8
}
constructor(a: String, b: Int = 4): this() {
y = 5
}
constructor(a: Double, b: Int = 6): this(a.toInt()) {
y = 7
}
// anonymous
init {
y = 9
}
}
---------------------
=====================
== <init> ==
constructor() {
x = 1
y = 2
}
---------------------
<v11>: A NEW: magic[IMPLICIT_RECEIVER](y) -> <v11>
<v3>: A NEW: magic[IMPLICIT_RECEIVER](z) -> <v3>
<v6>: A NEW: magic[IMPLICIT_RECEIVER](y) -> <v6>
<v9>: A NEW: magic[IMPLICIT_RECEIVER](x) -> <v9>
<v0>: * NEW: call(, <init>) -> <v0>
1 <v10>: Int NEW: r(1) -> <v10>
2 <v12>: Int NEW: r(2) -> <v12>
y = 2 !<v13>: *
{ x = 1 y = 2 } !<v13>: * COPY
=====================
== <init> ==
constructor(a: Int, b: Int = 3) {
x = a
y = x
}
---------------------
<v0>: Int NEW: magic[FAKE_INITIALIZER](a: Int) -> <v0>
<v10>: A NEW: magic[IMPLICIT_RECEIVER](y) -> <v10>
<v13>: A NEW: magic[IMPLICIT_RECEIVER](x) -> <v13>
<v15>: A NEW: magic[IMPLICIT_RECEIVER](y) -> <v15>
<v16>: A NEW: magic[IMPLICIT_RECEIVER](x) -> <v16>
<v2>: Int NEW: magic[FAKE_INITIALIZER](b: Int = 3) -> <v2>
<v7>: A NEW: magic[IMPLICIT_RECEIVER](z) -> <v7>
3 <v1>: Int NEW: r(3) -> <v1>
b: Int = 3 <v3>: Int NEW: merge(b: Int = 3|<v1>, <v2>) -> <v3>
<v4>: * NEW: call(, <init>) -> <v4>
a <v14>: Int NEW: r(a) -> <v14>
x <v17>: Int NEW: r(x|<v16>) -> <v17>
y = x !<v18>: *
{ x = a y = x } !<v18>: * COPY
=====================
== <init> ==
constructor(a: String, b: Int = 4): this() {
y = 5
}
---------------------
<v0>: String NEW: magic[FAKE_INITIALIZER](a: String) -> <v0>
<v2>: Int NEW: magic[FAKE_INITIALIZER](b: Int = 4) -> <v2>
<v5>: A NEW: magic[IMPLICIT_RECEIVER](y) -> <v5>
4 <v1>: Int NEW: r(4) -> <v1>
b: Int = 4 <v3>: Int NEW: merge(b: Int = 4|<v1>, <v2>) -> <v3>
this() <v4>: * NEW: call(this(), <init>) -> <v4>
5 <v6>: Int NEW: r(5) -> <v6>
y = 5 !<v7>: *
{ y = 5 } !<v7>: * COPY
=====================
== <init> ==
constructor(a: Double, b: Int = 6): this(a.toInt()) {
y = 7
}
---------------------
<v0>: Double NEW: magic[FAKE_INITIALIZER](a: Double) -> <v0>
<v2>: Int NEW: magic[FAKE_INITIALIZER](b: Int = 6) -> <v2>
<v7>: A NEW: magic[IMPLICIT_RECEIVER](y) -> <v7>
6 <v1>: Int NEW: r(6) -> <v1>
b: Int = 6 <v3>: Int NEW: merge(b: Int = 6|<v1>, <v2>) -> <v3>
a <v4>: {<: Number} NEW: r(a) -> <v4>
toInt() <v5>: Int NEW: call(toInt(), toInt|<v4>) -> <v5>
a.toInt() <v5>: Int COPY
this(a.toInt()) <v6>: * NEW: call(this(a.toInt()), <init>|<v5>) -> <v6>
7 <v8>: Int NEW: r(7) -> <v8>
y = 7 !<v9>: *
{ y = 7 } !<v9>: * COPY
=====================
@@ -0,0 +1,215 @@
== B ==
open class B(x: Int)
---------------------
L0:
1 <START>
v(x: Int)
magic[FAKE_INITIALIZER](x: Int) -> <v0>
w(x|<v0>)
L1:
<END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== A ==
class A : B {
val x: Int
var y: Int
val z: Int
val v = -1
constructor(): super(11) {
x = 1
y = 2
}
constructor(a: Int, b: Int = 3): super(b) {
x = a
y = x
}
// anonymous
init {
z = 8
}
constructor(a: String, b: Int = 4): this() {
y = 5
}
constructor(a: Double, b: Int = 6): this(a.toInt()) {
y = 7
}
// anonymous
init {
y = 9
}
}
---------------------
L0:
1 <START>
L1:
<END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== <init> ==
constructor(): super(11) {
x = 1
y = 2
}
---------------------
L0:
1 <START>
r(11) -> <v0>
mark(super(11))
call(super(11), <init>|<v0>) -> <v1>
v(val x: Int)
v(var y: Int)
v(val z: Int)
v(val v = -1)
r(1) -> <v2>
mark(-1)
call(-1, minus|<v2>) -> <v3>
w(v|<v3>)
2 mark({ z = 8 })
magic[IMPLICIT_RECEIVER](z) -> <v4>
r(8) -> <v5>
w(z|<v4>, <v5>)
mark({ y = 9 })
magic[IMPLICIT_RECEIVER](y) -> <v7>
r(9) -> <v8>
w(y|<v7>, <v8>)
mark({ x = 1 y = 2 })
magic[IMPLICIT_RECEIVER](x) -> <v10>
r(1) -> <v11>
w(x|<v10>, <v11>)
magic[IMPLICIT_RECEIVER](y) -> <v12>
r(2) -> <v13>
w(y|<v12>, <v13>)
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== <init> ==
constructor(a: Int, b: Int = 3): super(b) {
x = a
y = x
}
---------------------
L0:
1 <START>
v(a: Int)
magic[FAKE_INITIALIZER](a: Int) -> <v0>
w(a|<v0>)
v(b: Int = 3)
jmp?(L2) NEXT:[magic[FAKE_INITIALIZER](b: Int = 3) -> <v2>, r(3) -> <v1>]
r(3) -> <v1>
L2 [after default value for parameter b]:
magic[FAKE_INITIALIZER](b: Int = 3) -> <v2> PREV:[jmp?(L2), r(3) -> <v1>]
merge(b: Int = 3|<v1>, <v2>) -> <v3>
w(b|<v3>)
r(b) -> <v4>
mark(super(b))
call(super(b), <init>|<v4>) -> <v5>
v(val x: Int)
v(var y: Int)
v(val z: Int)
v(val v = -1)
r(1) -> <v6>
mark(-1)
call(-1, minus|<v6>) -> <v7>
w(v|<v7>)
2 mark({ z = 8 })
magic[IMPLICIT_RECEIVER](z) -> <v8>
r(8) -> <v9>
w(z|<v8>, <v9>)
mark({ y = 9 })
magic[IMPLICIT_RECEIVER](y) -> <v11>
r(9) -> <v12>
w(y|<v11>, <v12>)
mark({ x = a y = x })
magic[IMPLICIT_RECEIVER](x) -> <v14>
r(a) -> <v15>
w(x|<v14>, <v15>)
magic[IMPLICIT_RECEIVER](y) -> <v16>
magic[IMPLICIT_RECEIVER](x) -> <v17>
r(x|<v17>) -> <v18>
w(y|<v16>, <v18>)
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== <init> ==
constructor(a: String, b: Int = 4): this() {
y = 5
}
---------------------
L0:
1 <START>
v(a: String)
magic[FAKE_INITIALIZER](a: String) -> <v0>
w(a|<v0>)
v(b: Int = 4)
jmp?(L2) NEXT:[magic[FAKE_INITIALIZER](b: Int = 4) -> <v2>, r(4) -> <v1>]
r(4) -> <v1>
L2 [after default value for parameter b]:
magic[FAKE_INITIALIZER](b: Int = 4) -> <v2> PREV:[jmp?(L2), r(4) -> <v1>]
merge(b: Int = 4|<v1>, <v2>) -> <v3>
w(b|<v3>)
mark(this())
call(this(), <init>) -> <v4>
2 mark({ y = 5 })
magic[IMPLICIT_RECEIVER](y) -> <v5>
r(5) -> <v6>
w(y|<v5>, <v6>)
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== <init> ==
constructor(a: Double, b: Int = 6): this(a.toInt()) {
y = 7
}
---------------------
L0:
1 <START>
v(a: Double)
magic[FAKE_INITIALIZER](a: Double) -> <v0>
w(a|<v0>)
v(b: Int = 6)
jmp?(L2) NEXT:[magic[FAKE_INITIALIZER](b: Int = 6) -> <v2>, r(6) -> <v1>]
r(6) -> <v1>
L2 [after default value for parameter b]:
magic[FAKE_INITIALIZER](b: Int = 6) -> <v2> PREV:[jmp?(L2), r(6) -> <v1>]
merge(b: Int = 6|<v1>, <v2>) -> <v3>
w(b|<v3>)
mark(a.toInt())
r(a) -> <v4>
mark(toInt())
call(toInt(), toInt|<v4>) -> <v5>
mark(this(a.toInt()))
call(this(a.toInt()), <init>|<v5>) -> <v6>
2 mark({ y = 7 })
magic[IMPLICIT_RECEIVER](y) -> <v7>
r(7) -> <v8>
w(y|<v7>, <v8>)
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
@@ -0,0 +1,33 @@
open class B(x: Int)
class A : B {
val x: Int
var y: Int
val z: Int
val v = -1
constructor(): super(11) {
x = 1
y = 2
}
constructor(a: Int, b: Int = 3): super(b) {
x = a
y = x
}
// anonymous
init {
z = 8
}
constructor(a: String, b: Int = 4): this() {
y = 5
}
constructor(a: Double, b: Int = 6): this(a.toInt()) {
y = 7
}
// anonymous
init {
y = 9
}
}
@@ -0,0 +1,112 @@
== B ==
open class B(x: Int)
---------------------
<v0>: Int NEW: magic[FAKE_INITIALIZER](x: Int) -> <v0>
=====================
== A ==
class A : B {
val x: Int
var y: Int
val z: Int
val v = -1
constructor(): super(11) {
x = 1
y = 2
}
constructor(a: Int, b: Int = 3): super(b) {
x = a
y = x
}
// anonymous
init {
z = 8
}
constructor(a: String, b: Int = 4): this() {
y = 5
}
constructor(a: Double, b: Int = 6): this(a.toInt()) {
y = 7
}
// anonymous
init {
y = 9
}
}
---------------------
=====================
== <init> ==
constructor(): super(11) {
x = 1
y = 2
}
---------------------
<v10>: A NEW: magic[IMPLICIT_RECEIVER](x) -> <v10>
<v12>: A NEW: magic[IMPLICIT_RECEIVER](y) -> <v12>
<v4>: A NEW: magic[IMPLICIT_RECEIVER](z) -> <v4>
<v7>: A NEW: magic[IMPLICIT_RECEIVER](y) -> <v7>
11 <v0>: Int NEW: r(11) -> <v0>
super(11) <v1>: * NEW: call(super(11), <init>|<v0>) -> <v1>
1 <v11>: Int NEW: r(1) -> <v11>
2 <v13>: Int NEW: r(2) -> <v13>
y = 2 !<v14>: *
{ x = 1 y = 2 } !<v14>: * COPY
=====================
== <init> ==
constructor(a: Int, b: Int = 3): super(b) {
x = a
y = x
}
---------------------
<v0>: Int NEW: magic[FAKE_INITIALIZER](a: Int) -> <v0>
<v11>: A NEW: magic[IMPLICIT_RECEIVER](y) -> <v11>
<v14>: A NEW: magic[IMPLICIT_RECEIVER](x) -> <v14>
<v16>: A NEW: magic[IMPLICIT_RECEIVER](y) -> <v16>
<v17>: A NEW: magic[IMPLICIT_RECEIVER](x) -> <v17>
<v2>: Int NEW: magic[FAKE_INITIALIZER](b: Int = 3) -> <v2>
<v8>: A NEW: magic[IMPLICIT_RECEIVER](z) -> <v8>
3 <v1>: Int NEW: r(3) -> <v1>
b: Int = 3 <v3>: Int NEW: merge(b: Int = 3|<v1>, <v2>) -> <v3>
b <v4>: Int NEW: r(b) -> <v4>
super(b) <v5>: * NEW: call(super(b), <init>|<v4>) -> <v5>
a <v15>: Int NEW: r(a) -> <v15>
x <v18>: Int NEW: r(x|<v17>) -> <v18>
y = x !<v19>: *
{ x = a y = x } !<v19>: * COPY
=====================
== <init> ==
constructor(a: String, b: Int = 4): this() {
y = 5
}
---------------------
<v0>: String NEW: magic[FAKE_INITIALIZER](a: String) -> <v0>
<v2>: Int NEW: magic[FAKE_INITIALIZER](b: Int = 4) -> <v2>
<v5>: A NEW: magic[IMPLICIT_RECEIVER](y) -> <v5>
4 <v1>: Int NEW: r(4) -> <v1>
b: Int = 4 <v3>: Int NEW: merge(b: Int = 4|<v1>, <v2>) -> <v3>
this() <v4>: * NEW: call(this(), <init>) -> <v4>
5 <v6>: Int NEW: r(5) -> <v6>
y = 5 !<v7>: *
{ y = 5 } !<v7>: * COPY
=====================
== <init> ==
constructor(a: Double, b: Int = 6): this(a.toInt()) {
y = 7
}
---------------------
<v0>: Double NEW: magic[FAKE_INITIALIZER](a: Double) -> <v0>
<v2>: Int NEW: magic[FAKE_INITIALIZER](b: Int = 6) -> <v2>
<v7>: A NEW: magic[IMPLICIT_RECEIVER](y) -> <v7>
6 <v1>: Int NEW: r(6) -> <v1>
b: Int = 6 <v3>: Int NEW: merge(b: Int = 6|<v1>, <v2>) -> <v3>
a <v4>: {<: Number} NEW: r(a) -> <v4>
toInt() <v5>: Int NEW: call(toInt(), toInt|<v4>) -> <v5>
a.toInt() <v5>: Int COPY
this(a.toInt()) <v6>: * NEW: call(this(a.toInt()), <init>|<v5>) -> <v6>
7 <v8>: Int NEW: r(7) -> <v8>
y = 7 !<v9>: *
{ y = 7 } !<v9>: * COPY
=====================
@@ -0,0 +1,19 @@
package
internal final class A {
public constructor A()
public constructor A(/*0*/ w: kotlin.Char)
public constructor A(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int = ...)
internal final val overinitialized: kotlin.Int
internal final val uninitialized: kotlin.Int
internal final val useInitialized: kotlin.Int
internal final val useUnitialized: kotlin.Int
internal final val v: kotlin.Int = -1
internal final val w: kotlin.Char
internal final val x: kotlin.Int
internal final var y: kotlin.Int
internal final val z: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,20 @@
package
internal final class A {
public constructor A()
public constructor A(/*0*/ a: kotlin.Double, /*1*/ b: kotlin.Int = ...)
public constructor A(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int = ...)
public constructor A(/*0*/ x: kotlin.String)
public constructor A(/*0*/ a: kotlin.String, /*1*/ b: kotlin.Int = ...)
internal final val overinitialized: kotlin.Int
internal final val uninitialized: kotlin.Int
internal final val useInitialized: kotlin.Int
internal final val useUnitialized: kotlin.Int
internal final val v: kotlin.Int = -1
internal final val x: kotlin.Int
internal final var y: kotlin.Int
internal final val z: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,33 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A(val w: Char) {
val x: Int
var y: Int
val z: Int
val v = -1
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>val uninitialized: Int<!>
val overinitialized: Int
constructor(): this('a') {
y = 1
<!VAL_REASSIGNMENT!>overinitialized<!> = 2
<!VAL_REASSIGNMENT!>uninitialized<!> = 3
}
// anonymous
init {
x = 4
z = 5
overinitialized = 6
}
constructor(a: Int): this('b') {
y = 7
}
// anonymous
init {
y = 8
}
}
@@ -0,0 +1,17 @@
package
internal final class A {
public constructor A()
public constructor A(/*0*/ w: kotlin.Char)
public constructor A(/*0*/ a: kotlin.Int)
internal final val overinitialized: kotlin.Int
internal final val uninitialized: kotlin.Int
internal final val v: kotlin.Int = -1
internal final val w: kotlin.Char
internal final val x: kotlin.Int
internal final var y: kotlin.Int
internal final val z: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,39 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A {
val x: Int
var y: Int
val z: Int
val v = -1
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>val uninitialized: Int<!>
val overinitialized: Int
constructor() {
x = 1
y = 2
<!VAL_REASSIGNMENT!>overinitialized<!> = 3
uninitialized = 4
}
constructor(a: Int): super() {
x = 5
y = 6
}
constructor(x: String): this() {
y = 7
<!VAL_REASSIGNMENT!>uninitialized<!> = 8
}
//anonymous
init {
z = 9
overinitialized = 10
}
// anonymous
init {
y = 12
}
}
@@ -0,0 +1,16 @@
package
internal final class A {
public constructor A()
public constructor A(/*0*/ a: kotlin.Int)
public constructor A(/*0*/ x: kotlin.String)
internal final val overinitialized: kotlin.Int
internal final val uninitialized: kotlin.Int
internal final val v: kotlin.Int = -1
internal final val x: kotlin.Int
internal final var y: kotlin.Int
internal final val z: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -1,17 +1,16 @@
class A {
init {
<!RETURN_NOT_ALLOWED!>return<!>
<!RETURN_NOT_ALLOWED!>return 1<!>
<!RETURN_NOT_ALLOWED, UNREACHABLE_CODE!>return 1<!>
}
constructor() {
constructor() <!UNREACHABLE_CODE!>{
if (1 == 1) {
return
return <!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>
}
return
return <!TYPE_MISMATCH!>foo()<!>
}
}<!>
fun foo(): Int = 1
}
@@ -0,0 +1,38 @@
class A0 {
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>val x: Int<!>
constructor() {
if (1 == 1) {
return
}
x = 1
}
constructor(arg: Int) {
x = arg
}
}
class A1 {
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>val x: Int<!>
constructor() {
if (1 == 1) {
return
} else null!!
<!UNREACHABLE_CODE!>x = 1<!>
}
}
class A2 {
val x: Int
constructor() {
if (1 == 1) {
x = 1
return
}
else {
x = 2
}
}
constructor(arg: Int) {
x = arg
}
}
@@ -0,0 +1,27 @@
package
internal final class A0 {
public constructor A0()
public constructor A0(/*0*/ arg: kotlin.Int)
internal final val x: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
internal final class A1 {
public constructor A1()
internal final val x: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
internal final class A2 {
public constructor A2()
public constructor A2(/*0*/ arg: kotlin.Int)
internal final val x: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,30 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A(val w: Int) {
val x: Int
val useUnitialized = <!UNINITIALIZED_VARIABLE!>x<!> +
<!UNINITIALIZED_VARIABLE!>y<!> +
<!UNINITIALIZED_VARIABLE!>v<!>
var y: Int
val v = -1
val useInitialized = useUnitialized + v + w
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>val uninitialized: Int<!>
constructor(): this(1) {
x + y + v + uninitialized + w
}
// anonymous
init {
<!UNINITIALIZED_VARIABLE!>x<!> + <!UNINITIALIZED_VARIABLE!>y<!> + v + <!UNINITIALIZED_VARIABLE!>uninitialized<!> + w
x = 1
x + <!UNINITIALIZED_VARIABLE!>y<!> + v + <!UNINITIALIZED_VARIABLE!>uninitialized<!> + w
}
// anonymous
init {
x + <!UNINITIALIZED_VARIABLE!>y<!> + v + <!UNINITIALIZED_VARIABLE!>uninitialized<!> + w
y = 7
x + y + v + <!UNINITIALIZED_VARIABLE!>uninitialized<!> + w
}
}
@@ -0,0 +1,16 @@
package
internal final class A {
public constructor A()
public constructor A(/*0*/ w: kotlin.Int)
internal final val uninitialized: kotlin.Int
internal final val useInitialized: kotlin.Int
internal final val useUnitialized: kotlin.Int
internal final val v: kotlin.Int = -1
internal final val w: kotlin.Int
internal final val x: kotlin.Int
internal final var y: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,46 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A {
val x: Int
val useUnitialized = <!UNINITIALIZED_VARIABLE, UNINITIALIZED_VARIABLE!>x<!> + // reported on each secondary constructor
<!UNINITIALIZED_VARIABLE, UNINITIALIZED_VARIABLE!>y<!> +
<!UNINITIALIZED_VARIABLE, UNINITIALIZED_VARIABLE!>v<!>
var y: Int
val v = -1
val useInitialized = useUnitialized + v
<!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>val uninitialized: Int<!>
constructor() {
x = 1
y = 2
x + y + v + <!UNINITIALIZED_VARIABLE!>uninitialized<!>
uninitialized = 3
x + y + v + uninitialized
}
constructor(a: Int): super() {
<!UNINITIALIZED_VARIABLE!>x<!> + y + v + <!UNINITIALIZED_VARIABLE!>uninitialized<!>
x = 4
y = 5
x + y + v + <!UNINITIALIZED_VARIABLE!>uninitialized<!>
}
constructor(x: String): this() {
x + y + v + uninitialized
}
//anonymous
init {
<!UNINITIALIZED_VARIABLE, UNINITIALIZED_VARIABLE!>y<!>
}
// anonymous
init {
y = 9
}
}
@@ -0,0 +1,16 @@
package
internal final class A {
public constructor A()
public constructor A(/*0*/ a: kotlin.Int)
public constructor A(/*0*/ x: kotlin.String)
internal final val uninitialized: kotlin.Int
internal final val useInitialized: kotlin.Int
internal final val useUnitialized: kotlin.Int
internal final val v: kotlin.Int = -1
internal final val x: kotlin.Int
internal final var y: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -63,7 +63,7 @@ public abstract class AbstractPseudocodeTest extends KotlinTestWithEnvironment {
if (declaration instanceof JetDeclarationContainer) {
for (JetDeclaration member : ((JetDeclarationContainer) declaration).getDeclarations()) {
// Properties and initializers are processed elsewhere
if (member instanceof JetNamedFunction) {
if (member instanceof JetNamedFunction || member instanceof JetSecondaryConstructor) {
addDeclaration(data, bindingContext, member);
}
}
@@ -40,6 +40,7 @@ import java.util.regex.Pattern;
ControlFlowTestGenerated.Declarations.class,
ControlFlowTestGenerated.Expressions.class,
ControlFlowTestGenerated.Functions.class,
ControlFlowTestGenerated.SecondaryConstructors.class,
ControlFlowTestGenerated.TailCalls.class,
})
@RunWith(JUnit3RunnerWithInners.class)
@@ -611,6 +612,45 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest {
}
}
@TestMetadata("compiler/testData/cfg/secondaryConstructors")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class SecondaryConstructors extends AbstractControlFlowTest {
public void testAllFilesPresentInSecondaryConstructors() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/cfg/secondaryConstructors"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("withPrimary.kt")
public void testWithPrimary() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cfg/secondaryConstructors/withPrimary.kt");
doTest(fileName);
}
@TestMetadata("withPrimarySuper.kt")
public void testWithPrimarySuper() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cfg/secondaryConstructors/withPrimarySuper.kt");
doTest(fileName);
}
@TestMetadata("withReturn.kt")
public void testWithReturn() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cfg/secondaryConstructors/withReturn.kt");
doTest(fileName);
}
@TestMetadata("withoutPrimary.kt")
public void testWithoutPrimary() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cfg/secondaryConstructors/withoutPrimary.kt");
doTest(fileName);
}
@TestMetadata("withoutPrimarySuper.kt")
public void testWithoutPrimarySuper() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cfg/secondaryConstructors/withoutPrimarySuper.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/cfg/tailCalls")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -46,6 +46,7 @@ public class PseudoValueTestGenerated extends AbstractPseudoValueTest {
Cfg.Declarations.class,
Cfg.Expressions.class,
Cfg.Functions.class,
Cfg.SecondaryConstructors.class,
Cfg.TailCalls.class,
})
@RunWith(JUnit3RunnerWithInners.class)
@@ -617,6 +618,45 @@ public class PseudoValueTestGenerated extends AbstractPseudoValueTest {
}
}
@TestMetadata("compiler/testData/cfg/secondaryConstructors")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class SecondaryConstructors extends AbstractPseudoValueTest {
public void testAllFilesPresentInSecondaryConstructors() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/cfg/secondaryConstructors"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("withPrimary.kt")
public void testWithPrimary() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cfg/secondaryConstructors/withPrimary.kt");
doTest(fileName);
}
@TestMetadata("withPrimarySuper.kt")
public void testWithPrimarySuper() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cfg/secondaryConstructors/withPrimarySuper.kt");
doTest(fileName);
}
@TestMetadata("withReturn.kt")
public void testWithReturn() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cfg/secondaryConstructors/withReturn.kt");
doTest(fileName);
}
@TestMetadata("withoutPrimary.kt")
public void testWithoutPrimary() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cfg/secondaryConstructors/withoutPrimary.kt");
doTest(fileName);
}
@TestMetadata("withoutPrimarySuper.kt")
public void testWithoutPrimarySuper() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/cfg/secondaryConstructors/withoutPrimarySuper.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/cfg/tailCalls")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -10439,6 +10439,18 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("propertyInitializationWithPrimary.kt")
public void testPropertyInitializationWithPrimary() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/secondaryConstructors/propertyInitializationWithPrimary.kt");
doTest(fileName);
}
@TestMetadata("propertyInitializationWithoutPrimary.kt")
public void testPropertyInitializationWithoutPrimary() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/secondaryConstructors/propertyInitializationWithoutPrimary.kt");
doTest(fileName);
}
@TestMetadata("return.kt")
public void testReturn() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/secondaryConstructors/return.kt");
@@ -10463,6 +10475,24 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("unreachableCode.kt")
public void testUnreachableCode() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/secondaryConstructors/unreachableCode.kt");
doTest(fileName);
}
@TestMetadata("useOfPropertiesWithPrimary.kt")
public void testUseOfPropertiesWithPrimary() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/secondaryConstructors/useOfPropertiesWithPrimary.kt");
doTest(fileName);
}
@TestMetadata("useOfPropertiesWithoutPrimary.kt")
public void testUseOfPropertiesWithoutPrimary() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/secondaryConstructors/useOfPropertiesWithoutPrimary.kt");
doTest(fileName);
}
@TestMetadata("varargsInDelegationCallToPrimary.kt")
public void testVarargsInDelegationCallToPrimary() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/secondaryConstructors/varargsInDelegationCallToPrimary.kt");