Add some new tests on functions and extension functions
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
fun box(): String {
|
||||||
|
val f = fun (s: String): String = s
|
||||||
|
val g = f as String.() -> String
|
||||||
|
if ("OK".g() != "OK") return "Fail 1"
|
||||||
|
|
||||||
|
val h = fun String.(): String = this
|
||||||
|
val i = h as (String) -> String
|
||||||
|
if (i("OK") != "OK") return "Fail 2"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
import kotlin.jvm.functions.Function2;
|
||||||
|
import kotlin.reflect.KMemberFunction;
|
||||||
|
|
||||||
|
public class J {
|
||||||
|
public static String go() {
|
||||||
|
KMemberFunction<K, String> fun = K.Companion.getRef();
|
||||||
|
Object result = ((Function2) fun).invoke(new K(), "KO");
|
||||||
|
return (String) result;
|
||||||
|
}
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
class K {
|
||||||
|
fun reverse(s: String): String {
|
||||||
|
return s.reverse()
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun getRef() = K::reverse
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return J.go()
|
||||||
|
}
|
||||||
+2
@@ -0,0 +1,2 @@
|
|||||||
|
fun box(): String =
|
||||||
|
if (listOf("abc", "de", "f").map(String::length) == listOf(3, 2, 1)) "OK" else "Fail"
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
// This test checks that annotations on extension function types are preserved. See the corresponding .txt file
|
||||||
|
|
||||||
|
annotation class ann
|
||||||
|
|
||||||
|
interface Some {
|
||||||
|
fun f1(): String.() -> Int
|
||||||
|
fun f2(): @extension String.() -> Int
|
||||||
|
fun f3(): @ann String.() -> Int
|
||||||
|
fun f4(): @extension @ann String.() -> Int
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal interface Some {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
internal abstract fun f1(): kotlin.String.() -> kotlin.Int
|
||||||
|
internal abstract fun f2(): @[kotlin.extension()] kotlin.String.() -> kotlin.Int
|
||||||
|
internal abstract fun f3(): @[ann()] kotlin.String.() -> kotlin.Int
|
||||||
|
internal abstract fun f4(): @[kotlin.extension() ann()] kotlin.String.() -> kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
internal final annotation class ann : kotlin.Annotation {
|
||||||
|
public constructor ann()
|
||||||
|
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
|
||||||
|
}
|
||||||
@@ -711,6 +711,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("extensionFunctionType.kt")
|
||||||
|
public void testExtensionFunctionType() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/extensionFunctionType.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("forParameterAnnotationResolve.kt")
|
@TestMetadata("forParameterAnnotationResolve.kt")
|
||||||
public void testForParameterAnnotationResolve() throws Exception {
|
public void testForParameterAnnotationResolve() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/annotations/forParameterAnnotationResolve.kt");
|
||||||
|
|||||||
+6
@@ -3894,6 +3894,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/functions/invoke"), Pattern.compile("^(.+)\\.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/functions/invoke"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("castFunctionToExtension.kt")
|
||||||
|
public void testCastFunctionToExtension() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/functions/invoke/castFunctionToExtension.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("extensionInvokeOnExpr.kt")
|
@TestMetadata("extensionInvokeOnExpr.kt")
|
||||||
public void testExtensionInvokeOnExpr() throws Exception {
|
public void testExtensionInvokeOnExpr() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/functions/invoke/extensionInvokeOnExpr.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/functions/invoke/extensionInvokeOnExpr.kt");
|
||||||
|
|||||||
+6
@@ -229,6 +229,12 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege
|
|||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithJava/reflection"), Pattern.compile("^([^\\.]+)$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithJava/reflection"), Pattern.compile("^([^\\.]+)$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functionReferenceErasedToKFunction")
|
||||||
|
public void testFunctionReferenceErasedToKFunction() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/reflection/functionReferenceErasedToKFunction/");
|
||||||
|
doTestWithJava(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("javaPropertyInheritedInKotlin")
|
@TestMetadata("javaPropertyInheritedInKotlin")
|
||||||
public void testJavaPropertyInheritedInKotlin() throws Exception {
|
public void testJavaPropertyInheritedInKotlin() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/reflection/javaPropertyInheritedInKotlin/");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/reflection/javaPropertyInheritedInKotlin/");
|
||||||
|
|||||||
+6
@@ -513,6 +513,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
|||||||
doTestWithStdlib(fileName);
|
doTestWithStdlib(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("listOfStringsMapLength.kt")
|
||||||
|
public void testListOfStringsMapLength() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/callableReference/function/listOfStringsMapLength.kt");
|
||||||
|
doTestWithStdlib(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nestedConstructorFromClass.kt")
|
@TestMetadata("nestedConstructorFromClass.kt")
|
||||||
public void testNestedConstructorFromClass() throws Exception {
|
public void testNestedConstructorFromClass() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/callableReference/function/nestedConstructorFromClass.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/callableReference/function/nestedConstructorFromClass.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user