KT-1406 wrong generation of receiver for ext.fun called inside closure
This commit is contained in:
@@ -1246,11 +1246,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
if(resolvedCall == null) {
|
if(resolvedCall == null) {
|
||||||
throw new CompilationException("Cannot resolve: " + callee.getText(), null, expression);
|
throw new CompilationException("Cannot resolve: " + callee.getText(), null, expression);
|
||||||
}
|
}
|
||||||
receiver = StackValue.receiver(resolvedCall, receiver, this, null);
|
|
||||||
|
|
||||||
DeclarationDescriptor funDescriptor = resolvedCall.getResultingDescriptor();
|
DeclarationDescriptor funDescriptor = resolvedCall.getResultingDescriptor();
|
||||||
|
|
||||||
if (funDescriptor instanceof ConstructorDescriptor) {
|
if (funDescriptor instanceof ConstructorDescriptor) {
|
||||||
|
receiver = StackValue.receiver(resolvedCall, receiver, this, null);
|
||||||
return generateConstructorCall(expression, (JetSimpleNameExpression) callee, receiver);
|
return generateConstructorCall(expression, (JetSimpleNameExpression) callee, receiver);
|
||||||
}
|
}
|
||||||
else if (funDescriptor instanceof FunctionDescriptor) {
|
else if (funDescriptor instanceof FunctionDescriptor) {
|
||||||
@@ -1295,6 +1295,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
return returnValueAsStackValue((FunctionDescriptor) fd, callReturnType);
|
return returnValueAsStackValue((FunctionDescriptor) fd, callReturnType);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getCalleeExpression());
|
||||||
|
assert resolvedCall != null;
|
||||||
|
receiver = StackValue.receiver(resolvedCall, receiver, this, null);
|
||||||
|
|
||||||
IntrinsicMethod intrinsic = (IntrinsicMethod) callable;
|
IntrinsicMethod intrinsic = (IntrinsicMethod) callable;
|
||||||
List<JetExpression> args = new ArrayList<JetExpression>();
|
List<JetExpression> args = new ArrayList<JetExpression>();
|
||||||
for (ValueArgument argument : expression.getValueArguments()) {
|
for (ValueArgument argument : expression.getValueArguments()) {
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package pack
|
||||||
|
|
||||||
|
import java.util.Collection
|
||||||
|
import java.util.ArrayList
|
||||||
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
|
class C{
|
||||||
|
public fun foo(){
|
||||||
|
val items : Collection<Item> = java.util.Collections.singleton(Item()).sure()
|
||||||
|
val result = ArrayList<Item>()
|
||||||
|
val pattern: Pattern? = Pattern.compile("...")
|
||||||
|
items.filterTo(result) {
|
||||||
|
pattern.sure().matcher(it.name()).sure().matches()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Item.name() : String = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
class Item{
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box() : String {
|
||||||
|
C().foo()
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -199,6 +199,7 @@ public class PropertyGenTest extends CodegenTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testKt1170() throws Exception {
|
public void testKt1170() throws Exception {
|
||||||
|
createEnvironmentWithFullJdk();
|
||||||
blackBoxFile("regressions/kt1170.kt");
|
blackBoxFile("regressions/kt1170.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -116,4 +116,8 @@ public class StdlibTest extends CodegenTestCase {
|
|||||||
throw t instanceof Exception ? (Exception)t : new RuntimeException(t);
|
throw t instanceof Exception ? (Exception)t : new RuntimeException(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testKt1406() throws Exception {
|
||||||
|
blackBoxFile("regressions/kt1406.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user