JS: support toDelegateFor in JS backend (see KT-15163)

This commit is contained in:
Alexey Andreev
2016-12-08 14:20:10 +03:00
committed by Stanislav Erokhin
parent 937a933150
commit a01fac9d10
20 changed files with 171 additions and 223 deletions
@@ -1,5 +1,4 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JS
import kotlin.test.*
@@ -1,5 +1,4 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JS
import kotlin.test.*
@@ -1,5 +1,4 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JS
import kotlin.test.*
@@ -1,5 +1,4 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JS
import kotlin.test.*
@@ -1,5 +1,4 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JS
import kotlin.test.*
@@ -1,5 +1,4 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JS
import kotlin.test.*
@@ -1,5 +1,4 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JS
import kotlin.test.*
@@ -10,7 +9,7 @@ inline fun <T> runLogged(entry: String, action: () -> T): T {
return action()
}
operator fun String.toDelegateFor(host: Any?, p: Any): String =
operator fun String.toDelegateFor(host: Any?, p: Any): String =
runLogged("tdf($this);") { this }
operator fun String.getValue(receiver: Any?, p: Any): String =
@@ -1,5 +1,4 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JS
import kotlin.test.*
@@ -1,5 +1,4 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JS
import kotlin.test.*
@@ -1,5 +1,4 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JS
object Host {
class StringDelegate(val s: String) {
@@ -1,5 +1,4 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JS
import kotlin.test.*
import kotlin.reflect.KProperty
@@ -1234,7 +1234,7 @@ fun main(args: Array<String>) {
testGroup("js/js.tests/test", "js/js.translator/testData") {
testClass<AbstractBoxJsTest>() {
model("box/", pattern = "^([^_](.+))\\.kt$")
model("box/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.JS)
}
}
@@ -33,7 +33,7 @@ import java.util.regex.Pattern;
@RunWith(JUnit3RunnerWithInners.class)
public class BoxJsTestGenerated extends AbstractBoxJsTest {
public void testAllFilesPresentInBox() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("js/js.translator/testData/box/annotation")
@@ -41,7 +41,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Annotation extends AbstractBoxJsTest {
public void testAllFilesPresentInAnnotation() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/annotation"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/annotation"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("annotationClass.kt")
@@ -56,7 +56,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class CallableReference extends AbstractBoxJsTest {
public void testAllFilesPresentInCallableReference() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/callableReference"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/callableReference"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("js/js.translator/testData/box/callableReference/function")
@@ -70,7 +70,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
}
public void testAllFilesPresentInFunction() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/callableReference/function"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/callableReference/function"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("classMemberAndExtension.kt")
@@ -295,7 +295,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
}
public void testAllFilesPresentInProperty() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/callableReference/property"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/callableReference/property"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("delegated.kt")
@@ -383,7 +383,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Char extends AbstractBoxJsTest {
public void testAllFilesPresentInChar() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/char"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/char"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("charBinaryOperations.kt")
@@ -446,7 +446,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
}
public void testAllFilesPresentInClassObject() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/classObject"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/classObject"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("defaultObjectSameNamesAsInOuter.kt")
@@ -509,7 +509,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Closure extends AbstractBoxJsTest {
public void testAllFilesPresentInClosure() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/closure"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/closure"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("closureArrayListInstance.kt")
@@ -788,7 +788,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class CrossModuleRef extends AbstractBoxJsTest {
public void testAllFilesPresentInCrossModuleRef() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/crossModuleRef"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/crossModuleRef"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("callableObjectRef.kt")
@@ -863,7 +863,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class DataClass extends AbstractBoxJsTest {
public void testAllFilesPresentInDataClass() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/dataClass"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/dataClass"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("components.kt")
@@ -920,7 +920,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class DefaultArguments extends AbstractBoxJsTest {
public void testAllFilesPresentInDefaultArguments() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/defaultArguments"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/defaultArguments"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("complexExpressionAsDefaultArgument.kt")
@@ -1019,7 +1019,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class DelegateProperty extends AbstractBoxJsTest {
public void testAllFilesPresentInDelegateProperty() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/delegateProperty"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/delegateProperty"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("capturedLocalVal.kt")
@@ -1142,7 +1142,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Delegation extends AbstractBoxJsTest {
public void testAllFilesPresentInDelegation() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/delegation"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/delegation"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("complexDelegation.kt")
@@ -1277,7 +1277,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Dynamic extends AbstractBoxJsTest {
public void testAllFilesPresentInDynamic() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/dynamic"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/dynamic"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("binaryOperations.kt")
@@ -1406,7 +1406,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
}
public void testAllFilesPresentInEnum() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/enum"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/enum"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("enumInheritedFromTrait.kt")
@@ -1475,7 +1475,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Examples extends AbstractBoxJsTest {
public void testAllFilesPresentInExamples() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/examples"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/examples"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("basicmethod.kt")
@@ -1658,7 +1658,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Expression extends AbstractBoxJsTest {
public void testAllFilesPresentInExpression() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("js/js.translator/testData/box/expression/cast")
@@ -1666,7 +1666,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Cast extends AbstractBoxJsTest {
public void testAllFilesPresentInCast() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/cast"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/cast"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("castExtensionToKMutableProperty.kt")
@@ -1831,7 +1831,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class CompareTo extends AbstractBoxJsTest {
public void testAllFilesPresentInCompareTo() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/compareTo"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/compareTo"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("customCompareToMethod.kt")
@@ -1846,7 +1846,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class DollarParameter extends AbstractBoxJsTest {
public void testAllFilesPresentInDollarParameter() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/dollarParameter"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/dollarParameter"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("dollarParameter.kt")
@@ -1861,7 +1861,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Equals extends AbstractBoxJsTest {
public void testAllFilesPresentInEquals() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/equals"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/equals"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("arrays.kt")
@@ -1954,7 +1954,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
}
public void testAllFilesPresentInEvaluationOrder() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/evaluationOrder"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/evaluationOrder"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("andAndWithBreakContinueReturn.kt")
@@ -2137,7 +2137,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class For extends AbstractBoxJsTest {
public void testAllFilesPresentInFor() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/for"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/for"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("forIteratesOverArray.kt")
@@ -2224,7 +2224,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
}
public void testAllFilesPresentInFunction() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/function"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/function"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("callFunInInit.kt")
@@ -2419,7 +2419,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class IdentifierClash extends AbstractBoxJsTest {
public void testAllFilesPresentInIdentifierClash() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/identifierClash"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/identifierClash"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("overloadedFun.kt")
@@ -2440,7 +2440,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class IdentityEquals extends AbstractBoxJsTest {
public void testAllFilesPresentInIdentityEquals() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/identityEquals"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/identityEquals"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("identityEqualsMethod.kt")
@@ -2461,7 +2461,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class If extends AbstractBoxJsTest {
public void testAllFilesPresentInIf() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/if"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/if"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("ifElseAsExpressionWithThrow.kt")
@@ -2494,7 +2494,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Invoke extends AbstractBoxJsTest {
public void testAllFilesPresentInInvoke() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/invoke"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/invoke"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("explicitInvokeLambda.kt")
@@ -2575,7 +2575,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Misc extends AbstractBoxJsTest {
public void testAllFilesPresentInMisc() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/misc"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/misc"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("classWithoutPackage.kt")
@@ -2830,7 +2830,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class StringClass extends AbstractBoxJsTest {
public void testAllFilesPresentInStringClass() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/stringClass"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/stringClass"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("extensionMethods.kt")
@@ -2923,7 +2923,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class StringTemplates extends AbstractBoxJsTest {
public void testAllFilesPresentInStringTemplates() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/stringTemplates"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/stringTemplates"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("objectWithToString.kt")
@@ -2944,7 +2944,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Try extends AbstractBoxJsTest {
public void testAllFilesPresentInTry() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/try"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/try"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("exceptionToString.kt")
@@ -3007,7 +3007,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class When extends AbstractBoxJsTest {
public void testAllFilesPresentInWhen() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/when"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/when"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("doWhileWithOneStmWhen.kt")
@@ -3196,7 +3196,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class While extends AbstractBoxJsTest {
public void testAllFilesPresentInWhile() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/while"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/expression/while"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("doWhileWithComplexCondition.kt")
@@ -3236,7 +3236,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class ExtensionFunction extends AbstractBoxJsTest {
public void testAllFilesPresentInExtensionFunction() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/extensionFunction"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/extensionFunction"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("extensionForSuperclass.kt")
@@ -3347,7 +3347,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
}
public void testAllFilesPresentInExtensionProperty() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/extensionProperty"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/extensionProperty"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("externalExtensionProperty.kt")
@@ -3392,7 +3392,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
}
public void testAllFilesPresentInInheritance() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/inheritance"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/inheritance"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("baseCall.kt")
@@ -3514,7 +3514,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
}
public void testAllFilesPresentInInterfaces() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/inheritance/interfaces"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/inheritance/interfaces"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("withDefaultMethod.kt")
@@ -3542,7 +3542,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Initialize extends AbstractBoxJsTest {
public void testAllFilesPresentInInitialize() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/initialize"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/initialize"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("classInitializer.kt")
@@ -3587,7 +3587,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Inline extends AbstractBoxJsTest {
public void testAllFilesPresentInInline() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/inline"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/inline"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("anonymousFunction.kt")
@@ -3956,7 +3956,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class InlineEvaluationOrder extends AbstractBoxJsTest {
public void testAllFilesPresentInInlineEvaluationOrder() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/inlineEvaluationOrder"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/inlineEvaluationOrder"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("argumentOfCall.kt")
@@ -4265,7 +4265,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class InlineMultiFile extends AbstractBoxJsTest {
public void testAllFilesPresentInInlineMultiFile() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/inlineMultiFile"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/inlineMultiFile"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("anonymousObjectOnCallSite.kt")
@@ -4442,7 +4442,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class InlineMultiModule extends AbstractBoxJsTest {
public void testAllFilesPresentInInlineMultiModule() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/inlineMultiModule"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/inlineMultiModule"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("anotherModuleValInClosure.kt")
@@ -4541,7 +4541,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class InlineSizeReduction extends AbstractBoxJsTest {
public void testAllFilesPresentInInlineSizeReduction() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/inlineSizeReduction"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/inlineSizeReduction"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("inlineImportCleanup.kt")
@@ -4634,7 +4634,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class InlineStdlib extends AbstractBoxJsTest {
public void testAllFilesPresentInInlineStdlib() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/inlineStdlib"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/inlineStdlib"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("callNameClash.kt")
@@ -4691,7 +4691,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Java extends AbstractBoxJsTest {
public void testAllFilesPresentInJava() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/java"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/java"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("js/js.translator/testData/box/java/abstractList")
@@ -4699,7 +4699,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class AbstractList extends AbstractBoxJsTest {
public void testAllFilesPresentInAbstractList() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/java/abstractList"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/java/abstractList"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("iterator.kt")
@@ -4720,7 +4720,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
}
public void testAllFilesPresentInArrayList() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/java/arrayList"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/java/arrayList"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("arrayAccess.kt")
@@ -4820,7 +4820,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class JsCode extends AbstractBoxJsTest {
public void testAllFilesPresentInJsCode() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/jsCode"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/jsCode"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("break.kt")
@@ -4961,7 +4961,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class JsModule extends AbstractBoxJsTest {
public void testAllFilesPresentInJsModule() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/jsModule"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/jsModule"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("externalClass.kt")
@@ -5036,7 +5036,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class JsName extends AbstractBoxJsTest {
public void testAllFilesPresentInJsName() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/jsName"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/jsName"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("avoidNameClash.kt")
@@ -5111,7 +5111,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Labels extends AbstractBoxJsTest {
public void testAllFilesPresentInLabels() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/labels"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/labels"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("labelOnExpression.kt")
@@ -5186,7 +5186,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class MultiFile extends AbstractBoxJsTest {
public void testAllFilesPresentInMultiFile() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/multiFile"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/multiFile"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("classOfTheSameNameInAnotherPackage.kt")
@@ -5231,7 +5231,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class MultiModule extends AbstractBoxJsTest {
public void testAllFilesPresentInMultiModule() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/multiModule"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/multiModule"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("moduleAndVariableNameClash.kt")
@@ -5264,7 +5264,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class MultiModuleWrappers extends AbstractBoxJsTest {
public void testAllFilesPresentInMultiModuleWrappers() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/multiModuleWrappers"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/multiModuleWrappers"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("js/js.translator/testData/box/multiModuleWrappers/amd")
@@ -5272,7 +5272,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Amd extends AbstractBoxJsTest {
public void testAllFilesPresentInAmd() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/multiModuleWrappers/amd"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/multiModuleWrappers/amd"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("jsModuleOnPackage.kt")
@@ -5299,7 +5299,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Common_js extends AbstractBoxJsTest {
public void testAllFilesPresentInCommon_js() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/multiModuleWrappers/common_js"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/multiModuleWrappers/common_js"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("moduleWithNonIdentifierName.kt")
@@ -5320,7 +5320,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Plain extends AbstractBoxJsTest {
public void testAllFilesPresentInPlain() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/multiModuleWrappers/plain"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/multiModuleWrappers/plain"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("moduleWithNonIdentifierName.kt")
@@ -5341,7 +5341,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Umd extends AbstractBoxJsTest {
public void testAllFilesPresentInUmd() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/multiModuleWrappers/umd"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/multiModuleWrappers/umd"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("moduleWithNonIdentifierName.kt")
@@ -5363,7 +5363,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class MultiPackage extends AbstractBoxJsTest {
public void testAllFilesPresentInMultiPackage() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/multiPackage"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/multiPackage"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("classesInheritedFromOtherPackage.kt")
@@ -5426,7 +5426,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Multideclaration extends AbstractBoxJsTest {
public void testAllFilesPresentInMultideclaration() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/multideclaration"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/multideclaration"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("multiValForArray.kt")
@@ -5477,7 +5477,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class NameClashes extends AbstractBoxJsTest {
public void testAllFilesPresentInNameClashes() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/nameClashes"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/nameClashes"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("classAndCompanionObjectMembers.kt")
@@ -5576,7 +5576,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Native extends AbstractBoxJsTest {
public void testAllFilesPresentInNative() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/native"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/native"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("castToNativeClassChecked.kt")
@@ -5795,7 +5795,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class NestedTypes extends AbstractBoxJsTest {
public void testAllFilesPresentInNestedTypes() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/nestedTypes"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/nestedTypes"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("implicitOuterThisFromLambda.kt")
@@ -5900,7 +5900,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Number extends AbstractBoxJsTest {
public void testAllFilesPresentInNumber() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/number"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/number"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("byteAndShortConversions.kt")
@@ -6029,7 +6029,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class ObjectDeclaration extends AbstractBoxJsTest {
public void testAllFilesPresentInObjectDeclaration() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/objectDeclaration"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/objectDeclaration"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("dontPolluteObject.kt")
@@ -6104,7 +6104,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class OperatorOverloading extends AbstractBoxJsTest {
public void testAllFilesPresentInOperatorOverloading() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/operatorOverloading"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/operatorOverloading"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("augmentedAssignmentLhs.kt")
@@ -6263,7 +6263,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
}
public void testAllFilesPresentInPropertyAccess() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/propertyAccess"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/propertyAccess"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("classUsesPackageProperties.kt")
@@ -6386,7 +6386,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class PropertyOverride extends AbstractBoxJsTest {
public void testAllFilesPresentInPropertyOverride() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/propertyOverride"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/propertyOverride"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("checkSupertypeOrder.kt")
@@ -6461,7 +6461,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Range extends AbstractBoxJsTest {
public void testAllFilesPresentInRange() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/range"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/range"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("creatingProgressions.kt")
@@ -6530,7 +6530,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Reflection extends AbstractBoxJsTest {
public void testAllFilesPresentInReflection() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/reflection"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/reflection"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("jsClass.kt")
@@ -6605,7 +6605,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Regression extends AbstractBoxJsTest {
public void testAllFilesPresentInRegression() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/regression"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/regression"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("kt2470.kt")
@@ -6626,7 +6626,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Reified extends AbstractBoxJsTest {
public void testAllFilesPresentInReified() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/reified"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/reified"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("callChain.kt")
@@ -6749,7 +6749,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Rtti extends AbstractBoxJsTest {
public void testAllFilesPresentInRtti() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/rtti"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/rtti"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("collectionClassesIsCheck.kt")
@@ -6860,7 +6860,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class SafeCall extends AbstractBoxJsTest {
public void testAllFilesPresentInSafeCall() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/safeCall"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/safeCall"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("safeAccess.kt")
@@ -6905,7 +6905,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Simple extends AbstractBoxJsTest {
public void testAllFilesPresentInSimple() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/simple"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/simple"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("assign.kt")
@@ -7076,7 +7076,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class StandardClasses extends AbstractBoxJsTest {
public void testAllFilesPresentInStandardClasses() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/standardClasses"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/standardClasses"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("any.kt")
@@ -7163,7 +7163,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class SuperCall extends AbstractBoxJsTest {
public void testAllFilesPresentInSuperCall() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/superCall"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/superCall"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("classSuperCall.kt")
@@ -7190,7 +7190,7 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
@RunWith(JUnit3RunnerWithInners.class)
public static class Trait extends AbstractBoxJsTest {
public void testAllFilesPresentInTrait() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/trait"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/box/trait"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("checkImplementationCharacteristics.kt")
@@ -6899,37 +6899,19 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
@TestMetadata("differentReceivers.kt")
public void testDifferentReceivers() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/toDelegateFor/differentReceivers.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
doTest(fileName);
}
@TestMetadata("evaluationOrder.kt")
public void testEvaluationOrder() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/toDelegateFor/evaluationOrder.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
doTest(fileName);
}
@TestMetadata("evaluationOrderVar.kt")
public void testEvaluationOrderVar() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/toDelegateFor/evaluationOrderVar.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
doTest(fileName);
}
@TestMetadata("extensionDelegated.kt")
@@ -6941,37 +6923,19 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
@TestMetadata("generic.kt")
public void testGeneric() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/toDelegateFor/generic.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
doTest(fileName);
}
@TestMetadata("inClass.kt")
public void testInClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/toDelegateFor/inClass.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
doTest(fileName);
}
@TestMetadata("inlineToDelegateFor.kt")
public void testInlineToDelegateFor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/toDelegateFor/inlineToDelegateFor.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
doTest(fileName);
}
@TestMetadata("jvmStaticInObject.kt")
@@ -6989,61 +6953,31 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
@TestMetadata("local.kt")
public void testLocal() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/toDelegateFor/local.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
doTest(fileName);
}
@TestMetadata("localCaptured.kt")
public void testLocalCaptured() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/toDelegateFor/localCaptured.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
doTest(fileName);
}
@TestMetadata("localDifferentReceivers.kt")
public void testLocalDifferentReceivers() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/toDelegateFor/localDifferentReceivers.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
doTest(fileName);
}
@TestMetadata("memberExtension.kt")
public void testMemberExtension() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/toDelegateFor/memberExtension.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
doTest(fileName);
}
@TestMetadata("propertyMetadata.kt")
public void testPropertyMetadata() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/toDelegateFor/propertyMetadata.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
doTest(fileName);
}
}
}
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.js.translate.context.TranslationContext
import org.jetbrains.kotlin.js.translate.general.Translation
import org.jetbrains.kotlin.js.translate.utils.BindingUtils
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
import org.jetbrains.kotlin.js.translate.utils.JsDescriptorUtils
@@ -36,7 +35,7 @@ class FileDeclarationVisitor(private val context: TranslationContext) : Abstract
val innerName = context.getInnerNameForDescriptor(propertyDescriptor)
val backingFieldRequired = context.bindingContext()[BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor] ?: false
if (backingFieldRequired || expression.delegateExpression != null) {
val initializer = expression.delegateExpressionOrInitializer?.let { Translation.translateAsExpression(it, context) }
val initializer = context.translateDelegateOrInitializerExpression(expression)
context.addDeclarationStatement(JsAstUtils.newVar(innerName, null))
if (initializer != null) {
context.addTopLevelStatement(JsAstUtils.assignment(innerName.makeRef(), initializer).makeStmt())
@@ -97,15 +97,10 @@ class DefaultPropertyTranslator(
delegatedCall: ResolvedCall<FunctionDescriptor>,
function: JsFunction
) {
val delegateContext = contextWithPropertyMetadataCreationIntrinsified(context(), delegatedCall, getterDescriptor)
val host = translateHost(getterDescriptor, function)
val delegateContext = context().contextWithPropertyMetadataCreationIntrinsified(delegatedCall, descriptor, host)
val delegatedJsCall = CallTranslator.translate(delegateContext, delegatedCall, delegateReference)
if (getterDescriptor.isExtension) {
val receiver = function.addParameter(getReceiverParameterName()).name
val arguments = (delegatedJsCall as JsInvocation).arguments
arguments[0] = receiver.makeRef()
}
val returnResult = JsReturn(delegatedJsCall)
function.addStatement(returnResult)
}
@@ -118,14 +113,10 @@ class DefaultPropertyTranslator(
val delegatedCall = bindingContext()[BindingContext.DELEGATED_PROPERTY_RESOLVED_CALL, setterDescriptor]
if (delegatedCall != null) {
val delegateContext = contextWithPropertyMetadataCreationIntrinsified(withAliased, delegatedCall, setterDescriptor)
val host = translateHost(setterDescriptor, function)
val delegateContext = withAliased.contextWithPropertyMetadataCreationIntrinsified(delegatedCall, descriptor, host)
val delegatedJsCall = CallTranslator.translate(delegateContext, delegatedCall, delegateReference)
function.addStatement(delegatedJsCall.makeStmt())
if (setterDescriptor.isExtension) {
val receiver = function.addParameter(getReceiverParameterName(), 0).name
(delegatedJsCall as JsInvocation).arguments[0] = receiver.makeRef()
}
}
else {
assert(!descriptor.isExtension) { "Unexpected extension property $descriptor}" }
@@ -135,19 +126,47 @@ class DefaultPropertyTranslator(
}
}
private fun contextWithPropertyMetadataCreationIntrinsified(
context: TranslationContext, delegatedCall: ResolvedCall<FunctionDescriptor>, accessor: VariableAccessorDescriptor
): TranslationContext {
val propertyNameLiteral = context.program().getStringLiteral(accessor.correspondingVariable.name.asString())
// 0th argument is instance, 1st is KProperty, 2nd (for setter) is value
val fakeArgumentExpression =
(delegatedCall.valueArgumentsByIndex!![1] as ExpressionValueArgument).valueArgument!!.getArgumentExpression()
return context.innerContextWithAliasesForExpressions(mapOf(
fakeArgumentExpression to JsNew(pureFqn("PropertyMetadata", Namer.kotlinObject()), listOf(propertyNameLiteral))
))
private fun translateHost(accessorDescriptor: VariableAccessorDescriptor, function: JsFunction): JsExpression {
return if (accessorDescriptor.isExtension) {
function.addParameter(getReceiverParameterName(), 0).name.makeRef()
}
else {
JsLiteral.THIS
}
}
}
fun TranslationContext.translateDelegateOrInitializerExpression(expression: KtProperty): JsExpression? {
val propertyDescriptor = BindingUtils.getDescriptorForElement(bindingContext(), expression) as VariableDescriptorWithAccessors
val expressionPsi = expression.delegateExpressionOrInitializer ?: return null
val initializer = Translation.translateAsExpression(expressionPsi, this)
val toDelegateForCall = bindingContext()[BindingContext.TO_DELEGATE_FOR_RESOLVED_CALL, propertyDescriptor]
return if (toDelegateForCall != null) {
val innerContext = this.contextWithPropertyMetadataCreationIntrinsified(toDelegateForCall, propertyDescriptor, JsLiteral.THIS)
CallTranslator.translate(innerContext, toDelegateForCall, initializer)
}
else {
initializer
}
}
fun TranslationContext.contextWithPropertyMetadataCreationIntrinsified(
delegatedCall: ResolvedCall<FunctionDescriptor>,
property: VariableDescriptorWithAccessors,
host: JsExpression
): TranslationContext {
val propertyNameLiteral = program().getStringLiteral(property.name.asString())
// 0th argument is instance, 1st is KProperty, 2nd (for setter) is value
val hostExpression =
(delegatedCall.valueArgumentsByIndex!![0] as ExpressionValueArgument).valueArgument!!.getArgumentExpression()
val fakeArgumentExpression =
(delegatedCall.valueArgumentsByIndex!![1] as ExpressionValueArgument).valueArgument!!.getArgumentExpression()
return innerContextWithAliasesForExpressions(mapOf(
hostExpression to host,
fakeArgumentExpression to JsNew(pureFqn("PropertyMetadata", Namer.kotlinObject()), listOf(propertyNameLiteral))
))
}
fun KtProperty.hasCustomGetter() = getter?.hasBody() ?: false
@@ -204,10 +204,10 @@ public final class ExpressionVisitor extends TranslatorVisitor<JsNode> {
if (delegateExpression != null) {
SmartList<JsPropertyInitializer> propertyInitializers = new SmartList<JsPropertyInitializer>();
PropertyTranslatorKt.translateAccessors((VariableDescriptorWithAccessors) descriptor, propertyInitializers, context);
JsExpression initializerValue = PropertyTranslatorKt.translateDelegateOrInitializerExpression(context, expression);
assert initializerValue != null : "Initializer must be non-null for property with delegate";
JsPropertyInitializer delegateInitializer = new JsPropertyInitializer(
context.program().getStringLiteral(Namer.getDelegateName(descriptor.getName().asString())),
Translation.translateAsExpression(delegateExpression, context)
);
context.program().getStringLiteral(Namer.getDelegateName(descriptor.getName().asString())), initializerValue);
propertyInitializers.add(delegateInitializer);
initializer = new JsObjectLiteral(propertyInitializers, true);
}
@@ -16,16 +16,14 @@
package org.jetbrains.kotlin.js.translate.initializer;
import com.google.dart.compiler.backend.js.ast.*;
import com.google.dart.compiler.backend.js.ast.JsExpression;
import com.google.dart.compiler.backend.js.ast.JsStatement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
import org.jetbrains.kotlin.js.translate.context.Namer;
import org.jetbrains.kotlin.js.translate.context.TranslationContext;
import org.jetbrains.kotlin.js.translate.general.Translation;
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils;
import org.jetbrains.kotlin.psi.KtExpression;
import org.jetbrains.kotlin.psi.KtProperty;
import static org.jetbrains.kotlin.js.translate.utils.TranslationUtils.assignmentToBackingField;
@@ -34,21 +32,20 @@ public final class InitializerUtils {
}
@NotNull
public static JsStatement generateInitializerForProperty(@NotNull TranslationContext context,
public static JsStatement generateInitializerForProperty(
@NotNull TranslationContext context,
@NotNull PropertyDescriptor descriptor,
@NotNull JsExpression value) {
@NotNull JsExpression value
) {
return assignmentToBackingField(context, descriptor, value).makeStmt();
}
@Nullable
public static JsStatement generateInitializerForDelegate(@NotNull TranslationContext context, @NotNull KtProperty property) {
KtExpression delegate = property.getDelegateExpression();
if (delegate != null) {
JsExpression value = Translation.translateAsExpression(delegate, context);
String name = property.getName();
assert name != null: "Delegate property must have name";
return JsAstUtils.defineSimpleProperty(Namer.getDelegateName(name), value);
}
return null;
public static JsStatement generateInitializerForDelegate(
@NotNull PropertyDescriptor descriptor,
@NotNull JsExpression value
) {
String name = descriptor.getName().asString();
return JsAstUtils.defineSimpleProperty(Namer.getDelegateName(name), value);
}
}
@@ -16,18 +16,20 @@
package org.jetbrains.kotlin.js.translate.initializer;
import com.google.dart.compiler.backend.js.ast.JsExpression;
import com.google.dart.compiler.backend.js.ast.JsStatement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
import org.jetbrains.kotlin.js.translate.context.TranslationContext;
import org.jetbrains.kotlin.js.translate.general.Translation;
import org.jetbrains.kotlin.js.translate.declaration.PropertyTranslatorKt;
import org.jetbrains.kotlin.js.translate.general.TranslatorVisitor;
import org.jetbrains.kotlin.js.translate.utils.BindingUtils;
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils;
import org.jetbrains.kotlin.psi.*;
import static org.jetbrains.kotlin.js.translate.general.Translation.translateAsStatementAndMergeInBlockIfNeeded;
import static org.jetbrains.kotlin.js.translate.initializer.InitializerUtils.generateInitializerForDelegate;
import static org.jetbrains.kotlin.js.translate.initializer.InitializerUtils.generateInitializerForProperty;
import static org.jetbrains.kotlin.js.translate.utils.BindingUtils.getPropertyDescriptor;
public final class InitializerVisitor extends TranslatorVisitor<Void> {
@Override
@@ -37,18 +39,23 @@ public final class InitializerVisitor extends TranslatorVisitor<Void> {
@Override
public final Void visitProperty(@NotNull KtProperty property, @NotNull TranslationContext context) {
PropertyDescriptor descriptor = BindingUtils.getPropertyDescriptor(context.bindingContext(), property);
JsExpression value = PropertyTranslatorKt.translateDelegateOrInitializerExpression(context, property);
JsStatement statement = null;
KtExpression initializer = property.getInitializer();
KtExpression delegate = property.getDelegateExpression();
if (initializer != null) {
JsStatement statement = generateInitializerForProperty(context, getPropertyDescriptor(context.bindingContext(), property),
Translation.translateAsExpression(initializer, context));
if (!JsAstUtils.isEmptyStatement(statement)) {
context.addStatementsToCurrentBlock(JsAstUtils.flattenStatement(statement));
}
assert value != null;
statement = generateInitializerForProperty(context, descriptor, value);
}
if (delegate != null) {
assert value != null;
statement = generateInitializerForDelegate(descriptor, value);
}
JsStatement delegate = generateInitializerForDelegate(context, property);
if (delegate != null) {
context.addStatementToCurrentBlock(delegate);
if (statement != null && !JsAstUtils.isEmptyStatement(statement)) {
context.addStatementsToCurrentBlock(JsAstUtils.flattenStatement(statement));
}
return null;
@@ -18,7 +18,10 @@ package org.jetbrains.kotlin.js.translate.utils
import com.google.dart.compiler.backend.js.ast.*
import com.intellij.util.SmartList
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.js.translate.context.Namer
import org.jetbrains.kotlin.js.translate.context.TranslationContext
import org.jetbrains.kotlin.js.translate.reference.ReferenceTranslator