Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1545,14 +1545,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
Arrays.asList(expression.getLeft(), expression.getRight()), receiver);
|
Arrays.asList(expression.getLeft(), expression.getRight()), receiver);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
|
return invokeOperation(expression, (FunctionDescriptor)op, (CallableMethod) callable);
|
||||||
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());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1928,13 +1921,21 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
Arrays.asList(expression.getBaseExpression()), receiver);
|
Arrays.asList(expression.getBaseExpression()), receiver);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CallableMethod callableMethod = (CallableMethod) callable;
|
return invokeOperation(expression, (FunctionDescriptor) op, (CallableMethod) callable);
|
||||||
genToJVMStack(expression.getBaseExpression());
|
|
||||||
callableMethod.invoke(v);
|
|
||||||
return returnValueAsStackValue((FunctionDescriptor) op, callableMethod.getSignature().getAsmMethod().getReturnType());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
@Override
|
||||||
public StackValue visitPostfixExpression(JetPostfixExpression expression, StackValue receiver) {
|
public StackValue visitPostfixExpression(JetPostfixExpression expression, StackValue receiver) {
|
||||||
DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference());
|
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 {
|
public void testKt475() throws Exception {
|
||||||
blackBoxFile("regressions/kt475.jet");
|
blackBoxFile("regressions/kt475.jet");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testKt865() throws Exception {
|
||||||
|
createEnvironmentWithFullJdk();
|
||||||
|
blackBoxFile("regressions/kt865.jet");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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() {
|
class MoreDryTemplate(var name: String = "James", var time: Date = Date()) : TextTemplate() {
|
||||||
override fun render() {
|
override fun render() {
|
||||||
+"Hey there $name and how are you? Today is $time. Kotlin rocks"
|
+"Hey there $name and how are you? Today is $time. Kotlin rocks"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
class TemplateCoreTest() : TestSupport() {
|
class TemplateCoreTest() : TestSupport() {
|
||||||
fun testDefaultValues() {
|
fun testDefaultValues() {
|
||||||
@@ -41,9 +36,6 @@ class TemplateCoreTest() : TestSupport() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
TODO compile error
|
|
||||||
|
|
||||||
fun testMoreDryTemplate() {
|
fun testMoreDryTemplate() {
|
||||||
val text = MoreDryTemplate("Alex").renderToText()
|
val text = MoreDryTemplate("Alex").renderToText()
|
||||||
assert {
|
assert {
|
||||||
@@ -51,5 +43,4 @@ class TemplateCoreTest() : TestSupport() {
|
|||||||
text.startsWith("Hey there Alex")
|
text.startsWith("Hey there Alex")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user