Skip to content

Commit 844b368

Browse files
lunakolySpace Team
authored andcommitted
[Commonizer] Fix incorrect source code in the test data
The K2 pipeline is a bit stricter in what code it allows, so some of the existing test code samples no longer compile without these changes.
1 parent 4ae2429 commit 844b368

File tree

29 files changed

+234
-130
lines changed

29 files changed

+234
-130
lines changed

native/commonizer/testData/callableMemberCommonization/extensionReceivers/commonized/common/package_root.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ expect fun String.intFunction(): Int
1818
expect fun Planet.intFunction(): Int
1919

2020
expect val <T> T.propertyWithTypeParameter1: Int
21-
expect val <T : Any?> T.propertyWithTypeParameter2: Int
21+
expect val <T> T.propertyWithTypeParameter2: Int
2222
expect val <T : CharSequence> T.propertyWithTypeParameter4: Int
2323

2424
expect fun <T> T.functionWithTypeParameter1()

native/commonizer/testData/callableMemberCommonization/extensionReceivers/original/js/package_root.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ val <T> T.propertyWithTypeParameter1 get() = 42
2424
val <T> T.propertyWithTypeParameter2 get() = 42
2525
val <T> T.propertyWithTypeParameter3 get() = 42
2626
val <T : CharSequence> T.propertyWithTypeParameter4: Int get() = length
27-
val <T : CharSequence> T.propertyWithTypeParameter5: Int get() = length
27+
val <T : CharSequence> T.propertyWithTypeParameter5: Int get() = 20
2828
val <T : CharSequence> T.propertyWithTypeParameter6: Int get() = length
2929
val <T : CharSequence> T.propertyWithTypeParameter7: Int get() = length
3030
val <T> T.propertyWithTypeParameter8 get() = 42

native/commonizer/testData/callableMemberCommonization/extensionReceivers/original/jvm/package_root.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ val <T> T.propertyWithTypeParameter1 get() = 42
2424
val <T : Any?> T.propertyWithTypeParameter2 get() = 42
2525
val <T : Any> T.propertyWithTypeParameter3 get() = 42
2626
val <T : CharSequence> T.propertyWithTypeParameter4: Int get() = length
27-
val <T : Appendable> T.propertyWithTypeParameter5: Int get() = length
27+
val <T : Appendable> T.propertyWithTypeParameter5: Int get() = 20
2828
val <T : String> T.propertyWithTypeParameter6: Int get() = length
2929
val String.propertyWithTypeParameter7: Int get() = length
3030
val <Q> Q.propertyWithTypeParameter8 get() = 42
31-
val <T, Q> T.propertyWithTypeParameter9 get() = 42
31+
val <T, Q> Map<T, Q>.propertyWithTypeParameter9 get() = 42
3232

3333
fun <T> T.functionWithTypeParameter1() {}
3434
fun <Q> Q.functionWithTypeParameter2() {}

native/commonizer/testData/callableMemberCommonization/returnTypes/original/js/package_root.kt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@ val propertyWithInferredType1 = 1
44
val propertyWithInferredType2 = "hello"
55
val propertyWithInferredType3 = 42.toString()
66
val propertyWithInferredType4 = null
7-
val propertyWithInferredType5 = Planet("Earth", 12742)
7+
val propertyWithInferredType5 = Planet("Earth", 12742.0)
88

99
typealias A = Planet
1010
typealias C = Planet
1111

1212
// with inferred type:
1313
val property1 = 1
1414
val property2 = "hello"
15-
val property3 = Planet("Earth", 12742)
16-
val property4 = A("Earth", 12742)
17-
val property5 = A("Earth", 12742)
18-
val property6 = Planet("Earth", 12742)
19-
val property7 = C("Earth", 12742)
15+
val property3 = Planet("Earth", 12742.0)
16+
val property4 = A("Earth", 12742.0)
17+
val property5 = A("Earth", 12742.0)
18+
val property6 = Planet("Earth", 12742.0)
19+
val property7 = C("Earth", 12742.0)
2020

2121
// with inferred type:
2222
fun function1() = 1
2323
fun function2() = "hello"
24-
fun function3() = Planet("Earth", 12742)
25-
fun function4() = A("Earth", 12742)
26-
fun function5() = A("Earth", 12742)
27-
fun function6() = Planet("Earth", 12742)
28-
fun function7() = C("Earth", 12742)
24+
fun function3() = Planet("Earth", 12742.0)
25+
fun function4() = A("Earth", 12742.0)
26+
fun function5() = A("Earth", 12742.0)
27+
fun function6() = Planet("Earth", 12742.0)
28+
fun function7() = C("Earth", 12742.0)
2929

