Pseudocode: Generate instructions for callable reference expressions
This commit is contained in:
@@ -1414,6 +1414,12 @@ public class JetControlFlowProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitCallableReferenceExpression(@NotNull JetCallableReferenceExpression expression) {
|
||||
mark(expression);
|
||||
createNonSyntheticValue(expression, MagicKind.CALLABLE_REFERENCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitJetElement(@NotNull JetElement element) {
|
||||
builder.unsupported(element);
|
||||
|
||||
+1
@@ -139,6 +139,7 @@ public enum class MagicKind {
|
||||
NOT_NULL_ASSERTION
|
||||
EQUALS_IN_WHEN_CONDITION
|
||||
IS
|
||||
CALLABLE_REFERENCE
|
||||
// implicit operations
|
||||
LOOP_RANGE_ITERATION
|
||||
IMPLICIT_RECEIVER
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
== bar ==
|
||||
fun bar(): Int = 1
|
||||
---------------------
|
||||
L0:
|
||||
1 <START>
|
||||
r(1) -> <v0>
|
||||
ret(*|<v0>) L1
|
||||
L1:
|
||||
<END> NEXT:[<SINK>]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
=====================
|
||||
== foo ==
|
||||
fun foo(): Any = ::bar
|
||||
---------------------
|
||||
L0:
|
||||
1 <START>
|
||||
mark(::bar)
|
||||
magic[CALLABLE_REFERENCE](::bar) -> <v0>
|
||||
ret(*|<v0>) L1
|
||||
L1:
|
||||
<END> NEXT:[<SINK>]
|
||||
error:
|
||||
<ERROR> PREV:[]
|
||||
sink:
|
||||
<SINK> PREV:[<ERROR>, <END>]
|
||||
=====================
|
||||
@@ -0,0 +1,3 @@
|
||||
fun bar(): Int = 1
|
||||
|
||||
fun foo(): Any = ::bar
|
||||
@@ -0,0 +1,10 @@
|
||||
== bar ==
|
||||
fun bar(): Int = 1
|
||||
---------------------
|
||||
1 <v0>: Int NEW: r(1) -> <v0>
|
||||
=====================
|
||||
== foo ==
|
||||
fun foo(): Any = ::bar
|
||||
---------------------
|
||||
::bar <v0>: {<: Any} NEW: magic[CALLABLE_REFERENCE](::bar) -> <v0>
|
||||
=====================
|
||||
@@ -368,6 +368,11 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest {
|
||||
public void testAssignments() throws Exception {
|
||||
doTest("compiler/testData/cfg/expressions/Assignments.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callableReferences.kt")
|
||||
public void testCallableReferences() throws Exception {
|
||||
doTest("compiler/testData/cfg/expressions/callableReferences.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("chainedQualifiedExpression.kt")
|
||||
public void testChainedQualifiedExpression() throws Exception {
|
||||
|
||||
@@ -358,7 +358,9 @@ public class PseudoValueTestGenerated extends AbstractPseudoValueTest {
|
||||
@TestMetadata("compiler/testData/cfg/expressions")
|
||||
public static class Expressions extends AbstractPseudoValueTest {
|
||||
public void testAllFilesPresentInExpressions() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/cfg/expressions"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage",
|
||||
new File("compiler/testData/cfg/expressions"), Pattern.compile("^(.+)\\.kt$"),
|
||||
true);
|
||||
}
|
||||
|
||||
@TestMetadata("assignmentToThis.kt")
|
||||
@@ -370,6 +372,11 @@ public class PseudoValueTestGenerated extends AbstractPseudoValueTest {
|
||||
public void testAssignments() throws Exception {
|
||||
doTest("compiler/testData/cfg/expressions/Assignments.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("callableReferences.kt")
|
||||
public void testCallableReferences() throws Exception {
|
||||
doTest("compiler/testData/cfg/expressions/callableReferences.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("chainedQualifiedExpression.kt")
|
||||
public void testChainedQualifiedExpression() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user