Skip to content

Commit 4e5438b

Browse files
committed
fixing compiler-plugin tests
1 parent 6b63c96 commit 4e5438b

File tree

9 files changed

+313
-43
lines changed

9 files changed

+313
-43
lines changed

compiler-plugin/src/test-gen/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/runners/DiagnosticTestGenerated.java

-28
This file was deleted.

compiler-plugin/src/test/kotlin/org/jetbrains/kotlinx/spark/api/compilerPlugin/GenerateTests.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ fun main() {
1111
testDataRoot = "${Artifacts.projectRoot}/${Artifacts.compilerPluginArtifactId}/src/test/resources/testData",
1212
testsRoot = "${Artifacts.projectRoot}/${Artifacts.compilerPluginArtifactId}/src/test-gen/kotlin",
1313
) {
14-
testClass<AbstractDiagnosticTest> {
15-
model("diagnostics")
16-
}
14+
// testClass<AbstractDiagnosticTest> {
15+
// model("diagnostics")
16+
// }
1717

1818
testClass<AbstractBoxTest> {
1919
model("box")

compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.fir.ir.txt

+101-6
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,52 @@ FILE fqName:foo.bar fileName:/dataClassInFunctionTest.kt
4949
overridden:
5050
public open fun toString (): kotlin.String declared in kotlin.Annotation
5151
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
52+
CLASS INTERFACE name:Equals modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
53+
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:foo.bar.Equals
54+
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
55+
overridden:
56+
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any
57+
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
58+
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
59+
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
60+
overridden:
61+
public open fun hashCode (): kotlin.Int declared in kotlin.Any
62+
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
63+
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
64+
overridden:
65+
public open fun toString (): kotlin.String declared in kotlin.Any
66+
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
67+
FUN name:canEqual visibility:public modality:ABSTRACT <> ($this:foo.bar.Equals, that:kotlin.Any?) returnType:kotlin.Boolean
68+
$this: VALUE_PARAMETER name:<this> type:foo.bar.Equals
69+
VALUE_PARAMETER name:that index:0 type:kotlin.Any?
70+
CLASS INTERFACE name:Product modality:ABSTRACT visibility:public superTypes:[foo.bar.Equals]
71+
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:foo.bar.Product
72+
FUN FAKE_OVERRIDE name:canEqual visibility:public modality:ABSTRACT <> ($this:foo.bar.Equals, that:kotlin.Any?) returnType:kotlin.Boolean [fake_override]
73+
overridden:
74+
public abstract fun canEqual (that: kotlin.Any?): kotlin.Boolean declared in foo.bar.Equals
75+
$this: VALUE_PARAMETER name:<this> type:foo.bar.Equals
76+
VALUE_PARAMETER name:that index:0 type:kotlin.Any?
77+
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
78+
overridden:
79+
public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.bar.Equals
80+
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
81+
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
82+
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
83+
overridden:
84+
public open fun hashCode (): kotlin.Int declared in foo.bar.Equals
85+
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
86+
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
87+
overridden:
88+
public open fun toString (): kotlin.String declared in foo.bar.Equals
89+
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
90+
FUN name:productArity visibility:public modality:ABSTRACT <> ($this:foo.bar.Product) returnType:kotlin.Int
91+
$this: VALUE_PARAMETER name:<this> type:foo.bar.Product
92+
FUN name:productElement visibility:public modality:ABSTRACT <> ($this:foo.bar.Product, n:kotlin.Int) returnType:kotlin.Any
93+
$this: VALUE_PARAMETER name:<this> type:foo.bar.Product
94+
VALUE_PARAMETER name:n index:0 type:kotlin.Int
5295
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
5396
BLOCK_BODY
54-
CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any]
97+
CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any; foo.bar.Product]
5598
annotations:
5699
Sparkify
57100
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:foo.bar.box.User
@@ -125,7 +168,7 @@ FILE fqName:foo.bar fileName:/dataClassInFunctionTest.kt
125168
CONST Double type=kotlin.Double value=2.0
126169
BLOCK_BODY
127170
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
128-
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any]'
171+
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any; foo.bar.Product]'
129172
FUN GENERATED_DATA_CLASS_MEMBER name:component1 visibility:public modality:FINAL <> ($this:foo.bar.box.User) returnType:kotlin.String [operator]
130173
$this: VALUE_PARAMETER name:<this> type:foo.bar.box.User
131174
BLOCK_BODY
@@ -300,38 +343,90 @@ FILE fqName:foo.bar fileName:/dataClassInFunctionTest.kt
300343
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.Double visibility:private [final]' type=kotlin.Double origin=null
301344
receiver: GET_VAR '<this>: foo.bar.box.User declared in foo.bar.box.User.toString' type=foo.bar.box.User origin=null
302345
CONST String type=kotlin.String value=")"
346+
FUN name:canEqual visibility:public modality:OPEN <> ($this:foo.bar.box.User, that:kotlin.Any?) returnType:kotlin.Boolean
347+
overridden:
348+
public abstract fun canEqual (that: kotlin.Any?): kotlin.Boolean declared in foo.bar.Equals
349+
$this: VALUE_PARAMETER name:$this type:foo.bar.box.User
350+
VALUE_PARAMETER name:that index:0 type:kotlin.Any?
351+
BLOCK_BODY
352+
RETURN type=kotlin.Nothing from='public open fun canEqual (that: kotlin.Any?): kotlin.Boolean declared in foo.bar.box.User'
353+
TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=foo.bar.box.User
354+
GET_VAR 'that: kotlin.Any? declared in foo.bar.box.User.canEqual' type=kotlin.Any? origin=null
355+
FUN name:productArity visibility:public modality:OPEN <> ($this:foo.bar.box.User) returnType:kotlin.Int
356+
overridden:
357+
public abstract fun productArity (): kotlin.Int declared in foo.bar.Product
358+
$this: VALUE_PARAMETER name:$this type:foo.bar.box.User
359+
BLOCK_BODY
360+
RETURN type=kotlin.Nothing from='public open fun productArity (): kotlin.Int declared in foo.bar.box.User'
361+
CONST Int type=kotlin.Int value=4
362+
FUN name:productElement visibility:public modality:OPEN <> ($this:foo.bar.box.User, n:kotlin.Int) returnType:kotlin.Any?
363+
overridden:
364+
public abstract fun productElement (n: kotlin.Int): kotlin.Any declared in foo.bar.Product
365+
$this: VALUE_PARAMETER name:$this type:foo.bar.box.User
366+
VALUE_PARAMETER name:n index:0 type:kotlin.Int
367+
BLOCK_BODY
368+
RETURN type=kotlin.Nothing from='public open fun productElement (n: kotlin.Int): kotlin.Any? declared in foo.bar.box.User'
369+
WHEN type=kotlin.Any? origin=IF
370+
BRANCH
371+
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
372+
arg0: GET_VAR 'n: kotlin.Int declared in foo.bar.box.User.productElement' type=kotlin.Int origin=null
373+
arg1: CONST Int type=kotlin.Int value=0
374+
then: CALL 'public final fun <get-name> (): kotlin.String declared in foo.bar.box.User' type=kotlin.String origin=GET_PROPERTY
375+
$this: GET_VAR '$this: foo.bar.box.User declared in foo.bar.box.User.productElement' type=foo.bar.box.User origin=null
376+
BRANCH
377+
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
378+
arg0: GET_VAR 'n: kotlin.Int declared in foo.bar.box.User.productElement' type=kotlin.Int origin=null
379+
arg1: CONST Int type=kotlin.Int value=1
380+
then: CALL 'public final fun <get-age> (): kotlin.Int declared in foo.bar.box.User' type=kotlin.Int origin=GET_PROPERTY
381+
$this: GET_VAR '$this: foo.bar.box.User declared in foo.bar.box.User.productElement' type=foo.bar.box.User origin=null
382+
BRANCH
383+
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
384+
arg0: GET_VAR 'n: kotlin.Int declared in foo.bar.box.User.productElement' type=kotlin.Int origin=null
385+
arg1: CONST Int type=kotlin.Int value=2
386+
then: CALL 'public final fun <get-test> (): kotlin.Double declared in foo.bar.box.User' type=kotlin.Double origin=GET_PROPERTY
387+
$this: GET_VAR '$this: foo.bar.box.User declared in foo.bar.box.User.productElement' type=foo.bar.box.User origin=null
388+
BRANCH
389+
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
390+
arg0: GET_VAR 'n: kotlin.Int declared in foo.bar.box.User.productElement' type=kotlin.Int origin=null
391+
arg1: CONST Int type=kotlin.Int value=3
392+
then: CALL 'public final fun <get-test2> (): kotlin.Double declared in foo.bar.box.User' type=kotlin.Double origin=GET_PROPERTY
393+
$this: GET_VAR '$this: foo.bar.box.User declared in foo.bar.box.User.productElement' type=foo.bar.box.User origin=null
394+
BRANCH
395+
if: CONST Boolean type=kotlin.Boolean value=true
396+
then: THROW type=kotlin.Nothing
397+
CONSTRUCTOR_CALL 'public constructor <init> () declared in java.lang.IndexOutOfBoundsException' type=java.lang.IndexOutOfBoundsException origin=null
303398
VAR name:user type:foo.bar.box.User [val]
304399
CONSTRUCTOR_CALL 'public constructor <init> (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
305400
VAR name:name type:@[FlexibleNullability] kotlin.Any? [val]
306401
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
307402
$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
308403
$this: CALL 'public final fun <get-java> <T> (): java.lang.Class<T of kotlin.jvm.<get-java>> declared in kotlin.jvm' type=java.lang.Class<foo.bar.box.User> origin=GET_PROPERTY
309404
<T>: foo.bar.box.User
310-
$receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any]' type=kotlin.reflect.KClass<foo.bar.box.User>
405+
$receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any; foo.bar.Product]' type=kotlin.reflect.KClass<foo.bar.box.User>
311406
p0: CONST String type=kotlin.String value="name"
312407
p0: GET_VAR 'val user: foo.bar.box.User declared in foo.bar.box' type=foo.bar.box.User origin=null
313408
VAR name:age type:@[FlexibleNullability] kotlin.Any? [val]
314409
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
315410
$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
316411
$this: CALL 'public final fun <get-java> <T> (): java.lang.Class<T of kotlin.jvm.<get-java>> declared in kotlin.jvm' type=java.lang.Class<foo.bar.box.User> origin=GET_PROPERTY
317412
<T>: foo.bar.box.User
318-
$receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any]' type=kotlin.reflect.KClass<foo.bar.box.User>
413+
$receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any; foo.bar.Product]' type=kotlin.reflect.KClass<foo.bar.box.User>
319414
p0: CONST String type=kotlin.String value="age"
320415
p0: GET_VAR 'val user: foo.bar.box.User declared in foo.bar.box' type=foo.bar.box.User origin=null
321416
VAR name:a type:@[FlexibleNullability] kotlin.Any? [val]
322417
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
323418
$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
324419
$this: CALL 'public final fun <get-java> <T> (): java.lang.Class<T of kotlin.jvm.<get-java>> declared in kotlin.jvm' type=java.lang.Class<foo.bar.box.User> origin=GET_PROPERTY
325420
<T>: foo.bar.box.User
326-
$receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any]' type=kotlin.reflect.KClass<foo.bar.box.User>
421+
$receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any; foo.bar.Product]' type=kotlin.reflect.KClass<foo.bar.box.User>
327422
p0: CONST String type=kotlin.String value="a"
328423
p0: GET_VAR 'val user: foo.bar.box.User declared in foo.bar.box' type=foo.bar.box.User origin=null
329424
VAR name:b type:@[FlexibleNullability] kotlin.Any? [val]
330425
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
331426
$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
332427
$this: CALL 'public final fun <get-java> <T> (): java.lang.Class<T of kotlin.jvm.<get-java>> declared in kotlin.jvm' type=java.lang.Class<foo.bar.box.User> origin=GET_PROPERTY
333428
<T>: foo.bar.box.User
334-
$receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any]' type=kotlin.reflect.KClass<foo.bar.box.User>
429+
$receiver: CLASS_REFERENCE 'CLASS CLASS name:User modality:FINAL visibility:local [data] superTypes:[kotlin.Any; foo.bar.Product]' type=kotlin.reflect.KClass<foo.bar.box.User>
335430
p0: CONST String type=kotlin.String value="b"
336431
p0: GET_VAR 'val user: foo.bar.box.User declared in foo.bar.box' type=foo.bar.box.User origin=null
337432
WHEN type=kotlin.Unit origin=IF

compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.fir.txt

+10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ FILE: dataClassInFunctionTest.kt
1515
public final val name: R|kotlin/String| = R|<local>/name|
1616
public get(): R|kotlin/String|
1717

18+
}
19+
public abstract interface Equals : R|kotlin/Any| {
20+
public abstract fun canEqual(that: R|kotlin/Any?|): R|kotlin/Boolean|
21+
22+
}
23+
public abstract interface Product : R|foo/bar/Equals| {
24+
public abstract fun productElement(n: R|kotlin/Int|): R|kotlin/Any|
25+
26+
public abstract fun productArity(): R|kotlin/Int|
27+
1828
}
1929
public final fun box(): R|kotlin/String| {
2030
@R|foo/bar/Sparkify|() local final data class User : R|kotlin/Any| {

compiler-plugin/src/test/resources/testData/box/dataClassInFunctionTest.kt

+11
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ package foo.bar
33
annotation class Sparkify
44
annotation class ColumnName(val name: String)
55

6+
// Fake Equals
7+
interface Equals {
8+
fun canEqual(that: Any?): Boolean
9+
}
10+
11+
// Fake Product
12+
interface Product: Equals {
13+
fun productElement(n: Int): Any
14+
fun productArity(): Int
15+
}
16+
617
fun box(): String {
718

819
@Sparkify

0 commit comments

Comments
 (0)