3030
val propertyWithMismatchedType1: Int = 1
3131
val propertyWithMismatchedType2: Int = 1
@@ -51,8 +51,8 @@ fun functionWithTypeParametersInReturnType6(): List<String> = listOf("hello")
5151
fun functionWithTypeParametersInReturnType7() = Box(1)
5252
fun functionWithTypeParametersInReturnType8() = Box(1)
5353
fun functionWithTypeParametersInReturnType9() = Box("hello")
54-
fun functionWithTypeParametersInReturnType10() = Box(Planet("Earth", 12742))
55-
fun functionWithTypeParametersInReturnType11() = Box(Planet("Earth", 12742))
54+
fun functionWithTypeParametersInReturnType10() = Box(Planet("Earth", 12742.0))
55+
fun functionWithTypeParametersInReturnType11() = Box(Planet("Earth", 12742.0))
5656
fun functionWithTypeParametersInReturnType12() = Box(Fox())
5757

5858
fun <T> functionWithUnsubstitutedTypeParametersInReturnType1(): T = TODO()

native/commonizer/testData/callableMemberCommonization/returnTypes/original/jvm/package_root.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@ val propertyWithInferredType1 get() = 1
44
val propertyWithInferredType2 get() = "hello"
55
val propertyWithInferredType3 get() = 42.toString()
66
val propertyWithInferredType4 get() = null
7-
val propertyWithInferredType5 get() = Planet("Earth", 12742)
7+
val propertyWithInferredType5 get() = Planet("Earth", 12742.0)
88

99
typealias B = Planet
1010
typealias C = Planet
1111

1212
// with explicit type:
1313
val property1: Int = 1
1414
val property2: String = "hello"
15-
val property3: Planet = Planet("Earth", 12742)
16-
val property4: B = Planet("Earth", 12742)
17-
val property5: Planet = A("Earth", 12742)
18-
val property6: Planet = A("Earth", 12742)
19-
val property7: C = Planet("Earth", 12742)
15+
val property3: Planet = Planet("Earth", 12742.0)
16+
val property4: B = Planet("Earth", 12742.0)
17+
val property5: Planet = B("Earth", 12742.0)
18+
val property6: Planet = B("Earth", 12742.0)
19+
val property7: C = Planet("Earth", 12742.0)
2020

2121
// with explicit type:
2222
fun function1(): Int = 1
2323
fun function2(): String = "hello"
24-
fun function3(): Planet = Planet("Earth", 12742)
25-
fun function4(): B = A("Earth", 12742)
26-
fun function5(): Planet = A("Earth", 12742)
27-
fun function6(): Planet = Planet("Earth", 12742)
28-
fun function7(): C = C("Earth", 12742)
24+
fun function3(): Planet = Planet("Earth", 12742.0)
25+
fun function4(): B = B("Earth", 12742.0)
26+
fun function5(): Planet = B("Earth", 12742.0)
27+
fun function6(): Planet = Planet("Earth", 12742.0)
28+
fun function7(): C = C("Earth", 12742.0)
2929

3030
val propertyWithMismatchedType1: Long = 1
3131
val propertyWithMismatchedType2: Short = 1
@@ -51,7 +51,7 @@ fun functionWithTypeParametersInReturnType6(): List<String> = listOf("hello")
5151
fun functionWithTypeParametersInReturnType7() = Box(1)
5252
fun functionWithTypeParametersInReturnType8() = Box("hello")
5353
fun functionWithTypeParametersInReturnType9() = Box("hello")
54-
fun functionWithTypeParametersInReturnType10() = Box(Planet("Earth", 12742))
54+
fun functionWithTypeParametersInReturnType10() = Box(Planet("Earth", 12742.0))
5555
fun functionWithTypeParametersInReturnType11() = Box(Fox())
5656
fun functionWithTypeParametersInReturnType12() = Box(Fox())
5757

native/commonizer/testData/classifierCommonization/classKindAndModifiers/original/jvm/package_root.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ interface JJ {
137137
}
138138

139139
class KK1(override val property: String) : JJ {
140-
val property2 = property
140+
override val property2 = property
141141
override fun function() = property
142142
}
143143

native/commonizer/testData/classifierCommonization/typeAliases/commonized/common/package_root.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
2+
13
expect class A()
24
// Lifted up type aliases:
35
typealias B = A // class at the RHS
@@ -45,7 +47,7 @@ expect class X // different nullability of the RHS TA
4547
expect class Y // TA at the RHS with the different nullability of own RHS
4648

4749
// Supertypes:
48-
expect class FILE expect constructor(): kotlinx.cinterop.CStructVar
50+
expect class FILE constructor(rawPtr: kotlinx.cinterop.NativePtr): kotlinx.cinterop.CStructVar
4951

