Merge remote-tracking branch 'origin/master'

This commit is contained in:
James Strachan
2012-01-04 11:49:44 +00:00
4 changed files with 37 additions and 21 deletions
@@ -1545,14 +1545,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
Arrays.asList(expression.getLeft(), expression.getRight()), receiver);
}
else {
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
assert resolvedCall != null;
CallableMethod callableMethod = (CallableMethod) callable;
genThisAndReceiverFromResolvedCall(StackValue.none(), resolvedCall, callableMethod);
pushTypeArguments(resolvedCall);
pushMethodArguments(resolvedCall, callableMethod.getValueParameterTypes());
callableMethod.invoke(v);
return returnValueAsStackValue((FunctionDescriptor) op, callableMethod.getSignature().getAsmMethod().getReturnType());
return invokeOperation(expression, (FunctionDescriptor)op, (CallableMethod) callable);
}
}
}
@@ -1928,13 +1921,21 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
Arrays.asList(expression.getBaseExpression()), receiver);
}
else {
CallableMethod callableMethod = (CallableMethod) callable;
genToJVMStack(expression.getBaseExpression());
callableMethod.invoke(v);
return returnValueAsStackValue((FunctionDescriptor) op, callableMethod.getSignature().getAsmMethod().getReturnType());
return invokeOperation(expression, (FunctionDescriptor) op, (CallableMethod) callable);
}
}
private StackValue invokeOperation(JetOperationExpression expression, FunctionDescriptor op, CallableMethod callable) {
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
assert resolvedCall != null;
CallableMethod callableMethod = (CallableMethod) callable;
genThisAndReceiverFromResolvedCall(StackValue.none(), resolvedCall, callableMethod);
pushTypeArguments(resolvedCall);
pushMethodArguments(resolvedCall, callableMethod.getValueParameterTypes());
callableMethod.invoke(v);
return returnValueAsStackValue((FunctionDescriptor) op, callableMethod.getSignature().getAsmMethod().getReturnType());
}
@Override
public StackValue visitPostfixExpression(JetPostfixExpression expression, StackValue receiver) {
DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference());
@@ -0,0 +1,19 @@
import java.util.*
class Template() {
val collected = LinkedList<String>()
fun String.plus() {
collected.add(this@plus)
}
fun test() {
+ "239"
}
}
fun box() : String {
val u = Template()
u.test()
return if(u.collected.size() == 1 && u.collected.get(0) == "239") "OK" else "fail"
}
@@ -42,4 +42,9 @@ public class ExtensionFunctionsTest extends CodegenTestCase {
public void testKt475() throws Exception {
blackBoxFile("regressions/kt475.jet");
}
public void testKt865() throws Exception {
createEnvironmentWithFullJdk();
blackBoxFile("regressions/kt865.jet");
}
}
-9
View File
@@ -13,16 +13,11 @@ class EmailTemplate(var name: String = "James", var time: Date = Date()) : TextT
}
}
/**
TODO compile error
http://youtrack.jetbrains.net/issue/KT-865
class MoreDryTemplate(var name: String = "James", var time: Date = Date()) : TextTemplate() {
override fun render() {
+"Hey there $name and how are you? Today is $time. Kotlin rocks"
}
}
*/
class TemplateCoreTest() : TestSupport() {
fun testDefaultValues() {
@@ -41,9 +36,6 @@ class TemplateCoreTest() : TestSupport() {
}
}
/*
TODO compile error
fun testMoreDryTemplate() {
val text = MoreDryTemplate("Alex").renderToText()
assert {
@@ -51,5 +43,4 @@ class TemplateCoreTest() : TestSupport() {
text.startsWith("Hey there Alex")
}
}
*/
}