Disallow function types with big arity on JVM if LV < 1.3 or API < 1.3
The implementation is a bit obscure because this worked on JS since Kotlin 1.0 and we should not break that; however, on JVM, a diagnostic will be reported with old language/API version #KT-25241 Fixed
This commit is contained in:
+1
@@ -1,3 +1,4 @@
|
||||
// !LANGUAGE: +FunctionTypesWithBigArity
|
||||
// WITH_RUNTIME
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: J.java
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// !LANGUAGE: +FunctionTypesWithBigArity
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
|
||||
class A(val value: Int) {
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// !LANGUAGE: +FunctionTypesWithBigArity
|
||||
// IGNORE_BACKEND: JS_IR, JS
|
||||
|
||||
class A
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// !LANGUAGE: +FunctionTypesWithBigArity
|
||||
|
||||
class A
|
||||
|
||||
fun foo(
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// !LANGUAGE: +FunctionTypesWithBigArity
|
||||
|
||||
class A(val value: Int)
|
||||
|
||||
private fun check(actual: A, expected: Int) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// !LANGUAGE: +FunctionTypesWithBigArity
|
||||
// WITH_RUNTIME
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: J.java
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// !LANGUAGE: -FunctionTypesWithBigArity
|
||||
|
||||
// This test does not make sense for JVM because a diagnostic is reported when function types with big arity are not available
|
||||
// (see diagnostics/tests/sourceCompatibility/noBigFunctionTypes.kt)
|
||||
// IGNORE_BACKEND: JVM
|
||||
|
||||
class A
|
||||
|
||||
fun foo(
|
||||
p00: A, p01: A, p02: A, p03: A, p04: A, p05: A, p06: A, p07: A, p08: A, p09: A,
|
||||
p10: A, p11: A, p12: A, p13: A, p14: A, p15: A, p16: A, p17: A, p18: A, p19: A,
|
||||
p20: A, p21: A, p22: A, p23: A, p24: A, p25: A, p26: A, p27: A, p28: A, p29: A
|
||||
): String = "OK"
|
||||
|
||||
fun bar(x: Function30<A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, String>): String {
|
||||
val a = A()
|
||||
return x(a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a, a)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return bar(::foo)
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
// !LANGUAGE: +FunctionTypesWithBigArity
|
||||
|
||||
// Implementing function interface is prohibited in JavaScript
|
||||
// IGNORE_BACKEND: JS_IR, JS
|
||||
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// !LANGUAGE: +FunctionTypesWithBigArity
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// FILE: Test.java
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// !LANGUAGE: +FunctionTypesWithBigArity
|
||||
// IGNORE_BACKEND: JS_IR, JS, NATIVE
|
||||
// WITH_REFLECT
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// !LANGUAGE: +FunctionTypesWithBigArity
|
||||
// IGNORE_BACKEND: JS_IR, JS, NATIVE
|
||||
// WITH_REFLECT
|
||||
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// !LANGUAGE: -FunctionTypesWithBigArity
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
class A
|
||||
|
||||
fun foo(
|
||||
p00: A, p01: A, p02: A, p03: A, p04: A, p05: A, p06: A, p07: A, p08: A, p09: A,
|
||||
p10: A, p11: A, p12: A, p13: A, p14: A, p15: A, p16: A, p17: A, p18: A, p19: A,
|
||||
p20: A, p21: A, p22: A, p23: A, p24: A, p25: A, p26: A, p27: A, p28: A, p29: A
|
||||
) {}
|
||||
|
||||
fun bar(x: Any) {}
|
||||
|
||||
fun test(vararg x: <!UNSUPPORTED_FEATURE!>Function30<!><*, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, Unit>) {
|
||||
bar(<!UNSUPPORTED_FEATURE!>::foo<!>)
|
||||
bar(x)
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ x: kotlin.Any): kotlin.Unit
|
||||
public fun foo(/*0*/ p00: A, /*1*/ p01: A, /*2*/ p02: A, /*3*/ p03: A, /*4*/ p04: A, /*5*/ p05: A, /*6*/ p06: A, /*7*/ p07: A, /*8*/ p08: A, /*9*/ p09: A, /*10*/ p10: A, /*11*/ p11: A, /*12*/ p12: A, /*13*/ p13: A, /*14*/ p14: A, /*15*/ p15: A, /*16*/ p16: A, /*17*/ p17: A, /*18*/ p18: A, /*19*/ p19: A, /*20*/ p20: A, /*21*/ p21: A, /*22*/ p22: A, /*23*/ p23: A, /*24*/ p24: A, /*25*/ p25: A, /*26*/ p26: A, /*27*/ p27: A, /*28*/ p28: A, /*29*/ p29: A): kotlin.Unit
|
||||
public fun test(/*0*/ vararg x: kotlin.Function30<*, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, kotlin.Unit> /*kotlin.Array<out kotlin.Function30<*, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, *, kotlin.Unit>>*/): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user