JS/RTTI. Fix build and tests
This commit is contained in:
committed by
Alexey Andreev
parent
9bb60b48b2
commit
3a87049359
@@ -500,11 +500,6 @@ public class TypeUtils {
|
|||||||
return typeParameterDescriptor != null && !typeParameterDescriptor.isReified();
|
return typeParameterDescriptor != null && !typeParameterDescriptor.isReified();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isReifiedTypeParameter(@NotNull KotlinType type) {
|
|
||||||
TypeParameterDescriptor typeParameterDescriptor = getTypeParameterDescriptorOrNull(type);
|
|
||||||
return typeParameterDescriptor != null && typeParameterDescriptor.isReified();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static TypeParameterDescriptor getTypeParameterDescriptorOrNull(@NotNull KotlinType type) {
|
public static TypeParameterDescriptor getTypeParameterDescriptorOrNull(@NotNull KotlinType type) {
|
||||||
if (type.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor) {
|
if (type.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor) {
|
||||||
|
|||||||
@@ -1088,11 +1088,11 @@ fun main(args: Array<String>) {
|
|||||||
model("reified/cases")
|
model("reified/cases")
|
||||||
}
|
}
|
||||||
|
|
||||||
testClass(javaClass<AbstractRttiTest>()) {
|
testClass<AbstractRttiTest>() {
|
||||||
model("rtti/cases")
|
model("rtti/cases")
|
||||||
}
|
}
|
||||||
|
|
||||||
testClass(javaClass<AbstractCastTest>()) {
|
testClass<AbstractCastTest>() {
|
||||||
model("expression/cast/cases")
|
model("expression/cast/cases")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2016 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.
|
||||||
|
*/
|
||||||
|
|
||||||
package java.lang
|
package java.lang
|
||||||
|
|
||||||
@library
|
@library
|
||||||
@@ -27,7 +43,7 @@ public class NumberFormatException(message: String? = null) : RuntimeException(m
|
|||||||
@library
|
@library
|
||||||
public class NullPointerException(message: String? = null) : RuntimeException(message) {}
|
public class NullPointerException(message: String? = null) : RuntimeException(message) {}
|
||||||
|
|
||||||
library
|
@library
|
||||||
public class ClassCastException(message: String? = null) : RuntimeException(message) {}
|
public class ClassCastException(message: String? = null) : RuntimeException(message) {}
|
||||||
|
|
||||||
@library
|
@library
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ private fun RegExp.findNext(input: String, from: Int): MatchResult? {
|
|||||||
get() {
|
get() {
|
||||||
if (groupValues_ == null) {
|
if (groupValues_ == null) {
|
||||||
groupValues_ = object : java.util.AbstractList<String>() {
|
groupValues_ = object : java.util.AbstractList<String>() {
|
||||||
override val size: Int get() = match.size
|
override val size: Int get() = match.length
|
||||||
override fun get(index: Int): String = match[index] ?: ""
|
override fun get(index: Int): String = match[index] ?: ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -45,6 +45,6 @@ public fun RegExp.reset() {
|
|||||||
public val input: String
|
public val input: String
|
||||||
public val length: Int
|
public val length: Int
|
||||||
|
|
||||||
nativeGetter
|
@nativeGetter
|
||||||
public fun get(index: Int): String?
|
public operator fun get(index: Int): String?
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -54,13 +54,13 @@ class RegExpTest {
|
|||||||
@test fun regExpExec() {
|
@test fun regExpExec() {
|
||||||
val string = "R2D2 beats A5D5 "
|
val string = "R2D2 beats A5D5 "
|
||||||
var re = RegExp("""(\w\d)(\w\d)""", "g")
|
var re = RegExp("""(\w\d)(\w\d)""", "g")
|
||||||
val m1: Array<out String?> = re.exec(string)!!
|
val m1 = re.exec(string)!!
|
||||||
assertEquals(arrayOf("R2D2", "R2", "D2"), m1)
|
assertEquals(arrayOf("R2D2", "R2", "D2"), m1.toArray())
|
||||||
assertEquals(0, m1.index)
|
assertEquals(0, m1.index)
|
||||||
assertEquals(4, re.lastIndex)
|
assertEquals(4, re.lastIndex)
|
||||||
|
|
||||||
val m2: Array<out String?> = re.exec(string)!!
|
val m2 = re.exec(string)!!
|
||||||
assertEquals(arrayOf("A5D5", "A5", "D5"), m2)
|
assertEquals(arrayOf("A5D5", "A5", "D5"), m2.toArray())
|
||||||
assertEquals(string.indexOf(m2[0]!!), m2.index)
|
assertEquals(string.indexOf(m2[0]!!), m2.index)
|
||||||
|
|
||||||
val noMatch = re.exec(string)
|
val noMatch = re.exec(string)
|
||||||
@@ -68,4 +68,9 @@ class RegExpTest {
|
|||||||
assertEquals(0, re.lastIndex)
|
assertEquals(0, re.lastIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun RegExpMatch.toArray(): Array<out String?> {
|
||||||
|
val array = arrayOfNulls<String>(length)
|
||||||
|
array.indices.forEach { array[it] = this[it] }
|
||||||
|
return array
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -326,9 +326,9 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
|
|||||||
@NotNull String moduleId,
|
@NotNull String moduleId,
|
||||||
@NotNull EcmaVersion ecmaVersion,
|
@NotNull EcmaVersion ecmaVersion,
|
||||||
@Nullable List<String> libraries,
|
@Nullable List<String> libraries,
|
||||||
List<JetFile> jetFiles
|
List<KtFile> jetFiles
|
||||||
) {
|
) {
|
||||||
for (JetFile file : jetFiles) {
|
for (KtFile file : jetFiles) {
|
||||||
String text = file.getText();
|
String text = file.getText();
|
||||||
|
|
||||||
if (isDirectiveDefined(text, NO_INLINE_DIRECTIVE)) {
|
if (isDirectiveDefined(text, NO_INLINE_DIRECTIVE)) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.js.test.semantics;
|
|||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
import com.intellij.testFramework.TestDataPath;
|
||||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||||
import org.jetbrains.kotlin.test.JetTestUtils;
|
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||||
import org.jetbrains.kotlin.test.TestMetadata;
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@@ -32,108 +32,108 @@ import java.util.regex.Pattern;
|
|||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public class CastTestGenerated extends AbstractCastTest {
|
public class CastTestGenerated extends AbstractCastTest {
|
||||||
public void testAllFilesPresentInCases() throws Exception {
|
public void testAllFilesPresentInCases() throws Exception {
|
||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/expression/cast/cases"), Pattern.compile("^(.+)\\.kt$"), true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/expression/cast/cases"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("castToAny.kt")
|
@TestMetadata("castToAny.kt")
|
||||||
public void testCastToAny() throws Exception {
|
public void testCastToAny() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToAny.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToAny.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("castToArray.kt")
|
@TestMetadata("castToArray.kt")
|
||||||
public void testCastToArray() throws Exception {
|
public void testCastToArray() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToArray.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToArray.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("castToFunction.kt")
|
@TestMetadata("castToFunction.kt")
|
||||||
public void testCastToFunction() throws Exception {
|
public void testCastToFunction() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToFunction.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToFunction.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("castToGenericType.kt")
|
@TestMetadata("castToGenericType.kt")
|
||||||
public void testCastToGenericType() throws Exception {
|
public void testCastToGenericType() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToGenericType.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToGenericType.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("castToGenericTypeWithUpperBound.kt")
|
@TestMetadata("castToGenericTypeWithUpperBound.kt")
|
||||||
public void testCastToGenericTypeWithUpperBound() throws Exception {
|
public void testCastToGenericTypeWithUpperBound() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToGenericTypeWithUpperBound.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToGenericTypeWithUpperBound.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("castToNotNull.kt")
|
@TestMetadata("castToNotNull.kt")
|
||||||
public void testCastToNotNull() throws Exception {
|
public void testCastToNotNull() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToNotNull.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToNotNull.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("castToNullable.kt")
|
@TestMetadata("castToNullable.kt")
|
||||||
public void testCastToNullable() throws Exception {
|
public void testCastToNullable() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToNullable.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/castToNullable.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("reifiedToNotNull.kt")
|
@TestMetadata("reifiedToNotNull.kt")
|
||||||
public void testReifiedToNotNull() throws Exception {
|
public void testReifiedToNotNull() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/reifiedToNotNull.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/reifiedToNotNull.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("reifiedToNullable1.kt")
|
@TestMetadata("reifiedToNullable1.kt")
|
||||||
public void testReifiedToNullable1() throws Exception {
|
public void testReifiedToNullable1() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/reifiedToNullable1.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/reifiedToNullable1.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("reifiedToNullable2.kt")
|
@TestMetadata("reifiedToNullable2.kt")
|
||||||
public void testReifiedToNullable2() throws Exception {
|
public void testReifiedToNullable2() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/reifiedToNullable2.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/reifiedToNullable2.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("safeCastToGenericTypeWithUpperBound.kt")
|
@TestMetadata("safeCastToGenericTypeWithUpperBound.kt")
|
||||||
public void testSafeCastToGenericTypeWithUpperBound() throws Exception {
|
public void testSafeCastToGenericTypeWithUpperBound() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/safeCastToGenericTypeWithUpperBound.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/safeCastToGenericTypeWithUpperBound.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("safeCastToNotNull.kt")
|
@TestMetadata("safeCastToNotNull.kt")
|
||||||
public void testSafeCastToNotNull() throws Exception {
|
public void testSafeCastToNotNull() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/safeCastToNotNull.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/safeCastToNotNull.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("safeCastToNullable.kt")
|
@TestMetadata("safeCastToNullable.kt")
|
||||||
public void testSafeCastToNullable() throws Exception {
|
public void testSafeCastToNullable() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/safeCastToNullable.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/safeCastToNullable.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("safeCastToReifiedNotNull.kt")
|
@TestMetadata("safeCastToReifiedNotNull.kt")
|
||||||
public void testSafeCastToReifiedNotNull() throws Exception {
|
public void testSafeCastToReifiedNotNull() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/safeCastToReifiedNotNull.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/safeCastToReifiedNotNull.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("safeCastToReifiedNullable.kt")
|
@TestMetadata("safeCastToReifiedNullable.kt")
|
||||||
public void testSafeCastToReifiedNullable() throws Exception {
|
public void testSafeCastToReifiedNullable() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/safeCastToReifiedNullable.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/safeCastToReifiedNullable.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("smartCastInExtensionFunction.kt")
|
@TestMetadata("smartCastInExtensionFunction.kt")
|
||||||
public void testSmartCastInExtensionFunction() throws Exception {
|
public void testSmartCastInExtensionFunction() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/smartCastInExtensionFunction.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/smartCastInExtensionFunction.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("smartCastInFunction.kt")
|
@TestMetadata("smartCastInFunction.kt")
|
||||||
public void testSmartCastInFunction() throws Exception {
|
public void testSmartCastInFunction() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/smartCastInFunction.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/expression/cast/cases/smartCastInFunction.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class ReifiedTestGenerated extends AbstractReifiedTest {
|
|||||||
|
|
||||||
@TestMetadata("isTNullable.kt")
|
@TestMetadata("isTNullable.kt")
|
||||||
public void testIsTNullable() throws Exception {
|
public void testIsTNullable() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/reified/cases/isTNullable.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/reified/cases/isTNullable.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ public class ReifiedTestGenerated extends AbstractReifiedTest {
|
|||||||
|
|
||||||
@TestMetadata("withInlineTurnedOff.kt")
|
@TestMetadata("withInlineTurnedOff.kt")
|
||||||
public void testWithInlineTurnedOff() throws Exception {
|
public void testWithInlineTurnedOff() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/reified/cases/withInlineTurnedOff.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/reified/cases/withInlineTurnedOff.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.js.test.semantics;
|
|||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
import com.intellij.testFramework.TestDataPath;
|
||||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||||
import org.jetbrains.kotlin.test.JetTestUtils;
|
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||||
import org.jetbrains.kotlin.test.TestMetadata;
|
import org.jetbrains.kotlin.test.TestMetadata;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
@@ -32,72 +32,72 @@ import java.util.regex.Pattern;
|
|||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
public class RttiTestGenerated extends AbstractRttiTest {
|
public class RttiTestGenerated extends AbstractRttiTest {
|
||||||
public void testAllFilesPresentInCases() throws Exception {
|
public void testAllFilesPresentInCases() throws Exception {
|
||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/rtti/cases"), Pattern.compile("^(.+)\\.kt$"), true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/rtti/cases"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("collectionClassesIsCheck.kt")
|
@TestMetadata("collectionClassesIsCheck.kt")
|
||||||
public void testCollectionClassesIsCheck() throws Exception {
|
public void testCollectionClassesIsCheck() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/collectionClassesIsCheck.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/collectionClassesIsCheck.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("isComparable.kt")
|
@TestMetadata("isComparable.kt")
|
||||||
public void testIsComparable() throws Exception {
|
public void testIsComparable() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/isComparable.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/isComparable.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("isJsPrimitiveType.kt")
|
@TestMetadata("isJsPrimitiveType.kt")
|
||||||
public void testIsJsPrimitiveType() throws Exception {
|
public void testIsJsPrimitiveType() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/isJsPrimitiveType.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/isJsPrimitiveType.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("isSameClass.kt")
|
@TestMetadata("isSameClass.kt")
|
||||||
public void testIsSameClass() throws Exception {
|
public void testIsSameClass() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/isSameClass.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/isSameClass.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("notIsOtherClass.kt")
|
@TestMetadata("notIsOtherClass.kt")
|
||||||
public void testNotIsOtherClass() throws Exception {
|
public void testNotIsOtherClass() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/notIsOtherClass.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/notIsOtherClass.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("rttiForClass.kt")
|
@TestMetadata("rttiForClass.kt")
|
||||||
public void testRttiForClass() throws Exception {
|
public void testRttiForClass() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/rttiForClass.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/rttiForClass.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("rttiForTrait.kt")
|
@TestMetadata("rttiForTrait.kt")
|
||||||
public void testRttiForTrait() throws Exception {
|
public void testRttiForTrait() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/rttiForTrait.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/rttiForTrait.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("rttiForTrait2.kt")
|
@TestMetadata("rttiForTrait2.kt")
|
||||||
public void testRttiForTrait2() throws Exception {
|
public void testRttiForTrait2() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/rttiForTrait2.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/rttiForTrait2.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("sideEffectMethod.kt")
|
@TestMetadata("sideEffectMethod.kt")
|
||||||
public void testSideEffectMethod() throws Exception {
|
public void testSideEffectMethod() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/sideEffectMethod.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/sideEffectMethod.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("sideEffectProperty.kt")
|
@TestMetadata("sideEffectProperty.kt")
|
||||||
public void testSideEffectProperty() throws Exception {
|
public void testSideEffectProperty() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/sideEffectProperty.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/sideEffectProperty.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("stdlibEmptyListClass.kt")
|
@TestMetadata("stdlibEmptyListClass.kt")
|
||||||
public void testStdlibEmptyListClass() throws Exception {
|
public void testStdlibEmptyListClass() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/stdlibEmptyListClass.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/rtti/cases/stdlibEmptyListClass.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-12
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -17,7 +17,6 @@
|
|||||||
package org.jetbrains.kotlin.js.translate.expression;
|
package org.jetbrains.kotlin.js.translate.expression;
|
||||||
|
|
||||||
import com.google.dart.compiler.backend.js.ast.*;
|
import com.google.dart.compiler.backend.js.ast.*;
|
||||||
import com.google.dart.compiler.backend.js.ast.metadata.MetadataProperties;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.KtNodeTypes;
|
import org.jetbrains.kotlin.KtNodeTypes;
|
||||||
@@ -25,9 +24,8 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
|||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
||||||
import org.jetbrains.kotlin.js.descriptorUtils.DescriptorUtilsKt;
|
|
||||||
import org.jetbrains.kotlin.js.patterns.NamePredicate;
|
import org.jetbrains.kotlin.js.patterns.NamePredicate;
|
||||||
import org.jetbrains.kotlin.js.patterns.typePredicates.TypePredicatesPackage;
|
import org.jetbrains.kotlin.js.patterns.typePredicates.TypePredicatesKt;
|
||||||
import org.jetbrains.kotlin.js.translate.context.Namer;
|
import org.jetbrains.kotlin.js.translate.context.Namer;
|
||||||
import org.jetbrains.kotlin.js.translate.context.TemporaryVariable;
|
import org.jetbrains.kotlin.js.translate.context.TemporaryVariable;
|
||||||
import org.jetbrains.kotlin.js.translate.context.TranslationContext;
|
import org.jetbrains.kotlin.js.translate.context.TranslationContext;
|
||||||
@@ -42,16 +40,18 @@ import org.jetbrains.kotlin.psi.KtIsExpression;
|
|||||||
import org.jetbrains.kotlin.psi.KtTypeReference;
|
import org.jetbrains.kotlin.psi.KtTypeReference;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.kotlin.types.KotlinType;
|
import org.jetbrains.kotlin.types.KotlinType;
|
||||||
|
import org.jetbrains.kotlin.types.TypeIntersector;
|
||||||
|
|
||||||
import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.*;
|
|
||||||
import static org.jetbrains.kotlin.js.descriptorUtils.DescriptorUtilsPackage.getNameIfStandardType;
|
|
||||||
import static org.jetbrains.kotlin.builtins.FunctionTypesKt.isFunctionTypeOrSubtype;
|
import static org.jetbrains.kotlin.builtins.FunctionTypesKt.isFunctionTypeOrSubtype;
|
||||||
import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.isAnyOrNullableAny;
|
import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.isAnyOrNullableAny;
|
||||||
import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.isArray;
|
import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.isArray;
|
||||||
|
import static org.jetbrains.kotlin.js.descriptorUtils.DescriptorUtilsKt.getNameIfStandardType;
|
||||||
import static org.jetbrains.kotlin.js.translate.utils.JsAstUtils.equality;
|
import static org.jetbrains.kotlin.js.translate.utils.JsAstUtils.equality;
|
||||||
import static org.jetbrains.kotlin.js.translate.utils.JsAstUtils.negated;
|
import static org.jetbrains.kotlin.js.translate.utils.JsAstUtils.negated;
|
||||||
import static org.jetbrains.kotlin.psi.KtPsiUtil.findChildByType;
|
import static org.jetbrains.kotlin.psi.KtPsiUtil.findChildByType;
|
||||||
import static org.jetbrains.kotlin.types.TypeUtils.*;
|
import static org.jetbrains.kotlin.types.TypeUtils.getTypeParameterDescriptorOrNull;
|
||||||
|
import static org.jetbrains.kotlin.types.TypeUtils.isNullableType;
|
||||||
|
import static org.jetbrains.kotlin.types.TypeUtils.isReifiedTypeParameter;
|
||||||
|
|
||||||
public final class PatternTranslator extends AbstractTranslator {
|
public final class PatternTranslator extends AbstractTranslator {
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ public final class PatternTranslator extends AbstractTranslator {
|
|||||||
return getIsTypeCheckCallableForReifiedType(typeParameterDescriptor);
|
return getIsTypeCheckCallableForReifiedType(typeParameterDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
return doGetIsTypeCheckCallable(typeParameterDescriptor.getUpperBoundsAsType());
|
return doGetIsTypeCheckCallable(TypeIntersector.getUpperBoundsAsType(typeParameterDescriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
JsNameRef typeName = getClassNameReference(type);
|
JsNameRef typeName = getClassNameReference(type);
|
||||||
@@ -154,18 +154,18 @@ public final class PatternTranslator extends AbstractTranslator {
|
|||||||
private JsExpression getIsTypeCheckCallableForBuiltin(@NotNull KotlinType type) {
|
private JsExpression getIsTypeCheckCallableForBuiltin(@NotNull KotlinType type) {
|
||||||
if (isAnyOrNullableAny(type)) return namer().isAny();
|
if (isAnyOrNullableAny(type)) return namer().isAny();
|
||||||
|
|
||||||
if (isFunctionOrExtensionFunctionType(type)) return namer().isTypeOf(program().getStringLiteral("function"));
|
if (isFunctionTypeOrSubtype(type)) return namer().isTypeOf(program().getStringLiteral("function"));
|
||||||
|
|
||||||
if (isArray(type)) return Namer.IS_ARRAY_FUN_REF;
|
if (isArray(type)) return Namer.IS_ARRAY_FUN_REF;
|
||||||
|
|
||||||
if (TypePredicatesPackage.getCOMPARABLE().apply(type)) return namer().isComparable();
|
if (TypePredicatesKt.getCOMPARABLE().apply(type)) return namer().isComparable();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private JsExpression getIsTypeCheckCallableForBuiltin(@NotNull KotlinType type) {
|
private JsExpression getIsTypeCheckCallableForPrimitiveBuiltin(@NotNull KotlinType type) {
|
||||||
Name typeName = DescriptorUtilsKt.getNameIfStandardType(type);
|
Name typeName = getNameIfStandardType(type);
|
||||||
|
|
||||||
if (NamePredicate.STRING.apply(typeName)) {
|
if (NamePredicate.STRING.apply(typeName)) {
|
||||||
return namer().isTypeOf(program().getStringLiteral("string"));
|
return namer().isTypeOf(program().getStringLiteral("string"));
|
||||||
|
|||||||
+4
-4
@@ -4,13 +4,13 @@ open class A
|
|||||||
class B : A()
|
class B : A()
|
||||||
class C
|
class C
|
||||||
|
|
||||||
fun notNullToNotNullT<T : A>(a: Any): T = a as T
|
fun <T : A> notNullToNotNullT(a: Any): T = a as T
|
||||||
|
|
||||||
fun nullableToNotNullT<T : A>(a: Any?): T = a as T
|
fun <T : A> nullableToNotNullT(a: Any?): T = a as T
|
||||||
|
|
||||||
fun notNullToNullableT<T : A>(a: Any): T? = a as T?
|
fun <T : A> notNullToNullableT(a: Any): T? = a as T?
|
||||||
|
|
||||||
fun nullableToNullableT<T : A>(a: Any?): T? = a as T?
|
fun <T : A> nullableToNullableT(a: Any?): T? = a as T?
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
val a = A()
|
val a = A()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package foo
|
package foo
|
||||||
|
|
||||||
trait A
|
interface A
|
||||||
|
|
||||||
class AImpl: A
|
class AImpl: A
|
||||||
|
|
||||||
@@ -15,4 +15,4 @@ fun box(): String {
|
|||||||
failsClassCast("test(object{})") { test(object{}) }
|
failsClassCast("test(object{})") { test(object{}) }
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ package foo
|
|||||||
|
|
||||||
// CHECK_NOT_CALLED: test
|
// CHECK_NOT_CALLED: test
|
||||||
|
|
||||||
trait A
|
interface A
|
||||||
|
|
||||||
class AImpl: A
|
class AImpl: A
|
||||||
|
|
||||||
inline
|
inline
|
||||||
fun test<reified T>(x: Any?): T = x as T
|
fun <reified T> test(x: Any?): T = x as T
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
var a: A = AImpl()
|
var a: A = AImpl()
|
||||||
@@ -18,4 +18,4 @@ fun box(): String {
|
|||||||
failsClassCast("test(object{})") { test<A>(object{}) }
|
failsClassCast("test(object{})") { test<A>(object{}) }
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ interface A
|
|||||||
class AImpl : A {}
|
class AImpl : A {}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
fun test<reified T>(x: Any?): T = x as T
|
fun <reified T> test(x: Any?): T = x as T
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
var a: A? = AImpl()
|
var a: A? = AImpl()
|
||||||
@@ -16,4 +16,4 @@ fun box(): String {
|
|||||||
failsClassCast("test(object{})") { test<A?>(object{}) }
|
failsClassCast("test(object{})") { test<A?>(object{}) }
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ interface A
|
|||||||
class AImpl : A {}
|
class AImpl : A {}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
fun test<reified T>(x: Any?): T? = x as T?
|
fun <reified T> test(x: Any?): T? = x as T?
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
var a: A? = AImpl()
|
var a: A? = AImpl()
|
||||||
@@ -16,4 +16,4 @@ fun box(): String {
|
|||||||
failsClassCast("test(object{})") { test<A>(object{}) }
|
failsClassCast("test(object{})") { test<A>(object{}) }
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -4,9 +4,9 @@ open class A
|
|||||||
class B : A()
|
class B : A()
|
||||||
class C
|
class C
|
||||||
|
|
||||||
fun notNullToNullableT<T : A>(a: Any): T? = a as? T?
|
fun <T : A> notNullToNullableT(a: Any): T? = a as? T?
|
||||||
|
|
||||||
fun nullableToNullableT<T : A>(a: Any?): T? = a as? T?
|
fun <T : A> nullableToNullableT(a: Any?): T? = a as? T?
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
val a = A()
|
val a = A()
|
||||||
|
|||||||
+2
-2
@@ -6,7 +6,7 @@ class A
|
|||||||
class B
|
class B
|
||||||
|
|
||||||
inline
|
inline
|
||||||
fun Any?.castTo<reified T>(): T? = this as? T
|
fun <reified T> Any?.castTo(): T? = this as? T
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
val a: Any? = A()
|
val a: Any? = A()
|
||||||
@@ -18,4 +18,4 @@ fun box(): String {
|
|||||||
assertEquals(null, b.castTo<A>(), "b")
|
assertEquals(null, b.castTo<A>(), "b")
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -6,7 +6,7 @@ class A
|
|||||||
class B
|
class B
|
||||||
|
|
||||||
inline
|
inline
|
||||||
fun Any?.castTo<reified T>(): T? = this as? T?
|
fun <reified T> Any?.castTo(): T? = this as? T?
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
val a: Any? = A()
|
val a: Any? = A()
|
||||||
@@ -18,4 +18,4 @@ fun box(): String {
|
|||||||
assertEquals(null, b.castTo<A>(), "b")
|
assertEquals(null, b.castTo<A>(), "b")
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -4,7 +4,7 @@ package foo
|
|||||||
// CHECK_NULLS_COUNT: function=box count=8
|
// CHECK_NULLS_COUNT: function=box count=8
|
||||||
|
|
||||||
inline
|
inline
|
||||||
fun Any?.isTypeOfOrNull<reified T>() = this is T?
|
fun <reified T> Any?.isTypeOfOrNull() = this is T?
|
||||||
|
|
||||||
class A
|
class A
|
||||||
class B
|
class B
|
||||||
@@ -18,4 +18,4 @@ fun box(): String {
|
|||||||
assertEquals(false, A().isTypeOfOrNull<B?>(), "A().isTypeOfOrNull<B?>()")
|
assertEquals(false, A().isTypeOfOrNull<B?>(), "A().isTypeOfOrNull<B?>()")
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user