diff --git a/compiler/testData/builtin-classes.txt b/compiler/testData/builtin-classes.txt index ba12e7f348a..294e121a80e 100644 --- a/compiler/testData/builtin-classes.txt +++ b/compiler/testData/builtin-classes.txt @@ -476,98 +476,6 @@ public abstract class Enum> : kotlin.Comparable { } } -public interface ExtensionFunction0 { - public abstract fun T.invoke(): R -} - -public interface ExtensionFunction1 { - public abstract fun T.invoke(/*0*/ p1: P1): R -} - -public interface ExtensionFunction10 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3, /*3*/ p4: P4, /*4*/ p5: P5, /*5*/ p6: P6, /*6*/ p7: P7, /*7*/ p8: P8, /*8*/ p9: P9, /*9*/ p10: P10): R -} - -public interface ExtensionFunction11 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3, /*3*/ p4: P4, /*4*/ p5: P5, /*5*/ p6: P6, /*6*/ p7: P7, /*7*/ p8: P8, /*8*/ p9: P9, /*9*/ p10: P10, /*10*/ p11: P11): R -} - -public interface ExtensionFunction12 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3, /*3*/ p4: P4, /*4*/ p5: P5, /*5*/ p6: P6, /*6*/ p7: P7, /*7*/ p8: P8, /*8*/ p9: P9, /*9*/ p10: P10, /*10*/ p11: P11, /*11*/ p12: P12): R -} - -public interface ExtensionFunction13 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3, /*3*/ p4: P4, /*4*/ p5: P5, /*5*/ p6: P6, /*6*/ p7: P7, /*7*/ p8: P8, /*8*/ p9: P9, /*9*/ p10: P10, /*10*/ p11: P11, /*11*/ p12: P12, /*12*/ p13: P13): R -} - -public interface ExtensionFunction14 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3, /*3*/ p4: P4, /*4*/ p5: P5, /*5*/ p6: P6, /*6*/ p7: P7, /*7*/ p8: P8, /*8*/ p9: P9, /*9*/ p10: P10, /*10*/ p11: P11, /*11*/ p12: P12, /*12*/ p13: P13, /*13*/ p14: P14): R -} - -public interface ExtensionFunction15 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3, /*3*/ p4: P4, /*4*/ p5: P5, /*5*/ p6: P6, /*6*/ p7: P7, /*7*/ p8: P8, /*8*/ p9: P9, /*9*/ p10: P10, /*10*/ p11: P11, /*11*/ p12: P12, /*12*/ p13: P13, /*13*/ p14: P14, /*14*/ p15: P15): R -} - -public interface ExtensionFunction16 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3, /*3*/ p4: P4, /*4*/ p5: P5, /*5*/ p6: P6, /*6*/ p7: P7, /*7*/ p8: P8, /*8*/ p9: P9, /*9*/ p10: P10, /*10*/ p11: P11, /*11*/ p12: P12, /*12*/ p13: P13, /*13*/ p14: P14, /*14*/ p15: P15, /*15*/ p16: P16): R -} - -public interface ExtensionFunction17 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3, /*3*/ p4: P4, /*4*/ p5: P5, /*5*/ p6: P6, /*6*/ p7: P7, /*7*/ p8: P8, /*8*/ p9: P9, /*9*/ p10: P10, /*10*/ p11: P11, /*11*/ p12: P12, /*12*/ p13: P13, /*13*/ p14: P14, /*14*/ p15: P15, /*15*/ p16: P16, /*16*/ p17: P17): R -} - -public interface ExtensionFunction18 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3, /*3*/ p4: P4, /*4*/ p5: P5, /*5*/ p6: P6, /*6*/ p7: P7, /*7*/ p8: P8, /*8*/ p9: P9, /*9*/ p10: P10, /*10*/ p11: P11, /*11*/ p12: P12, /*12*/ p13: P13, /*13*/ p14: P14, /*14*/ p15: P15, /*15*/ p16: P16, /*16*/ p17: P17, /*17*/ p18: P18): R -} - -public interface ExtensionFunction19 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3, /*3*/ p4: P4, /*4*/ p5: P5, /*5*/ p6: P6, /*6*/ p7: P7, /*7*/ p8: P8, /*8*/ p9: P9, /*9*/ p10: P10, /*10*/ p11: P11, /*11*/ p12: P12, /*12*/ p13: P13, /*13*/ p14: P14, /*14*/ p15: P15, /*15*/ p16: P16, /*16*/ p17: P17, /*17*/ p18: P18, /*18*/ p19: P19): R -} - -public interface ExtensionFunction2 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2): R -} - -public interface ExtensionFunction20 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3, /*3*/ p4: P4, /*4*/ p5: P5, /*5*/ p6: P6, /*6*/ p7: P7, /*7*/ p8: P8, /*8*/ p9: P9, /*9*/ p10: P10, /*10*/ p11: P11, /*11*/ p12: P12, /*12*/ p13: P13, /*13*/ p14: P14, /*14*/ p15: P15, /*15*/ p16: P16, /*16*/ p17: P17, /*17*/ p18: P18, /*18*/ p19: P19, /*19*/ p20: P20): R -} - -public interface ExtensionFunction21 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3, /*3*/ p4: P4, /*4*/ p5: P5, /*5*/ p6: P6, /*6*/ p7: P7, /*7*/ p8: P8, /*8*/ p9: P9, /*9*/ p10: P10, /*10*/ p11: P11, /*11*/ p12: P12, /*12*/ p13: P13, /*13*/ p14: P14, /*14*/ p15: P15, /*15*/ p16: P16, /*16*/ p17: P17, /*17*/ p18: P18, /*18*/ p19: P19, /*19*/ p20: P20, /*20*/ p21: P21): R -} - -public interface ExtensionFunction22 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3, /*3*/ p4: P4, /*4*/ p5: P5, /*5*/ p6: P6, /*6*/ p7: P7, /*7*/ p8: P8, /*8*/ p9: P9, /*9*/ p10: P10, /*10*/ p11: P11, /*11*/ p12: P12, /*12*/ p13: P13, /*13*/ p14: P14, /*14*/ p15: P15, /*15*/ p16: P16, /*16*/ p17: P17, /*17*/ p18: P18, /*18*/ p19: P19, /*19*/ p20: P20, /*20*/ p21: P21, /*21*/ p22: P22): R -} - -public interface ExtensionFunction3 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3): R -} - -public interface ExtensionFunction4 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3, /*3*/ p4: P4): R -} - -public interface ExtensionFunction5 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3, /*3*/ p4: P4, /*4*/ p5: P5): R -} - -public interface ExtensionFunction6 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3, /*3*/ p4: P4, /*4*/ p5: P5, /*5*/ p6: P6): R -} - -public interface ExtensionFunction7 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3, /*3*/ p4: P4, /*4*/ p5: P5, /*5*/ p6: P6, /*6*/ p7: P7): R -} - -public interface ExtensionFunction8 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3, /*3*/ p4: P4, /*4*/ p5: P5, /*5*/ p6: P6, /*6*/ p7: P7, /*7*/ p8: P8): R -} - -public interface ExtensionFunction9 { - public abstract fun T.invoke(/*0*/ p1: P1, /*1*/ p2: P2, /*2*/ p3: P3, /*3*/ p4: P4, /*4*/ p5: P5, /*5*/ p6: P6, /*6*/ p7: P7, /*7*/ p8: P8, /*8*/ p9: P9): R -} - public final class Float : kotlin.Number, kotlin.Comparable { /*primary*/ private constructor Float() public final fun compareTo(/*0*/ other: kotlin.Byte): kotlin.Int diff --git a/core/builtins/src/kotlin/ExtensionFunctions.kt b/core/builtins/src/kotlin/ExtensionFunctions.kt deleted file mode 100644 index 7621541f9e5..00000000000 --- a/core/builtins/src/kotlin/ExtensionFunctions.kt +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Auto-generated file. DO NOT EDIT! - -package kotlin - -/** An extension function that takes 0 arguments. */ -public interface ExtensionFunction0 : Function { - /** Invokes the function. */ - public fun T.invoke(): R -} -/** An extension function that takes 1 argument. */ -public interface ExtensionFunction1 : Function { - /** Invokes the function with the specified argument. */ - public fun T.invoke(p1: P1): R -} -/** An extension function that takes 2 arguments. */ -public interface ExtensionFunction2 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2): R -} -/** An extension function that takes 3 arguments. */ -public interface ExtensionFunction3 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3): R -} -/** An extension function that takes 4 arguments. */ -public interface ExtensionFunction4 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4): R -} -/** An extension function that takes 5 arguments. */ -public interface ExtensionFunction5 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): R -} -/** An extension function that takes 6 arguments. */ -public interface ExtensionFunction6 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): R -} -/** An extension function that takes 7 arguments. */ -public interface ExtensionFunction7 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): R -} -/** An extension function that takes 8 arguments. */ -public interface ExtensionFunction8 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): R -} -/** An extension function that takes 9 arguments. */ -public interface ExtensionFunction9 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): R -} -/** An extension function that takes 10 arguments. */ -public interface ExtensionFunction10 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10): R -} -/** An extension function that takes 11 arguments. */ -public interface ExtensionFunction11 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11): R -} -/** An extension function that takes 12 arguments. */ -public interface ExtensionFunction12 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12): R -} -/** An extension function that takes 13 arguments. */ -public interface ExtensionFunction13 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13): R -} -/** An extension function that takes 14 arguments. */ -public interface ExtensionFunction14 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14): R -} -/** An extension function that takes 15 arguments. */ -public interface ExtensionFunction15 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15): R -} -/** An extension function that takes 16 arguments. */ -public interface ExtensionFunction16 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16): R -} -/** An extension function that takes 17 arguments. */ -public interface ExtensionFunction17 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17): R -} -/** An extension function that takes 18 arguments. */ -public interface ExtensionFunction18 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18): R -} -/** An extension function that takes 19 arguments. */ -public interface ExtensionFunction19 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19): R -} -/** An extension function that takes 20 arguments. */ -public interface ExtensionFunction20 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20): R -} -/** An extension function that takes 21 arguments. */ -public interface ExtensionFunction21 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21): R -} -/** An extension function that takes 22 arguments. */ -public interface ExtensionFunction22 : Function { - /** Invokes the function with the specified arguments. */ - public fun T.invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21, p22: P22): R -} diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/functions.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/functions.kt index 16bde8d463b..25c1625bfb6 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/functions.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/functions.kt @@ -21,30 +21,11 @@ import java.io.PrintWriter val MAX_PARAM_COUNT = 22 -enum class FunctionKind( - val classFqNamePrefix: String, - val docPrefix: String, - val hasReceiverParameter: Boolean -) { - FUNCTION : FunctionKind("kotlin.jvm.functions.Function", "A function", false) - EXTENSION_FUNCTION : FunctionKind("kotlin.ExtensionFunction", "An extension function", true) - - val classNamePrefix: String get() = classFqNamePrefix.substringAfterLast('.') - val packageFqName: String get() = classFqNamePrefix.substringBeforeLast('.') - val fileName: String get() = classFqNamePrefix.replace('.', '/') + "s.kt" - - fun getClassName(i: Int) = classNamePrefix + i -} - -class GenerateFunctions(out: PrintWriter, val kind: FunctionKind) : BuiltInsSourceGenerator(out) { - override fun getPackage() = kind.packageFqName +class GenerateFunctions(out: PrintWriter) : BuiltInsSourceGenerator(out) { + override fun getPackage() = "kotlin.jvm.functions" fun generateTypeParameters(i: Int, variance: Boolean) { out.print("<") - if (kind.hasReceiverParameter) { - if (variance) out.print("in ") - out.print("T, ") - } for (j in 1..i) { if (variance) out.print("in ") @@ -64,7 +45,7 @@ class GenerateFunctions(out: PrintWriter, val kind: FunctionKind) : BuiltInsSour override fun generateBody() { for (i in 0..MAX_PARAM_COUNT) { generateDocumentation(i) - out.print("public interface " + kind.getClassName(i)) + out.print("public interface Function$i") generateTypeParameters(i, variance = true) generateSuperClass() generateFunctionClassBody(i) @@ -73,7 +54,7 @@ class GenerateFunctions(out: PrintWriter, val kind: FunctionKind) : BuiltInsSour fun generateDocumentation(i: Int) { val suffix = if (i == 1) "" else "s" - out.println("/** ${kind.docPrefix} that takes $i argument${suffix}. */") + out.println("/** A function that takes $i argument${suffix}. */") } fun generateSuperClass() { @@ -91,11 +72,12 @@ class GenerateFunctions(out: PrintWriter, val kind: FunctionKind) : BuiltInsSour fun generateInvokeSignature(i: Int) { if (i == 0) { out.println(" /** Invokes the function. */") - } else { + } + else { val suffix = if (i == 1) "" else "s" out.println(" /** Invokes the function with the specified argument${suffix}. */") } - out.print(" public fun ${if (kind.hasReceiverParameter) "T." else ""}invoke(") + out.print(" public fun invoke(") for (j in 1..i) { out.print("p$j: P$j") if (j < i) { diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/generateBuiltIns.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/generateBuiltIns.kt index a001e133092..b34f6c8ad41 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/generateBuiltIns.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/generateBuiltIns.kt @@ -19,7 +19,6 @@ package org.jetbrains.kotlin.generators.builtins.generateBuiltIns import org.jetbrains.kotlin.generators.builtins.arrayIterators.GenerateArrayIterators import org.jetbrains.kotlin.generators.builtins.arrays.GenerateArrays import org.jetbrains.kotlin.generators.builtins.functionImpl.GenerateFunctionImpl -import org.jetbrains.kotlin.generators.builtins.functions.FunctionKind import org.jetbrains.kotlin.generators.builtins.functions.GenerateFunctions import org.jetbrains.kotlin.generators.builtins.iterators.GenerateIterators import org.jetbrains.kotlin.generators.builtins.progressionIterators.GenerateProgressionIterators @@ -67,11 +66,7 @@ fun generateBuiltIns(generate: (File, (PrintWriter) -> BuiltInsSourceGenerator) assertExists(BUILT_INS_SRC_DIR) assertExists(RUNTIME_JVM_DIR) - for (kind in FunctionKind.values()) { - val dir = if (kind == FunctionKind.FUNCTION) RUNTIME_JVM_DIR else BUILT_INS_SRC_DIR - generate(File(dir, kind.fileName)) { GenerateFunctions(it, kind) } - } - + generate(File(RUNTIME_JVM_DIR, "kotlin/jvm/functions/Functions.kt")) { GenerateFunctions(it) } generate(File(RUNTIME_JVM_DIR, "kotlin/jvm/internal/FunctionImpl.java")) { GenerateFunctionImpl(it) } generate(File(BUILT_INS_NATIVE_DIR, "kotlin/Arrays.kt")) { GenerateArrays(it) } generate(File(BUILT_INS_NATIVE_DIR, "kotlin/Primitives.kt")) { GeneratePrimitives(it) } diff --git a/jslib_files.xml b/jslib_files.xml index ba89c65595f..6b228850dba 100644 --- a/jslib_files.xml +++ b/jslib_files.xml @@ -2,7 +2,6 @@ -