diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 27b1abc6..72b315f7 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -2,7 +2,7 @@ object Versions : Dsl { const val project = "2.0.0-SNAPSHOT" const val kotlinSparkApiGradlePlugin = "2.0.0-SNAPSHOT" const val groupID = "org.jetbrains.kotlinx.spark" -// const val kotlin = "2.0.0-Beta5" todo issues with NonSerializable lambdas +// const val kotlin = "2.0.0-Beta5" // todo issues with NonSerializable lambdas const val kotlin = "1.9.23" const val jvmTarget = "8" const val jupyterJvmTarget = "8" diff --git a/compiler-plugin/src/main/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/ir/DataClassPropertyAnnotationGenerator.kt b/compiler-plugin/src/main/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/ir/DataClassPropertyAnnotationGenerator.kt index b0f338c9..91ddf573 100644 --- a/compiler-plugin/src/main/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/ir/DataClassPropertyAnnotationGenerator.kt +++ b/compiler-plugin/src/main/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/ir/DataClassPropertyAnnotationGenerator.kt @@ -9,6 +9,7 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclaration import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrModuleFragment import org.jetbrains.kotlin.ir.declarations.IrProperty +import org.jetbrains.kotlin.ir.expressions.IrBlockBody import org.jetbrains.kotlin.ir.expressions.IrConst import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl @@ -40,9 +41,13 @@ class DataClassPropertyAnnotationGenerator( override fun visitElement(element: IrElement) { when (element) { - is IrDeclaration, - is IrFile, - is IrModuleFragment -> element.acceptChildrenVoid(this) +// is IrDeclaration, +// is IrFile, +// is IrBlockBody, +// is IrModuleFragment -> element.acceptChildrenVoid(this) + + // test for now + else -> element.acceptChildrenVoid(this) } } diff --git a/compiler-plugin/src/test-gen/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/runners/BoxTestGenerated.java b/compiler-plugin/src/test-gen/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/runners/BoxTestGenerated.java index 4e843bee..fef04e1c 100644 --- a/compiler-plugin/src/test-gen/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/runners/BoxTestGenerated.java +++ b/compiler-plugin/src/test-gen/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/runners/BoxTestGenerated.java @@ -21,6 +21,12 @@ public void testAllFilesPresentInBox() { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("/mnt/data/Projects/kotlin-spark-api/compiler-plugin/src/test/resources/testData/box"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("dataClassInFunctionTest.kt") + public void testDataClassInFunctionTest() { + runTest("/mnt/data/Projects/kotlin-spark-api/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.kt"); + } + @Test @TestMetadata("dataClassTest.kt") public void testDataClassTest() { 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 new file mode 100644 index 00000000..ec43187d --- /dev/null +++ b/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.fir.ir.txt @@ -0,0 +1,374 @@ +FILE fqName:foo.bar fileName:/dataClassInFunctionTest.kt + CLASS ANNOTATION_CLASS name:ColumnName modality:OPEN visibility:public superTypes:[kotlin.Annotation] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.bar.ColumnName + PROPERTY name:name visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final] + EXPRESSION_BODY + GET_VAR 'name: kotlin.String declared in foo.bar.ColumnName.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:foo.bar.ColumnName) returnType:kotlin.String + correspondingProperty: PROPERTY name:name visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:foo.bar.ColumnName + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in foo.bar.ColumnName' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': foo.bar.ColumnName declared in foo.bar.ColumnName.' type=foo.bar.ColumnName origin=null + CONSTRUCTOR visibility:public <> (name:kotlin.String) returnType:foo.bar.ColumnName [primary] + VALUE_PARAMETER name:name index:0 type:kotlin.String + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ANNOTATION_CLASS name:ColumnName modality:OPEN visibility:public superTypes:[kotlin.Annotation]' + 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.Annotation + $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.Annotation + $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.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS ANNOTATION_CLASS name:Sparkify modality:OPEN visibility:public superTypes:[kotlin.Annotation] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.bar.Sparkify + CONSTRUCTOR visibility:public <> () returnType:foo.bar.Sparkify [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ANNOTATION_CLASS name:Sparkify modality:OPEN visibility:public superTypes:[kotlin.Annotation]' + 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.Annotation + $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.Annotation + $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.Annotation + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any] + annotations: + Sparkify + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.bar.box.User + PROPERTY name:name visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final] + EXPRESSION_BODY + GET_VAR 'name: kotlin.String declared in foo.bar.box.User.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:foo.bar.box.User) returnType:kotlin.String + annotations: + JvmName(name = "name") + correspondingProperty: PROPERTY name:name visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:foo.bar.box.User + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in foo.bar.box.User' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': foo.bar.box.User declared in foo.bar.box.User.' type=foo.bar.box.User origin=null + PROPERTY name:age visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:age type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + GET_VAR 'age: kotlin.Int declared in foo.bar.box.User.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:foo.bar.box.User) returnType:kotlin.Int + annotations: + JvmName(name = "age") + correspondingProperty: PROPERTY name:age visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:foo.bar.box.User + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in foo.bar.box.User' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:age type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': foo.bar.box.User declared in foo.bar.box.User.' type=foo.bar.box.User origin=null + PROPERTY name:test visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:test type:kotlin.Double visibility:private [final] + EXPRESSION_BODY + GET_VAR 'test: kotlin.Double declared in foo.bar.box.User.' type=kotlin.Double origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:foo.bar.box.User) returnType:kotlin.Double + annotations: + JvmName(name = "a") + correspondingProperty: PROPERTY name:test visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:foo.bar.box.User + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Double declared in foo.bar.box.User' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test type:kotlin.Double visibility:private [final]' type=kotlin.Double origin=null + receiver: GET_VAR ': foo.bar.box.User declared in foo.bar.box.User.' type=foo.bar.box.User origin=null + PROPERTY name:test2 visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.Double visibility:private [final] + EXPRESSION_BODY + GET_VAR 'test2: kotlin.Double declared in foo.bar.box.User.' type=kotlin.Double origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:foo.bar.box.User) returnType:kotlin.Double + annotations: + ColumnName(name = "b") + JvmName(name = "b") + correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:foo.bar.box.User + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Double declared in foo.bar.box.User' + 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.' type=foo.bar.box.User origin=null + CONSTRUCTOR visibility:public <> (name:kotlin.String, age:kotlin.Int, test:kotlin.Double, test2:kotlin.Double) returnType:foo.bar.box.User [primary] + VALUE_PARAMETER name:name index:0 type:kotlin.String + EXPRESSION_BODY + CONST String type=kotlin.String value="John Doe" + VALUE_PARAMETER name:age index:1 type:kotlin.Int + EXPRESSION_BODY + CONST Int type=kotlin.Int value=25 + VALUE_PARAMETER name:test index:2 type:kotlin.Double + annotations: + ColumnName(name = "a") + EXPRESSION_BODY + CONST Double type=kotlin.Double value=1.0 + VALUE_PARAMETER name:test2 index:3 type:kotlin.Double + EXPRESSION_BODY + 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]' + 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 + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.String declared in foo.bar.box.User' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': foo.bar.box.User declared in foo.bar.box.User.component1' type=foo.bar.box.User origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:component2 visibility:public modality:FINAL <> ($this:foo.bar.box.User) returnType:kotlin.Int [operator] + $this: VALUE_PARAMETER name: type:foo.bar.box.User + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.Int declared in foo.bar.box.User' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:age type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': foo.bar.box.User declared in foo.bar.box.User.component2' type=foo.bar.box.User origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:component3 visibility:public modality:FINAL <> ($this:foo.bar.box.User) returnType:kotlin.Double [operator] + $this: VALUE_PARAMETER name: type:foo.bar.box.User + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun component3 (): kotlin.Double declared in foo.bar.box.User' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test type:kotlin.Double visibility:private [final]' type=kotlin.Double origin=null + receiver: GET_VAR ': foo.bar.box.User declared in foo.bar.box.User.component3' type=foo.bar.box.User origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:component4 visibility:public modality:FINAL <> ($this:foo.bar.box.User) returnType:kotlin.Double [operator] + $this: VALUE_PARAMETER name: type:foo.bar.box.User + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun component4 (): kotlin.Double declared in foo.bar.box.User' + 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.component4' type=foo.bar.box.User origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:copy visibility:public modality:FINAL <> ($this:foo.bar.box.User, name:kotlin.String, age:kotlin.Int, test:kotlin.Double, test2:kotlin.Double) returnType:foo.bar.box.User + $this: VALUE_PARAMETER name: type:foo.bar.box.User + VALUE_PARAMETER name:name index:0 type:kotlin.String + EXPRESSION_BODY + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': foo.bar.box.User declared in foo.bar.box.User.copy' type=foo.bar.box.User origin=null + VALUE_PARAMETER name:age index:1 type:kotlin.Int + EXPRESSION_BODY + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:age type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': foo.bar.box.User declared in foo.bar.box.User.copy' type=foo.bar.box.User origin=null + VALUE_PARAMETER name:test index:2 type:kotlin.Double + annotations: + ColumnName(name = "a") + EXPRESSION_BODY + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test type:kotlin.Double visibility:private [final]' type=kotlin.Double origin=null + receiver: GET_VAR ': foo.bar.box.User declared in foo.bar.box.User.copy' type=foo.bar.box.User origin=null + VALUE_PARAMETER name:test2 index:3 type:kotlin.Double + EXPRESSION_BODY + 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.copy' type=foo.bar.box.User origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (name: kotlin.String, age: kotlin.Int, test: kotlin.Double, test2: kotlin.Double): foo.bar.box.User declared in foo.bar.box.User' + 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 + name: GET_VAR 'name: kotlin.String declared in foo.bar.box.User.copy' type=kotlin.String origin=null + age: GET_VAR 'age: kotlin.Int declared in foo.bar.box.User.copy' type=kotlin.Int origin=null + test: GET_VAR 'test: kotlin.Double declared in foo.bar.box.User.copy' type=kotlin.Double origin=null + test2: GET_VAR 'test2: kotlin.Double declared in foo.bar.box.User.copy' type=kotlin.Double origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:foo.bar.box.User, other:kotlin.Any?) returnType:kotlin.Boolean [operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any + $this: VALUE_PARAMETER name: type:foo.bar.box.User + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + BLOCK_BODY + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun EQEQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQEQ + arg0: GET_VAR ': foo.bar.box.User declared in foo.bar.box.User.equals' type=foo.bar.box.User origin=null + arg1: GET_VAR 'other: kotlin.Any? declared in foo.bar.box.User.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.bar.box.User' + CONST Boolean type=kotlin.Boolean value=true + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=foo.bar.box.User + GET_VAR 'other: kotlin.Any? declared in foo.bar.box.User.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.bar.box.User' + CONST Boolean type=kotlin.Boolean value=false + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:foo.bar.box.User [val] + TYPE_OP type=foo.bar.box.User origin=CAST typeOperand=foo.bar.box.User + GET_VAR 'other: kotlin.Any? declared in foo.bar.box.User.equals' type=kotlin.Any? origin=null + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': foo.bar.box.User declared in foo.bar.box.User.equals' type=foo.bar.box.User origin=null + arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR 'val tmp_0: foo.bar.box.User declared in foo.bar.box.User.equals' type=foo.bar.box.User origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.bar.box.User' + CONST Boolean type=kotlin.Boolean value=false + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:age type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': foo.bar.box.User declared in foo.bar.box.User.equals' type=foo.bar.box.User origin=null + arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:age type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR 'val tmp_0: foo.bar.box.User declared in foo.bar.box.User.equals' type=foo.bar.box.User origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.bar.box.User' + CONST Boolean type=kotlin.Boolean value=false + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test type:kotlin.Double visibility:private [final]' type=kotlin.Double origin=null + receiver: GET_VAR ': foo.bar.box.User declared in foo.bar.box.User.equals' type=foo.bar.box.User origin=null + arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test type:kotlin.Double visibility:private [final]' type=kotlin.Double origin=null + receiver: GET_VAR 'val tmp_0: foo.bar.box.User declared in foo.bar.box.User.equals' type=foo.bar.box.User origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.bar.box.User' + CONST Boolean type=kotlin.Boolean value=false + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: 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.equals' type=foo.bar.box.User origin=null + arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.Double visibility:private [final]' type=kotlin.Double origin=null + receiver: GET_VAR 'val tmp_0: foo.bar.box.User declared in foo.bar.box.User.equals' type=foo.bar.box.User origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.bar.box.User' + CONST Boolean type=kotlin.Boolean value=false + RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.bar.box.User' + CONST Boolean type=kotlin.Boolean value=true + FUN GENERATED_DATA_CLASS_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:foo.bar.box.User) returnType:kotlin.Int + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:foo.bar.box.User + BLOCK_BODY + VAR name:result type:kotlin.Int [var] + CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': foo.bar.box.User declared in foo.bar.box.User.hashCode' type=foo.bar.box.User origin=null + SET_VAR 'var result: kotlin.Int declared in foo.bar.box.User.hashCode' type=kotlin.Unit origin=EQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun times (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var result: kotlin.Int declared in foo.bar.box.User.hashCode' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=31 + other: CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:age type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': foo.bar.box.User declared in foo.bar.box.User.hashCode' type=foo.bar.box.User origin=null + SET_VAR 'var result: kotlin.Int declared in foo.bar.box.User.hashCode' type=kotlin.Unit origin=EQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun times (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var result: kotlin.Int declared in foo.bar.box.User.hashCode' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=31 + other: CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Double' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test type:kotlin.Double visibility:private [final]' type=kotlin.Double origin=null + receiver: GET_VAR ': foo.bar.box.User declared in foo.bar.box.User.hashCode' type=foo.bar.box.User origin=null + SET_VAR 'var result: kotlin.Int declared in foo.bar.box.User.hashCode' type=kotlin.Unit origin=EQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun times (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var result: kotlin.Int declared in foo.bar.box.User.hashCode' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=31 + other: CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Double' type=kotlin.Int origin=null + $this: 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.hashCode' type=foo.bar.box.User origin=null + RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in foo.bar.box.User' + GET_VAR 'var result: kotlin.Int declared in foo.bar.box.User.hashCode' type=kotlin.Int origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:toString visibility:public modality:OPEN <> ($this:foo.bar.box.User) returnType:kotlin.String + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:foo.bar.box.User + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in foo.bar.box.User' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="User(" + CONST String type=kotlin.String value="name=" + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:name type:kotlin.String visibility:private [final]' type=kotlin.String 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=", " + CONST String type=kotlin.String value="age=" + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:age type:kotlin.Int visibility:private [final]' type=kotlin.Int 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=", " + CONST String type=kotlin.String value="test=" + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test 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=", " + CONST String type=kotlin.String value="test2=" + 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=")" + 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] + CALL 'public open fun invoke (p0: @[FlexibleNullability] kotlin.Any?, vararg p1: @[FlexibleNullability] kotlin.Any?): @[FlexibleNullability] kotlin.Any? declared in java.lang.reflect.Method' type=@[FlexibleNullability] kotlin.Any? origin=null + $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 + 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] + CALL 'public open fun invoke (p0: @[FlexibleNullability] kotlin.Any?, vararg p1: @[FlexibleNullability] kotlin.Any?): @[FlexibleNullability] kotlin.Any? declared in java.lang.reflect.Method' type=@[FlexibleNullability] kotlin.Any? origin=null + $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 + 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] + CALL 'public open fun invoke (p0: @[FlexibleNullability] kotlin.Any?, vararg p1: @[FlexibleNullability] kotlin.Any?): @[FlexibleNullability] kotlin.Any? declared in java.lang.reflect.Method' type=@[FlexibleNullability] kotlin.Any? origin=null + $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 + 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] + CALL 'public open fun invoke (p0: @[FlexibleNullability] kotlin.Any?, vararg p1: @[FlexibleNullability] kotlin.Any?): @[FlexibleNullability] kotlin.Any? declared in java.lang.reflect.Method' type=@[FlexibleNullability] kotlin.Any? origin=null + $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 + 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 + BRANCH + if: WHEN type=kotlin.Boolean origin=OROR + BRANCH + if: WHEN type=kotlin.Boolean origin=OROR + BRANCH + if: WHEN type=kotlin.Boolean origin=OROR + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'val name: @[FlexibleNullability] kotlin.Any? declared in foo.bar.box' type=@[FlexibleNullability] kotlin.Any? origin=null + arg1: CONST String type=kotlin.String value="John Doe" + then: CONST Boolean type=kotlin.Boolean value=true + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'val age: @[FlexibleNullability] kotlin.Any? declared in foo.bar.box' type=@[FlexibleNullability] kotlin.Any? origin=null + arg1: CONST Int type=kotlin.Int value=25 + then: CONST Boolean type=kotlin.Boolean value=true + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'val a: @[FlexibleNullability] kotlin.Any? declared in foo.bar.box' type=@[FlexibleNullability] kotlin.Any? origin=null + arg1: CONST Double type=kotlin.Double value=1.0 + then: CONST Boolean type=kotlin.Boolean value=true + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun not (): kotlin.Boolean declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'val b: @[FlexibleNullability] kotlin.Any? declared in foo.bar.box' type=@[FlexibleNullability] kotlin.Any? origin=null + arg1: CONST Double type=kotlin.Double value=2.0 + then: BLOCK type=kotlin.Unit origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in foo.bar' + CONST String type=kotlin.String value="Could not invoke functions name(), age(), a(), or b() from Java" + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in foo.bar' + CONST String type=kotlin.String value="OK" diff --git a/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.fir.txt b/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.fir.txt new file mode 100644 index 00000000..fdd20f3a --- /dev/null +++ b/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.fir.txt @@ -0,0 +1,61 @@ +FILE: dataClassInFunctionTest.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 final fun box(): R|kotlin/String| { + @R|foo/bar/Sparkify|() local final data class User : R|kotlin/Any| { + 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|/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|/User|.R|/name|, age: R|kotlin/Int| = this@R|/User|.R|/age|, @R|foo/bar/ColumnName|(name = String(a)) test: R|kotlin/Double| = this@R|/User|.R|/test|, test2: R|kotlin/Double| = this@R|/User|.R|/test2|): R|/User| + + } + + lval user: R|/User| = R|/User.User|() + lval name: R|kotlin/Any!| = (Q|/User|).R|kotlin/jvm/java|/User|>.R|SubstitutionOverride|(String(name)).R|java/lang/reflect/Method.invoke|(R|/user|) + lval age: R|kotlin/Any!| = (Q|/User|).R|kotlin/jvm/java|/User|>.R|SubstitutionOverride|(String(age)).R|java/lang/reflect/Method.invoke|(R|/user|) + lval a: R|kotlin/Any!| = (Q|/User|).R|kotlin/jvm/java|/User|>.R|SubstitutionOverride|(String(a)).R|java/lang/reflect/Method.invoke|(R|/user|) + lval b: R|kotlin/Any!| = (Q|/User|).R|kotlin/jvm/java|/User|>.R|SubstitutionOverride|(String(b)).R|java/lang/reflect/Method.invoke|(R|/user|) + when () { + !=(R|/name|, String(John Doe)) || !=(R|/age|, Int(25)) || !=(R|/a|, Double(1.0)) || !=(R|/b|, Double(2.0)) -> { + ^box String(Could not invoke functions name(), age(), a(), or b() from Java) + } + } + + ^box String(OK) + } diff --git a/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.kt b/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.kt new file mode 100644 index 00000000..293595aa --- /dev/null +++ b/compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.kt @@ -0,0 +1,26 @@ +package foo.bar + +annotation class Sparkify +annotation class ColumnName(val name: String) + +fun box(): String { + + @Sparkify + data class User( + val name: String = "John Doe", + val age: Int = 25, + @ColumnName("a") val test: Double = 1.0, + @get:ColumnName("b") val test2: Double = 2.0, + ) + + val user = User() + val name = User::class.java.getMethod("name").invoke(user) + val age = User::class.java.getMethod("age").invoke(user) + val a = User::class.java.getMethod("a").invoke(user) + val b = User::class.java.getMethod("b").invoke(user) + + if (name != "John Doe" || age != 25 || a != 1.0 || b != 2.0) { + return "Could not invoke functions name(), age(), a(), or b() from Java" + } + return "OK" +} diff --git a/kotlin-spark-api/src/main/kotlin/org/jetbrains/kotlinx/spark/api/Dataset.kt b/kotlin-spark-api/src/main/kotlin/org/jetbrains/kotlinx/spark/api/Dataset.kt index efb4fae1..3f04e166 100644 --- a/kotlin-spark-api/src/main/kotlin/org/jetbrains/kotlinx/spark/api/Dataset.kt +++ b/kotlin-spark-api/src/main/kotlin/org/jetbrains/kotlinx/spark/api/Dataset.kt @@ -358,11 +358,11 @@ fun Dataset>.sortByValue(): Dataset> = so /** Returns a dataset sorted by the first (`first`) value of each [Pair] inside. */ @JvmName("sortByPairKey") -fun Dataset>.sortByKey(): Dataset> = sort("first") +fun Dataset>.sortByKey(): Dataset> = sort("getFirst") /** Returns a dataset sorted by the second (`second`) value of each [Pair] inside. */ @JvmName("sortByPairValue") -fun Dataset>.sortByValue(): Dataset> = sort("second") +fun Dataset>.sortByValue(): Dataset> = sort("getSecond") /** * This function creates block, where one can call any further computations on already cached dataset diff --git a/kotlin-spark-api/src/test/kotlin/org/jetbrains/kotlinx/spark/api/DatasetFunctionTest.kt b/kotlin-spark-api/src/test/kotlin/org/jetbrains/kotlinx/spark/api/DatasetFunctionTest.kt index 066860a8..be155590 100644 --- a/kotlin-spark-api/src/test/kotlin/org/jetbrains/kotlinx/spark/api/DatasetFunctionTest.kt +++ b/kotlin-spark-api/src/test/kotlin/org/jetbrains/kotlinx/spark/api/DatasetFunctionTest.kt @@ -77,6 +77,8 @@ class DatasetFunctionTest : ShouldSpec({ val first = dsOf(Left(1, "a"), Left(2, "b")) val second = dsOf(Right(1, 100), Right(3, 300)) + first.show() + second.show() val result = first .leftJoin(second, first.col("id") eq second.col("id")) .map { it._1.id X it._1.name X it._2?.value } @@ -211,8 +213,7 @@ class DatasetFunctionTest : ShouldSpec({ s = key s shouldBe key - if (collected.size > 1) collected.iterator() - else emptyList>().iterator() + if (collected.size > 1) collected else emptyList() } flatMappedWithState.count() shouldBe 2 diff --git a/kotlin-spark-api/src/test/kotlin/org/jetbrains/kotlinx/spark/api/TypeInferenceTest.kt b/kotlin-spark-api/src/test/kotlin/org/jetbrains/kotlinx/spark/api/TypeInferenceTest.kt index 0d4d6d52..c64c24f7 100644 --- a/kotlin-spark-api/src/test/kotlin/org/jetbrains/kotlinx/spark/api/TypeInferenceTest.kt +++ b/kotlin-spark-api/src/test/kotlin/org/jetbrains/kotlinx/spark/api/TypeInferenceTest.kt @@ -39,7 +39,7 @@ class TypeInferenceTest : ShouldSpec({ @Sparkify data class Test2(val vala2: T, val para2: Pair) @Sparkify data class Test(val vala: T, val tripl1: Triple, T>) - val struct = Struct.fromJson(kotlinEncoderFor>>().schema().prettyJson())!! + val struct = Struct.fromJson(schemaFor>>().prettyJson())!! should("contain correct typings") { expect(struct.fields).notToEqualNull().toContain.inAnyOrder.only.entries( hasField("first", "string"), @@ -70,7 +70,7 @@ class TypeInferenceTest : ShouldSpec({ data class Test2(val vala2: T, val para2: Pair>) @Sparkify data class Test(val vala: T, val tripl1: Triple, T>) - val struct = Struct.fromJson(kotlinEncoderFor>>().schema().prettyJson())!! + val struct = Struct.fromJson(schemaFor>>().prettyJson())!! should("contain correct typings") { expect(struct.fields).notToEqualNull().toContain.inAnyOrder.only.entries( hasField("first", "string"), @@ -101,7 +101,7 @@ class TypeInferenceTest : ShouldSpec({ context("org.jetbrains.spark.api.org.jetbrains.spark.api.schema without generics") { data class Test(val a: String, val b: Int, val c: Double) - val struct = Struct.fromJson(kotlinEncoderFor().schema().prettyJson())!! + val struct = Struct.fromJson(schemaFor().prettyJson())!! should("return correct types too") { expect(struct.fields).notToEqualNull().toContain.inAnyOrder.only.entries( hasField("a", "string"), @@ -111,7 +111,7 @@ class TypeInferenceTest : ShouldSpec({ } } context("type with list of ints") { - val struct = Struct.fromJson(kotlinEncoderFor>().schema().prettyJson())!! + val struct = Struct.fromJson(schemaFor>().prettyJson())!! should("return correct types too") { expect(struct) { isOfType("array") @@ -120,7 +120,7 @@ class TypeInferenceTest : ShouldSpec({ } } context("type with list of Pairs int to long") { - val struct = Struct.fromJson(kotlinEncoderFor>>().schema().prettyJson())!! + val struct = Struct.fromJson(schemaFor>>().prettyJson())!! should("return correct types too") { expect(struct) { isOfType("array") @@ -136,7 +136,7 @@ class TypeInferenceTest : ShouldSpec({ context("type with list of generic data class with E generic name") { data class Test(val e: E) - val struct = Struct.fromJson(kotlinEncoderFor>>().schema().prettyJson())!! + val struct = Struct.fromJson(schemaFor>>().prettyJson())!! should("return correct types too") { expect(struct) { isOfType("array") @@ -149,7 +149,7 @@ class TypeInferenceTest : ShouldSpec({ } } context("type with list of list of int") { - val struct = Struct.fromJson(kotlinEncoderFor>>().schema().prettyJson())!! + val struct = Struct.fromJson(schemaFor>>().prettyJson())!! should("return correct types too") { expect(struct) { isOfType("array") @@ -160,7 +160,7 @@ class TypeInferenceTest : ShouldSpec({ } } context("Subtypes of list") { - val struct = Struct.fromJson(kotlinEncoderFor>().schema().prettyJson())!! + val struct = Struct.fromJson(schemaFor>().prettyJson())!! should("return correct types too") { expect(struct) { isOfType("array") @@ -170,7 +170,7 @@ class TypeInferenceTest : ShouldSpec({ } } context("Subtypes of list with nullable values") { - val struct = Struct.fromJson(kotlinEncoderFor>().schema().prettyJson())!! + val struct = Struct.fromJson(schemaFor>().prettyJson())!! should("return correct types too") { expect(struct) { isOfType("array") @@ -182,7 +182,7 @@ class TypeInferenceTest : ShouldSpec({ context("data class with props in order lon → lat") { data class Test(val lon: Double, val lat: Double) - val struct = Struct.fromJson(kotlinEncoderFor().schema().prettyJson())!! + val struct = Struct.fromJson(schemaFor().prettyJson())!! should("Not change order of fields") { expect(struct.fields).notToEqualNull().containsExactly( hasField("lon", "double"), @@ -193,7 +193,7 @@ class TypeInferenceTest : ShouldSpec({ context("data class with nullable list inside") { data class Sample(val optionList: List?) - val struct = Struct.fromJson(kotlinEncoderFor().schema().prettyJson())!! + val struct = Struct.fromJson(schemaFor().prettyJson())!! should("show that list is nullable and element is not") { expect(struct) @@ -215,7 +215,7 @@ class TypeInferenceTest : ShouldSpec({ } should("generate valid serializer schema") { - expect(kotlinEncoderFor().schema()) { + expect(schemaFor() as org.apache.spark.sql.types.StructType) { this .feature("data type", { this.fields()?.toList() }) { this.notToEqualNull().toContain.inOrder.only.entry {