diff --git a/js/js.translator/testData/expression/invoke/cases/inheritFromFunctionTraits.kt b/js/js.translator/testData/expression/invoke/cases/inheritFromFunctionTraits.kt index 81b6bb60977..32d4d7e9cda 100644 --- a/js/js.translator/testData/expression/invoke/cases/inheritFromFunctionTraits.kt +++ b/js/js.translator/testData/expression/invoke/cases/inheritFromFunctionTraits.kt @@ -1,31 +1,39 @@ +/** + * NOTE: this test originally checked that values of classes inheriting from functions could be invoked as functions. + * However, Function{n} / ExtensionFunction{n} classes were incompatible with JS functions our lambdas were compiled to. + * This led to runtime errors (see KT-7692), so the test is temporarily disabled. + * + * TODO: support inheritance from function types and re-enable this test + */ + package foo -class Bar : Function0 { - override fun invoke() = "Bar.invoke()" +class Bar/* : Function0*/ { + fun invoke() = "Bar.invoke()" } -class Baz : Function2 { - override fun invoke(i: Int, b: Boolean) = "Baz.invoke($i, $b)" +class Baz/* : Function2*/ { + fun invoke(i: Int, b: Boolean) = "Baz.invoke($i, $b)" } -class ExtBar : ExtensionFunction0 { - override fun String.invoke() = "ExtBar.invoke($this)" +class ExtBar/* : ExtensionFunction0*/ { + fun String.invoke() = "ExtBar.invoke($this)" } -class ExtBaz : ExtensionFunction2 { - override fun String.invoke(i: Int, b: Boolean) = "ExtBaz.invoke($this, $i, $b)" +class ExtBaz/* : ExtensionFunction2*/ { + fun String.invoke(i: Int, b: Boolean) = "ExtBaz.invoke($this, $i, $b)" } -class Mixed : +class Mixed/* : Function1, Function2, ExtensionFunction1, - ExtensionFunction2 + ExtensionFunction2*/ { - override fun invoke(i: Int) = "Mixed.invoke($i)" - override fun invoke(i: Int, b: Boolean) = "Mixed.invoke($i, $b)" - override fun Int.invoke(b: Boolean) = "ext Mixed.invoke($this, $b)" - override fun Int.invoke(i: Int, b: Boolean) = "ext Mixed.invoke($this, $i, $b)" + fun invoke(i: Int) = "Mixed.invoke($i)" + fun invoke(i: Int, b: Boolean) = "Mixed.invoke($i, $b)" + fun Int.invoke(b: Boolean) = "ext Mixed.invoke($this, $b)" + fun Int.invoke(i: Int, b: Boolean) = "ext Mixed.invoke($this, $i, $b)" } fun box(): String { @@ -46,4 +54,4 @@ fun box(): String { assertEquals("ext Mixed.invoke(29, 304, false)", 29.mixed(304, false)) return "OK" -} \ No newline at end of file +}