5052
typealias uuid_t = __darwin_uuid_t
5153
typealias __darwin_uuid_t = kotlinx.cinterop.CArrayPointer<kotlinx.cinterop.UByteVar>

native/commonizer/testData/classifierCommonization/typeAliases/original/linux/package_root.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
2+
13
class A
24

35
// Lifted up type aliases:
@@ -53,7 +55,7 @@ typealias Y = V // TA at the RHS with the different nullability of own RHS
5355
// Supertypes:
5456
typealias FILE = _IO_FILE
5557

56-
final class _IO_FILE : kotlinx.cinterop.CStructVar {}
58+
final class _IO_FILE(rawPtr: kotlinx.cinterop.NativePtr) : kotlinx.cinterop.CStructVar(rawPtr) {}
5759

5860
typealias uuid_t = __darwin_uuid_t
5961
typealias __darwin_uuid_t = kotlinx.cinterop.CArrayPointer<kotlinx.cinterop.UByteVar>

native/commonizer/testData/classifierCommonization/typeAliases/original/macos/package_root.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@file:OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
2+
13
class A
24

35
// Lifted up type aliases:
@@ -53,7 +55,7 @@ typealias Y = V // TA at the RHS with the different nullability of own RHS
5355
// Supertypes:
5456
typealias FILE = __sFILE
5557

56-
final class __sFILE : kotlinx.cinterop.CStructVar {}
58+
final class __sFILE(rawPtr: kotlinx.cinterop.NativePtr) : kotlinx.cinterop.CStructVar(rawPtr) {}
5759

5860
typealias uuid_t = __darwin_uuid_t
5961
typealias __darwin_uuid_t = kotlinx.cinterop.CArrayPointer<kotlinx.cinterop.UByteVar>

native/commonizer/testData/classifierCommonization/typeParameters/commonized/common/package_root.kt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
expect class A2<T : Any?>() {
1+
expect class A2<T>() {
22
val property: T
33
fun function(value: T): T
44

5-
expect class Nested<T : Any?>() {
5+
class Nested<T>() {
66
val property: T
77
fun function(value: T): T
88
}
99

10-
expect inner class Inner() {
10+
inner class Inner() {
1111
val property: T
1212
fun function(value: T): T
1313
}
@@ -17,12 +17,12 @@ expect class B4<T : Any>() {
1717
val property: T
1818
fun function(value: T): T
1919

20-
expect class Nested<T : Any>() {
20+
class Nested<T : Any>() {
2121
val property: T
2222
fun function(value: T): T
2323
}
2424

25-
expect inner class Inner() {
25+
inner class Inner() {
2626
val property: T
2727
fun function(value: T): T
2828
}
@@ -32,12 +32,12 @@ expect class C5<T : CharSequence>() {
3232
val property: T
3333
fun function(value: T): T
3434

35-
expect class Nested<T : CharSequence>() {
35+
class Nested<T : CharSequence>() {
3636
val property: T
3737
fun function(value: T): T
3838
}
3939

40-
expect inner class Inner() {
40+
inner class Inner() {
4141
val property: T
4242
fun function(value: T): T
4343
}
@@ -47,12 +47,12 @@ expect class D6<T : String>() {
4747
val property: T
4848
fun function(value: T): T
4949

50-
expect class Nested<T : String>() {
50+
class Nested<T : String>() {
5151
val property: T
5252
fun function(value: T): T
5353
}
5454

55-
expect inner class Inner() {
55+
inner class Inner() {
5656
val property: T
5757
fun function(value: T): T
5858
}
@@ -62,12 +62,12 @@ expect class E7<String>() {
6262
val property: String
6363
fun function(value: String): String
6464

65-
expect class Nested<String>() {
65+
class Nested<String>() {
6666
val property: String
6767
fun function(value: String): String
6868
}
6969

70-
expect inner class Inner() {
70+
inner class Inner() {
7171
val property: String
7272
fun function(value: String): String
7373
}
@@ -77,12 +77,12 @@ expect class F1<T>() {
7777
val property: T
7878
fun function(value: T): T
7979

80-
expect class Nested<T>() {
80+
class Nested<T>() {
8181
val property: T
8282
fun function(value: T): T
8383
}
8484

85-
expect inner class Inner() {
85+
inner class Inner() {
8686
val property: T
8787
fun function(value: T): T
8888
}
@@ -93,13 +93,13 @@ expect class G1<T, R>() {
9393
val property2: R
9494
fun function(value: T): R
9595

96-
expect class Nested<T, R>() {
96+
class Nested<T, R>() {
9797
val property1: T
9898
val property2: R
9999
fun function(value: T): R
100100
}
101101

102-
expect inner class Inner() {
102+
inner class Inner() {
103103
val property1: T
104104
val property2: R
105105
fun function(value: T): R

0 commit comments

Comments
 (0)