diff --git a/compiler/visualizer/testData/uncommonCases/resultFiles/dataClass.kt b/compiler/visualizer/testData/uncommonCases/resultFiles/dataClass.kt new file mode 100644 index 00000000000..d40b485366b --- /dev/null +++ b/compiler/visualizer/testData/uncommonCases/resultFiles/dataClass.kt @@ -0,0 +1,55 @@ +data class Vector(val x: Int, val y: Int) { +// Vector +// │ constructor Vector(Int, Int) +// │ │ val (Vector).x: Int +// │ │ │ fun (Int).plus(Int): Int +// │ │ │ │ Vector.plus.other: Vector +// │ │ │ │ │ val (Vector).x: Int +// │ │ │ │ │ │ val (Vector).y: Int +// │ │ │ │ │ │ │ fun (Int).plus(Int): Int +// │ │ │ │ │ │ │ │ Vector.plus.other: Vector +// │ │ │ │ │ │ │ │ │ val (Vector).y: Int +// │ │ │ │ │ │ │ │ │ │ + fun plus(other: Vector): Vector = Vector(x + other.x, y + other.y) +} + +fun main() { +// Vector +// │ constructor Vector(Int, Int) +// │ │ Int +// │ │ │ Int +// │ │ │ │ + val a = Vector(1, 2) +// Vector +// │ constructor Vector(Int, Int) +// │ │ fun (Int).unaryMinus(): Int +// │ │ │Int +// │ │ ││ Int +// │ │ ││ │ + val b = Vector(-1, 10) + +// fun io/println(Any?): Unit +// │ val main.a: Vector +// │ │ val main.b: Vector +// │ │ │ fun (Vector).toString(): String +// │ │ │ │ + println("a = $a, b = ${b.toString()}") +// fun io/println(Any?): Unit +// │ fun (String).plus(Any?): String +// │ │ val main.a: Vector +// │ │ │ fun (Vector).plus(Vector): Vector +// │ │ │ │ val main.b: Vector +// │ │ │ │ │ + println("a + b = " + (a + b)) +// fun io/println(Any?): Unit +// │ val main.a: Vector +// │ │ fun (Vector).hashCode(): Int +// │ │ │ + println("a hash - ${a.hashCode()}") + +// val main.a: Vector +// │ fun (Vector).equals(Any?): Boolean +// fun io/println(Any?): Unit │ │ val main.b: Vector +// │ │ │ │ + println("a is equal to b ${a.equals(b)}") +} diff --git a/compiler/visualizer/testData/uncommonCases/resultFiles/delegation.kt b/compiler/visualizer/testData/uncommonCases/resultFiles/delegation.kt new file mode 100644 index 00000000000..b9e3ca590ae --- /dev/null +++ b/compiler/visualizer/testData/uncommonCases/resultFiles/delegation.kt @@ -0,0 +1,41 @@ +interface Base { + fun printMessage() + fun printMessageLine() +} + +class BaseImpl(val x: Int) : Base { +// fun io/print(Int): Unit +// │ val (BaseImpl).x: Int +// │ │ + override fun printMessage() { print(x) } +// fun io/println(Int): Unit +// │ val (BaseImpl).x: Int +// │ │ + override fun printMessageLine() { println(x) } +} + +// Derived..b: Base +// │ +class Derived(b: Base) : Base by b { +// fun io/print(Any?): Unit +// │ + override fun printMessage() { print("abc") } +} + +fun main() { +// BaseImpl +// │ constructor BaseImpl(Int) +// │ │ Int +// │ │ │ + val b = BaseImpl(10) +// constructor Derived(Base) +// │ val main.b: BaseImpl +// │ │ fun (Derived).printMessage(): Unit +// │ │ │ + Derived(b).printMessage() +// constructor Derived(Base) +// │ val main.b: BaseImpl +// │ │ fun (Derived).printMessageLine(): Unit +// │ │ │ + Derived(b).printMessageLine() +} diff --git a/compiler/visualizer/testData/uncommonCases/resultFiles/receiver.kt b/compiler/visualizer/testData/uncommonCases/resultFiles/receiver.kt new file mode 100644 index 00000000000..814d2e58704 --- /dev/null +++ b/compiler/visualizer/testData/uncommonCases/resultFiles/receiver.kt @@ -0,0 +1,27 @@ +fun Int.addOne(): Int { +// fun (Int).plus(Int): Int +// │ Int +// │ │ + return this + 1 +} + +// Int +// │ +val Int.repeat: Int + get() = this + +fun main() { +// Int Int +// │ │ + val i = 2 +// val main.i: Int +// │ fun Int.addOne(): Int +// │ │ + i.addOne() +// val main.i: Int +// │ val Int.repeat: Int +// │ │ fun (Int).times(Int): Int +// Int │ │ │ Int +// │ │ │ │ │ + val p = i.repeat * 2 +} \ No newline at end of file diff --git a/compiler/visualizer/testData/uncommonCases/testFiles/dataClass.kt b/compiler/visualizer/testData/uncommonCases/testFiles/dataClass.kt new file mode 100644 index 00000000000..21ef0517b0c --- /dev/null +++ b/compiler/visualizer/testData/uncommonCases/testFiles/dataClass.kt @@ -0,0 +1,14 @@ +data class Vector(val x: Int, val y: Int) { + fun plus(other: Vector): Vector = Vector(x + other.x, y + other.y) +} + +fun main() { + val a = Vector(1, 2) + val b = Vector(-1, 10) + + println("a = $a, b = ${b.toString()}") + println("a + b = " + (a + b)) + println("a hash - ${a.hashCode()}") + + println("a is equal to b ${a.equals(b)}") +} \ No newline at end of file diff --git a/compiler/visualizer/testData/uncommonCases/testFiles/delegation.kt b/compiler/visualizer/testData/uncommonCases/testFiles/delegation.kt new file mode 100644 index 00000000000..dbd26e638c9 --- /dev/null +++ b/compiler/visualizer/testData/uncommonCases/testFiles/delegation.kt @@ -0,0 +1,19 @@ +interface Base { + fun printMessage() + fun printMessageLine() +} + +class BaseImpl(val x: Int) : Base { + override fun printMessage() { print(x) } + override fun printMessageLine() { println(x) } +} + +class Derived(b: Base) : Base by b { + override fun printMessage() { print("abc") } +} + +fun main() { + val b = BaseImpl(10) + Derived(b).printMessage() + Derived(b).printMessageLine() +} \ No newline at end of file diff --git a/compiler/visualizer/testData/uncommonCases/testFiles/receiver.kt b/compiler/visualizer/testData/uncommonCases/testFiles/receiver.kt new file mode 100644 index 00000000000..1e90618325c --- /dev/null +++ b/compiler/visualizer/testData/uncommonCases/testFiles/receiver.kt @@ -0,0 +1,12 @@ +fun Int.addOne(): Int { + return this + 1 +} + +val Int.repeat: Int + get() = this + +fun main() { + val i = 2 + i.addOne() + val p = i.repeat * 2 +} \ No newline at end of file diff --git a/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/fir/FirVisualizerForUncommonCasesGenerated.java b/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/fir/FirVisualizerForUncommonCasesGenerated.java index b07ac39f885..915c8a03039 100644 --- a/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/fir/FirVisualizerForUncommonCasesGenerated.java +++ b/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/fir/FirVisualizerForUncommonCasesGenerated.java @@ -29,6 +29,16 @@ public class FirVisualizerForUncommonCasesGenerated extends AbstractFirVisualize KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/visualizer/testData/uncommonCases/testFiles"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } + @TestMetadata("dataClass.kt") + public void testDataClass() throws Exception { + runTest("compiler/visualizer/testData/uncommonCases/testFiles/dataClass.kt"); + } + + @TestMetadata("delegation.kt") + public void testDelegation() throws Exception { + runTest("compiler/visualizer/testData/uncommonCases/testFiles/delegation.kt"); + } + @TestMetadata("innerWith.kt") public void testInnerWith() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/innerWith.kt"); @@ -44,6 +54,11 @@ public class FirVisualizerForUncommonCasesGenerated extends AbstractFirVisualize runTest("compiler/visualizer/testData/uncommonCases/testFiles/properties.kt"); } + @TestMetadata("receiver.kt") + public void testReceiver() throws Exception { + runTest("compiler/visualizer/testData/uncommonCases/testFiles/receiver.kt"); + } + @TestMetadata("superTypes.kt") public void testSuperTypes() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/superTypes.kt"); diff --git a/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/psi/PsiVisualizerForUncommonCasesGenerated.java b/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/psi/PsiVisualizerForUncommonCasesGenerated.java index 3ed79bfc053..866e672c46b 100644 --- a/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/psi/PsiVisualizerForUncommonCasesGenerated.java +++ b/compiler/visualizer/tests/org/jetbrains/kotlin/visualizer/psi/PsiVisualizerForUncommonCasesGenerated.java @@ -29,6 +29,16 @@ public class PsiVisualizerForUncommonCasesGenerated extends AbstractPsiVisualize KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/visualizer/testData/uncommonCases/testFiles"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } + @TestMetadata("dataClass.kt") + public void testDataClass() throws Exception { + runTest("compiler/visualizer/testData/uncommonCases/testFiles/dataClass.kt"); + } + + @TestMetadata("delegation.kt") + public void testDelegation() throws Exception { + runTest("compiler/visualizer/testData/uncommonCases/testFiles/delegation.kt"); + } + @TestMetadata("innerWith.kt") public void testInnerWith() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/innerWith.kt"); @@ -44,6 +54,11 @@ public class PsiVisualizerForUncommonCasesGenerated extends AbstractPsiVisualize runTest("compiler/visualizer/testData/uncommonCases/testFiles/properties.kt"); } + @TestMetadata("receiver.kt") + public void testReceiver() throws Exception { + runTest("compiler/visualizer/testData/uncommonCases/testFiles/receiver.kt"); + } + @TestMetadata("superTypes.kt") public void testSuperTypes() throws Exception { runTest("compiler/visualizer/testData/uncommonCases/testFiles/superTypes.kt");