Remove unused parameter of JetTypeMapper#mapOwner, simplify lots of code

This commit is contained in:
Alexander Udalov
2015-09-14 19:57:02 +03:00
parent 90cef6553c
commit 7c0780455a
12 changed files with 86 additions and 137 deletions
@@ -17,7 +17,6 @@
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.codegen.binding.CodegenBinding
import org.jetbrains.kotlin.codegen.context.CodegenContext
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.psi.JetClass
@@ -25,8 +24,8 @@ import org.jetbrains.kotlin.psi.JetClassOrObject
import org.jetbrains.kotlin.psi.JetElement
import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.jvm.diagnostics.OtherOrigin
import org.jetbrains.kotlin.resolve.jvm.annotations.hasJvmOverloadsAnnotation
import org.jetbrains.kotlin.resolve.jvm.diagnostics.OtherOrigin
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
@@ -39,12 +38,13 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) {
* If all of the parameters of the specified constructor declare default values,
* generates a no-argument constructor that passes default values for all arguments.
*/
fun generateConstructorOverloadsIfNeeded(constructorDescriptor: ConstructorDescriptor,
classBuilder: ClassBuilder,
context: CodegenContext<*>,
classOrObject: JetClassOrObject) {
if (generateOverloadsIfNeeded(classOrObject, constructorDescriptor, constructorDescriptor,
context, classBuilder)) {
fun generateConstructorOverloadsIfNeeded(
constructorDescriptor: ConstructorDescriptor,
classBuilder: ClassBuilder,
contextKind: OwnerKind,
classOrObject: JetClassOrObject
) {
if (generateOverloadsIfNeeded(classOrObject, constructorDescriptor, constructorDescriptor, contextKind, classBuilder)) {
return
}
@@ -52,8 +52,7 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) {
return
}
generateOverloadWithSubstitutedParameters(constructorDescriptor, constructorDescriptor, classBuilder, classOrObject,
context,
generateOverloadWithSubstitutedParameters(constructorDescriptor, constructorDescriptor, classBuilder, classOrObject, contextKind,
constructorDescriptor.countDefaultParameters())
}
@@ -70,21 +69,25 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) {
* implementation in the companion object class)
* @return true if the overloads annotation was found on the element, false otherwise
*/
fun generateOverloadsIfNeeded(methodElement: JetElement?,
functionDescriptor: FunctionDescriptor,
delegateFunctionDescriptor: FunctionDescriptor,
owner: CodegenContext<*>,
classBuilder: ClassBuilder): Boolean {
fun generateOverloadsIfNeeded(
methodElement: JetElement?,
functionDescriptor: FunctionDescriptor,
delegateFunctionDescriptor: FunctionDescriptor,
contextKind: OwnerKind,
classBuilder: ClassBuilder
): Boolean {
if (!functionDescriptor.hasJvmOverloadsAnnotation()) {
return false
}
val count = functionDescriptor.countDefaultParameters()
val context = owner.intoFunction(functionDescriptor)
for (i in 1..count) {
generateOverloadWithSubstitutedParameters(functionDescriptor, delegateFunctionDescriptor, classBuilder, methodElement, context, i)
generateOverloadWithSubstitutedParameters(
functionDescriptor, delegateFunctionDescriptor, classBuilder, methodElement, contextKind, i
)
}
return true
}
@@ -102,18 +105,19 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) {
* implementation in the companion object class)
* @param methodElement the PSI element for the method implementation (used in diagnostic messages only)
*/
fun generateOverloadWithSubstitutedParameters(functionDescriptor: FunctionDescriptor,
delegateFunctionDescriptor: FunctionDescriptor,
classBuilder: ClassBuilder,
methodElement: JetElement?,
context: CodegenContext<*>,
substituteCount: Int) {
private fun generateOverloadWithSubstitutedParameters(
functionDescriptor: FunctionDescriptor,
delegateFunctionDescriptor: FunctionDescriptor,
classBuilder: ClassBuilder,
methodElement: JetElement?,
contextKind: OwnerKind,
substituteCount: Int
) {
val typeMapper = state.typeMapper
val isStatic = AsmUtil.isStaticMethod(context.getContextKind(), functionDescriptor)
val isStatic = AsmUtil.isStaticMethod(contextKind, functionDescriptor)
val flags = AsmUtil.getVisibilityAccessFlag(functionDescriptor) or (if (isStatic) Opcodes.ACC_STATIC else 0)
val remainingParameters = getRemainingParameters(functionDescriptor.getOriginal(), substituteCount)
val signature = typeMapper.mapSignature(functionDescriptor, context.getContextKind(), remainingParameters)
val signature = typeMapper.mapSignature(functionDescriptor, contextKind, remainingParameters)
val mv = classBuilder.newMethod(OtherOrigin(methodElement, functionDescriptor), flags,
signature.getAsmMethod().getName(),
signature.getAsmMethod().getDescriptor(),
@@ -136,7 +140,7 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) {
val v = InstructionAdapter(mv)
mv.visitCode()
val methodOwner = typeMapper.mapToCallableMethod(delegateFunctionDescriptor, false, context).owner
val methodOwner = typeMapper.mapToCallableMethod(delegateFunctionDescriptor, false).owner
if (!isStatic) {
val thisIndex = frameMap.enterTemp(AsmTypes.OBJECT_TYPE)
v.load(thisIndex, methodOwner) // Load this on stack
@@ -187,7 +191,7 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) {
v.aconst(null)
}
val defaultMethod = typeMapper.mapDefaultMethod(delegateFunctionDescriptor, context.getContextKind(), context)
val defaultMethod = typeMapper.mapDefaultMethod(delegateFunctionDescriptor, contextKind)
if (functionDescriptor is ConstructorDescriptor) {
v.invokespecial(methodOwner.getInternalName(), defaultMethod.getName(), defaultMethod.getDescriptor(), false)
}
@@ -2210,22 +2210,21 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
PropertyGetterDescriptor getter = propertyDescriptor.getGetter();
if (getter != null) {
callableGetter = typeMapper.mapToCallableMethod(getter, isSuper, context);
callableGetter = typeMapper.mapToCallableMethod(getter, isSuper);
}
}
if (propertyDescriptor.isVar()) {
PropertySetterDescriptor setter = propertyDescriptor.getSetter();
if (setter != null && !couldUseDirectAccessToProperty(propertyDescriptor, false, isDelegatedProperty, context)) {
callableSetter = typeMapper.mapToCallableMethod(setter, isSuper, context);
callableSetter = typeMapper.mapToCallableMethod(setter, isSuper);
}
}
}
propertyDescriptor = DescriptorUtils.unwrapFakeOverride(propertyDescriptor);
Type backingFieldOwner =
typeMapper.mapOwner(changeOwnerOnTypeMapping ? propertyDescriptor.getContainingDeclaration() : propertyDescriptor,
isCallInsideSameModuleAsDeclared(propertyDescriptor, context, state.getOutDirectory()));
typeMapper.mapOwner(changeOwnerOnTypeMapping ? propertyDescriptor.getContainingDeclaration() : propertyDescriptor);
String fieldName;
if (isExtensionProperty && !isDelegatedProperty) {
@@ -2247,11 +2246,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
@NotNull
private StackValue.Property intermediateValueForSyntheticExtensionProperty(@NotNull SyntheticJavaPropertyDescriptor propertyDescriptor, StackValue receiver) {
private StackValue.Property intermediateValueForSyntheticExtensionProperty(
@NotNull SyntheticJavaPropertyDescriptor propertyDescriptor,
StackValue receiver
) {
Type type = typeMapper.mapType(propertyDescriptor.getOriginal().getType());
CallableMethod callableGetter = typeMapper.mapToCallableMethod(propertyDescriptor.getGetMethod(), false, context);
CallableMethod callableGetter = typeMapper.mapToCallableMethod(propertyDescriptor.getGetMethod(), false);
FunctionDescriptor setMethod = propertyDescriptor.getSetMethod();
CallableMethod callableSetter = setMethod != null ? typeMapper.mapToCallableMethod(setMethod, false, context) : null;
CallableMethod callableSetter = setMethod != null ? typeMapper.mapToCallableMethod(setMethod, false) : null;
return StackValue.property(propertyDescriptor, null, type, false, null, callableGetter, callableSetter, state, receiver);
}
@@ -2393,12 +2395,12 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
return intrinsic.toCallable(fd, superCall, resolvedCall, this);
}
return resolveToCallableMethod(fd, superCall, context);
return resolveToCallableMethod(fd, superCall);
}
@NotNull
private CallableMethod resolveToCallableMethod(@NotNull FunctionDescriptor fd, boolean superCall, @NotNull CodegenContext context) {
return typeMapper.mapToCallableMethod(SamCodegenUtil.resolveSamAdapter(fd), superCall, context);
private CallableMethod resolveToCallableMethod(@NotNull FunctionDescriptor fd, boolean superCall) {
return typeMapper.mapToCallableMethod(SamCodegenUtil.resolveSamAdapter(fd), superCall);
}
public void invokeMethodWithArguments(
@@ -3483,7 +3485,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
boolean isGetter = "get".equals(operationDescriptor.getName().asString());
Callable callable = resolveToCallable(operationDescriptor, false, isGetter ? resolvedGetCall : resolvedSetCall);
Callable callableMethod = resolveToCallableMethod(operationDescriptor, false, context);
Callable callableMethod = resolveToCallableMethod(operationDescriptor, false);
Type[] argumentTypes = callableMethod.getParameterTypes();
StackValue collectionElementReceiver = createCollectionElementReceiver(
@@ -27,7 +27,10 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.backend.common.bridges.Bridge;
import org.jetbrains.kotlin.backend.common.bridges.BridgesPackage;
import org.jetbrains.kotlin.codegen.annotation.AnnotatedWithOnlyTargetedAnnotations;
import org.jetbrains.kotlin.codegen.context.*;
import org.jetbrains.kotlin.codegen.context.CodegenContext;
import org.jetbrains.kotlin.codegen.context.CodegenContextUtil;
import org.jetbrains.kotlin.codegen.context.DelegatingFacadeContext;
import org.jetbrains.kotlin.codegen.context.MethodContext;
import org.jetbrains.kotlin.codegen.optimization.OptimizationMethodVisitor;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.state.JetTypeMapper;
@@ -121,10 +124,9 @@ public class FunctionCodegen {
@NotNull FunctionDescriptor functionDescriptor,
@NotNull FunctionDescriptor delegateFunctionDescriptor
) {
new DefaultParameterValueSubstitutor(state).generateOverloadsIfNeeded(function,
functionDescriptor,
delegateFunctionDescriptor,
owner, v);
new DefaultParameterValueSubstitutor(state).generateOverloadsIfNeeded(
function, functionDescriptor, delegateFunctionDescriptor, owner.getContextKind(), v
);
}
public void generateMethod(
@@ -580,7 +582,7 @@ public class FunctionCodegen {
// $default methods are never private to be accessible from other class files (e.g. inner) without the need of synthetic accessors
flags &= ~ACC_PRIVATE;
Method defaultMethod = typeMapper.mapDefaultMethod(functionDescriptor, kind, owner);
Method defaultMethod = typeMapper.mapDefaultMethod(functionDescriptor, kind);
MethodVisitor mv = v.newMethod(
Synthetic(function, functionDescriptor),
@@ -667,7 +669,7 @@ public class FunctionCodegen {
method = state.getTypeMapper().mapToCallableMethod((ConstructorDescriptor) functionDescriptor);
}
else {
method = state.getTypeMapper().mapToCallableMethod(functionDescriptor, false, methodContext);
method = state.getTypeMapper().mapToCallableMethod(functionDescriptor, false);
}
generator.genCallWithoutAssertions(method, codegen);
@@ -944,7 +944,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
((AccessorForCallableDescriptor) accessorDescriptor).getSuperCallExpression() != null;
CallableMethod callableMethod = isConstructor ?
typeMapper.mapToCallableMethod((ConstructorDescriptor) functionDescriptor) :
typeMapper.mapToCallableMethod(functionDescriptor, superCall, context);
typeMapper.mapToCallableMethod(functionDescriptor, superCall);
int reg = 1;
if (isConstructor && !accessorIsConstructor) {
@@ -1084,8 +1084,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
functionCodegen.generateDefaultIfNeeded(constructorContext, constructorDescriptor, OwnerKind.IMPLEMENTATION,
DefaultParameterValueLoader.DEFAULT, null);
new DefaultParameterValueSubstitutor(state).generateConstructorOverloadsIfNeeded(constructorDescriptor, v,
constructorContext, myClass);
new DefaultParameterValueSubstitutor(state).generateConstructorOverloadsIfNeeded(constructorDescriptor, v, kind, myClass);
if (isCompanionObject(descriptor)) {
context.recordSyntheticAccessorIfNeeded(constructorDescriptor, bindingContext);
@@ -1110,8 +1109,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
functionCodegen.generateDefaultIfNeeded(constructorContext, constructorDescriptor, OwnerKind.IMPLEMENTATION,
DefaultParameterValueLoader.DEFAULT, null);
new DefaultParameterValueSubstitutor(state).generateOverloadsIfNeeded(myClass, constructorDescriptor, constructorDescriptor,
constructorContext, v);
new DefaultParameterValueSubstitutor(state).generateOverloadsIfNeeded(
myClass, constructorDescriptor, constructorDescriptor, kind, v
);
}
private void generatePrimaryConstructorImpl(
@@ -65,8 +65,7 @@ class PlatformStaticGenerator(
val syntheticOrOriginalMethod = typeMapper.mapToCallableMethod(
codegen.getContext().accessibleDescriptor(descriptor, /* superCallExpression = */ null),
false,
codegen.getContext()
false
)
syntheticOrOriginalMethod.genInvokeInstruction(iv)
iv.areturn(asmMethod.returnType)
@@ -101,7 +101,7 @@ public class TraitImplBodyCodegen(
override fun doGenerateBody(codegen: ExpressionCodegen, signature: JvmMethodSignature) {
val iv = codegen.v
val method = typeMapper.mapToCallableMethod(delegateTo, true, context)
val method = typeMapper.mapToCallableMethod(delegateTo, true)
val myParameters = signature.getValueParameters()
val calleeParameters = method.getValueParameters()
@@ -185,7 +185,7 @@ public class InlineCodegen extends CallGenerator {
Method asmMethod;
if (callDefault) {
asmMethod = typeMapper.mapDefaultMethod(functionDescriptor, context.getContextKind(), context);
asmMethod = typeMapper.mapDefaultMethod(functionDescriptor, context.getContextKind());
}
else {
asmMethod = jvmSignature.getAsmMethod();
@@ -231,7 +231,7 @@ public class InlineCodegen extends CallGenerator {
SMAP smap;
if (callDefault) {
Type ownerType = typeMapper.mapOwner(functionDescriptor, true/*TODO: false, migration*/);
Type ownerType = typeMapper.mapOwner(functionDescriptor);
FakeMemberCodegen parentCodegen = new FakeMemberCodegen(codegen.getParentCodegen(), inliningFunction,
(FieldOwnerContext) methodContext.getParentContext(),
ownerType.getInternalName());
@@ -343,7 +343,7 @@ public class InlineCodegen extends CallGenerator {
new FakeMemberCodegen(codegen.getParentCodegen(), expression,
(FieldOwnerContext) context.getParentContext(),
isLambda ? codegen.getParentCodegen().getClassName()
: typeMapper.mapOwner(descriptor, true /*TODO: false, migration*/).getInternalName());
: typeMapper.mapOwner(descriptor).getInternalName());
FunctionGenerationStrategy strategy =
expression instanceof JetCallableReferenceExpression ?
@@ -33,7 +33,7 @@ public abstract class IntrinsicMethod {
@NotNull ResolvedCall resolvedCall,
@NotNull ExpressionCodegen codegen
) {
return toCallable(codegen.getState().getTypeMapper().mapToCallableMethod(fd, false, codegen.getContext()), isSuper, resolvedCall);
return toCallable(codegen.getState().getTypeMapper().mapToCallableMethod(fd, false), isSuper, resolvedCall);
}
@NotNull
@@ -58,4 +58,4 @@ public abstract class IntrinsicMethod {
public Type nullOr(Type type, Type newType) {
return type == null ? null : newType;
}
}
}
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.codegen.optimization.OptimizationClassBuilderFactory
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.ScriptDescriptor
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
import org.jetbrains.kotlin.modules.TargetId
import org.jetbrains.kotlin.name.FqName
@@ -41,7 +40,7 @@ import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.DelegatingBindingTrace
import java.io.File
public class GenerationState jvmOverloads constructor(
public class GenerationState @JvmOverloads constructor(
public val project: Project,
builderFactory: ClassBuilderFactory,
public val module: ModuleDescriptor,
@@ -58,7 +57,9 @@ public class GenerationState jvmOverloads constructor(
// for PackageCodegen in incremental compilation mode
public val targetId: TargetId? = null,
moduleName: String? = null,
// TODO: temporary hack, see JetTypeMapperWithOutDirectory state for details
// 'outDirectory' is a hack to correctly determine if a compiled class is from the same module as the callee during
// partial compilation. Module chunks are treated as a single module.
// TODO: get rid of it with the proper module infrastructure
public val outDirectory: File? = null,
public val incrementalCompilationComponents: IncrementalCompilationComponents? = null,
public val progress: Progress = Progress.DEAF
@@ -87,8 +88,7 @@ public class GenerationState jvmOverloads constructor(
public val classBuilderMode: ClassBuilderMode = builderFactory.getClassBuilderMode()
public val bindingTrace: BindingTrace = DelegatingBindingTrace(bindingContext, "trace in GenerationState")
public val bindingContext: BindingContext = bindingTrace.getBindingContext()
public val typeMapper: JetTypeMapper =
JetTypeMapperWithOutDirectory(this.bindingContext, classBuilderMode, fileClassesProvider, outDirectory)
public val typeMapper: JetTypeMapper = JetTypeMapper(this.bindingContext, classBuilderMode, fileClassesProvider)
public val intrinsics: IntrinsicMethods = IntrinsicMethods()
public val samWrapperClasses: SamWrapperClasses = SamWrapperClasses(this)
public val inlineCycleReporter: InlineCycleReporter = InlineCycleReporter(diagnostics)
@@ -101,13 +101,13 @@ public class GenerationState jvmOverloads constructor(
private var used = false
public val isCallAssertionsEnabled: Boolean = !disableCallAssertions
@jvmName("isCallAssertionsEnabled") get
@JvmName("isCallAssertionsEnabled") get
public val isParamAssertionsEnabled: Boolean = !disableParamAssertions
@jvmName("isParamAssertionsEnabled") get
@JvmName("isParamAssertionsEnabled") get
public val isInlineEnabled: Boolean = !disableInline
@jvmName("isInlineEnabled") get
@JvmName("isInlineEnabled") get
public val moduleName: String = moduleName ?: JvmCodegenUtil.getModuleName(module)
@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.codegen.*;
import org.jetbrains.kotlin.codegen.binding.CodegenBinding;
import org.jetbrains.kotlin.codegen.binding.MutableClosure;
import org.jetbrains.kotlin.codegen.binding.PsiCodegenPredictor;
import org.jetbrains.kotlin.codegen.context.CodegenContext;
import org.jetbrains.kotlin.codegen.signature.BothSignatureWriter;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.fileClasses.FileClassesPackage;
@@ -69,7 +68,6 @@ import org.jetbrains.kotlin.types.expressions.OperatorConventions;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.Method;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@@ -139,7 +137,7 @@ public class JetTypeMapper {
}
@NotNull
public Type mapOwner(@NotNull DeclarationDescriptor descriptor, boolean isInsideModule) {
public Type mapOwner(@NotNull DeclarationDescriptor descriptor) {
if (isLocalFunction(descriptor)) {
return asmTypeForAnonymousClass(bindingContext, (FunctionDescriptor) descriptor);
}
@@ -594,11 +592,7 @@ public class JetTypeMapper {
}
@NotNull
public CallableMethod mapToCallableMethod(
@NotNull FunctionDescriptor descriptor,
boolean superCall,
@NotNull CodegenContext<?> context
) {
public CallableMethod mapToCallableMethod(@NotNull FunctionDescriptor descriptor, boolean superCall) {
DeclarationDescriptor functionParent = descriptor.getOriginal().getContainingDeclaration();
FunctionDescriptor functionDescriptor = unwrapFakeOverride(descriptor.getOriginal());
@@ -663,7 +657,7 @@ public class JetTypeMapper {
}
else {
signature = mapSignature(functionDescriptor.getOriginal());
owner = mapOwner(functionDescriptor, isCallInsideSameModuleAsDeclared(functionDescriptor, context, getOutDirectory()));
owner = mapOwner(functionDescriptor);
ownerForDefaultParam = owner;
ownerForDefaultImpl = owner;
if (functionParent instanceof PackageFragmentDescriptor) {
@@ -852,13 +846,15 @@ public class JetTypeMapper {
}
@NotNull
public Method mapDefaultMethod(@NotNull FunctionDescriptor functionDescriptor, @NotNull OwnerKind kind, @NotNull CodegenContext<?> context) {
public Method mapDefaultMethod(@NotNull FunctionDescriptor functionDescriptor, @NotNull OwnerKind kind) {
Method jvmSignature = mapSignature(functionDescriptor, kind).getAsmMethod();
Type ownerType = mapOwner(functionDescriptor, isCallInsideSameModuleAsDeclared(functionDescriptor, context, getOutDirectory()));
Type ownerType = mapOwner(functionDescriptor);
boolean isConstructor = isConstructor(jvmSignature);
String descriptor = getDefaultDescriptor(jvmSignature,
isStaticMethod(kind, functionDescriptor) || isConstructor ? null : ownerType.getDescriptor(),
functionDescriptor.getExtensionReceiverParameter() != null);
String descriptor = getDefaultDescriptor(
jvmSignature,
isStaticMethod(kind, functionDescriptor) || isConstructor ? null : ownerType.getDescriptor(),
functionDescriptor.getExtensionReceiverParameter() != null
);
return new Method(isConstructor ? "<init>" : jvmSignature.getName() + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX, descriptor);
}
@@ -1142,10 +1138,4 @@ public class JetTypeMapper {
}
return null;
}
// TODO Temporary hack until modules infrastructure is implemented. See JetTypeMapperWithOutDirectory for details
@Nullable
protected File getOutDirectory() {
return null;
}
}
@@ -1,48 +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.state;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.ClassBuilderMode;
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider;
import org.jetbrains.kotlin.resolve.BindingContext;
import java.io.File;
// TODO Temporary hack until modules infrastructure is implemented.
// This class is necessary for detecting if compiled class is from the same module as callee.
// Module chunks are treated as single module.
public class JetTypeMapperWithOutDirectory extends JetTypeMapper {
private final File outDirectory;
public JetTypeMapperWithOutDirectory(
@NotNull BindingContext bindingContext,
@NotNull ClassBuilderMode classBuilderMode,
@NotNull JvmFileClassesProvider fileClassesManager,
@Nullable File outDirectory
) {
super(bindingContext, classBuilderMode, fileClassesManager);
this.outDirectory = outDirectory;
}
@Nullable
@Override
public File getOutDirectory() {
return outDirectory;
}
}
@@ -408,8 +408,8 @@ public class JetPositionManager(private val myDebugProcess: DebugProcess) : Mult
public fun getJvmInternalNameForPropertyOwner(typeMapper: JetTypeMapper, descriptor: PropertyDescriptor): String {
return typeMapper.mapOwner(
if (AsmUtil.isPropertyWithBackingFieldInOuterClass(descriptor)) descriptor.getContainingDeclaration() else descriptor,
true).getInternalName()
if (AsmUtil.isPropertyWithBackingFieldInOuterClass(descriptor)) descriptor.containingDeclaration else descriptor
).internalName
}
private fun isInPropertyAccessor(element: PsiElement?) =