From 4e5438b242e7638a6752b4000cd52b8c869f2b0f Mon Sep 17 00:00:00 2001 From: Jolan Rensen Date: Mon, 25 Mar 2024 21:13:57 +0100 Subject: [PATCH] fixing compiler-plugin tests --- .../runners/DiagnosticTestGenerated.java | 28 ----- .../spark/api/compilerPlugin/GenerateTests.kt | 6 +- .../box/dataClassInFunctionTest.fir.ir.txt | 107 +++++++++++++++++- .../box/dataClassInFunctionTest.fir.txt | 10 ++ .../testData/box/dataClassInFunctionTest.kt | 11 ++ .../testData/box/dataClassTest.fir.ir.txt | 107 +++++++++++++++++- .../testData/box/dataClassTest.fir.txt | 10 ++ .../resources/testData/box/dataClassTest.kt | 11 ++ .../diagnostics/dataClassTest.fir.txt | 66 +++++++++++ 9 files changed, 313 insertions(+), 43 deletions(-) delete mode 100644 compiler-plugin/src/test-gen/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/runners/DiagnosticTestGenerated.java create mode 100644 compiler-plugin/src/test/resources/testData/diagnostics/dataClassTest.fir.txt diff --git a/compiler-plugin/src/test-gen/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/runners/DiagnosticTestGenerated.java b/compiler-plugin/src/test-gen/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/runners/DiagnosticTestGenerated.java deleted file mode 100644 index 566db49b..00000000 --- a/compiler-plugin/src/test-gen/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/runners/DiagnosticTestGenerated.java +++ /dev/null @@ -1,28 +0,0 @@ - - -package org.jetbrains.kotlinx.spark.api.compilerPlugin.runners; - -import com.intellij.testFramework.TestDataPath; -import org.jetbrains.kotlin.test.util.KtTestUtil; -import org.jetbrains.kotlin.test.TestMetadata; -import org.junit.jupiter.api.Test; - -import java.io.File; -import java.util.regex.Pattern; - -/** This class is generated by {@link org.jetbrains.kotlinx.spark.api.compilerPlugin.GenerateTestsKt}. DO NOT MODIFY MANUALLY */ -@SuppressWarnings("all") -@TestMetadata("/mnt/data/Projects/kotlin-spark-api/compiler-plugin/src/test/resources/testData/diagnostics") -@TestDataPath("$PROJECT_ROOT") -public class DiagnosticTestGenerated extends AbstractDiagnosticTest { - @Test - public void testAllFilesPresentInDiagnostics() { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("/mnt/data/Projects/kotlin-spark-api/compiler-plugin/src/test/resources/testData/diagnostics"), Pattern.compile("^(.+)\\.kt$"), null, true); - } - - @Test - @TestMetadata("dataClassTest.kt") - public void testDataClassTest() { - runTest("/mnt/data/Projects/kotlin-spark-api/compiler-plugin/src/test/resources/testData/diagnostics/dataClassTest.kt"); - } -} diff --git a/compiler-plugin/src/test/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/GenerateTests.kt b/compiler-plugin/src/test/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/GenerateTests.kt index 35eda3b4..fb0fde9a 100644 --- a/compiler-plugin/src/test/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/GenerateTests.kt +++ b/compiler-plugin/src/test/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/GenerateTests.kt @@ -11,9 +11,9 @@ fun main() { testDataRoot = "${Artifacts.projectRoot}/${Artifacts.compilerPluginArtifactId}/src/test/resources/testData", testsRoot = "${Artifacts.projectRoot}/${Artifacts.compilerPluginArtifactId}/src/test-gen/kotlin", ) { - testClass { - model("diagnostics") - } +// testClass { +// model("diagnostics") +// } testClass { model("box") diff --git a/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.fir.ir.txt b/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.fir.ir.txt index ec43187d..c8c2aa17 100644 --- a/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.fir.ir.txt +++ b/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.fir.ir.txt @@ -49,9 +49,52 @@ FILE fqName:foo.bar fileName:/dataClassInFunctionTest.kt overridden: public open fun toString (): kotlin.String declared in kotlin.Annotation $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:Equals modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.bar.Equals + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:canEqual visibility:public modality:ABSTRACT <> ($this:foo.bar.Equals, that:kotlin.Any?) returnType:kotlin.Boolean + $this: VALUE_PARAMETER name: type:foo.bar.Equals + VALUE_PARAMETER name:that index:0 type:kotlin.Any? + CLASS INTERFACE name:Product modality:ABSTRACT visibility:public superTypes:[foo.bar.Equals] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.bar.Product + FUN FAKE_OVERRIDE name:canEqual visibility:public modality:ABSTRACT <> ($this:foo.bar.Equals, that:kotlin.Any?) returnType:kotlin.Boolean [fake_override] + overridden: + public abstract fun canEqual (that: kotlin.Any?): kotlin.Boolean declared in foo.bar.Equals + $this: VALUE_PARAMETER name: type:foo.bar.Equals + VALUE_PARAMETER name:that index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.bar.Equals + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in foo.bar.Equals + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in foo.bar.Equals + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:productArity visibility:public modality:ABSTRACT <> ($this:foo.bar.Product) returnType:kotlin.Int + $this: VALUE_PARAMETER name: type:foo.bar.Product + FUN name:productElement visibility:public modality:ABSTRACT <> ($this:foo.bar.Product, n:kotlin.Int) returnType:kotlin.Any + $this: VALUE_PARAMETER name: type:foo.bar.Product + VALUE_PARAMETER name:n index:0 type:kotlin.Int FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String BLOCK_BODY - CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any] + CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any; foo.bar.Product] annotations: Sparkify $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.bar.box.User @@ -125,7 +168,7 @@ FILE fqName:foo.bar fileName:/dataClassInFunctionTest.kt CONST Double type=kotlin.Double value=2.0 BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any]' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any; foo.bar.Product]' FUN GENERATED_DATA_CLASS_MEMBER name:component1 visibility:public modality:FINAL <> ($this:foo.bar.box.User) returnType:kotlin.String [operator] $this: VALUE_PARAMETER name: type:foo.bar.box.User BLOCK_BODY @@ -300,6 +343,58 @@ FILE fqName:foo.bar fileName:/dataClassInFunctionTest.kt GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.Double visibility:private [final]' type=kotlin.Double origin=null receiver: GET_VAR ': foo.bar.box.User declared in foo.bar.box.User.toString' type=foo.bar.box.User origin=null CONST String type=kotlin.String value=")" + FUN name:canEqual visibility:public modality:OPEN <> ($this:foo.bar.box.User, that:kotlin.Any?) returnType:kotlin.Boolean + overridden: + public abstract fun canEqual (that: kotlin.Any?): kotlin.Boolean declared in foo.bar.Equals + $this: VALUE_PARAMETER name:$this type:foo.bar.box.User + VALUE_PARAMETER name:that index:0 type:kotlin.Any? + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun canEqual (that: kotlin.Any?): kotlin.Boolean declared in foo.bar.box.User' + TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=foo.bar.box.User + GET_VAR 'that: kotlin.Any? declared in foo.bar.box.User.canEqual' type=kotlin.Any? origin=null + FUN name:productArity visibility:public modality:OPEN <> ($this:foo.bar.box.User) returnType:kotlin.Int + overridden: + public abstract fun productArity (): kotlin.Int declared in foo.bar.Product + $this: VALUE_PARAMETER name:$this type:foo.bar.box.User + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun productArity (): kotlin.Int declared in foo.bar.box.User' + CONST Int type=kotlin.Int value=4 + FUN name:productElement visibility:public modality:OPEN <> ($this:foo.bar.box.User, n:kotlin.Int) returnType:kotlin.Any? + overridden: + public abstract fun productElement (n: kotlin.Int): kotlin.Any declared in foo.bar.Product + $this: VALUE_PARAMETER name:$this type:foo.bar.box.User + VALUE_PARAMETER name:n index:0 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun productElement (n: kotlin.Int): kotlin.Any? declared in foo.bar.box.User' + WHEN type=kotlin.Any? origin=IF + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'n: kotlin.Int declared in foo.bar.box.User.productElement' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=0 + then: CALL 'public final fun (): kotlin.String declared in foo.bar.box.User' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR '$this: foo.bar.box.User declared in foo.bar.box.User.productElement' type=foo.bar.box.User origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'n: kotlin.Int declared in foo.bar.box.User.productElement' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: CALL 'public final fun (): kotlin.Int declared in foo.bar.box.User' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '$this: foo.bar.box.User declared in foo.bar.box.User.productElement' type=foo.bar.box.User origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'n: kotlin.Int declared in foo.bar.box.User.productElement' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: CALL 'public final fun (): kotlin.Double declared in foo.bar.box.User' type=kotlin.Double origin=GET_PROPERTY + $this: GET_VAR '$this: foo.bar.box.User declared in foo.bar.box.User.productElement' type=foo.bar.box.User origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'n: kotlin.Int declared in foo.bar.box.User.productElement' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=3 + then: CALL 'public final fun (): kotlin.Double declared in foo.bar.box.User' type=kotlin.Double origin=GET_PROPERTY + $this: GET_VAR '$this: foo.bar.box.User declared in foo.bar.box.User.productElement' type=foo.bar.box.User origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: THROW type=kotlin.Nothing + CONSTRUCTOR_CALL 'public constructor () declared in java.lang.IndexOutOfBoundsException' type=java.lang.IndexOutOfBoundsException origin=null VAR name:user type:foo.bar.box.User [val] CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, age: kotlin.Int, test: kotlin.Double, test2: kotlin.Double) declared in foo.bar.box.User' type=foo.bar.box.User origin=null VAR name:name type:@[FlexibleNullability] kotlin.Any? [val] @@ -307,7 +402,7 @@ FILE fqName:foo.bar fileName:/dataClassInFunctionTest.kt $this: CALL 'public open fun getMethod (p0: @[FlexibleNullability] kotlin.String?, vararg p1: @[FlexibleNullability] java.lang.Class<*>?): @[FlexibleNullability] java.lang.reflect.Method? declared in java.lang.Class' type=@[FlexibleNullability] java.lang.reflect.Method? origin=null $this: CALL 'public final fun (): java.lang.Class> declared in kotlin.jvm' type=java.lang.Class origin=GET_PROPERTY : foo.bar.box.User - $receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any]' type=kotlin.reflect.KClass + $receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any; foo.bar.Product]' type=kotlin.reflect.KClass p0: CONST String type=kotlin.String value="name" p0: GET_VAR 'val user: foo.bar.box.User declared in foo.bar.box' type=foo.bar.box.User origin=null VAR name:age type:@[FlexibleNullability] kotlin.Any? [val] @@ -315,7 +410,7 @@ FILE fqName:foo.bar fileName:/dataClassInFunctionTest.kt $this: CALL 'public open fun getMethod (p0: @[FlexibleNullability] kotlin.String?, vararg p1: @[FlexibleNullability] java.lang.Class<*>?): @[FlexibleNullability] java.lang.reflect.Method? declared in java.lang.Class' type=@[FlexibleNullability] java.lang.reflect.Method? origin=null $this: CALL 'public final fun (): java.lang.Class> declared in kotlin.jvm' type=java.lang.Class origin=GET_PROPERTY : foo.bar.box.User - $receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any]' type=kotlin.reflect.KClass + $receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any; foo.bar.Product]' type=kotlin.reflect.KClass p0: CONST String type=kotlin.String value="age" p0: GET_VAR 'val user: foo.bar.box.User declared in foo.bar.box' type=foo.bar.box.User origin=null VAR name:a type:@[FlexibleNullability] kotlin.Any? [val] @@ -323,7 +418,7 @@ FILE fqName:foo.bar fileName:/dataClassInFunctionTest.kt $this: CALL 'public open fun getMethod (p0: @[FlexibleNullability] kotlin.String?, vararg p1: @[FlexibleNullability] java.lang.Class<*>?): @[FlexibleNullability] java.lang.reflect.Method? declared in java.lang.Class' type=@[FlexibleNullability] java.lang.reflect.Method? origin=null $this: CALL 'public final fun (): java.lang.Class> declared in kotlin.jvm' type=java.lang.Class origin=GET_PROPERTY : foo.bar.box.User - $receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any]' type=kotlin.reflect.KClass + $receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any; foo.bar.Product]' type=kotlin.reflect.KClass p0: CONST String type=kotlin.String value="a" p0: GET_VAR 'val user: foo.bar.box.User declared in foo.bar.box' type=foo.bar.box.User origin=null VAR name:b type:@[FlexibleNullability] kotlin.Any? [val] @@ -331,7 +426,7 @@ FILE fqName:foo.bar fileName:/dataClassInFunctionTest.kt $this: CALL 'public open fun getMethod (p0: @[FlexibleNullability] kotlin.String?, vararg p1: @[FlexibleNullability] java.lang.Class<*>?): @[FlexibleNullability] java.lang.reflect.Method? declared in java.lang.Class' type=@[FlexibleNullability] java.lang.reflect.Method? origin=null $this: CALL 'public final fun (): java.lang.Class> declared in kotlin.jvm' type=java.lang.Class origin=GET_PROPERTY : foo.bar.box.User - $receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any]' type=kotlin.reflect.KClass + $receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any; foo.bar.Product]' type=kotlin.reflect.KClass p0: CONST String type=kotlin.String value="b" p0: GET_VAR 'val user: foo.bar.box.User declared in foo.bar.box' type=foo.bar.box.User origin=null WHEN type=kotlin.Unit origin=IF diff --git a/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.fir.txt b/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.fir.txt index fdd20f3a..44e5a93f 100644 --- a/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.fir.txt +++ b/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.fir.txt @@ -15,6 +15,16 @@ FILE: dataClassInFunctionTest.kt public final val name: R|kotlin/String| = R|/name| public get(): R|kotlin/String| + } + public abstract interface Equals : R|kotlin/Any| { + public abstract fun canEqual(that: R|kotlin/Any?|): R|kotlin/Boolean| + + } + public abstract interface Product : R|foo/bar/Equals| { + public abstract fun productElement(n: R|kotlin/Int|): R|kotlin/Any| + + public abstract fun productArity(): R|kotlin/Int| + } public final fun box(): R|kotlin/String| { @R|foo/bar/Sparkify|() local final data class User : R|kotlin/Any| { diff --git a/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.kt b/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.kt index 293595aa..bb5bd34d 100644 --- a/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.kt +++ b/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.kt @@ -3,6 +3,17 @@ package foo.bar annotation class Sparkify annotation class ColumnName(val name: String) +// Fake Equals +interface Equals { + fun canEqual(that: Any?): Boolean +} + +// Fake Product +interface Product: Equals { + fun productElement(n: Int): Any + fun productArity(): Int +} + fun box(): String { @Sparkify diff --git a/compiler-plugin/src/test/resources/testData/box/dataClassTest.fir.ir.txt b/compiler-plugin/src/test/resources/testData/box/dataClassTest.fir.ir.txt index 68834cea..842274d2 100644 --- a/compiler-plugin/src/test/resources/testData/box/dataClassTest.fir.ir.txt +++ b/compiler-plugin/src/test/resources/testData/box/dataClassTest.fir.ir.txt @@ -189,7 +189,7 @@ FILE fqName:foo.bar fileName:/dataClassTest.kt GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:age type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null receiver: GET_VAR ': foo.bar.NormalUser declared in foo.bar.NormalUser.toString' type=foo.bar.NormalUser origin=null CONST String type=kotlin.String value=")" - CLASS CLASS name:User modality:FINAL visibility:public [data] superTypes:[kotlin.Any] + CLASS CLASS name:User modality:FINAL visibility:public [data] superTypes:[kotlin.Any; foo.bar.Product] annotations: Sparkify $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.bar.User @@ -263,7 +263,7 @@ FILE fqName:foo.bar fileName:/dataClassTest.kt CONST Double type=kotlin.Double value=2.0 BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:User modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:User modality:FINAL visibility:public [data] superTypes:[kotlin.Any; foo.bar.Product]' FUN GENERATED_DATA_CLASS_MEMBER name:component1 visibility:public modality:FINAL <> ($this:foo.bar.User) returnType:kotlin.String [operator] $this: VALUE_PARAMETER name: type:foo.bar.User BLOCK_BODY @@ -438,6 +438,101 @@ FILE fqName:foo.bar fileName:/dataClassTest.kt GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.Double visibility:private [final]' type=kotlin.Double origin=null receiver: GET_VAR ': foo.bar.User declared in foo.bar.User.toString' type=foo.bar.User origin=null CONST String type=kotlin.String value=")" + FUN name:canEqual visibility:public modality:OPEN <> ($this:foo.bar.User, that:kotlin.Any?) returnType:kotlin.Boolean + overridden: + public abstract fun canEqual (that: kotlin.Any?): kotlin.Boolean declared in foo.bar.Equals + $this: VALUE_PARAMETER name:$this type:foo.bar.User + VALUE_PARAMETER name:that index:0 type:kotlin.Any? + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun canEqual (that: kotlin.Any?): kotlin.Boolean declared in foo.bar.User' + TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=foo.bar.User + GET_VAR 'that: kotlin.Any? declared in foo.bar.User.canEqual' type=kotlin.Any? origin=null + FUN name:productArity visibility:public modality:OPEN <> ($this:foo.bar.User) returnType:kotlin.Int + overridden: + public abstract fun productArity (): kotlin.Int declared in foo.bar.Product + $this: VALUE_PARAMETER name:$this type:foo.bar.User + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun productArity (): kotlin.Int declared in foo.bar.User' + CONST Int type=kotlin.Int value=4 + FUN name:productElement visibility:public modality:OPEN <> ($this:foo.bar.User, n:kotlin.Int) returnType:kotlin.Any? + overridden: + public abstract fun productElement (n: kotlin.Int): kotlin.Any declared in foo.bar.Product + $this: VALUE_PARAMETER name:$this type:foo.bar.User + VALUE_PARAMETER name:n index:0 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun productElement (n: kotlin.Int): kotlin.Any? declared in foo.bar.User' + WHEN type=kotlin.Any? origin=IF + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'n: kotlin.Int declared in foo.bar.User.productElement' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=0 + then: CALL 'public final fun (): kotlin.String declared in foo.bar.User' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR '$this: foo.bar.User declared in foo.bar.User.productElement' type=foo.bar.User origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'n: kotlin.Int declared in foo.bar.User.productElement' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: CALL 'public final fun (): kotlin.Int declared in foo.bar.User' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '$this: foo.bar.User declared in foo.bar.User.productElement' type=foo.bar.User origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'n: kotlin.Int declared in foo.bar.User.productElement' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: CALL 'public final fun (): kotlin.Double declared in foo.bar.User' type=kotlin.Double origin=GET_PROPERTY + $this: GET_VAR '$this: foo.bar.User declared in foo.bar.User.productElement' type=foo.bar.User origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'n: kotlin.Int declared in foo.bar.User.productElement' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=3 + then: CALL 'public final fun (): kotlin.Double declared in foo.bar.User' type=kotlin.Double origin=GET_PROPERTY + $this: GET_VAR '$this: foo.bar.User declared in foo.bar.User.productElement' type=foo.bar.User origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: THROW type=kotlin.Nothing + CONSTRUCTOR_CALL 'public constructor () declared in java.lang.IndexOutOfBoundsException' type=java.lang.IndexOutOfBoundsException origin=null + CLASS INTERFACE name:Equals modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.bar.Equals + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:canEqual visibility:public modality:ABSTRACT <> ($this:foo.bar.Equals, that:kotlin.Any?) returnType:kotlin.Boolean + $this: VALUE_PARAMETER name: type:foo.bar.Equals + VALUE_PARAMETER name:that index:0 type:kotlin.Any? + CLASS INTERFACE name:Product modality:ABSTRACT visibility:public superTypes:[foo.bar.Equals] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.bar.Product + FUN FAKE_OVERRIDE name:canEqual visibility:public modality:ABSTRACT <> ($this:foo.bar.Equals, that:kotlin.Any?) returnType:kotlin.Boolean [fake_override] + overridden: + public abstract fun canEqual (that: kotlin.Any?): kotlin.Boolean declared in foo.bar.Equals + $this: VALUE_PARAMETER name: type:foo.bar.Equals + VALUE_PARAMETER name:that index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.bar.Equals + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in foo.bar.Equals + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in foo.bar.Equals + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:productArity visibility:public modality:ABSTRACT <> ($this:foo.bar.Product) returnType:kotlin.Int + $this: VALUE_PARAMETER name: type:foo.bar.Product + FUN name:productElement visibility:public modality:ABSTRACT <> ($this:foo.bar.Product, n:kotlin.Int) returnType:kotlin.Any + $this: VALUE_PARAMETER name: type:foo.bar.Product + VALUE_PARAMETER name:n index:0 type:kotlin.Int FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String BLOCK_BODY VAR name:user type:foo.bar.User [val] @@ -447,7 +542,7 @@ FILE fqName:foo.bar fileName:/dataClassTest.kt $this: CALL 'public open fun getMethod (p0: @[FlexibleNullability] kotlin.String?, vararg p1: @[FlexibleNullability] java.lang.Class<*>?): @[FlexibleNullability] java.lang.reflect.Method? declared in java.lang.Class' type=@[FlexibleNullability] java.lang.reflect.Method? origin=null $this: CALL 'public final fun (): java.lang.Class> declared in kotlin.jvm' type=java.lang.Class origin=GET_PROPERTY : foo.bar.User - $receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' type=kotlin.reflect.KClass + $receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:public [data] superTypes:[kotlin.Any; foo.bar.Product]' type=kotlin.reflect.KClass p0: CONST String type=kotlin.String value="name" p0: GET_VAR 'val user: foo.bar.User declared in foo.bar.box' type=foo.bar.User origin=null VAR name:age type:@[FlexibleNullability] kotlin.Any? [val] @@ -455,7 +550,7 @@ FILE fqName:foo.bar fileName:/dataClassTest.kt $this: CALL 'public open fun getMethod (p0: @[FlexibleNullability] kotlin.String?, vararg p1: @[FlexibleNullability] java.lang.Class<*>?): @[FlexibleNullability] java.lang.reflect.Method? declared in java.lang.Class' type=@[FlexibleNullability] java.lang.reflect.Method? origin=null $this: CALL 'public final fun (): java.lang.Class> declared in kotlin.jvm' type=java.lang.Class origin=GET_PROPERTY : foo.bar.User - $receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' type=kotlin.reflect.KClass + $receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:public [data] superTypes:[kotlin.Any; foo.bar.Product]' type=kotlin.reflect.KClass p0: CONST String type=kotlin.String value="age" p0: GET_VAR 'val user: foo.bar.User declared in foo.bar.box' type=foo.bar.User origin=null VAR name:a type:@[FlexibleNullability] kotlin.Any? [val] @@ -463,7 +558,7 @@ FILE fqName:foo.bar fileName:/dataClassTest.kt $this: CALL 'public open fun getMethod (p0: @[FlexibleNullability] kotlin.String?, vararg p1: @[FlexibleNullability] java.lang.Class<*>?): @[FlexibleNullability] java.lang.reflect.Method? declared in java.lang.Class' type=@[FlexibleNullability] java.lang.reflect.Method? origin=null $this: CALL 'public final fun (): java.lang.Class> declared in kotlin.jvm' type=java.lang.Class origin=GET_PROPERTY : foo.bar.User - $receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' type=kotlin.reflect.KClass + $receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:public [data] superTypes:[kotlin.Any; foo.bar.Product]' type=kotlin.reflect.KClass p0: CONST String type=kotlin.String value="a" p0: GET_VAR 'val user: foo.bar.User declared in foo.bar.box' type=foo.bar.User origin=null VAR name:b type:@[FlexibleNullability] kotlin.Any? [val] @@ -471,7 +566,7 @@ FILE fqName:foo.bar fileName:/dataClassTest.kt $this: CALL 'public open fun getMethod (p0: @[FlexibleNullability] kotlin.String?, vararg p1: @[FlexibleNullability] java.lang.Class<*>?): @[FlexibleNullability] java.lang.reflect.Method? declared in java.lang.Class' type=@[FlexibleNullability] java.lang.reflect.Method? origin=null $this: CALL 'public final fun (): java.lang.Class> declared in kotlin.jvm' type=java.lang.Class origin=GET_PROPERTY : foo.bar.User - $receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' type=kotlin.reflect.KClass + $receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:public [data] superTypes:[kotlin.Any; foo.bar.Product]' type=kotlin.reflect.KClass p0: CONST String type=kotlin.String value="b" p0: GET_VAR 'val user: foo.bar.User declared in foo.bar.box' type=foo.bar.User origin=null WHEN type=kotlin.Unit origin=IF diff --git a/compiler-plugin/src/test/resources/testData/box/dataClassTest.fir.txt b/compiler-plugin/src/test/resources/testData/box/dataClassTest.fir.txt index abd7219f..7a880636 100644 --- a/compiler-plugin/src/test/resources/testData/box/dataClassTest.fir.txt +++ b/compiler-plugin/src/test/resources/testData/box/dataClassTest.fir.txt @@ -15,6 +15,16 @@ FILE: dataClassTest.kt public final val name: R|kotlin/String| = R|/name| public get(): R|kotlin/String| + } + public abstract interface Equals : R|kotlin/Any| { + public abstract fun canEqual(that: R|kotlin/Any?|): R|kotlin/Boolean| + + } + public abstract interface Product : R|foo/bar/Equals| { + public abstract fun productElement(n: R|kotlin/Int|): R|kotlin/Any| + + public abstract fun productArity(): R|kotlin/Int| + } public final fun box(): R|kotlin/String| { lval user: R|foo/bar/User| = R|foo/bar/User.User|() diff --git a/compiler-plugin/src/test/resources/testData/box/dataClassTest.kt b/compiler-plugin/src/test/resources/testData/box/dataClassTest.kt index 25cd0988..2fa3973a 100644 --- a/compiler-plugin/src/test/resources/testData/box/dataClassTest.kt +++ b/compiler-plugin/src/test/resources/testData/box/dataClassTest.kt @@ -3,6 +3,17 @@ package foo.bar annotation class Sparkify annotation class ColumnName(val name: String) +// Fake Equals +interface Equals { + fun canEqual(that: Any?): Boolean +} + +// Fake Product +interface Product: Equals { + fun productElement(n: Int): Any + fun productArity(): Int +} + fun box(): String { val user = User() val name = User::class.java.getMethod("name").invoke(user) diff --git a/compiler-plugin/src/test/resources/testData/diagnostics/dataClassTest.fir.txt b/compiler-plugin/src/test/resources/testData/diagnostics/dataClassTest.fir.txt new file mode 100644 index 00000000..165e02fd --- /dev/null +++ b/compiler-plugin/src/test/resources/testData/diagnostics/dataClassTest.fir.txt @@ -0,0 +1,66 @@ +FILE: dataClassTest.kt + package foo.bar + + public final annotation class Sparkify : R|kotlin/Annotation| { + public constructor(): R|foo/bar/Sparkify| { + super() + } + + } + public final annotation class ColumnName : R|kotlin/Annotation| { + public constructor(name: R|kotlin/String|): R|foo/bar/ColumnName| { + super() + } + + public final val name: R|kotlin/String| = R|/name| + public get(): R|kotlin/String| + + } + public abstract interface Equals : R|kotlin/Any| { + public abstract fun canEqual(that: R|kotlin/Any?|): R|kotlin/Boolean| + + } + public abstract interface Product : R|foo/bar/Equals| { + public abstract fun productElement(n: R|kotlin/Int|): R|kotlin/Any| + + public abstract fun productArity(): R|kotlin/Int| + + } + public final fun test(): R|kotlin/Unit| { + lval user: R|foo/bar/User| = R|foo/bar/User.User|() + R|/user|.R|foo/bar/User.productArity|() + } + @R|foo/bar/Sparkify|() public final data class User : R|kotlin/Any|, R|foo/bar/Product| { + public constructor(name: R|kotlin/String| = String(John Doe), age: R|kotlin/Int| = Int(25), @R|foo/bar/ColumnName|(name = String(a)) test: R|kotlin/Double| = Double(1.0), test2: R|kotlin/Double| = Double(2.0)): R|foo/bar/User| { + super() + } + + public final val name: R|kotlin/String| = R|/name| + public get(): R|kotlin/String| + + public final val age: R|kotlin/Int| = R|/age| + public get(): R|kotlin/Int| + + public final val test: R|kotlin/Double| = R|/test| + public get(): R|kotlin/Double| + + public final val test2: R|kotlin/Double| = R|/test2| + @PROPERTY_GETTER:R|foo/bar/ColumnName|(name = String(b)) public get(): R|kotlin/Double| + + public final operator fun component1(): R|kotlin/String| + + public final operator fun component2(): R|kotlin/Int| + + public final operator fun component3(): R|kotlin/Double| + + public final operator fun component4(): R|kotlin/Double| + + public final fun copy(name: R|kotlin/String| = this@R|foo/bar/User|.R|foo/bar/User.name|, age: R|kotlin/Int| = this@R|foo/bar/User|.R|foo/bar/User.age|, @R|foo/bar/ColumnName|(name = String(a)) test: R|kotlin/Double| = this@R|foo/bar/User|.R|foo/bar/User.test|, test2: R|kotlin/Double| = this@R|foo/bar/User|.R|foo/bar/User.test2|): R|foo/bar/User| + + public final fun productArity(): R|kotlin/Int| + + public final fun productElement(n: R|kotlin/Int|): R|kotlin/Any?| + + public final fun canEqual(that: R|kotlin/Any?|): R|kotlin/Boolean| + + }