Uncomment test for KT-921

Minor code improvements
This commit is contained in:
pTalanov
2012-05-05 22:17:19 +04:00
parent 7b30cc3269
commit 9dfca4feb5
4 changed files with 23 additions and 10 deletions
@@ -93,14 +93,18 @@ public class FunctionTest extends AbstractExpressionTest {
fooBoxTest();
}
//TODO: disabled. Probable cause : vars in closures.
public void testKT921() throws Exception {
//public void testKT921() throws Exception {
//
// checkOutput("KT-921.kt", "1,\n" +
// "1, 2,\n" +
// "2, ");
//}
checkOutput("KT-921.kt", "1, end\n" +
"1, 2, end\n" +
"1, 2, 3, end\n" +
"2, 3, end\n" +
"!\n" +
"3, end\n" +
"!\n" +
"end\n" +
"!");
}
public void testFunctionInsideFunction() throws Exception {
fooBoxTest();
@@ -58,7 +58,7 @@ public final class ClassInitializerTranslator extends AbstractTranslator {
@NotNull
public JsPropertyInitializer generateInitializeMethod() {
//TODO: it's inconsistent that we scope for class and function for constructor, currently have problems implementing better way
//TODO: it's inconsistent that we have scope for class and function for constructor, currently have problems implementing better way
ConstructorDescriptor primaryConstructor = getConstructor(bindingContext(), classDeclaration);
JsFunction result = context().getFunctionObject(primaryConstructor);
//NOTE: while we translate constructor parameters we also add property initializer statements
@@ -56,4 +56,13 @@ public final class CallParameters {
public JsExpression getReceiver() {
return receiver;
}
@Nullable
public JsExpression getThisOrReceiverOrNull() {
if (thisObject == null) {
return receiver;
}
assert receiver == null;
return thisObject;
}
}
@@ -130,7 +130,7 @@ public final class CallTranslator extends AbstractTranslator {
private JsExpression intrinsicInvocation() {
assert descriptor instanceof FunctionDescriptor;
Intrinsic intrinsic = context().intrinsics().getFunctionIntrinsic((FunctionDescriptor) descriptor);
return intrinsic.apply(callParameters.getThisObject(), arguments, context());
return intrinsic.apply(callParameters.getThisOrReceiverOrNull(), arguments, context());
}
private boolean isConstructor() {
@@ -244,7 +244,7 @@ public final class CallTranslator extends AbstractTranslator {
}
@Nullable
JsExpression getThisObjectOrQualifier() {
private JsExpression getThisObjectOrQualifier() {
JsExpression thisObject = callParameters.getThisObject();
if (thisObject != null) {
return thisObject;