Support class reference expressions without kotlin-reflect.jar in classpath
Currently not much you can do with them, but in the future '.java' extension property will allow to get the Class instance from it. Also introduce codegen tests with stdlib but without reflection in the classpath. Based on the work by @dnpetrov
This commit is contained in:
+7
-2
@@ -20,7 +20,6 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import kotlin.Charsets;
|
||||
import kotlin.KotlinPackage;
|
||||
import kotlin.io.IoPackage;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.cli.common.output.outputUtils.OutputUtilsPackage;
|
||||
@@ -68,11 +67,17 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
|
||||
|
||||
public void doTestWithStdlib(@NotNull String filename) {
|
||||
myEnvironment = JetTestUtils.createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea(
|
||||
getTestRootDisposable(), ConfigurationKind.ALL, getTestJdkKind(filename)
|
||||
getTestRootDisposable(), getTestConfigurationKind(filename), getTestJdkKind(filename)
|
||||
);
|
||||
blackBoxFileByFullPath(filename);
|
||||
}
|
||||
|
||||
private static ConfigurationKind getTestConfigurationKind(String filename) {
|
||||
return InTextDirectivesUtils.isDirectiveDefined(
|
||||
IoPackage.readText(new File(filename), Charsets.UTF_8), "NO_KOTLIN_REFLECT"
|
||||
) ? ConfigurationKind.NO_KOTLIN_REFLECT : ConfigurationKind.ALL;
|
||||
}
|
||||
|
||||
public void doTestMultiFile(@NotNull String folderName) {
|
||||
final List<String> files = new ArrayList<String>(2);
|
||||
FileUtil.processFilesRecursively(new File(folderName), new Processor<File>() {
|
||||
|
||||
+10
-5
@@ -14,10 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.test;
|
||||
package org.jetbrains.kotlin.test
|
||||
|
||||
public enum ConfigurationKind {
|
||||
JDK_ONLY, // Java runtime classes
|
||||
JDK_AND_ANNOTATIONS, // Java runtime classes with Kotlin's external annotations
|
||||
ALL, // Java runtime classes with Kotlin's external annotations and Kotlin stdlib
|
||||
public enum class ConfigurationKind(
|
||||
public val withJdkAnnotations: Boolean,
|
||||
public val withRuntime: Boolean,
|
||||
public val withReflection: Boolean
|
||||
) {
|
||||
JDK_ONLY(withJdkAnnotations = false, withRuntime = false, withReflection = false),
|
||||
JDK_AND_ANNOTATIONS(withJdkAnnotations = true, withRuntime = false, withReflection = false),
|
||||
NO_KOTLIN_REFLECT(withJdkAnnotations = true, withRuntime = true, withReflection = false),
|
||||
ALL(withJdkAnnotations = true, withRuntime = true, withReflection = true),
|
||||
}
|
||||
@@ -94,7 +94,6 @@ import static org.jetbrains.kotlin.cli.jvm.config.JVMConfigurationKeys.ANNOTATIO
|
||||
import static org.jetbrains.kotlin.jvm.compiler.LoadDescriptorUtil.compileKotlinToDirAndGetAnalysisResult;
|
||||
import static org.jetbrains.kotlin.psi.PsiPackage.JetPsiFactory;
|
||||
import static org.jetbrains.kotlin.test.ConfigurationKind.ALL;
|
||||
import static org.jetbrains.kotlin.test.ConfigurationKind.JDK_AND_ANNOTATIONS;
|
||||
|
||||
public class JetTestUtils {
|
||||
public static final String TEST_GENERATOR_NAME = "org.jetbrains.kotlin.generators.tests.TestsPackage";
|
||||
@@ -459,13 +458,17 @@ public class JetTestUtils {
|
||||
else {
|
||||
addJvmClasspathRoots(configuration, PathUtil.getJdkClassesRoots());
|
||||
}
|
||||
if (configurationKind == ALL) {
|
||||
|
||||
if (configurationKind.getWithRuntime()) {
|
||||
addJvmClasspathRoot(configuration, ForTestCompileRuntime.runtimeJarForTests());
|
||||
}
|
||||
if (configurationKind.getWithReflection()) {
|
||||
addJvmClasspathRoot(configuration, ForTestCompileRuntime.reflectJarForTests());
|
||||
}
|
||||
|
||||
addJvmClasspathRoots(configuration, classpath);
|
||||
|
||||
if (configurationKind == ALL || configurationKind == JDK_AND_ANNOTATIONS) {
|
||||
if (configurationKind.getWithJdkAnnotations()) {
|
||||
if (jdkKind == TestJdkKind.ANDROID_API) {
|
||||
configuration.add(ANNOTATIONS_PATH_KEY, getAndroidSdkAnnotationsJar());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user