diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java index 13dbb5d164a..0c974c96109 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/FunctionCodegen.java @@ -40,7 +40,6 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget; import org.jetbrains.kotlin.jvm.RuntimeAssertionInfo; import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature; import org.jetbrains.kotlin.load.java.JvmAbi; -import org.jetbrains.kotlin.load.java.JvmAnnotationNames; import org.jetbrains.kotlin.load.java.SpecialBuiltinMembers; import org.jetbrains.kotlin.load.kotlin.nativeDeclarations.NativeKt; import org.jetbrains.kotlin.name.FqName; @@ -162,7 +161,7 @@ public class FunctionCodegen { int flags = getMethodAsmFlags(functionDescriptor, contextKind); boolean isNative = NativeKt.hasNativeAnnotation(functionDescriptor); - if (isNative && owner instanceof DelegatingFacadeContext) { + if (isNative && owner instanceof MultifileClassFacadeContext) { // Native methods are only defined in facades and do not need package part implementations return; } @@ -234,22 +233,6 @@ public class FunctionCodegen { else { annotationCodegen.genAnnotations(functionDescriptor, asmMethod.getReturnType()); } - - writePackageFacadeMethodAnnotationsIfNeeded(mv); - } - - private void writePackageFacadeMethodAnnotationsIfNeeded(MethodVisitor mv) { - if (owner instanceof PackageFacadeContext) { - PackageFacadeContext packageFacadeContext = (PackageFacadeContext) owner; - Type delegateToClassType = packageFacadeContext.getPublicFacadeType(); - if (delegateToClassType != null) { - String className = delegateToClassType.getClassName(); - AnnotationVisitor - av = mv.visitAnnotation(AsmUtil.asmDescByFqNameWithoutInnerClasses(JvmAnnotationNames.KOTLIN_DELEGATED_METHOD), true); - av.visit(JvmAnnotationNames.IMPLEMENTATION_CLASS_NAME_FIELD_NAME, className); - av.visitEnd(); - } - } } private void generateParameterAnnotations( @@ -358,8 +341,8 @@ public class FunctionCodegen { int functionFakeIndex = -1; int lambdaFakeIndex = -1; - if (context.getParentContext() instanceof DelegatingFacadeContext) { - generateFacadeDelegateMethodBody(mv, signature.getAsmMethod(), (DelegatingFacadeContext) context.getParentContext()); + if (context.getParentContext() instanceof MultifileClassFacadeContext) { + generateFacadeDelegateMethodBody(mv, signature.getAsmMethod(), (MultifileClassFacadeContext) context.getParentContext()); methodEnd = new Label(); } else { @@ -462,9 +445,9 @@ public class FunctionCodegen { private static void generateFacadeDelegateMethodBody( @NotNull MethodVisitor mv, @NotNull Method asmMethod, - @NotNull DelegatingFacadeContext context + @NotNull MultifileClassFacadeContext context ) { - generateDelegateToMethodBody(true, mv, asmMethod, context.getDelegateToClassType().getInternalName()); + generateDelegateToMethodBody(true, mv, asmMethod, context.getFilePartType().getInternalName()); } private static void generateDelegateToMethodBody( @@ -687,9 +670,9 @@ public class FunctionCodegen { AnnotationCodegen.forMethod(mv, typeMapper).genAnnotations(functionDescriptor, defaultMethod.getReturnType()); if (state.getClassBuilderMode() == ClassBuilderMode.FULL) { - if (this.owner instanceof DelegatingFacadeContext) { + if (this.owner instanceof MultifileClassFacadeContext) { mv.visitCode(); - generateFacadeDelegateMethodBody(mv, defaultMethod, (DelegatingFacadeContext) this.owner); + generateFacadeDelegateMethodBody(mv, defaultMethod, (MultifileClassFacadeContext) this.owner); endVisit(mv, "default method delegation", getSourceFromDescriptor(functionDescriptor)); } else { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java index 8048770decd..cd7ae0659a6 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/MemberCodegen.java @@ -302,7 +302,7 @@ public abstract class MemberCodegen): Type? = when (owner) { - is DelegatingFacadeContext -> owner.delegateToClassType + is MultifileClassFacadeContext -> owner.filePartType is DelegatingToPartContext -> owner.implementationOwnerClassType else -> null } @JvmStatic public fun isImplClassOwner(owner: CodegenContext<*>): Boolean = - owner !is DelegatingFacadeContext + owner !is MultifileClassFacadeContext } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/DelegatingFacadeContext.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/DelegatingFacadeContext.java deleted file mode 100644 index 478d6db2667..00000000000 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/DelegatingFacadeContext.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2010-2015 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 org.jetbrains.kotlin.codegen.context; - -import org.jetbrains.annotations.Nullable; -import org.jetbrains.org.objectweb.asm.Type; - -public interface DelegatingFacadeContext { - @Nullable - Type getDelegateToClassType(); -} diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/MultifileClassFacadeContext.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/MultifileClassFacadeContext.java index 2bb6f57ca5e..fe42068495b 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/MultifileClassFacadeContext.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/MultifileClassFacadeContext.java @@ -16,11 +16,10 @@ package org.jetbrains.kotlin.codegen.context; -import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor; import org.jetbrains.org.objectweb.asm.Type; -public class MultifileClassFacadeContext extends MultifileClassContextBase implements DelegatingFacadeContext { +public class MultifileClassFacadeContext extends MultifileClassContextBase { public MultifileClassFacadeContext( PackageFragmentDescriptor descriptor, CodegenContext parent, @@ -29,10 +28,4 @@ public class MultifileClassFacadeContext extends MultifileClassContextBase imple ) { super(descriptor, parent, multifileClassType, filePartType); } - - @Nullable - @Override - public Type getDelegateToClassType() { - return getFilePartType(); - } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/PackageContext.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/PackageContext.java index fa909492855..7606e998a83 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/PackageContext.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/PackageContext.java @@ -25,7 +25,7 @@ import org.jetbrains.org.objectweb.asm.Type; public class PackageContext extends FieldOwnerContext implements DelegatingToPartContext, FacadePartWithSourceFile { private final Type packagePartType; - @Nullable private KtFile sourceFile; + private final KtFile sourceFile; public PackageContext( @NotNull PackageFragmentDescriptor contextDescriptor, diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/PackageFacadeContext.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/PackageFacadeContext.java deleted file mode 100644 index f31b34bb946..00000000000 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/PackageFacadeContext.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2010-2015 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 org.jetbrains.kotlin.codegen.context; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor; -import org.jetbrains.org.objectweb.asm.Type; - -public class PackageFacadeContext extends PackageContext implements DelegatingFacadeContext { - private final Type publicFacadeType; - - public PackageFacadeContext( - @NotNull PackageFragmentDescriptor contextDescriptor, - @NotNull CodegenContext parent, - @NotNull Type packagePartType - ) { - this(contextDescriptor, parent, packagePartType, packagePartType); - } - - public PackageFacadeContext( - @NotNull PackageFragmentDescriptor contextDescriptor, - @NotNull CodegenContext parent, - @NotNull Type packagePartType, - @NotNull Type publicFacadeType - ) { - super(contextDescriptor, parent, packagePartType, null); - - this.publicFacadeType = publicFacadeType; - } - - @Override - @Nullable - public Type getDelegateToClassType() { - return getPackagePartType(); - } - - public Type getPublicFacadeType() { - return publicFacadeType; - } -} diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java index eaa8de0c46b..73a82cf342a 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.java @@ -16,7 +16,7 @@ package org.jetbrains.kotlin.load.java; -import kotlin.SetsKt; +import kotlin.collections.SetsKt; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.name.ClassId; import org.jetbrains.kotlin.name.FqName; @@ -37,9 +37,6 @@ public final class JvmAnnotationNames { public static final FqName KOTLIN_INTERFACE_DEFAULT_IMPLS = new FqName("kotlin.jvm.internal.KotlinInterfaceDefaultImpls"); public static final FqName KOTLIN_LOCAL_CLASS = new FqName("kotlin.jvm.internal.KotlinLocalClass"); - public static final FqName KOTLIN_DELEGATED_METHOD = new FqName("kotlin.jvm.internal.KotlinDelegatedMethod"); - public static final String IMPLEMENTATION_CLASS_NAME_FIELD_NAME = "implementationClassName"; - public static final String VERSION_FIELD_NAME = "version"; public static final String FILE_PART_CLASS_NAMES_FIELD_NAME = "filePartClassNames"; public static final String MULTIFILE_CLASS_NAME_FIELD_NAME = "multifileClassName"; diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/KotlinDelegatedMethod.java b/core/runtime.jvm/src/kotlin/jvm/internal/KotlinDelegatedMethod.java deleted file mode 100644 index 00159cd944c..00000000000 --- a/core/runtime.jvm/src/kotlin/jvm/internal/KotlinDelegatedMethod.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2010-2015 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 kotlin.jvm.internal; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface KotlinDelegatedMethod { - String implementationClassName(); -}