Introduced test flag: JVM8_TARGET_WITH_DEFAULTS

This commit is contained in:
Mikhael Bogdanov
2017-01-11 13:44:53 +01:00
parent 7f8acbb759
commit 0a363fd1a5
49 changed files with 148 additions and 61 deletions
@@ -181,7 +181,7 @@ public class AsmUtil {
public static boolean isAbstractMethod(FunctionDescriptor functionDescriptor, OwnerKind kind, GenerationState state) {
return (functionDescriptor.getModality() == Modality.ABSTRACT ||
(isJvmInterface(functionDescriptor.getContainingDeclaration()) && !state.isJvm8Target()))
(isJvmInterface(functionDescriptor.getContainingDeclaration()) && !state.isJvm8TargetWithDefaults()))
&& !isStaticMethod(kind, functionDescriptor);
}
@@ -99,7 +99,7 @@ public class FunctionCodegen {
private final Function1<DeclarationDescriptor, Boolean> IS_PURE_INTERFACE_CHECKER = new Function1<DeclarationDescriptor, Boolean>() {
@Override
public Boolean invoke(DeclarationDescriptor descriptor) {
return JvmCodegenUtil.isAnnotationOrJvm6Interface(descriptor, state);
return JvmCodegenUtil.isAnnotationOrJvmInterfaceWithoutDefaults(descriptor, state);
}
};
@@ -201,7 +201,7 @@ public class FunctionCodegen {
generateBridges(functionDescriptor);
if (isJvm8InterfaceMember(functionDescriptor, state) && contextKind != OwnerKind.DEFAULT_IMPLS && state.getGenerateDefaultImplsForJvm8()) {
if (isJvm8InterfaceWithDefaultsMember(functionDescriptor, state) && contextKind != OwnerKind.DEFAULT_IMPLS && state.getGenerateDefaultImplsForJvm8()) {
generateDelegateForDefaultImpl(functionDescriptor, origin.getElement());
}
@@ -419,7 +419,7 @@ public class FunctionCodegen {
generateFacadeDelegateMethodBody(mv, signature.getAsmMethod(), (MultifileClassFacadeContext) context.getParentContext());
methodEnd = new Label();
}
else if (OwnerKind.DEFAULT_IMPLS == context.getContextKind() && isJvm8InterfaceMember(functionDescriptor, parentCodegen.state)) {
else if (OwnerKind.DEFAULT_IMPLS == context.getContextKind() && isJvm8InterfaceWithDefaultsMember(functionDescriptor, parentCodegen.state)) {
int flags = AsmUtil.getMethodAsmFlags(functionDescriptor, OwnerKind.DEFAULT_IMPLS, context.getState());
assert (flags & Opcodes.ACC_ABSTRACT) == 0 : "Interface method with body should be non-abstract" + functionDescriptor;
Type type = typeMapper.mapOwner(functionDescriptor);
@@ -724,7 +724,7 @@ public class FunctionCodegen {
public void generateBridges(@NotNull FunctionDescriptor descriptor) {
if (descriptor instanceof ConstructorDescriptor) return;
if (owner.getContextKind() == OwnerKind.DEFAULT_IMPLS) return;
if (isAnnotationOrJvm6Interface(descriptor.getContainingDeclaration(), state)) return;
if (isAnnotationOrJvmInterfaceWithoutDefaults(descriptor.getContainingDeclaration(), state)) return;
// equals(Any?), hashCode(), toString() never need bridges
if (isMethodOfAny(descriptor)) return;
@@ -1089,7 +1089,7 @@ public class FunctionCodegen {
iv.invokespecial(parentInternalName, delegateTo.getName(), delegateTo.getDescriptor(), false);
}
else {
if (isJvm8InterfaceMember(descriptor, state)) {
if (isJvm8InterfaceWithDefaultsMember(descriptor, state)) {
iv.invokeinterface(v.getThisName(), delegateTo.getName(), delegateTo.getDescriptor());
}
else {
@@ -1257,6 +1257,6 @@ public class FunctionCodegen {
@NotNull GenerationState state
) {
assert isInterface(contextClass) : "'processInterface' method should be called only for interfaces, but: " + contextClass;
return isJvm8Interface(contextClass, state) ? kind != OwnerKind.DEFAULT_IMPLS : kind == OwnerKind.DEFAULT_IMPLS;
return JvmCodegenUtil.isJvm8InterfaceWithDefaults(contextClass, state) ? kind != OwnerKind.DEFAULT_IMPLS : kind == OwnerKind.DEFAULT_IMPLS;
}
}
@@ -233,7 +233,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
@Override
protected void generateDefaultImplsIfNeeded() {
if (isInterface(descriptor) && !isLocal && (!isJvm8Interface(descriptor, state) || state.getGenerateDefaultImplsForJvm8())) {
if (isInterface(descriptor) && !isLocal && (!JvmCodegenUtil.isJvm8InterfaceWithDefaults(descriptor, state) || state.getGenerateDefaultImplsForJvm8())) {
Type defaultImplsType = state.getTypeMapper().mapDefaultImpls(descriptor);
ClassBuilder defaultImplsBuilder =
state.getFactory().newVisitor(JvmDeclarationOriginKt.DefaultImpls(myClass.getPsiOrParent(), descriptor), defaultImplsType, myClass.getContainingKtFile());
@@ -1293,14 +1293,14 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
private void generateTraitMethods() {
if (isAnnotationOrJvm6Interface(descriptor, state)) return;
if (isAnnotationOrJvmInterfaceWithoutDefaults(descriptor, state)) return;
List<FunctionDescriptor> restrictedInheritance = new ArrayList<FunctionDescriptor>();
for (Map.Entry<FunctionDescriptor, FunctionDescriptor> entry : CodegenUtil.getNonPrivateTraitMethods(descriptor).entrySet()) {
FunctionDescriptor interfaceFun = entry.getKey();
//skip java 8 default methods
if (!CodegenUtilKt.isDefinitelyNotDefaultImplsMethod(interfaceFun) && !isJvm8InterfaceMember(interfaceFun, state)) {
if (state.isJvm8Target() && !JvmCodegenUtil.isJvm8Interface(interfaceFun.getContainingDeclaration(), state)) {
if (!CodegenUtilKt.isDefinitelyNotDefaultImplsMethod(interfaceFun) && !isJvm8InterfaceWithDefaultsMember(interfaceFun, state)) {
if (state.isJvm8TargetWithDefaults() && !JvmCodegenUtil.isJvm8InterfaceWithDefaults(interfaceFun.getContainingDeclaration(), state)) {
restrictedInheritance.add(interfaceFun);
}
else {
@@ -30,8 +30,6 @@ import org.jetbrains.kotlin.codegen.context.MethodContext;
import org.jetbrains.kotlin.codegen.context.RootContext;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
import org.jetbrains.kotlin.config.LanguageFeature;
import org.jetbrains.kotlin.config.LanguageVersionSettings;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor;
import org.jetbrains.kotlin.load.java.descriptors.JavaPropertyDescriptor;
@@ -64,11 +62,11 @@ public class JvmCodegenUtil {
private JvmCodegenUtil() {
}
public static boolean isAnnotationOrJvm6Interface(@NotNull DeclarationDescriptor descriptor, @NotNull GenerationState state) {
return isAnnotationOrJvm6Interface(descriptor, state.isJvm8Target());
public static boolean isAnnotationOrJvmInterfaceWithoutDefaults(@NotNull DeclarationDescriptor descriptor, @NotNull GenerationState state) {
return isAnnotationOrJvmInterfaceWithoutDefaults(descriptor, state.isJvm8Target(), state.isJvm8TargetWithDefaults());
}
public static boolean isAnnotationOrJvm6Interface(@NotNull DeclarationDescriptor descriptor, boolean isJvm8Target) {
private static boolean isAnnotationOrJvmInterfaceWithoutDefaults(@NotNull DeclarationDescriptor descriptor, boolean isJvm8Target, boolean isJvm8TargetWithDefaults) {
if (!isJvmInterface(descriptor)) {
return false;
}
@@ -80,23 +78,24 @@ public class JvmCodegenUtil {
KotlinJvmBinaryClass binaryClass = ((KotlinJvmBinarySourceElement) source).getBinaryClass();
assert binaryClass instanceof FileBasedKotlinClass :
"KotlinJvmBinaryClass should be subclass of FileBasedKotlinClass, but " + binaryClass;
return ((FileBasedKotlinClass) binaryClass).getClassVersion() == Opcodes.V1_6;
/*TODO need add some flags to compiled code*/
return true || ((FileBasedKotlinClass) binaryClass).getClassVersion() == Opcodes.V1_6;
}
}
return !isJvm8Target;
return !isJvm8TargetWithDefaults;
}
public static boolean isJvm8Interface(@NotNull DeclarationDescriptor descriptor, @NotNull GenerationState state) {
return isJvm8Interface(descriptor, state.isJvm8Target());
public static boolean isJvm8InterfaceWithDefaults(@NotNull DeclarationDescriptor descriptor, @NotNull GenerationState state) {
return isJvm8InterfaceWithDefaults(descriptor, state.isJvm8Target(), state.isJvm8TargetWithDefaults());
}
public static boolean isJvm8Interface(@NotNull DeclarationDescriptor descriptor, boolean isJvm8Target) {
return DescriptorUtils.isInterface(descriptor) && !isAnnotationOrJvm6Interface(descriptor, isJvm8Target);
public static boolean isJvm8InterfaceWithDefaults(@NotNull DeclarationDescriptor descriptor, boolean isJvm8Target, boolean isJvm8TargetWithDefaults) {
return DescriptorUtils.isInterface(descriptor) && !isAnnotationOrJvmInterfaceWithoutDefaults(descriptor, isJvm8Target, isJvm8TargetWithDefaults);
}
public static boolean isJvm8InterfaceMember(@NotNull CallableMemberDescriptor descriptor, @NotNull GenerationState state) {
public static boolean isJvm8InterfaceWithDefaultsMember(@NotNull CallableMemberDescriptor descriptor, @NotNull GenerationState state) {
DeclarationDescriptor declaration = descriptor.getContainingDeclaration();
return isJvm8Interface(declaration, state);
return isJvm8InterfaceWithDefaults(declaration, state);
}
public static boolean isJvmInterface(DeclarationDescriptor descriptor) {
@@ -66,7 +66,7 @@ import org.jetbrains.org.objectweb.asm.commons.Method;
import java.util.*;
import static org.jetbrains.kotlin.codegen.AsmUtil.*;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isJvm8InterfaceMember;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isJvm8InterfaceWithDefaultsMember;
import static org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.SYNTHESIZED;
import static org.jetbrains.kotlin.resolve.BindingContext.*;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
@@ -377,7 +377,7 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
ClassDescriptor classDescriptor = ((ClassContext) outermost).getContextDescriptor();
if (context instanceof MethodContext) {
FunctionDescriptor functionDescriptor = ((MethodContext) context).getFunctionDescriptor();
if (isInterface(functionDescriptor.getContainingDeclaration()) && !isJvm8InterfaceMember(functionDescriptor, state)) {
if (isInterface(functionDescriptor.getContainingDeclaration()) && !isJvm8InterfaceWithDefaultsMember(functionDescriptor, state)) {
return typeMapper.mapDefaultImpls(classDescriptor);
}
}
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.KotlinToJvmSignatureMapper
class KotlinToJvmSignatureMapperImpl : KotlinToJvmSignatureMapper {
// We use empty BindingContext, because it is only used by KotlinTypeMapper for purposes irrelevant to the needs of this class
private val typeMapper = KotlinTypeMapper(BindingContext.EMPTY, ClassBuilderMode.LIGHT_CLASSES, NoResolveFileClassesProvider,
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, false)
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, false, false)
override fun mapToJvmMethodSignature(function: FunctionDescriptor) = typeMapper.mapAsmMethod(function)
}
@@ -63,7 +63,7 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
// Avoid errors when some classes are not loaded for some reason
private val typeMapper = KotlinTypeMapper(
bindingContext, ClassBuilderMode.LIGHT_CLASSES, fileClassesProvider, IncompatibleClassTracker.DoNothing, moduleName, false
bindingContext, ClassBuilderMode.LIGHT_CLASSES, fileClassesProvider, IncompatibleClassTracker.DoNothing, moduleName, false, false
)
private val reportDiagnosticsTasks = ArrayList<() -> Unit>()
@@ -125,6 +125,7 @@ class GenerationState @JvmOverloads constructor(
}
val isJvm8Target: Boolean = configuration.get(JVMConfigurationKeys.JVM_TARGET) == JvmTarget.JVM_1_8
val isJvm8TargetWithDefaults: Boolean = isJvm8Target && configuration.getBoolean(JVMConfigurationKeys.JVM8_TARGET_WITH_DEFAULTS)
val generateDefaultImplsForJvm8: Boolean = configuration.getBoolean(JVMConfigurationKeys.INTERFACE_COMPATIBILITY)
val moduleName: String = moduleName ?: JvmCodegenUtil.getModuleName(module)
@@ -134,7 +135,7 @@ class GenerationState @JvmOverloads constructor(
val bindingContext: BindingContext = bindingTrace.bindingContext
val typeMapper: KotlinTypeMapper = KotlinTypeMapper(
this.bindingContext, classBuilderMode, fileClassesProvider, IncompatibleClassTrackerImpl(extraJvmDiagnosticsTrace),
this.moduleName, isJvm8Target
this.moduleName, isJvm8Target, isJvm8TargetWithDefaults
)
val intrinsics: IntrinsicMethods = IntrinsicMethods()
val samWrapperClasses: SamWrapperClasses = SamWrapperClasses(this)
@@ -98,6 +98,7 @@ public class KotlinTypeMapper {
private final IncompatibleClassTracker incompatibleClassTracker;
private final String moduleName;
private final boolean isJvm8Target;
private final boolean isJvm8TargetWithDefaults;
private final TypeMappingConfiguration<Type> typeMappingConfiguration = new TypeMappingConfiguration<Type>() {
private final Function2<String, String, String> defaultClassNameFactory
@@ -153,7 +154,8 @@ public class KotlinTypeMapper {
@NotNull JvmFileClassesProvider fileClassesProvider,
@NotNull IncompatibleClassTracker incompatibleClassTracker,
@NotNull String moduleName,
boolean isJvm8Target
boolean isJvm8Target,
boolean isJvm8TargetWithDefaults
) {
this.bindingContext = bindingContext;
this.classBuilderMode = classBuilderMode;
@@ -161,6 +163,7 @@ public class KotlinTypeMapper {
this.incompatibleClassTracker = incompatibleClassTracker;
this.moduleName = moduleName;
this.isJvm8Target = isJvm8Target;
this.isJvm8TargetWithDefaults = isJvm8TargetWithDefaults;
}
@NotNull
@@ -682,7 +685,7 @@ public class KotlinTypeMapper {
descriptor = classCallable;
continue;
}
else if (isSuperCall && !isJvm8Target && !isInterface(descriptor.getContainingDeclaration())) {
else if (isSuperCall && !isJvm8TargetWithDefaults && !isInterface(descriptor.getContainingDeclaration())) {
//Don't unwrap fake overrides from class to interface cause substituted override would be implicitly generated for target 1.6
return descriptor;
}
@@ -738,12 +741,12 @@ public class KotlinTypeMapper {
baseMethodDescriptor = findBaseDeclaration(functionDescriptor).getOriginal();
ClassDescriptor ownerForDefault = (ClassDescriptor) baseMethodDescriptor.getContainingDeclaration();
ownerForDefaultImpl =
isJvmInterface(ownerForDefault) && !isJvm8Interface(ownerForDefault) ?
isJvmInterface(ownerForDefault) && !isJvm8InterfaceWithDefaults(ownerForDefault) ?
mapDefaultImpls(ownerForDefault) : mapClass(ownerForDefault);
if (isInterface && (superCall || descriptor.getVisibility() == Visibilities.PRIVATE || isAccessor(descriptor))) {
thisClass = mapClass(currentOwner);
if (declarationOwner instanceof JavaClassDescriptor || isJvm8Interface(declarationOwner)) {
if (declarationOwner instanceof JavaClassDescriptor || isJvm8InterfaceWithDefaults(declarationOwner)) {
invokeOpcode = INVOKESPECIAL;
signature = mapSignatureSkipGeneric(functionDescriptor);
owner = thisClass;
@@ -782,7 +785,6 @@ public class KotlinTypeMapper {
signature = mapSignatureSkipGeneric(functionToCall);
/*TODO: isInterfaceMember?*/
ClassDescriptor receiver = (currentIsInterface && !originalIsInterface) || currentOwner instanceof FunctionClassDescriptor
? declarationOwner
: currentOwner;
@@ -828,8 +830,9 @@ public class KotlinTypeMapper {
isJvm8Target ? isInterfaceMember : invokeOpcode == INVOKEINTERFACE );
}
private boolean isJvm8Interface(@NotNull ClassDescriptor ownerForDefault) {
return isJvmInterface(ownerForDefault) && JvmCodegenUtil.isJvm8Interface(ownerForDefault, isJvm8Target);
private boolean isJvm8InterfaceWithDefaults(@NotNull ClassDescriptor ownerForDefault) {
return isJvmInterface(ownerForDefault) &&
JvmCodegenUtil.isJvm8InterfaceWithDefaults(ownerForDefault, isJvm8Target, isJvm8TargetWithDefaults);
}
public static boolean isAccessor(@NotNull CallableMemberDescriptor descriptor) {
@@ -87,6 +87,9 @@ public class JVMConfigurationKeys {
public static final CompilerConfigurationKey<Boolean> INTERFACE_COMPATIBILITY =
CompilerConfigurationKey.create("Generate additional 'DefaultImpls' class files for jvm 8 target for compatibility with 6 target interfaces");
public static final CompilerConfigurationKey<Boolean> JVM8_TARGET_WITH_DEFAULTS =
CompilerConfigurationKey.create("Generate default methods in interfaces");
public static final CompilerConfigurationKey<IncrementalCompilationComponents> INCREMENTAL_COMPILATION_COMPONENTS =
CompilerConfigurationKey.create("incremental cache provider");
@@ -61,12 +61,12 @@ class BridgeLowering(val state: GenerationState) : ClassLoweringPass {
val typeMapper = state.typeMapper
private val IS_PURE_INTERFACE_CHECKER = fun(descriptor: DeclarationDescriptor): Boolean {
return JvmCodegenUtil.isAnnotationOrJvm6Interface(descriptor, state)
return JvmCodegenUtil.isAnnotationOrJvmInterfaceWithoutDefaults(descriptor, state)
}
override fun lower(irClass: IrClass) {
val classDescriptor = irClass.descriptor
if (JvmCodegenUtil.isAnnotationOrJvm6Interface(classDescriptor, state) || classDescriptor is FileClassDescriptor) return
if (JvmCodegenUtil.isAnnotationOrJvmInterfaceWithoutDefaults(classDescriptor, state) || classDescriptor is FileClassDescriptor) return
if (classDescriptor is DefaultImplsClassDescriptor) {
return /*TODO?*/
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
interface Test<T> {
fun test(p: T): T {
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
interface Test<T> {
fun test(p: T): T {
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
interface Z {
fun test(s: String = "OK"): String {
+1
View File
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
// WITH_REFLECT
// FULL_JDK
+1
View File
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
// WITH_RUNTIME
// IGNORE_BACKEND: JS
+1
View File
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
interface Z<T> {
fun test(p: T): T {
+1
View File
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
interface Z<T> {
fun test(p: T): T {
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
interface Z<T> {
val value: T
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
// WITH_RUNTIME
// FULL_JDK
interface Test {
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
// WITH_RUNTIME
// FULL_JDK
interface Test {
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
// WITH_RUNTIME
// FULL_JDK
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
interface KCallable {
val returnType: String
}
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
interface KCallable {
val returnType: String
}
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
// WITH_REFLECT
annotation class Property(val value: String)
@@ -1,6 +1,6 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS, +JVM.INTERFACE_COMPATIBILITY
// WITH_REFLECT
// KOTLIN_CONFIGURATION_FLAGS: +JVM.INTERFACE_COMPATIBILITY
annotation class Property(val value: String)
annotation class Accessor(val value: String)
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
interface Test {
fun test(): String {
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
interface Z {
val z: String;
+1
View File
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
interface Test {
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
// FULL_JDK
// There should be no DefaultImpls method for MutableMap.remove(K;V)
@@ -7,6 +7,7 @@ interface Test {
// FILE: 2.kt
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
class TestClass : Test {
override fun test(): String {
return super.test()
@@ -7,6 +7,7 @@ interface Test {
// FILE: 2.kt
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
interface Test2 : Test {
override fun test(): String {
return super.test()
@@ -7,6 +7,7 @@ interface Test {
// FILE: 2.kt
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
interface Test2 : Test {
override fun test(): String {
return super.test()
@@ -7,6 +7,7 @@ interface Test {
// FILE: 2.kt
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
interface Test2 : Test {
override fun test(): String {
return super.test()
@@ -7,6 +7,7 @@ interface Test {
// FILE: 2.kt
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
open class TestClass : Test {
override fun test(): String {
return super.test()
@@ -7,6 +7,7 @@ interface Test {
// FILE: 2.kt
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
abstract class TestClass : Test {
abstract override fun test(): String
}
@@ -8,6 +8,7 @@ interface Test {
// FILE: 2.kt
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
class TestClass : Test {
override fun test(): String {
return super.test()
@@ -8,6 +8,7 @@ interface Test {
// FILE: 2.kt
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
interface Test2 : Test {
override fun test(): String {
return super.test()
@@ -7,6 +7,7 @@ interface Test {
// FILE: 2.kt
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
class TestClass : Test {
override val test: String
get() = super.test
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
interface Test {
fun test(): String {
@@ -1,6 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.INTERFACE_COMPATIBILITY
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS, +JVM.INTERFACE_COMPATIBILITY
interface Test {
fun test(): String {
@@ -1,4 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS
interface Test {
var z: String
@@ -1,5 +1,5 @@
// JVM_TARGET: 1.8
// KOTLIN_CONFIGURATION_FLAGS: +JVM.INTERFACE_COMPATIBILITY
// KOTLIN_CONFIGURATION_FLAGS: +JVM.JVM8_TARGET_WITH_DEFAULTS, +JVM.INTERFACE_COMPATIBILITY
interface Test {
var z: String
@@ -0,0 +1,17 @@
// JVM_TARGET: 1.8
interface Test {
fun test(): String {
return "OK"
}
fun testAbstract(): String
}
// TESTED_OBJECT_KIND: function
// TESTED_OBJECTS: Test, test
// FLAGS: ACC_PUBLIC, ACC_ABSTRACT
// TESTED_OBJECT_KIND: function
// TESTED_OBJECTS: Test, testAbstract
// FLAGS: ACC_PUBLIC, ACC_ABSTRACT
@@ -0,0 +1,15 @@
// JVM_TARGET: 1.8
interface Test {
var z: String
get() = "OK"
set(value) {}
}
// TESTED_OBJECT_KIND: function
// TESTED_OBJECTS: Test, getZ
// FLAGS: ACC_PUBLIC, ACC_ABSTRACT
// TESTED_OBJECT_KIND: function
// TESTED_OBJECTS: Test, setZ
// FLAGS: ACC_PUBLIC, ACC_ABSTRACT
@@ -36,27 +36,48 @@ public class WriteFlagsTestGenerated extends AbstractWriteFlagsTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/java8/writeFlags"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("defaultMethod.kt")
public void testDefaultMethod() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/writeFlags/defaultMethod.kt");
@TestMetadata("interfaceMethod.kt")
public void testInterfaceMethod() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/writeFlags/interfaceMethod.kt");
doTest(fileName);
}
@TestMetadata("defaultMethodCompatibility.kt")
public void testDefaultMethodCompatibility() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/writeFlags/defaultMethodCompatibility.kt");
@TestMetadata("interfaceProperty.kt")
public void testInterfaceProperty() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/writeFlags/interfaceProperty.kt");
doTest(fileName);
}
@TestMetadata("defaultProperty.kt")
public void testDefaultProperty() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/writeFlags/defaultProperty.kt");
doTest(fileName);
}
@TestMetadata("compiler/testData/codegen/java8/writeFlags/defaults")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Defaults extends AbstractWriteFlagsTest {
public void testAllFilesPresentInDefaults() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/java8/writeFlags/defaults"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("defaultPropertyCompatibility.kt")
public void testDefaultPropertyCompatibility() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/writeFlags/defaultPropertyCompatibility.kt");
doTest(fileName);
@TestMetadata("defaultMethod.kt")
public void testDefaultMethod() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/writeFlags/defaults/defaultMethod.kt");
doTest(fileName);
}
@TestMetadata("defaultMethodCompatibility.kt")
public void testDefaultMethodCompatibility() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/writeFlags/defaults/defaultMethodCompatibility.kt");
doTest(fileName);
}
@TestMetadata("defaultProperty.kt")
public void testDefaultProperty() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/writeFlags/defaults/defaultProperty.kt");
doTest(fileName);
}
@TestMetadata("defaultPropertyCompatibility.kt")
public void testDefaultPropertyCompatibility() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/writeFlags/defaults/defaultPropertyCompatibility.kt");
doTest(fileName);
}
}
}
@@ -196,7 +196,7 @@ abstract class AbstractAnnotationProcessingExtension(
private fun KotlinProcessingEnvironment.createTypeMapper(): KotlinTypeMapper {
return KotlinTypeMapper(bindingContext(), ClassBuilderMode.full(false), NoResolveFileClassesProvider,
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, false)
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, false, false)
}
private fun KotlinProcessingEnvironment.doAnnotationProcessing(files: Collection<KtFile>): ProcessingResult {
@@ -31,7 +31,7 @@ class IdeaKotlinUastBindingContextProviderService : KotlinUastBindingContextProv
override fun getTypeMapper(element: KtElement): KotlinTypeMapper? {
return KotlinTypeMapper(getBindingContext(element),
ClassBuilderMode.LIGHT_CLASSES, NoResolveFileClassesProvider,
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, false)
ClassBuilderMode.LIGHT_CLASSES, NoResolveFileClassesProvider,
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, false, false)
}
}
@@ -41,7 +41,7 @@ class UastAnalysisHandlerExtension : AnalysisHandlerExtension {
val bindingContext = context ?: return null
val typeMapper = KotlinTypeMapper(bindingContext, ClassBuilderMode.LIGHT_CLASSES, NoResolveFileClassesProvider,
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, false)
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, false, false)
this.typeMapper = typeMapper
return typeMapper
}