Use new annotations in mutability tests instead of old ones

This commit is contained in:
Ilya Gorbunov
2017-11-25 07:09:45 +03:00
parent 9995a31c46
commit 4f76cdfc34
20 changed files with 68 additions and 41 deletions
@@ -1,6 +1,7 @@
// JVM_ANNOTATIONS
package test; package test;
import org.jetbrains.annotations.*; import kotlin.annotations.jvm.*;
public interface LoadIterable<T> { public interface LoadIterable<T> {
public @Mutable Iterable<T> getIterable(); public @Mutable Iterable<T> getIterable();
@@ -1,8 +1,8 @@
package test package test
public interface LoadIterable</*0*/ T : kotlin.Any!> { public interface LoadIterable</*0*/ T : kotlin.Any!> {
@org.jetbrains.annotations.Mutable public abstract fun getIterable(): kotlin.collections.MutableIterable<T!>! @kotlin.annotations.jvm.Mutable public abstract fun getIterable(): kotlin.collections.MutableIterable<T!>!
@org.jetbrains.annotations.ReadOnly public abstract fun getReadOnlyIterable(): kotlin.collections.Iterable<T!>! @kotlin.annotations.jvm.ReadOnly public abstract fun getReadOnlyIterable(): kotlin.collections.Iterable<T!>!
public abstract fun setIterable(/*0*/ @org.jetbrains.annotations.Mutable p0: kotlin.collections.MutableIterable<T!>!): kotlin.Unit public abstract fun setIterable(/*0*/ @kotlin.annotations.jvm.Mutable p0: kotlin.collections.MutableIterable<T!>!): kotlin.Unit
public abstract fun setReadOnlyIterable(/*0*/ @org.jetbrains.annotations.ReadOnly p0: kotlin.collections.Iterable<T!>!): kotlin.Unit public abstract fun setReadOnlyIterable(/*0*/ @kotlin.annotations.jvm.ReadOnly p0: kotlin.collections.Iterable<T!>!): kotlin.Unit
} }
@@ -1,6 +1,7 @@
// JVM_ANNOTATIONS
package test; package test;
import org.jetbrains.annotations.*; import kotlin.annotations.jvm.*;
public interface LoadIterableWithConflict<T> { public interface LoadIterableWithConflict<T> {
public @ReadOnly @Mutable Iterable<T> getIterable(); public @ReadOnly @Mutable Iterable<T> getIterable();
@@ -1,6 +1,6 @@
package test package test
public interface LoadIterableWithConflict</*0*/ T : kotlin.Any!> { public interface LoadIterableWithConflict</*0*/ T : kotlin.Any!> {
@org.jetbrains.annotations.ReadOnly @org.jetbrains.annotations.Mutable public abstract fun getIterable(): kotlin.collections.(Mutable)Iterable<T!>! @kotlin.annotations.jvm.ReadOnly @kotlin.annotations.jvm.Mutable public abstract fun getIterable(): kotlin.collections.(Mutable)Iterable<T!>!
public abstract fun setIterable(/*0*/ @org.jetbrains.annotations.ReadOnly @org.jetbrains.annotations.Mutable p0: kotlin.collections.(Mutable)Iterable<T!>!): kotlin.Unit public abstract fun setIterable(/*0*/ @kotlin.annotations.jvm.ReadOnly @kotlin.annotations.jvm.Mutable p0: kotlin.collections.(Mutable)Iterable<T!>!): kotlin.Unit
} }
@@ -1,6 +1,8 @@
// JVM_ANNOTATIONS
package test; package test;
import org.jetbrains.annotations.*; import kotlin.annotations.jvm.*;
import org.jetbrains.annotations.NotNull;
public interface LoadIterableWithNullability<T> { public interface LoadIterableWithNullability<T> {
public @NotNull @Mutable Iterable<T> getIterable(); public @NotNull @Mutable Iterable<T> getIterable();
@@ -1,8 +1,8 @@
package test package test
public interface LoadIterableWithNullability</*0*/ T : kotlin.Any!> { public interface LoadIterableWithNullability</*0*/ T : kotlin.Any!> {
@org.jetbrains.annotations.NotNull @org.jetbrains.annotations.Mutable public abstract fun getIterable(): kotlin.collections.MutableIterable<T!> @org.jetbrains.annotations.NotNull @kotlin.annotations.jvm.Mutable public abstract fun getIterable(): kotlin.collections.MutableIterable<T!>
@org.jetbrains.annotations.NotNull @org.jetbrains.annotations.ReadOnly public abstract fun getReadOnlyIterable(): kotlin.collections.Iterable<T!> @org.jetbrains.annotations.NotNull @kotlin.annotations.jvm.ReadOnly public abstract fun getReadOnlyIterable(): kotlin.collections.Iterable<T!>
public abstract fun setIterable(/*0*/ @org.jetbrains.annotations.Mutable @org.jetbrains.annotations.NotNull p0: kotlin.collections.MutableIterable<T!>): kotlin.Unit public abstract fun setIterable(/*0*/ @kotlin.annotations.jvm.Mutable @org.jetbrains.annotations.NotNull p0: kotlin.collections.MutableIterable<T!>): kotlin.Unit
public abstract fun setReadOnlyIterable(/*0*/ @org.jetbrains.annotations.ReadOnly @org.jetbrains.annotations.NotNull p0: kotlin.collections.Iterable<T!>): kotlin.Unit public abstract fun setReadOnlyIterable(/*0*/ @kotlin.annotations.jvm.ReadOnly @org.jetbrains.annotations.NotNull p0: kotlin.collections.Iterable<T!>): kotlin.Unit
} }
@@ -1,6 +1,7 @@
// JVM_ANNOTATIONS
package test; package test;
import org.jetbrains.annotations.*; import kotlin.annotations.jvm.*;
import java.util.ArrayList; import java.util.ArrayList;
public interface LoadIterableWithPropagation { public interface LoadIterableWithPropagation {
@@ -3,10 +3,10 @@ package test
public interface LoadIterableWithPropagation { public interface LoadIterableWithPropagation {
public interface LoadIterable</*0*/ T : kotlin.Any!> { public interface LoadIterable</*0*/ T : kotlin.Any!> {
@org.jetbrains.annotations.Mutable public abstract fun getIterable(): kotlin.collections.MutableIterable<T!>! @kotlin.annotations.jvm.Mutable public abstract fun getIterable(): kotlin.collections.MutableIterable<T!>!
@org.jetbrains.annotations.ReadOnly public abstract fun getReadOnlyIterable(): kotlin.collections.Iterable<T!>! @kotlin.annotations.jvm.ReadOnly public abstract fun getReadOnlyIterable(): kotlin.collections.Iterable<T!>!
public abstract fun setIterable(/*0*/ @org.jetbrains.annotations.Mutable p0: kotlin.collections.MutableIterable<T!>!): kotlin.Unit public abstract fun setIterable(/*0*/ @kotlin.annotations.jvm.Mutable p0: kotlin.collections.MutableIterable<T!>!): kotlin.Unit
public abstract fun setReadOnlyIterable(/*0*/ @org.jetbrains.annotations.ReadOnly p0: kotlin.collections.Iterable<T!>!): kotlin.Unit public abstract fun setReadOnlyIterable(/*0*/ @kotlin.annotations.jvm.ReadOnly p0: kotlin.collections.Iterable<T!>!): kotlin.Unit
} }
public open class LoadIterableImpl</*0*/ T : kotlin.Any!> : test.LoadIterableWithPropagation.LoadIterable<T!> { public open class LoadIterableImpl</*0*/ T : kotlin.Any!> : test.LoadIterableWithPropagation.LoadIterable<T!> {
@@ -1,6 +1,8 @@
// JVM_ANNOTATIONS
package test; package test;
import org.jetbrains.annotations.*; import kotlin.annotations.jvm.*;
import org.jetbrains.annotations.NotNull;
import java.util.*; import java.util.*;
@@ -2,5 +2,5 @@ package test
public interface ReadOnlyExtendsWildcard { public interface ReadOnlyExtendsWildcard {
public abstract fun bar(): kotlin.Unit public abstract fun bar(): kotlin.Unit
public abstract fun foo(/*0*/ @org.jetbrains.annotations.ReadOnly p0: kotlin.collections.List<kotlin.CharSequence!>!, /*1*/ @org.jetbrains.annotations.NotNull p1: kotlin.Comparable<kotlin.String!>): kotlin.Unit public abstract fun foo(/*0*/ @kotlin.annotations.jvm.ReadOnly p0: kotlin.collections.List<kotlin.CharSequence!>!, /*1*/ @org.jetbrains.annotations.NotNull p1: kotlin.Comparable<kotlin.String!>): kotlin.Unit
} }
@@ -1,6 +1,7 @@
// JVM_ANNOTATIONS
package test package test
import org.jetbrains.annotations.* import kotlin.annotations.jvm.*
public interface LoadIterable<T> { public interface LoadIterable<T> {
@Mutable @Mutable
@@ -1,8 +1,8 @@
package test package test
public interface LoadIterable</*0*/ T> { public interface LoadIterable</*0*/ T> {
@org.jetbrains.annotations.Mutable public abstract fun getIterable(): kotlin.collections.MutableIterable<T>? @kotlin.annotations.jvm.Mutable public abstract fun getIterable(): kotlin.collections.MutableIterable<T>?
@org.jetbrains.annotations.ReadOnly public abstract fun getReadOnlyIterable(): kotlin.collections.Iterable<T>? @kotlin.annotations.jvm.ReadOnly public abstract fun getReadOnlyIterable(): kotlin.collections.Iterable<T>?
public abstract fun setIterable(/*0*/ @org.jetbrains.annotations.Mutable p0: kotlin.collections.MutableIterable<T>?): kotlin.Unit public abstract fun setIterable(/*0*/ @kotlin.annotations.jvm.Mutable p0: kotlin.collections.MutableIterable<T>?): kotlin.Unit
public abstract fun setReadOnlyIterable(/*0*/ @org.jetbrains.annotations.ReadOnly p0: kotlin.collections.Iterable<T>?): kotlin.Unit public abstract fun setReadOnlyIterable(/*0*/ @kotlin.annotations.jvm.ReadOnly p0: kotlin.collections.Iterable<T>?): kotlin.Unit
} }
@@ -1,6 +1,7 @@
// JVM_ANNOTATIONS
package test package test
import org.jetbrains.annotations.* import kotlin.annotations.jvm.*
public interface LoadIterableWithConflict<T> { public interface LoadIterableWithConflict<T> {
@ReadOnly @Mutable @ReadOnly @Mutable
@@ -1,6 +1,6 @@
package test package test
public interface LoadIterableWithConflict</*0*/ T> { public interface LoadIterableWithConflict</*0*/ T> {
@org.jetbrains.annotations.ReadOnly @org.jetbrains.annotations.Mutable public abstract fun getIterable(): kotlin.collections.MutableIterable<T>? @kotlin.annotations.jvm.ReadOnly @kotlin.annotations.jvm.Mutable public abstract fun getIterable(): kotlin.collections.MutableIterable<T>?
public abstract fun setIterable(/*0*/ @org.jetbrains.annotations.ReadOnly @org.jetbrains.annotations.Mutable p0: kotlin.collections.MutableIterable<T>?): kotlin.Unit public abstract fun setIterable(/*0*/ @kotlin.annotations.jvm.ReadOnly @kotlin.annotations.jvm.Mutable p0: kotlin.collections.MutableIterable<T>?): kotlin.Unit
} }
@@ -1,6 +1,7 @@
// JVM_ANNOTATIONS
package test package test
import org.jetbrains.annotations.* import kotlin.annotations.jvm.*
public interface LoadIterableWithNullability<T> { public interface LoadIterableWithNullability<T> {
@Mutable @Mutable
@@ -1,8 +1,8 @@
package test package test
public interface LoadIterableWithNullability</*0*/ T> { public interface LoadIterableWithNullability</*0*/ T> {
@org.jetbrains.annotations.Mutable public abstract fun getIterable(): kotlin.collections.MutableIterable<T> @kotlin.annotations.jvm.Mutable public abstract fun getIterable(): kotlin.collections.MutableIterable<T>
@org.jetbrains.annotations.ReadOnly public abstract fun getReadOnlyIterable(): kotlin.collections.Iterable<T> @kotlin.annotations.jvm.ReadOnly public abstract fun getReadOnlyIterable(): kotlin.collections.Iterable<T>
public abstract fun setIterable(/*0*/ @org.jetbrains.annotations.Mutable p0: kotlin.collections.MutableIterable<T>): kotlin.Unit public abstract fun setIterable(/*0*/ @kotlin.annotations.jvm.Mutable p0: kotlin.collections.MutableIterable<T>): kotlin.Unit
public abstract fun setReadOnlyIterable(/*0*/ @org.jetbrains.annotations.ReadOnly p0: kotlin.collections.Iterable<T>): kotlin.Unit public abstract fun setReadOnlyIterable(/*0*/ @kotlin.annotations.jvm.ReadOnly p0: kotlin.collections.Iterable<T>): kotlin.Unit
} }
@@ -1,7 +1,8 @@
// JVM_ANNOTATIONS
package test package test
import java.util.ArrayList import java.util.ArrayList
import org.jetbrains.annotations.* import kotlin.annotations.jvm.*
public interface LoadIterableWithPropagation { public interface LoadIterableWithPropagation {
public interface LoadIterable<T> { public interface LoadIterable<T> {
@@ -3,10 +3,10 @@ package test
public interface LoadIterableWithPropagation { public interface LoadIterableWithPropagation {
public interface LoadIterable</*0*/ T> { public interface LoadIterable</*0*/ T> {
@org.jetbrains.annotations.Mutable public abstract fun getIterable(): kotlin.collections.MutableIterable<T>? @kotlin.annotations.jvm.Mutable public abstract fun getIterable(): kotlin.collections.MutableIterable<T>?
@org.jetbrains.annotations.ReadOnly public abstract fun getReadOnlyIterable(): kotlin.collections.Iterable<T>? @kotlin.annotations.jvm.ReadOnly public abstract fun getReadOnlyIterable(): kotlin.collections.Iterable<T>?
public abstract fun setIterable(/*0*/ @org.jetbrains.annotations.Mutable p0: kotlin.collections.MutableIterable<T>?): kotlin.Unit public abstract fun setIterable(/*0*/ @kotlin.annotations.jvm.Mutable p0: kotlin.collections.MutableIterable<T>?): kotlin.Unit
public abstract fun setReadOnlyIterable(/*0*/ @org.jetbrains.annotations.ReadOnly p0: kotlin.collections.Iterable<T>?): kotlin.Unit public abstract fun setReadOnlyIterable(/*0*/ @kotlin.annotations.jvm.ReadOnly p0: kotlin.collections.Iterable<T>?): kotlin.Unit
} }
public open class LoadIterableImpl</*0*/ T> : test.LoadIterableWithPropagation.LoadIterable<T> { public open class LoadIterableImpl</*0*/ T> : test.LoadIterableWithPropagation.LoadIterable<T> {
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles;
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment; import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
import org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM; import org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM;
import org.jetbrains.kotlin.cli.jvm.config.JvmContentRootsKt; import org.jetbrains.kotlin.cli.jvm.config.JvmContentRootsKt;
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime;
import org.jetbrains.kotlin.config.*; import org.jetbrains.kotlin.config.*;
import org.jetbrains.kotlin.descriptors.ClassDescriptor; import org.jetbrains.kotlin.descriptors.ClassDescriptor;
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor; import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
@@ -118,7 +119,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
if (useTypeTableInSerializer) { if (useTypeTableInSerializer) {
configuration.put(JVMConfigurationKeys.USE_TYPE_TABLE, true); configuration.put(JVMConfigurationKeys.USE_TYPE_TABLE, true);
} }
updateConfigurationWithLanguageVersionDirective(ktFile, configuration); updateConfigurationWithDirectives(ktFile, configuration);
KotlinCoreEnvironment environment = KotlinCoreEnvironment environment =
KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES); KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
@@ -145,8 +146,9 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
compareDescriptors(packageFromSource, packageFromBinary, comparatorConfiguration, txtFile); compareDescriptors(packageFromSource, packageFromBinary, comparatorConfiguration, txtFile);
} }
private static void updateConfigurationWithLanguageVersionDirective(File file, CompilerConfiguration configuration) throws IOException { private static void updateConfigurationWithDirectives(File file, CompilerConfiguration configuration) throws IOException {
String version = InTextDirectivesUtils.findStringWithPrefixes(FileUtil.loadFile(file, true), "// LANGUAGE_VERSION:"); String content = FileUtil.loadFile(file, true);
String version = InTextDirectivesUtils.findStringWithPrefixes(content, "// LANGUAGE_VERSION:");
if (version != null) { if (version != null) {
LanguageVersion explicitVersion = LanguageVersion.fromVersionString(version); LanguageVersion explicitVersion = LanguageVersion.fromVersionString(version);
CommonConfigurationKeysKt.setLanguageVersionSettings( CommonConfigurationKeysKt.setLanguageVersionSettings(
@@ -154,6 +156,14 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
new LanguageVersionSettingsImpl(explicitVersion, ApiVersion.createByLanguageVersion(explicitVersion)) new LanguageVersionSettingsImpl(explicitVersion, ApiVersion.createByLanguageVersion(explicitVersion))
); );
} }
if (InTextDirectivesUtils.isDirectiveDefined(content, "ANDROID_ANNOTATIONS")) {
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.androidAnnotationsForTests());
}
if (InTextDirectivesUtils.isDirectiveDefined(content, "JVM_ANNOTATIONS")) {
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.jvmAnnotationsForTests());
}
} }
protected boolean useFastClassFilesReading() { protected boolean useFastClassFilesReading() {
@@ -87,7 +87,9 @@ public class LoadDescriptorUtil {
@Nullable LanguageVersionSettings explicitLanguageVersionSettings @Nullable LanguageVersionSettings explicitLanguageVersionSettings
) { ) {
List<File> javaBinaryRoots = new ArrayList<>(); List<File> javaBinaryRoots = new ArrayList<>();
// TODO: use the same additional binary roots as those were used for compilation
javaBinaryRoots.add(KotlinTestUtils.getAnnotationsJar()); javaBinaryRoots.add(KotlinTestUtils.getAnnotationsJar());
javaBinaryRoots.add(ForTestCompileRuntime.jvmAnnotationsForTests());
List<File> javaSourceRoots = new ArrayList<>(); List<File> javaSourceRoots = new ArrayList<>();
javaSourceRoots.add(new File("compiler/testData/loadJava/include")); javaSourceRoots.add(new File("compiler/testData/loadJava/include"));
@@ -127,6 +129,10 @@ public class LoadDescriptorUtil {
if (InTextDirectivesUtils.isDirectiveDefined(content, "ANDROID_ANNOTATIONS")) { if (InTextDirectivesUtils.isDirectiveDefined(content, "ANDROID_ANNOTATIONS")) {
classpath.add(ForTestCompileRuntime.androidAnnotationsForTests()); classpath.add(ForTestCompileRuntime.androidAnnotationsForTests());
} }
if (InTextDirectivesUtils.isDirectiveDefined(content, "JVM_ANNOTATIONS")) {
classpath.add(ForTestCompileRuntime.jvmAnnotationsForTests());
}
} }
KotlinTestUtils.compileJavaFiles(javaFiles, Arrays.asList( KotlinTestUtils.compileJavaFiles(javaFiles, Arrays.asList(