Merge ParentCodegenAware and ParentCodegenAwareImpl
Unextend ExpressionCodegen from ParentCodegenAware and make its getParentCodegen() non-null. This fixes some nullability warnings related to getParentCodegen()
This commit is contained in:
@@ -25,13 +25,13 @@ import org.jetbrains.jet.codegen.binding.CalculatedClosure;
|
||||
import org.jetbrains.jet.codegen.context.CodegenContext;
|
||||
import org.jetbrains.jet.codegen.context.LocalLookup;
|
||||
import org.jetbrains.jet.codegen.signature.BothSignatureWriter;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
@@ -50,7 +50,7 @@ import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
|
||||
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass;
|
||||
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
||||
|
||||
public class ClosureCodegen extends ParentCodegenAwareImpl {
|
||||
public class ClosureCodegen extends ParentCodegenAware {
|
||||
private final PsiElement fun;
|
||||
private final FunctionDescriptor funDescriptor;
|
||||
private final SamType samType;
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.jetbrains.jet.codegen.context.*;
|
||||
import org.jetbrains.jet.codegen.inline.InlineCodegen;
|
||||
import org.jetbrains.jet.codegen.inline.NameGenerator;
|
||||
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethod;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
@@ -51,6 +50,7 @@ import org.jetbrains.jet.lang.resolve.constants.IntegerValueTypeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.descriptor.SamConstructorDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.*;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -77,7 +77,7 @@ import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSynth
|
||||
import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue.NO_RECEIVER;
|
||||
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
||||
|
||||
public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implements LocalLookup, ParentCodegenAware {
|
||||
public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implements LocalLookup {
|
||||
private static final Set<DeclarationDescriptor> INTEGRAL_RANGES = KotlinBuiltIns.getInstance().getIntegralRanges();
|
||||
|
||||
private int myLastLineNumber = -1;
|
||||
@@ -96,7 +96,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
private final Stack<BlockStackElement> blockStackElements = new Stack<BlockStackElement>();
|
||||
|
||||
@Nullable
|
||||
private final MemberCodegen<?> parentCodegen;
|
||||
|
||||
/*
|
||||
@@ -160,7 +159,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
@NotNull Type returnType,
|
||||
@NotNull MethodContext context,
|
||||
@NotNull GenerationState state,
|
||||
@Nullable MemberCodegen<?> parentCodegen
|
||||
@NotNull MemberCodegen<?> parentCodegen
|
||||
) {
|
||||
this.myFrameMap = myMap;
|
||||
this.parentCodegen = parentCodegen;
|
||||
@@ -200,8 +199,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
return bindingContext;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@NotNull
|
||||
public MemberCodegen<?> getParentCodegen() {
|
||||
return parentCodegen;
|
||||
}
|
||||
|
||||
@@ -31,9 +31,6 @@ import org.jetbrains.jet.codegen.bridges.BridgesPackage;
|
||||
import org.jetbrains.jet.codegen.context.CodegenContext;
|
||||
import org.jetbrains.jet.codegen.context.MethodContext;
|
||||
import org.jetbrains.jet.codegen.context.PackageFacadeContext;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodParameterKind;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodParameterSignature;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
@@ -45,6 +42,9 @@ import org.jetbrains.jet.lang.resolve.calls.CallResolverUtil;
|
||||
import org.jetbrains.jet.lang.resolve.constants.ArrayValue;
|
||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||
import org.jetbrains.jet.lang.resolve.constants.JavaClassValue;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodParameterKind;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodParameterSignature;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
|
||||
@@ -74,7 +74,7 @@ import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.OBJECT_TYPE;
|
||||
import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.OLD_JET_VALUE_PARAMETER_ANNOTATION;
|
||||
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
||||
|
||||
public class FunctionCodegen extends ParentCodegenAwareImpl {
|
||||
public class FunctionCodegen extends ParentCodegenAware {
|
||||
private final CodegenContext owner;
|
||||
|
||||
private final ClassBuilder v;
|
||||
|
||||
@@ -17,13 +17,12 @@
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.codegen.context.MethodContext;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetDeclarationWithBody;
|
||||
import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
||||
|
||||
public abstract class FunctionGenerationStrategy {
|
||||
@@ -34,7 +33,7 @@ public abstract class FunctionGenerationStrategy {
|
||||
@NotNull MethodVisitor mv,
|
||||
@NotNull JvmMethodSignature signature,
|
||||
@NotNull MethodContext context,
|
||||
@Nullable MemberCodegen<?> parentCodegen
|
||||
@NotNull MemberCodegen<?> parentCodegen
|
||||
);
|
||||
|
||||
@NotNull
|
||||
@@ -82,7 +81,7 @@ public abstract class FunctionGenerationStrategy {
|
||||
@NotNull MethodVisitor mv,
|
||||
@NotNull JvmMethodSignature signature,
|
||||
@NotNull MethodContext context,
|
||||
@Nullable MemberCodegen<?> parentCodegen
|
||||
@NotNull MemberCodegen<?> parentCodegen
|
||||
) {
|
||||
ExpressionCodegen codegen = new ExpressionCodegen(mv, getFrameMap(state.getTypeMapper(), context),
|
||||
signature.getReturnType(), context, state, parentCodegen);
|
||||
|
||||
@@ -779,7 +779,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
@NotNull MethodVisitor mv,
|
||||
@NotNull JvmMethodSignature signature,
|
||||
@NotNull MethodContext context,
|
||||
@Nullable MemberCodegen<?> parentCodegen
|
||||
@NotNull MemberCodegen<?> parentCodegen
|
||||
) {
|
||||
Type componentType = signature.getReturnType();
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
@@ -805,7 +805,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
@NotNull MethodVisitor mv,
|
||||
@NotNull JvmMethodSignature signature,
|
||||
@NotNull MethodContext context,
|
||||
@Nullable MemberCodegen<?> parentCodegen
|
||||
@NotNull MemberCodegen<?> parentCodegen
|
||||
) {
|
||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ import static org.jetbrains.jet.lang.resolve.BindingContext.VARIABLE;
|
||||
import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.*;
|
||||
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
||||
|
||||
public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclarationContainer*/> extends ParentCodegenAwareImpl {
|
||||
public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclarationContainer*/> extends ParentCodegenAware {
|
||||
protected final T element;
|
||||
protected final FieldOwnerContext context;
|
||||
protected final ClassBuilder v;
|
||||
|
||||
@@ -163,7 +163,7 @@ public class PackageCodegen {
|
||||
@NotNull MethodVisitor mv,
|
||||
@NotNull JvmMethodSignature signature,
|
||||
@NotNull MethodContext context,
|
||||
@Nullable MemberCodegen<?> parentCodegen
|
||||
@NotNull MemberCodegen<?> parentCodegen
|
||||
) {
|
||||
throw new IllegalStateException("shouldn't be called");
|
||||
}
|
||||
|
||||
@@ -16,9 +16,27 @@
|
||||
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
|
||||
public class ParentCodegenAware {
|
||||
protected final GenerationState state;
|
||||
protected final JetTypeMapper typeMapper;
|
||||
protected final BindingContext bindingContext;
|
||||
private final MemberCodegen<?> parentCodegen;
|
||||
|
||||
public ParentCodegenAware(@NotNull GenerationState state, @Nullable MemberCodegen<?> parentCodegen) {
|
||||
this.state = state;
|
||||
this.typeMapper = state.getTypeMapper();
|
||||
this.bindingContext = state.getBindingContext();
|
||||
this.parentCodegen = parentCodegen;
|
||||
}
|
||||
|
||||
public interface ParentCodegenAware {
|
||||
@Nullable
|
||||
MemberCodegen<?> getParentCodegen();
|
||||
public MemberCodegen<?> getParentCodegen() {
|
||||
return parentCodegen;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.jet.codegen;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
|
||||
public class ParentCodegenAwareImpl implements ParentCodegenAware {
|
||||
protected final GenerationState state;
|
||||
protected final JetTypeMapper typeMapper;
|
||||
protected final BindingContext bindingContext;
|
||||
private final MemberCodegen<?> parentCodegen;
|
||||
|
||||
public ParentCodegenAwareImpl(@NotNull GenerationState state, @Nullable MemberCodegen<?> parentCodegen) {
|
||||
this.state = state;
|
||||
this.typeMapper = state.getTypeMapper();
|
||||
this.bindingContext = state.getBindingContext();
|
||||
this.parentCodegen = parentCodegen;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public MemberCodegen<?> getParentCodegen() {
|
||||
return parentCodegen;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user