Removed unnecessary final on local variables.

This commit is contained in:
Evgeny Gerashchenko
2013-03-13 14:11:44 +04:00
parent c24f1605f3
commit ec5331057a
284 changed files with 1135 additions and 1132 deletions
@@ -111,9 +111,9 @@ public class BytecodeCompilerTask extends Task {
@Override
public void execute() {
final BytecodeCompiler compiler = new BytecodeCompiler();
final String stdlibPath = (this.stdlib != null ? getPath(this.stdlib) : null);
final String[] classpath = (this.compileClasspath != null ? this.compileClasspath.list() : null);
BytecodeCompiler compiler = new BytecodeCompiler();
String stdlibPath = (this.stdlib != null ? getPath(this.stdlib) : null);
String[] classpath = (this.compileClasspath != null ? this.compileClasspath.list() : null);
if (this.src != null) {
@@ -57,7 +57,7 @@ public class CodegenTestsOnAndroidRunner {
if (resultOutput == null) return suite;
// Test name -> stackTrace
final Map<String, String> resultMap = parseOutputForFailedTests(resultOutput);
Map<String, String> resultMap = parseOutputForFailedTests(resultOutput);
final Statistics statistics;
// If map is empty => there are no failed tests
@@ -107,7 +107,7 @@ public class RunUtils {
final StringBuilder stdOut = new StringBuilder();
final StringBuilder stdErr = new StringBuilder();
final OSProcessHandler handler;
OSProcessHandler handler;
try {
handler = new OSProcessHandler(settings.commandLine.createProcess(), settings.commandLine.getCommandLineString(), Charsets.UTF_8);
if (settings.input != null) {
@@ -133,7 +133,7 @@ public class CodegenTestsOnAndroidGenerator extends UsefulTestCase {
String generatedTestName = generateTestName(file.getName());
String packageName = file.getPath().replaceAll("\\\\|-|\\.|/", "_");
text = changePackage(packageName, text);
final ClassFileFactory factory;
ClassFileFactory factory;
if (filesCompiledWithoutStdLib.contains(file.getName())) {
factory = getFactoryFromText(file.getAbsolutePath(), text, environmentWithMockJdk);
}
@@ -122,7 +122,7 @@ public class AsmUtil {
return Type.getType(internalName.substring(1));
}
public static Type unboxType(final Type type) {
public static Type unboxType(Type type) {
JvmPrimitiveType jvmPrimitiveType = JvmPrimitiveType.getByWrapperAsmType(type);
if (jvmPrimitiveType != null) {
return jvmPrimitiveType.getAsmType();
@@ -270,7 +270,7 @@ public class AsmUtil {
}
private static Type stringValueOfOrStringBuilderAppendType(Type type) {
final int sort = type.getSort();
int sort = type.getSort();
return sort == Type.OBJECT || sort == Type.ARRAY
? AsmTypeConstants.OBJECT_TYPE
: sort == Type.BYTE || sort == Type.SHORT ? Type.INT_TYPE : type;
@@ -293,20 +293,20 @@ public class AsmUtil {
}
public static void genClosureFields(CalculatedClosure closure, ClassBuilder v, JetTypeMapper typeMapper) {
final ClassifierDescriptor captureThis = closure.getCaptureThis();
final int access = NO_FLAG_PACKAGE_PRIVATE | ACC_SYNTHETIC | ACC_FINAL;
ClassifierDescriptor captureThis = closure.getCaptureThis();
int access = NO_FLAG_PACKAGE_PRIVATE | ACC_SYNTHETIC | ACC_FINAL;
if (captureThis != null) {
v.newField(null, access, CAPTURED_THIS_FIELD, typeMapper.mapType(captureThis).getDescriptor(), null,
null);
}
final ClassifierDescriptor captureReceiver = closure.getCaptureReceiver();
ClassifierDescriptor captureReceiver = closure.getCaptureReceiver();
if (captureReceiver != null) {
v.newField(null, access, CAPTURED_RECEIVER_FIELD, typeMapper.mapType(captureReceiver).getDescriptor(),
null, null);
}
final List<Pair<String, Type>> fields = closure.getRecordedFields();
List<Pair<String, Type>> fields = closure.getRecordedFields();
for (Pair<String, Type> field : fields) {
v.newField(null, access, field.first, field.second.getDescriptor(), null, null);
}
@@ -339,7 +339,7 @@ public class AsmUtil {
}
public static StackValue genToString(InstructionAdapter v, StackValue receiver) {
final Type type = stringValueOfOrStringBuilderAppendType(receiver.type);
Type type = stringValueOfOrStringBuilderAppendType(receiver.type);
receiver.put(type, v);
v.invokestatic("java/lang/String", "valueOf", "(" + type.getDescriptor() + ")Ljava/lang/String;");
return StackValue.onStack(JAVA_STRING_TYPE);
@@ -347,7 +347,7 @@ public class AsmUtil {
static void genHashCode(MethodVisitor mv, InstructionAdapter iv, Type type) {
if (type.getSort() == Type.ARRAY) {
final Type elementType = correctElementType(type);
Type elementType = correctElementType(type);
if (elementType.getSort() == Type.OBJECT || elementType.getSort() == Type.ARRAY) {
iv.invokestatic("java/util/Arrays", "hashCode", "([Ljava/lang/Object;)I");
}
@@ -71,8 +71,8 @@ public abstract class ClassBodyCodegen extends MemberCodegen {
}
private void generateClassBody() {
final FunctionCodegen functionCodegen = new FunctionCodegen(context, v, state);
final PropertyCodegen propertyCodegen = new PropertyCodegen(context, v, functionCodegen);
FunctionCodegen functionCodegen = new FunctionCodegen(context, v, state);
PropertyCodegen propertyCodegen = new PropertyCodegen(context, v, functionCodegen);
for (JetDeclaration declaration : myClass.getDeclarations()) {
generateDeclaration(propertyCodegen, declaration, functionCodegen);
@@ -114,7 +114,7 @@ public abstract class ClassBodyCodegen extends MemberCodegen {
private void generateStaticInitializer() {
if (staticInitializerChunks.size() > 0) {
final MethodVisitor mv = v.newMethod(null, ACC_PUBLIC | ACC_STATIC, "<clinit>", "()V", null, null);
MethodVisitor mv = v.newMethod(null, ACC_PUBLIC | ACC_STATIC, "<clinit>", "()V", null, null);
if (state.getClassBuilderMode() == ClassBuilderMode.FULL) {
mv.visitCode();
@@ -133,7 +133,7 @@ public abstract class ClassBodyCodegen extends MemberCodegen {
private void generateRemoveInIterator() {
// generates stub 'remove' function for subclasses of Iterator to be compatible with java.util.Iterator
if (DescriptorUtils.isIteratorWithoutRemoveImpl(descriptor)) {
final MethodVisitor mv = v.getVisitor().visitMethod(ACC_PUBLIC, "remove", "()V", null, null);
MethodVisitor mv = v.getVisitor().visitMethod(ACC_PUBLIC, "remove", "()V", null, null);
genMethodThrow(mv, "java/lang/UnsupportedOperationException", "Mutating method called on a Kotlin Iterator");
}
}
@@ -57,7 +57,7 @@ public final class ClassFileFactory extends GenerationStateAware {
private ClassBuilder newVisitor(String outputFilePath, Collection<? extends PsiFile> sourceFiles) {
state.getProgress().reportOutput(toIoFilesIgnoringNonPhysical(sourceFiles), new File(outputFilePath));
final ClassBuilder answer = builderFactory.newClassBuilder();
ClassBuilder answer = builderFactory.newClassBuilder();
generators.put(outputFilePath, answer);
return answer;
}
@@ -63,19 +63,19 @@ public class ClosureCodegen extends GenerationStateAware {
}
public ClosureCodegen gen(JetExpression fun, CodegenContext context, ExpressionCodegen expressionCodegen) {
final SimpleFunctionDescriptor descriptor = bindingContext.get(BindingContext.FUNCTION, fun);
SimpleFunctionDescriptor descriptor = bindingContext.get(BindingContext.FUNCTION, fun);
assert descriptor != null;
name = classNameForAnonymousClass(state.getBindingContext(), fun);
final ClassBuilder cv = state.getFactory().newVisitor(name.getInternalName() + ".class", fun.getContainingFile());
ClassBuilder cv = state.getFactory().newVisitor(name.getInternalName() + ".class", fun.getContainingFile());
final FunctionDescriptor funDescriptor = bindingContext.get(BindingContext.FUNCTION, fun);
FunctionDescriptor funDescriptor = bindingContext.get(BindingContext.FUNCTION, fun);
SignatureWriter signatureWriter = new SignatureWriter();
assert funDescriptor != null;
final List<ValueParameterDescriptor> parameters = funDescriptor.getValueParameters();
final JvmClassName funClass = getInternalClassName(funDescriptor);
List<ValueParameterDescriptor> parameters = funDescriptor.getValueParameters();
JvmClassName funClass = getInternalClassName(funDescriptor);
signatureWriter.visitClassType(funClass.getInternalName());
for (ValueParameterDescriptor parameter : parameters) {
appendType(signatureWriter, parameter.getType(), '=');
@@ -113,7 +113,7 @@ public class ClosureCodegen extends GenerationStateAware {
private void generateConstInstance(PsiElement fun, ClassBuilder cv) {
MethodVisitor mv = cv.newMethod(fun, ACC_PUBLIC | ACC_STATIC | ACC_SYNTHETIC, "<clinit>", "()V", null, new String[0]);
final InstructionAdapter iv = new InstructionAdapter(mv);
InstructionAdapter iv = new InstructionAdapter(mv);
cv.newField(fun, ACC_PUBLIC | ACC_STATIC | ACC_FINAL, JvmAbi.INSTANCE_FIELD, name.getDescriptor(), null, null);
@@ -136,7 +136,7 @@ public class ClosureCodegen extends GenerationStateAware {
ExpressionCodegen expressionCodegen
) {
final CodegenContext closureContext = context.intoClosure(funDescriptor, expressionCodegen);
CodegenContext closureContext = context.intoClosure(funDescriptor, expressionCodegen);
FunctionCodegen fc = new FunctionCodegen(closureContext, cv, state);
JvmMethodSignature jvmMethodSignature = typeMapper.invokeSignature(funDescriptor);
fc.generateMethod(body, jvmMethodSignature, false, null, funDescriptor);
@@ -149,14 +149,14 @@ public class ClosureCodegen extends GenerationStateAware {
JetExpression fun,
ClassBuilder cv
) {
final JvmMethodSignature bridge = erasedInvokeSignature(funDescriptor);
final Method delegate = typeMapper.invokeSignature(funDescriptor).getAsmMethod();
JvmMethodSignature bridge = erasedInvokeSignature(funDescriptor);
Method delegate = typeMapper.invokeSignature(funDescriptor).getAsmMethod();
if (bridge.getAsmMethod().getDescriptor().equals(delegate.getDescriptor())) {
return;
}
final MethodVisitor mv =
MethodVisitor mv =
cv.newMethod(fun, ACC_PUBLIC | ACC_BRIDGE | ACC_VOLATILE, "invoke", bridge.getAsmMethod().getDescriptor(), null,
new String[0]);
if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
@@ -169,14 +169,14 @@ public class ClosureCodegen extends GenerationStateAware {
iv.load(0, Type.getObjectType(className));
final ReceiverParameterDescriptor receiver = funDescriptor.getReceiverParameter();
ReceiverParameterDescriptor receiver = funDescriptor.getReceiverParameter();
int count = 1;
if (receiver != null) {
StackValue.local(count, OBJECT_TYPE).put(typeMapper.mapType(receiver.getType()), iv);
count++;
}
final List<ValueParameterDescriptor> params = funDescriptor.getValueParameters();
List<ValueParameterDescriptor> params = funDescriptor.getValueParameters();
for (ValueParameterDescriptor param : params) {
StackValue.local(count, OBJECT_TYPE).put(typeMapper.mapType(param.getType()), iv);
count++;
@@ -197,13 +197,13 @@ public class ClosureCodegen extends GenerationStateAware {
ClassBuilder cv,
CalculatedClosure closure
) {
final ArrayList<Pair<String, Type>> args = new ArrayList<Pair<String, Type>>();
ArrayList<Pair<String, Type>> args = new ArrayList<Pair<String, Type>>();
calculateConstructorParameters(args, state, closure);
final Type[] argTypes = nameAnTypeListToTypeArray(args);
Type[] argTypes = nameAnTypeListToTypeArray(args);
final Method constructor = new Method("<init>", Type.VOID_TYPE, argTypes);
final MethodVisitor mv = cv.newMethod(fun, ACC_PUBLIC, "<init>", constructor.getDescriptor(), null, new String[0]);
Method constructor = new Method("<init>", Type.VOID_TYPE, argTypes);
MethodVisitor mv = cv.newMethod(fun, ACC_PUBLIC, "<init>", constructor.getDescriptor(), null, new String[0]);
if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
genStubCode(mv);
}
@@ -217,8 +217,8 @@ public class ClosureCodegen extends GenerationStateAware {
int k = 1;
for (int i = 0; i != argTypes.length; ++i) {
StackValue.local(0, OBJECT_TYPE).put(OBJECT_TYPE, iv);
final Pair<String, Type> nameAndType = args.get(i);
final Type type = nameAndType.second;
Pair<String, Type> nameAndType = args.get(i);
Type type = nameAndType.second;
StackValue.local(k, type).put(type, iv);
k += type.getSize();
StackValue.field(type, name, nameAndType.first, false).store(type, iv);
@@ -236,27 +236,27 @@ public class ClosureCodegen extends GenerationStateAware {
GenerationState state,
CalculatedClosure closure
) {
final ClassDescriptor captureThis = closure.getCaptureThis();
ClassDescriptor captureThis = closure.getCaptureThis();
if (captureThis != null) {
final Type type = typeMapper.mapType(captureThis);
Type type = typeMapper.mapType(captureThis);
args.add(new Pair<String, Type>(CAPTURED_THIS_FIELD, type));
}
final ClassifierDescriptor captureReceiver = closure.getCaptureReceiver();
ClassifierDescriptor captureReceiver = closure.getCaptureReceiver();
if (captureReceiver != null) {
args.add(new Pair<String, Type>(CAPTURED_RECEIVER_FIELD, typeMapper.mapType(captureReceiver)));
}
for (DeclarationDescriptor descriptor : closure.getCaptureVariables().keySet()) {
if (descriptor instanceof VariableDescriptor && !(descriptor instanceof PropertyDescriptor)) {
final Type sharedVarType = typeMapper.getSharedVarType(descriptor);
Type sharedVarType = typeMapper.getSharedVarType(descriptor);
final Type type = sharedVarType != null
Type type = sharedVarType != null
? sharedVarType
: typeMapper.mapType((VariableDescriptor) descriptor);
args.add(new Pair<String, Type>("$" + descriptor.getName().getName(), type));
}
else if (isLocalNamedFun(state.getBindingContext(), descriptor)) {
final Type type =
Type type =
classNameForAnonymousClass(bindingContext,
(JetElement) BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor))
.getAsmType();
@@ -270,7 +270,7 @@ public class ClosureCodegen extends GenerationStateAware {
}
private static Type[] nameAnTypeListToTypeArray(List<Pair<String, Type>> args) {
final Type[] argTypes = new Type[args.size()];
Type[] argTypes = new Type[args.size()];
for (int i = 0; i != argTypes.length; ++i) {
argTypes[i] = args.get(i).second;
}
@@ -280,7 +280,7 @@ public class ClosureCodegen extends GenerationStateAware {
private void appendType(SignatureWriter signatureWriter, JetType type, char variance) {
signatureWriter.visitTypeArgument(variance);
final Type rawRetType = typeMapper.mapType(type, JetTypeMapperMode.TYPE_PARAMETER);
Type rawRetType = typeMapper.mapType(type, JetTypeMapperMode.TYPE_PARAMETER);
signatureWriter.visitClassType(rawRetType.getInternalName());
signatureWriter.visitEnd();
}
@@ -58,7 +58,7 @@ public class CodegenUtil {
public static boolean isInterface(DeclarationDescriptor descriptor) {
if (descriptor instanceof ClassDescriptor) {
final ClassKind kind = ((ClassDescriptor) descriptor).getKind();
ClassKind kind = ((ClassDescriptor) descriptor).getKind();
return kind == ClassKind.TRAIT || kind == ClassKind.ANNOTATION_CLASS;
}
return false;
@@ -123,7 +123,7 @@ public class CodegenUtil {
@NotNull
public static JvmClassName getInternalClassName(FunctionDescriptor descriptor) {
final int paramCount = descriptor.getValueParameters().size();
int paramCount = descriptor.getValueParameters().size();
if (descriptor.getReceiverParameter() != null) {
return JvmClassName.byInternalName("jet/ExtensionFunction" + paramCount);
}
@@ -181,7 +181,7 @@ public class CodegenUtil {
}
public static JetType getSuperClass(ClassDescriptor classDescriptor) {
final List<ClassDescriptor> superclassDescriptors = DescriptorUtils.getSuperclassDescriptors(classDescriptor);
List<ClassDescriptor> superclassDescriptors = DescriptorUtils.getSuperclassDescriptors(classDescriptor);
for (ClassDescriptor descriptor : superclassDescriptors) {
if (descriptor.getKind() != ClassKind.TRAIT) {
return descriptor.getDefaultType();
@@ -34,7 +34,7 @@ public class ConstructorFrameMap extends FrameMap {
public ConstructorFrameMap(CallableMethod callableMethod, @Nullable ConstructorDescriptor descriptor) {
enterTemp(OBJECT_TYPE); // this
final List<JvmMethodParameterSignature> parameterTypes = callableMethod.getSignature().getKotlinParameterTypes();
List<JvmMethodParameterSignature> parameterTypes = callableMethod.getSignature().getKotlinParameterTypes();
if (parameterTypes != null) {
for (JvmMethodParameterSignature parameterType : parameterTypes) {
if (parameterType.getKind() == JvmMethodParameterKind.OUTER) {
@@ -115,16 +115,16 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
className.getInternalName() + ".class",
literal.getContainingFile());
final ClassDescriptor classDescriptor = bindingContext.get(CLASS, objectDeclaration);
ClassDescriptor classDescriptor = bindingContext.get(CLASS, objectDeclaration);
assert classDescriptor != null;
//noinspection SuspiciousMethodCalls
final CalculatedClosure closure = bindingContext.get(CLOSURE, classDescriptor);
CalculatedClosure closure = bindingContext.get(CLOSURE, classDescriptor);
final CodegenContext contextForInners = context.intoClass(classDescriptor, OwnerKind.IMPLEMENTATION, state);
CodegenContext contextForInners = context.intoClass(classDescriptor, OwnerKind.IMPLEMENTATION, state);
final CodegenContext objectContext = context.intoAnonymousClass(classDescriptor, this);
final ImplementationBodyCodegen implementationBodyCodegen = new ImplementationBodyCodegen(objectDeclaration, objectContext, classBuilder, state);
CodegenContext objectContext = context.intoAnonymousClass(classDescriptor, this);
ImplementationBodyCodegen implementationBodyCodegen = new ImplementationBodyCodegen(objectDeclaration, objectContext, classBuilder, state);
implementationBodyCodegen.genInners(contextForInners, state, objectDeclaration);
@@ -200,7 +200,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
if (!isInterface(provided) && isInterface(required)) {
inner.put(OBJECT_TYPE, v);
final Type type = asmType(required.getDefaultType());
Type type = asmType(required.getDefaultType());
v.checkcast(type);
return StackValue.onStack(type);
}
@@ -283,7 +283,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
declaration.getContainingFile()
);
final CodegenContext objectContext = context.intoAnonymousClass(descriptor, this);
CodegenContext objectContext = context.intoAnonymousClass(descriptor, this);
new ImplementationBodyCodegen(declaration, objectContext, classBuilder, state).generate();
return StackValue.none();
@@ -406,7 +406,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
Label end = new Label();
blockStackElements.push(new LoopBlockStackElement(end, condition, targetLabel(expression)));
final StackValue conditionValue = gen(expression.getCondition());
StackValue conditionValue = gen(expression.getCondition());
conditionValue.condJump(end, true, v);
gen(expression.getBody(), Type.VOID_TYPE);
@@ -471,8 +471,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
}
final JetExpression loopRange = forExpression.getLoopRange();
final JetType loopRangeType = bindingContext.get(BindingContext.EXPRESSION_TYPE, loopRange);
JetExpression loopRange = forExpression.getLoopRange();
JetType loopRangeType = bindingContext.get(BindingContext.EXPRESSION_TYPE, loopRange);
assert loopRangeType != null;
Type asmLoopRangeType = asmType(loopRangeType);
if (asmLoopRangeType.getSort() == Type.ARRAY) {
@@ -1173,7 +1173,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@Override
public StackValue visitStringTemplateExpression(JetStringTemplateExpression expression, StackValue receiver) {
StringBuilder constantValue = new StringBuilder("");
final JetStringTemplateEntry[] entries = expression.getEntries();
JetStringTemplateEntry[] entries = expression.getEntries();
if (entries.length == 1 && entries[0] instanceof JetStringTemplateEntryWithExpression) {
return genToString(v, gen(entries[0].getExpression()));
@@ -1192,7 +1192,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
}
if (constantValue != null) {
final Type type = expressionType(expression);
Type type = expressionType(expression);
return StackValue.constant(constantValue.toString(), type);
}
else {
@@ -1251,16 +1251,16 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
private StackValue genClosure(JetExpression expression) {
final FunctionDescriptor descriptor = bindingContext.get(BindingContext.FUNCTION, expression);
final ClassDescriptor classDescriptor =
FunctionDescriptor descriptor = bindingContext.get(BindingContext.FUNCTION, expression);
ClassDescriptor classDescriptor =
bindingContext.get(CLASS_FOR_FUNCTION, descriptor);
//noinspection SuspiciousMethodCalls
final CalculatedClosure closure = bindingContext.get(CLOSURE, classDescriptor);
CalculatedClosure closure = bindingContext.get(CLOSURE, classDescriptor);
ClosureCodegen closureCodegen = new ClosureCodegen(state, (MutableClosure) closure).gen(expression, context, this);
final JvmClassName className = closureCodegen.name;
final Type asmType = className.getAsmType();
JvmClassName className = closureCodegen.name;
Type asmType = className.getAsmType();
if (isConst(closure)) {
v.getstatic(className.getInternalName(), JvmAbi.INSTANCE_FIELD, className.getDescriptor());
}
@@ -1268,7 +1268,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
v.anew(asmType);
v.dup();
final Method cons = closureCodegen.constructor;
Method cons = closureCodegen.constructor;
pushClosureOnStack(closure, false);
v.invokespecial(className.getInternalName(), "<init>", cons.getDescriptor());
}
@@ -1283,17 +1283,17 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
assert constructorDescriptor != null;
CallableMethod constructor = typeMapper.mapToCallableMethod(constructorDescriptor, closure);
final JvmClassName name = bindingContext.get(FQN, constructorDescriptor.getContainingDeclaration());
JvmClassName name = bindingContext.get(FQN, constructorDescriptor.getContainingDeclaration());
assert name != null;
Type type = name.getAsmType();
v.anew(type);
v.dup();
final Method cons = constructor.getSignature().getAsmMethod();
Method cons = constructor.getSignature().getAsmMethod();
pushClosureOnStack(closure, false);
final JetDelegatorToSuperCall superCall = closure.getSuperCall();
JetDelegatorToSuperCall superCall = closure.getSuperCall();
if (superCall != null) {
ConstructorDescriptor superConstructor = (ConstructorDescriptor) bindingContext.get(BindingContext.REFERENCE_TARGET,
superCall
@@ -1315,14 +1315,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
protected void pushClosureOnStack(CalculatedClosure closure, boolean ignoreThisAndReceiver) {
if (closure != null) {
if (!ignoreThisAndReceiver) {
final ClassDescriptor captureThis = closure.getCaptureThis();
ClassDescriptor captureThis = closure.getCaptureThis();
if (captureThis != null) {
generateThisOrOuter(captureThis, false).put(OBJECT_TYPE, v);
}
final ClassifierDescriptor captureReceiver = closure.getCaptureReceiver();
ClassifierDescriptor captureReceiver = closure.getCaptureReceiver();
if (captureReceiver != null) {
final Type asmType = typeMapper.mapType(captureReceiver.getDefaultType(), JetTypeMapperMode.IMPL);
Type asmType = typeMapper.mapType(captureReceiver.getDefaultType(), JetTypeMapperMode.IMPL);
v.load(context.isStatic() ? 0 : 1, asmType);
}
}
@@ -1340,7 +1340,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
private StackValue generateBlock(List<JetElement> statements, boolean lastStatementIsExpression) {
final Label blockEnd = new Label();
Label blockEnd = new Label();
List<Function<StackValue, Void>> leaveTasks = Lists.newArrayList();
@@ -1452,7 +1452,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
private void markLineNumber(@NotNull JetElement statement) {
final Document document = statement.getContainingFile().getViewProvider().getDocument();
Document document = statement.getContainingFile().getViewProvider().getDocument();
if (document != null) {
int lineNumber = document.getLineNumber(statement.getTextRange().getStartOffset()); // 0-based
if (lineNumber == myLastLineNumber) {
@@ -1485,7 +1485,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@Override
public StackValue visitReturnExpression(JetReturnExpression expression, StackValue receiver) {
final JetExpression returnedExpression = expression.getReturnedExpression();
JetExpression returnedExpression = expression.getReturnedExpression();
if (returnedExpression != null) {
gen(returnedExpression, returnType);
doFinallyOnReturn();
@@ -1512,7 +1512,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
private static boolean endsWithReturn(JetElement bodyExpression) {
if (bodyExpression instanceof JetBlockExpression) {
final List<JetElement> statements = ((JetBlockExpression) bodyExpression).getStatements();
List<JetElement> statements = ((JetBlockExpression) bodyExpression).getStatements();
return statements.size() > 0 && statements.get(statements.size() - 1) instanceof JetReturnExpression;
}
@@ -1548,12 +1548,12 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
intrinsic = state.getIntrinsics().getIntrinsic(memberDescriptor);
}
if (intrinsic != null) {
final Type expectedType = expressionType(expression);
Type expectedType = expressionType(expression);
return intrinsic.generate(this, v, expectedType, expression, Collections.<JetExpression>emptyList(), receiver, state);
}
assert descriptor != null;
final DeclarationDescriptor container = descriptor.getContainingDeclaration();
DeclarationDescriptor container = descriptor.getContainingDeclaration();
if (descriptor instanceof VariableDescriptor) {
VariableDescriptor variableDescriptor = (VariableDescriptor) descriptor;
@@ -1572,12 +1572,12 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
boolean isStatic = container instanceof NamespaceDescriptor;
final boolean directToField =
boolean directToField =
expression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER && contextKind() != OwnerKind.TRAIT_IMPL;
JetExpression r = getReceiverForSelector(expression);
final boolean isSuper = r instanceof JetSuperExpression;
boolean isSuper = r instanceof JetSuperExpression;
propertyDescriptor = accessablePropertyDescriptor(propertyDescriptor);
final StackValue.Property iValue =
StackValue.Property iValue =
intermediateValueForProperty(propertyDescriptor, directToField, isSuper ? (JetSuperExpression) r : null);
if (!directToField && resolvedCall != null && !isSuper) {
receiver.put(propertyDescriptor.getReceiverParameter() != null || isStatic
@@ -1656,8 +1656,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
assert scriptDescriptor != null;
JvmClassName scriptClassName = classNameForScriptDescriptor(bindingContext, scriptDescriptor);
ValueParameterDescriptor valueParameterDescriptor = (ValueParameterDescriptor) descriptor;
final ClassDescriptor scriptClass = bindingContext.get(CLASS_FOR_FUNCTION, scriptDescriptor);
final StackValue script = StackValue.thisOrOuter(this, scriptClass, false);
ClassDescriptor scriptClass = bindingContext.get(CLASS_FOR_FUNCTION, scriptDescriptor);
StackValue script = StackValue.thisOrOuter(this, scriptClass, false);
script.put(script.type, v);
Type fieldType = typeMapper.mapType(valueParameterDescriptor);
return StackValue.field(fieldType, scriptClassName, valueParameterDescriptor.getName().getIdentifier(), false);
@@ -1682,7 +1682,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
private StackValue stackValueForLocal(DeclarationDescriptor descriptor, int index) {
if (descriptor instanceof VariableDescriptor) {
Type sharedVarType = typeMapper.getSharedVarType(descriptor);
final JetType outType = ((VariableDescriptor) descriptor).getType();
JetType outType = ((VariableDescriptor) descriptor).getType();
if (sharedVarType != null) {
return StackValue.shared(index, asmType(outType));
}
@@ -1706,7 +1706,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
public StackValue.Property intermediateValueForProperty(
PropertyDescriptor propertyDescriptor,
final boolean forceField,
boolean forceField,
@Nullable JetSuperExpression superExpression
) {
boolean isSuper = superExpression != null;
@@ -1845,7 +1845,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
private static boolean isOverrideForTrait(CallableMemberDescriptor propertyDescriptor) {
if (propertyDescriptor.getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
final Set<? extends CallableMemberDescriptor> overriddenDescriptors = propertyDescriptor.getOverriddenDescriptors();
Set<? extends CallableMemberDescriptor> overriddenDescriptors = propertyDescriptor.getOverriddenDescriptors();
for (CallableMemberDescriptor descriptor : overriddenDescriptors) {
if (isInterface(descriptor.getContainingDeclaration())) {
return true;
@@ -1857,7 +1857,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@Override
public StackValue visitCallExpression(JetCallExpression expression, StackValue receiver) {
final JetExpression callee = expression.getCalleeExpression();
JetExpression callee = expression.getCalleeExpression();
assert callee != null;
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, callee);
@@ -1895,7 +1895,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
PropertySetterDescriptor setter = propertyDescriptor.getSetter();
PropertyGetterDescriptor getter = propertyDescriptor.getGetter();
final int flag = getVisibilityAccessFlag(propertyDescriptor) |
int flag = getVisibilityAccessFlag(propertyDescriptor) |
(getter == null ? 0 : getVisibilityAccessFlag(getter)) |
(setter == null ? 0 : getVisibilityAccessFlag(setter));
@@ -1907,7 +1907,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
private FunctionDescriptor accessableFunctionDescriptor(FunctionDescriptor fd) {
final int flag = getVisibilityAccessFlag(fd);
int flag = getVisibilityAccessFlag(fd);
if ((flag & ACC_PRIVATE) == 0) {
return fd;
}
@@ -1954,10 +1954,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
Callable callable = resolveToCallable(fd, superCall);
if (callable instanceof CallableMethod) {
final CallableMethod callableMethod = (CallableMethod) callable;
CallableMethod callableMethod = (CallableMethod) callable;
invokeMethodWithArguments(callableMethod, resolvedCall, call, receiver);
final Type callReturnType = callableMethod.getSignature().getAsmMethod().getReturnType();
Type callReturnType = callableMethod.getSignature().getAsmMethod().getReturnType();
return returnValueAsStackValue(fd, callReturnType);
}
else {
@@ -2012,7 +2012,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
if (callReturnType != Type.VOID_TYPE) {
JetType type = fd.getReturnType();
assert type != null;
final Type retType = typeMapper.mapReturnType(type);
Type retType = typeMapper.mapReturnType(type);
StackValue.coerce(callReturnType, retType, v);
return StackValue.onStack(retType);
}
@@ -2020,7 +2020,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
Callable resolveToCallable(@NotNull FunctionDescriptor fd, boolean superCall) {
final IntrinsicMethod intrinsic = state.getIntrinsics().getIntrinsic(fd);
IntrinsicMethod intrinsic = state.getIntrinsics().getIntrinsic(fd);
if (intrinsic != null) {
return intrinsic;
}
@@ -2083,7 +2083,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@NotNull Call call,
@NotNull StackValue receiver
) {
final Type calleeType = callableMethod.getGenerateCalleeType();
Type calleeType = callableMethod.getGenerateCalleeType();
if (calleeType != null) {
assert !callableMethod.isNeedsThis();
gen(call.getCalleeExpression(), calleeType);
@@ -2165,7 +2165,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@Nullable
private static JetExpression getReceiverForSelector(PsiElement expression) {
if (expression.getParent() instanceof JetDotQualifiedExpression && !isReceiver(expression)) {
final JetDotQualifiedExpression parent = (JetDotQualifiedExpression) expression.getParent();
JetDotQualifiedExpression parent = (JetDotQualifiedExpression) expression.getParent();
return parent.getReceiverExpression();
}
return null;
@@ -2222,7 +2222,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
throw new UnsupportedOperationException();
}
public StackValue generateThisOrOuter(@NotNull final ClassDescriptor calleeContainingClass, boolean isSuper) {
public StackValue generateThisOrOuter(@NotNull ClassDescriptor calleeContainingClass, boolean isSuper) {
boolean isSingleton = CodegenBinding.isSingleton(bindingContext, calleeContainingClass);
if (isSingleton) {
assert !isSuper;
@@ -2244,7 +2244,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
assert cur != null;
final ClassDescriptor thisDescriptor = cur.getThisDescriptor();
ClassDescriptor thisDescriptor = cur.getThisDescriptor();
if (!isSuper && thisDescriptor.equals(calleeContainingClass)
|| isSuper && DescriptorUtils.isSubclass(thisDescriptor, calleeContainingClass)) {
return castToRequiredTypeOfInterfaceIfNeeded(result, thisDescriptor, calleeContainingClass);
@@ -2263,9 +2263,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
private static boolean isReceiver(PsiElement expression) {
final PsiElement parent = expression.getParent();
PsiElement parent = expression.getParent();
if (parent instanceof JetQualifiedExpression) {
final JetExpression receiverExpression = ((JetQualifiedExpression) parent).getReceiverExpression();
JetExpression receiverExpression = ((JetQualifiedExpression) parent).getReceiverExpression();
return expression == receiverExpression;
}
return false;
@@ -2388,7 +2388,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
public int indexOfLocal(JetReferenceExpression lhs) {
final DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, lhs);
DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, lhs);
if (isVarCapturedInClosure(bindingContext, declarationDescriptor)) {
return -1;
}
@@ -2437,7 +2437,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@Override
public StackValue visitBinaryExpression(JetBinaryExpression expression, StackValue receiver) {
final IElementType opToken = expression.getOperationReference().getReferencedNameElementType();
IElementType opToken = expression.getOperationReference().getReferencedNameElementType();
if (opToken == JetTokens.EQ) {
return generateAssignmentExpression(expression);
}
@@ -2466,7 +2466,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
else {
DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference());
final Callable callable = resolveToCallable((FunctionDescriptor) op, false);
Callable callable = resolveToCallable((FunctionDescriptor) op, false);
if (callable instanceof IntrinsicMethod) {
IntrinsicMethod intrinsic = (IntrinsicMethod) callable;
return intrinsic.generate(this, v, expressionType(expression), expression,
@@ -2689,8 +2689,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
private StackValue generateAugmentedAssignment(JetBinaryExpression expression) {
DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference());
final Callable callable = resolveToCallable((FunctionDescriptor) op, false);
final JetExpression lhs = expression.getLeft();
Callable callable = resolveToCallable((FunctionDescriptor) op, false);
JetExpression lhs = expression.getLeft();
// if (lhs instanceof JetArrayAccessExpression) {
// JetArrayAccessExpression arrayAccessExpression = (JetArrayAccessExpression) lhs;
@@ -2706,7 +2706,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
StackValue value = gen(lhs); // receiver
value.dupReceiver(v); // receiver receiver
value.put(lhsType, v); // receiver lhs
final IntrinsicMethod intrinsic = (IntrinsicMethod) callable;
IntrinsicMethod intrinsic = (IntrinsicMethod) callable;
//noinspection NullableProblems
JetExpression right = expression.getRight();
assert right != null;
@@ -2722,14 +2722,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
else {
JetType type = ((FunctionDescriptor) op).getReturnType();
assert type != null;
final boolean keepReturnValue = !type.equals(KotlinBuiltIns.getInstance().getUnitType());
boolean keepReturnValue = !type.equals(KotlinBuiltIns.getInstance().getUnitType());
callAugAssignMethod(expression, (CallableMethod) callable, lhsType, keepReturnValue);
}
return StackValue.none();
}
private void callAugAssignMethod(JetBinaryExpression expression, CallableMethod callable, Type lhsType, final boolean keepReturnValue) {
private void callAugAssignMethod(JetBinaryExpression expression, CallableMethod callable, Type lhsType, boolean keepReturnValue) {
ResolvedCall<? extends CallableDescriptor> resolvedCall =
bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
assert resolvedCall != null;
@@ -2753,9 +2753,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
}
public void invokeAppend(final JetExpression expr) {
public void invokeAppend(JetExpression expr) {
if (expr instanceof JetBinaryExpression) {
final JetBinaryExpression binaryExpression = (JetBinaryExpression) expr;
JetBinaryExpression binaryExpression = (JetBinaryExpression) expr;
if (binaryExpression.getOperationToken() == JetTokens.PLUS) {
JetExpression left = binaryExpression.getLeft();
JetExpression right = binaryExpression.getRight();
@@ -2794,7 +2794,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference());
final Callable callable = resolveToCallable((FunctionDescriptor) op, false);
Callable callable = resolveToCallable((FunctionDescriptor) op, false);
if (callable instanceof IntrinsicMethod) {
IntrinsicMethod intrinsic = (IntrinsicMethod) callable;
//noinspection ConstantConditions
@@ -2859,14 +2859,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
DeclarationDescriptor op = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference());
if (op instanceof FunctionDescriptor) {
final Type asmType = expressionType(expression);
Type asmType = expressionType(expression);
DeclarationDescriptor cls = op.getContainingDeclaration();
if (op.getName().getName().equals("inc") || op.getName().getName().equals("dec")) {
if (isPrimitiveNumberClassDescriptor(cls)) {
receiver.put(receiver.type, v);
JetExpression operand = expression.getBaseExpression();
if (operand instanceof JetReferenceExpression) {
final int index = indexOfLocal((JetReferenceExpression) operand);
int index = indexOfLocal((JetReferenceExpression) operand);
if (index >= 0 && isIntPrimitive(asmType)) {
int increment = op.getName().getName().equals("inc") ? 1 : -1;
return StackValue.postIncrement(index, increment);
@@ -2881,7 +2881,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
bindingContext.get(BindingContext.RESOLVED_CALL, expression.getOperationReference());
assert resolvedCall != null;
final Callable callable = resolveToCallable((FunctionDescriptor) op, false);
Callable callable = resolveToCallable((FunctionDescriptor) op, false);
StackValue value = gen(expression.getBaseExpression());
value.dupReceiver(v);
@@ -2935,7 +2935,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
private void generateIncrement(DeclarationDescriptor op, Type asmType, JetExpression operand, StackValue receiver) {
int increment = op.getName().getName().equals("inc") ? 1 : -1;
if (operand instanceof JetReferenceExpression) {
final int index = indexOfLocal((JetReferenceExpression) operand);
int index = indexOfLocal((JetReferenceExpression) operand);
if (index >= 0 && isIntPrimitive(asmType)) {
v.iinc(index, increment);
return;
@@ -2973,11 +2973,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
JetType initializerType = bindingContext.get(EXPRESSION_TYPE, initializer);
assert initializerType != null;
final Type initializerAsmType = asmType(initializerType);
Type initializerAsmType = asmType(initializerType);
final TransientReceiver initializerAsReceiver = new TransientReceiver(initializerType);
final int tempVarIndex = myFrameMap.enterTemp(initializerAsmType);
int tempVarIndex = myFrameMap.enterTemp(initializerAsmType);
gen(initializer, initializerAsmType);
v.store(tempVarIndex, initializerAsmType);
@@ -3053,7 +3053,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
) {
DeclarationDescriptor constructorDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, constructorReference);
assert constructorDescriptor != null;
final PsiElement declaration = BindingContextUtils.descriptorToDeclaration(bindingContext, constructorDescriptor);
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(bindingContext, constructorDescriptor);
Type type;
if (declaration instanceof PsiMethod) {
type = generateJavaConstructorCall(expression);
@@ -3070,13 +3070,13 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
v.anew(type);
v.dup();
final ClassDescriptor classDescriptor = ((ConstructorDescriptor) constructorDescriptor).getContainingDeclaration();
ClassDescriptor classDescriptor = ((ConstructorDescriptor) constructorDescriptor).getContainingDeclaration();
CallableMethod method = typeMapper.mapToCallableMethod((ConstructorDescriptor) constructorDescriptor);
receiver.put(receiver.type, v);
final MutableClosure closure = bindingContext.get(CLOSURE, classDescriptor);
MutableClosure closure = bindingContext.get(CLOSURE, classDescriptor);
if(receiver.type.getSort() != Type.VOID && (closure == null || closure.getCaptureThis() == null)) {
v.pop();
@@ -3105,7 +3105,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
Type type = asmType(javaClass.getDefaultType());
v.anew(type);
v.dup();
final CallableMethod callableMethod = typeMapper.mapToCallableMethod(
CallableMethod callableMethod = typeMapper.mapToCallableMethod(
descriptor,
false,
isCallInsideSameClassAsDeclared(descriptor, context),
@@ -3184,10 +3184,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@Override
public StackValue visitArrayAccessExpression(JetArrayAccessExpression expression, StackValue receiver) {
final JetExpression array = expression.getArrayExpression();
JetExpression array = expression.getArrayExpression();
JetType type = bindingContext.get(BindingContext.EXPRESSION_TYPE, array);
final Type arrayType = asmTypeOrVoid(type);
final List<JetExpression> indices = expression.getIndexExpressions();
Type arrayType = asmTypeOrVoid(type);
List<JetExpression> indices = expression.getIndexExpressions();
FunctionDescriptor operationDescriptor = (FunctionDescriptor) bindingContext.get(BindingContext.REFERENCE_TARGET, expression);
assert operationDescriptor != null;
if (arrayType.getSort() == Type.ARRAY &&
@@ -3274,7 +3274,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
@Override
public StackValue visitThisExpression(JetThisExpression expression, StackValue receiver) {
final DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getInstanceReference());
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getInstanceReference());
if (descriptor instanceof ClassDescriptor) {
return StackValue.thisOrOuter(this, (ClassDescriptor) descriptor, false);
}
@@ -3399,7 +3399,7 @@ The "returned" value of try expression with no finally is either the last expres
}
@Override
public StackValue visitBinaryWithTypeRHSExpression(final JetBinaryExpressionWithTypeRHS expression, StackValue receiver) {
public StackValue visitBinaryWithTypeRHSExpression(JetBinaryExpressionWithTypeRHS expression, StackValue receiver) {
JetSimpleNameExpression operationSign = expression.getOperationSign();
IElementType opToken = operationSign.getReferencedNameElementType();
if (opToken == JetTokens.COLON) {
@@ -3449,8 +3449,8 @@ The "returned" value of try expression with no finally is either the last expres
}
@Override
public StackValue visitIsExpression(final JetIsExpression expression, StackValue receiver) {
final StackValue match = StackValue.expression(OBJECT_TYPE, expression.getLeftHandSide(), this);
public StackValue visitIsExpression(JetIsExpression expression, StackValue receiver) {
StackValue match = StackValue.expression(OBJECT_TYPE, expression.getLeftHandSide(), this);
return generateIsCheck(match, expression.getTypeRef(), expression.isNegated());
}
@@ -3520,9 +3520,9 @@ The "returned" value of try expression with no finally is either the last expres
public StackValue generateWhenExpression(JetWhenExpression expression, boolean isStatement) {
JetExpression expr = expression.getSubjectExpression();
JetType subjectJetType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expr);
final Type subjectType = asmTypeOrVoid(subjectJetType);
final Type resultType = isStatement ? Type.VOID_TYPE : expressionType(expression);
final int subjectLocal = expr != null ? myFrameMap.enterTemp(subjectType) : -1;
Type subjectType = asmTypeOrVoid(subjectJetType);
Type resultType = isStatement ? Type.VOID_TYPE : expressionType(expression);
int subjectLocal = expr != null ? myFrameMap.enterTemp(subjectType) : -1;
if (subjectLocal != -1) {
gen(expr, subjectType);
tempVariables.put(expr, StackValue.local(subjectLocal, subjectType));
@@ -3547,7 +3547,7 @@ The "returned" value of try expression with no finally is either the last expres
FrameMap.Mark mark = myFrameMap.mark();
Label thisEntry = new Label();
if (!whenEntry.isElse()) {
final JetWhenCondition[] conditions = whenEntry.getConditions();
JetWhenCondition[] conditions = whenEntry.getConditions();
for (int i = 0; i < conditions.length; i++) {
StackValue conditionValue = generateWhenCondition(subjectType, subjectLocal, conditions[i]);
conditionValue.condJump(nextCondition, true, v);
@@ -3631,18 +3631,18 @@ The "returned" value of try expression with no finally is either the last expres
if (binaryExpression.getOperationReference().getReferencedNameElementType() == JetTokens.RANGE) {
JetType jetType = bindingContext.get(BindingContext.EXPRESSION_TYPE, rangeExpression);
assert jetType != null;
final DeclarationDescriptor descriptor = jetType.getConstructor().getDeclarationDescriptor();
DeclarationDescriptor descriptor = jetType.getConstructor().getDeclarationDescriptor();
return INTEGRAL_RANGES.contains(descriptor);
}
}
return false;
}
private void throwNewException(@NotNull final String className) {
private void throwNewException(@NotNull String className) {
throwNewException(className, null);
}
private void throwNewException(@NotNull final String className, @Nullable final String message) {
private void throwNewException(@NotNull String className, @Nullable String message) {
v.anew(Type.getObjectType(className));
v.dup();
if (message != null) {
@@ -69,7 +69,7 @@ public class FunctionCodegen extends GenerationStateAware {
}
public void gen(JetNamedFunction f) {
final SimpleFunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, f);
SimpleFunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, f);
assert functionDescriptor != null;
JvmMethodSignature method =
typeMapper.mapToCallableMethod(
@@ -383,7 +383,7 @@ public class FunctionCodegen extends GenerationStateAware {
throw new IllegalStateException();
}
final List<JvmMethodParameterSignature> kotlinParameterTypes = jvmSignature.getKotlinParameterTypes();
List<JvmMethodParameterSignature> kotlinParameterTypes = jvmSignature.getKotlinParameterTypes();
assert kotlinParameterTypes != null;
if (receiverParameter != null) {
@@ -572,7 +572,7 @@ public class FunctionCodegen extends GenerationStateAware {
if (!isStatic && !isConstructor) {
descriptor = descriptor.replace("(", "(" + ownerInternalName.getDescriptor());
}
final MethodVisitor mv = v.newMethod(null, flags | (isConstructor ? 0 : ACC_STATIC),
MethodVisitor mv = v.newMethod(null, flags | (isConstructor ? 0 : ACC_STATIC),
isConstructor ? "<init>" : jvmSignature.getName() + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX,
descriptor, null, null);
InstructionAdapter iv = new InstructionAdapter(mv);
@@ -628,8 +628,8 @@ public class FunctionCodegen extends GenerationStateAware {
receiverType = state.getTypeMapper().mapType(receiverParameter.getType());
}
final int extraInLocalVariablesTable = getSizeOfExplicitArgumentsInLocalVariablesTable(aStatic, hasOuter, isEnumConstructor, receiverType);
final int countOfExtraVarsInMethodArgs = getCountOfExplicitArgumentsInMethodArguments(hasOuter, hasReceiver, isEnumConstructor);
int extraInLocalVariablesTable = getSizeOfExplicitArgumentsInLocalVariablesTable(aStatic, hasOuter, isEnumConstructor, receiverType);
int countOfExtraVarsInMethodArgs = getCountOfExplicitArgumentsInMethodArguments(hasOuter, hasReceiver, isEnumConstructor);
Type[] argTypes = jvmSignature.getArgumentTypes();
List<ValueParameterDescriptor> paramDescrs = functionDescriptor.getValueParameters();
@@ -641,7 +641,7 @@ public class FunctionCodegen extends GenerationStateAware {
paramSizeInLocalVariablesTable += size;
}
final int maskIndex = extraInLocalVariablesTable + paramSizeInLocalVariablesTable;
int maskIndex = extraInLocalVariablesTable + paramSizeInLocalVariablesTable;
loadExplicitArgumentsOnStack(iv, OBJECT_TYPE, receiverType, ownerInternalName.getAsmType(), aStatic, hasOuter, isEnumConstructor);
@@ -674,9 +674,9 @@ public class FunctionCodegen extends GenerationStateAware {
indexInLocalVariablesTable += t.getSize();
}
final String internalName = ownerInternalName.getInternalName();
final String jvmSignatureName = jvmSignature.getName();
final String jvmSignatureDescriptor = jvmSignature.getDescriptor();
String internalName = ownerInternalName.getInternalName();
String jvmSignatureName = jvmSignature.getName();
String jvmSignatureDescriptor = jvmSignature.getDescriptor();
if (!aStatic) {
if (kind == OwnerKind.TRAIT_IMPL) {
iv.invokeinterface(internalName, jvmSignatureName, jvmSignatureDescriptor);
@@ -806,7 +806,7 @@ public class FunctionCodegen extends GenerationStateAware {
) {
int flags = ACC_PUBLIC | ACC_BRIDGE | ACC_SYNTHETIC; // TODO.
final MethodVisitor mv = v.newMethod(null, flags, jvmSignature.getName(), overridden.getDescriptor(), null, null);
MethodVisitor mv = v.newMethod(null, flags, jvmSignature.getName(), overridden.getDescriptor(), null, null);
if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
genStubCode(mv);
}
@@ -854,7 +854,7 @@ public class FunctionCodegen extends GenerationStateAware {
int flags = ACC_PUBLIC | ACC_SYNTHETIC; // TODO.
final MethodVisitor mv = v.newMethod(null, flags, delegateMethod.getName(), delegateMethod.getDescriptor(), null, null);
MethodVisitor mv = v.newMethod(null, flags, delegateMethod.getName(), delegateMethod.getDescriptor(), null, null);
if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
genStubCode(mv);
}
@@ -505,8 +505,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
private void generateDataClassEqualsMethod(List<PropertyDescriptor> properties) {
final MethodVisitor mv = v.getVisitor().visitMethod(ACC_PUBLIC, "equals", "(Ljava/lang/Object;)Z", null, null);
final InstructionAdapter iv = new InstructionAdapter(mv);
MethodVisitor mv = v.getVisitor().visitMethod(ACC_PUBLIC, "equals", "(Ljava/lang/Object;)Z", null, null);
InstructionAdapter iv = new InstructionAdapter(mv);
mv.visitCode();
Label eq = new Label();
@@ -531,7 +531,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
genPropertyOnStack(iv, propertyDescriptor, 2);
if (asmType.getSort() == Type.ARRAY) {
final Type elementType = correctElementType(asmType);
Type elementType = correctElementType(asmType);
if (elementType.getSort() == Type.OBJECT || elementType.getSort() == Type.ARRAY) {
iv.invokestatic("java/util/Arrays", "equals", "([Ljava/lang/Object;[Ljava/lang/Object;)Z");
}
@@ -559,8 +559,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
private void generateDataClassHashCodeMethod(List<PropertyDescriptor> properties) {
final MethodVisitor mv = v.getVisitor().visitMethod(ACC_PUBLIC, "hashCode", "()I", null, null);
final InstructionAdapter iv = new InstructionAdapter(mv);
MethodVisitor mv = v.getVisitor().visitMethod(ACC_PUBLIC, "hashCode", "()I", null, null);
InstructionAdapter iv = new InstructionAdapter(mv);
mv.visitCode();
boolean first = true;
@@ -605,8 +605,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
private void generateDataClassToStringMethod(List<PropertyDescriptor> properties) {
final MethodVisitor mv = v.getVisitor().visitMethod(ACC_PUBLIC, "toString", "()Ljava/lang/String;", null, null);
final InstructionAdapter iv = new InstructionAdapter(mv);
MethodVisitor mv = v.getVisitor().visitMethod(ACC_PUBLIC, "toString", "()Ljava/lang/String;", null, null);
InstructionAdapter iv = new InstructionAdapter(mv);
mv.visitCode();
genStringBuilderConstructor(iv);
@@ -625,7 +625,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
Type type = genPropertyOnStack(iv, propertyDescriptor, 0);
if (type.getSort() == Type.ARRAY) {
final Type elementType = correctElementType(type);
Type elementType = correctElementType(type);
if (elementType.getSort() == Type.OBJECT || elementType.getSort() == Type.ARRAY) {
iv.invokestatic("java/util/Arrays", "toString", "([Ljava/lang/Object;)Ljava/lang/String;");
type = JAVA_STRING_TYPE;
@@ -651,7 +651,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private Type genPropertyOnStack(InstructionAdapter iv, PropertyDescriptor propertyDescriptor, int index) {
iv.load(index, classAsmType);
final Method
Method
method = typeMapper.mapGetterSignature(propertyDescriptor, OwnerKind.IMPLEMENTATION).getJvmMethodSignature().getAsmMethod();
iv.invokevirtual(classAsmType.getInternalName(), method.getName(), method.getDescriptor());
@@ -676,7 +676,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
assert returnType != null : "Return type of component function should not be null: " + function;
Type componentType = typeMapper.mapReturnType(returnType);
final String desc = "()" + componentType.getDescriptor();
String desc = "()" + componentType.getDescriptor();
MethodVisitor mv = v.newMethod(myClass,
AsmUtil.getMethodAsmFlags(function, OwnerKind.IMPLEMENTATION),
function.getName().getName(),
@@ -701,7 +701,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
assert returnType != null : "Return type of copy function should not be null: " + function;
JvmMethodSignature methodSignature = typeMapper.mapSignature(function.getName(), function);
final String methodDesc = methodSignature.getAsmMethod().getDescriptor();
String methodDesc = methodSignature.getAsmMethod().getDescriptor();
MethodVisitor mv = v.newMethod(myClass, AsmUtil.getMethodAsmFlags(function, OwnerKind.IMPLEMENTATION),
function.getName().getName(), methodDesc,
@@ -729,7 +729,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
MutableClosure closure = context.closure;
if (closure != null && closure.getCaptureThis() != null) {
final Type type = typeMapper.mapType(enclosingClassDescriptor(bindingContext, descriptor));
Type type = typeMapper.mapType(enclosingClassDescriptor(bindingContext, descriptor));
iv.load(0, classAsmType);
iv.getfield(JvmClassName.byType(classAsmType).getInternalName(), CAPTURED_THIS_FIELD, type.getDescriptor());
}
@@ -754,7 +754,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
FunctionCodegen.endVisit(mv, function.getName().getName(), myClass);
final MethodContext functionContext = context.intoFunction(function);
MethodContext functionContext = context.intoFunction(function);
FunctionCodegen.generateDefaultIfNeeded(functionContext, state, v, methodSignature.getAsmMethod(), function, OwnerKind.IMPLEMENTATION,
new DefaultParameterValueLoader() {
@Override
@@ -820,7 +820,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
FunctionDescriptor original = (FunctionDescriptor) entry.getKey();
Method method = typeMapper.mapSignature(bridge.getName(), bridge).getAsmMethod();
final boolean isConstructor = original instanceof ConstructorDescriptor;
boolean isConstructor = original instanceof ConstructorDescriptor;
Method originalMethod = isConstructor ?
typeMapper.mapToCallableMethod((ConstructorDescriptor) original).getSignature().getAsmMethod() :
typeMapper.mapSignature(original.getName(), original).getAsmMethod();
@@ -977,7 +977,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
ConstructorDescriptor constructorDescriptor = bindingContext.get(BindingContext.CONSTRUCTOR, myClass);
final ConstructorContext constructorContext = context.intoConstructor(constructorDescriptor);
ConstructorContext constructorContext = context.intoConstructor(constructorDescriptor);
if (state.getClassBuilderMode() == ClassBuilderMode.FULL) {
lookupConstructorExpressionsInClosureIfPresent(constructorContext);
@@ -986,12 +986,12 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
MutableClosure closure = context.closure;
boolean hasCapturedThis = closure != null && closure.getCaptureThis() != null;
final CallableMethod callableMethod = typeMapper.mapToCallableMethod(constructorDescriptor, context.closure);
final JvmMethodSignature constructorMethod = callableMethod.getSignature();
CallableMethod callableMethod = typeMapper.mapToCallableMethod(constructorDescriptor, context.closure);
JvmMethodSignature constructorMethod = callableMethod.getSignature();
assert constructorDescriptor != null;
int flags = getConstructorAsmFlags(constructorDescriptor);
final MethodVisitor mv = v.newMethod(myClass, flags, constructorMethod.getName(), constructorMethod.getAsmMethod().getDescriptor(),
MethodVisitor mv = v.newMethod(myClass, flags, constructorMethod.getName(), constructorMethod.getAsmMethod().getDescriptor(),
constructorMethod.getGenericsSignature(), null);
if (state.getClassBuilderMode() != ClassBuilderMode.SIGNATURES) {
@@ -1037,7 +1037,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
ConstructorFrameMap frameMap = new ConstructorFrameMap(callableMethod, constructorDescriptor);
final InstructionAdapter iv = new InstructionAdapter(mv);
InstructionAdapter iv = new InstructionAdapter(mv);
ExpressionCodegen codegen = new ExpressionCodegen(mv, frameMap, Type.VOID_TYPE, constructorContext, state);
JvmClassName classname = JvmClassName.byType(classAsmType);
@@ -1053,7 +1053,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
if (hasCapturedThis) {
final Type type = typeMapper
Type type = typeMapper
.mapType(enclosingClassDescriptor(bindingContext, descriptor));
String interfaceDesc = type.getDescriptor();
iv.load(0, classAsmType);
@@ -1063,11 +1063,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
if (closure != null) {
int k = hasCapturedThis ? 2 : 1;
final String internalName = typeMapper.mapType(descriptor).getInternalName();
final ClassifierDescriptor captureReceiver = closure.getCaptureReceiver();
String internalName = typeMapper.mapType(descriptor).getInternalName();
ClassifierDescriptor captureReceiver = closure.getCaptureReceiver();
if (captureReceiver != null) {
iv.load(0, OBJECT_TYPE);
final Type asmType = typeMapper.mapType(captureReceiver.getDefaultType(), JetTypeMapperMode.IMPL);
Type asmType = typeMapper.mapType(captureReceiver.getDefaultType(), JetTypeMapperMode.IMPL);
iv.load(k, asmType);
iv.putfield(internalName, CAPTURED_RECEIVER_FIELD, asmType.getDescriptor());
k += asmType.getSize();
@@ -1190,14 +1190,14 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
int n,
JetDelegationSpecifier specifier
) {
final JetExpression expression = ((JetDelegatorByExpressionSpecifier) specifier).getDelegateExpression();
JetExpression expression = ((JetDelegatorByExpressionSpecifier) specifier).getDelegateExpression();
PropertyDescriptor propertyDescriptor = null;
if (expression instanceof JetSimpleNameExpression) {
final ResolvedCall<? extends CallableDescriptor> call = bindingContext.get(BindingContext.RESOLVED_CALL, expression);
ResolvedCall<? extends CallableDescriptor> call = bindingContext.get(BindingContext.RESOLVED_CALL, expression);
if (call != null) {
final CallableDescriptor callResultingDescriptor = call.getResultingDescriptor();
CallableDescriptor callResultingDescriptor = call.getResultingDescriptor();
if (callResultingDescriptor instanceof ValueParameterDescriptor) {
final ValueParameterDescriptor valueParameterDescriptor = (ValueParameterDescriptor) callResultingDescriptor;
ValueParameterDescriptor valueParameterDescriptor = (ValueParameterDescriptor) callResultingDescriptor;
// constructor parameter
if (valueParameterDescriptor.getContainingDeclaration() instanceof ConstructorDescriptor) {
// constructor of my class
@@ -1217,7 +1217,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
assert superClassDescriptor != null;
final Type superTypeAsmType = typeMapper.mapType(superType, JetTypeMapperMode.IMPL);
Type superTypeAsmType = typeMapper.mapType(superType, JetTypeMapperMode.IMPL);
StackValue field;
if (propertyDescriptor != null &&
@@ -1245,7 +1245,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
private void lookupConstructorExpressionsInClosureIfPresent(final ConstructorContext constructorContext) {
final JetVisitorVoid visitor = new JetVisitorVoid() {
JetVisitorVoid visitor = new JetVisitorVoid() {
@Override
public void visitJetElement(JetElement e) {
e.acceptChildren(this);
@@ -1253,7 +1253,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
@Override
public void visitSimpleNameExpression(JetSimpleNameExpression expr) {
final DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, expr);
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, expr);
if (descriptor instanceof VariableDescriptor && !(descriptor instanceof PropertyDescriptor)) {
ConstructorDescriptor constructorDescriptor = (ConstructorDescriptor) constructorContext.getContextDescriptor();
for (ValueParameterDescriptor parameterDescriptor : constructorDescriptor.getValueParameters()) {
@@ -1268,7 +1268,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
@Override
public void visitThisExpression(JetThisExpression expression) {
final DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getInstanceReference());
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getInstanceReference());
if (descriptor instanceof ClassDescriptor) {
// @todo for now all our classes are inner so no need to lookup this. change it when we have real inners
}
@@ -1283,14 +1283,14 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
for (JetDeclaration declaration : myClass.getDeclarations()) {
if (declaration instanceof JetProperty) {
final JetProperty property = (JetProperty) declaration;
final JetExpression initializer = property.getInitializer();
JetProperty property = (JetProperty) declaration;
JetExpression initializer = property.getInitializer();
if (initializer != null) {
initializer.accept(visitor);
}
}
else if (declaration instanceof JetClassInitializer) {
final JetClassInitializer initializer = (JetClassInitializer) declaration;
JetClassInitializer initializer = (JetClassInitializer) declaration;
initializer.accept(visitor);
}
}
@@ -1305,7 +1305,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
else {
if (superCall instanceof JetDelegatorToSuperCall) {
final JetValueArgumentList argumentList = ((JetDelegatorToSuperCall) superCall).getValueArgumentList();
JetValueArgumentList argumentList = ((JetDelegatorToSuperCall) superCall).getValueArgumentList();
if (argumentList != null) {
argumentList.accept(visitor);
}
@@ -1384,7 +1384,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
functionOriginal = typeMapper.mapSignature(fun.getName(), fun.getOriginal()).getAsmMethod();
}
final MethodVisitor mv = v.newMethod(myClass, flags, function.getName(), function.getDescriptor(), null, null);
MethodVisitor mv = v.newMethod(myClass, flags, function.getName(), function.getDescriptor(), null, null);
AnnotationCodegen.forMethod(mv, state.getTypeMapper()).genAnnotations(fun);
JvmMethodSignature jvmSignature = typeMapper.mapToCallableMethod(
@@ -1471,13 +1471,13 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
CallableMethod method = typeMapper.mapToCallableMethod(constructorDescriptor, context.closure);
final ResolvedCall<? extends CallableDescriptor> resolvedCall =
ResolvedCall<? extends CallableDescriptor> resolvedCall =
bindingContext.get(BindingContext.RESOLVED_CALL, ((JetCallElement) superCall).getCalleeExpression());
assert resolvedCall != null;
final ConstructorDescriptor superConstructor = (ConstructorDescriptor) resolvedCall.getResultingDescriptor();
ConstructorDescriptor superConstructor = (ConstructorDescriptor) resolvedCall.getResultingDescriptor();
//noinspection SuspiciousMethodCalls
final CalculatedClosure closureForSuper = bindingContext.get(CLOSURE, superConstructor.getContainingDeclaration());
CalculatedClosure closureForSuper = bindingContext.get(CLOSURE, superConstructor.getContainingDeclaration());
CallableMethod superCallable = typeMapper.mapToCallableMethod(superConstructor, closureForSuper);
if (closureForSuper != null && closureForSuper.getCaptureThis() != null) {
@@ -1500,7 +1500,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
private static int findFirstSuperArgument(CallableMethod method) {
final List<JvmMethodParameterSignature> types = method.getSignature().getKotlinParameterTypes();
List<JvmMethodParameterSignature> types = method.getSignature().getKotlinParameterTypes();
if (types != null) {
int i = 0;
for (JvmMethodParameterSignature type : types) {
@@ -1520,7 +1520,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
else if (declaration instanceof JetEnumEntry) {
String name = declaration.getName();
final String desc = "L" + classAsmType.getInternalName() + ";";
String desc = "L" + classAsmType.getInternalName() + ";";
v.newField(declaration, ACC_PUBLIC | ACC_ENUM | ACC_STATIC | ACC_FINAL, name, desc, null, null);
if (myEnumConstants.isEmpty()) {
staticInitializerChunks.add(new CodeChunk() {
@@ -1564,7 +1564,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
assert classDescriptor != null;
String implClass = typeMapper.mapType(classDescriptor.getDefaultType(), JetTypeMapperMode.IMPL).getInternalName();
final List<JetDelegationSpecifier> delegationSpecifiers = enumConstant.getDelegationSpecifiers();
List<JetDelegationSpecifier> delegationSpecifiers = enumConstant.getDelegationSpecifiers();
if (delegationSpecifiers.size() > 1) {
throw new UnsupportedOperationException("multiple delegation specifiers for enum constant not supported");
}
@@ -1576,9 +1576,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
iv.iconst(ordinal);
if (delegationSpecifiers.size() == 1 && !enumEntryNeedSubclass(state.getBindingContext(), enumConstant)) {
final JetDelegationSpecifier specifier = delegationSpecifiers.get(0);
JetDelegationSpecifier specifier = delegationSpecifiers.get(0);
if (specifier instanceof JetDelegatorToSuperCall) {
final JetDelegatorToSuperCall superCall = (JetDelegatorToSuperCall) specifier;
JetDelegatorToSuperCall superCall = (JetDelegatorToSuperCall) specifier;
ConstructorDescriptor constructorDescriptor = (ConstructorDescriptor) bindingContext
.get(BindingContext.REFERENCE_TARGET, superCall.getCalleeExpression().getConstructorReferenceExpression());
assert constructorDescriptor != null;
@@ -1607,13 +1607,13 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
JetTypeMapper typeMapper = state.getTypeMapper();
for (JetDeclaration declaration : declarations) {
if (declaration instanceof JetProperty) {
final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) bindingContext.get(BindingContext.VARIABLE, declaration);
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) bindingContext.get(BindingContext.VARIABLE, declaration);
assert propertyDescriptor != null;
if (Boolean.TRUE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor))) {
final JetExpression initializer = ((JetProperty) declaration).getInitializer();
JetExpression initializer = ((JetProperty) declaration).getInitializer();
if (initializer != null) {
CompileTimeConstant<?> compileTimeValue = bindingContext.get(BindingContext.COMPILE_TIME_VALUE, initializer);
final JetType jetType = propertyDescriptor.getType();
JetType jetType = propertyDescriptor.getType();
if (compileTimeValue != null) {
Object value = compileTimeValue.getValue();
Type type = typeMapper.mapType(jetType);
@@ -1677,8 +1677,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
protected void generateDelegates(ClassDescriptor toClass, StackValue field) {
final FunctionCodegen functionCodegen = new FunctionCodegen(context, v, state);
final PropertyCodegen propertyCodegen = new PropertyCodegen(context, v, functionCodegen);
FunctionCodegen functionCodegen = new FunctionCodegen(context, v, state);
PropertyCodegen propertyCodegen = new PropertyCodegen(context, v, functionCodegen);
for (DeclarationDescriptor declaration : descriptor.getDefaultType().getMemberScope().getAllDescriptors()) {
if (declaration instanceof CallableMemberDescriptor) {
@@ -122,7 +122,7 @@ public class MemberCodegen extends GenerationStateAware {
ClassBuilder classBuilder = state.getFactory().forClassImplementation(descriptor, aClass.getContainingFile());
final CodegenContext contextForInners = context.intoClass(descriptor, OwnerKind.IMPLEMENTATION, state);
CodegenContext contextForInners = context.intoClass(descriptor, OwnerKind.IMPLEMENTATION, state);
if (state.getClassBuilderMode() == ClassBuilderMode.SIGNATURES) {
// Outer class implementation must happen prior inner classes so we get proper scoping tree in JetLightClass's delegate
@@ -148,12 +148,12 @@ public class NamespaceCodegen extends MemberCodegen {
for (JetDeclaration declaration : file.getDeclarations()) {
if (declaration instanceof JetNamedFunction || declaration instanceof JetProperty) {
{
final CodegenContext context =
CodegenContext context =
CodegenContext.STATIC.intoNamespace(descriptor);
genFunctionOrProperty(context, (JetTypeParameterListOwner) declaration, builder);
}
{
final CodegenContext context =
CodegenContext context =
CodegenContext.STATIC.intoNamespacePart(className, descriptor);
genFunctionOrProperty(context, (JetTypeParameterListOwner) declaration, v.getClassBuilder());
}
@@ -216,9 +216,9 @@ public class NamespaceCodegen extends MemberCodegen {
for (JetDeclaration declaration : file.getDeclarations()) {
if (declaration instanceof JetProperty) {
final JetExpression initializer = ((JetProperty) declaration).getInitializer();
JetExpression initializer = ((JetProperty) declaration).getInitializer();
if (initializer != null && !(initializer instanceof JetConstantExpression)) {
final PropertyDescriptor descriptor =
PropertyDescriptor descriptor =
(PropertyDescriptor) state.getBindingContext().get(BindingContext.VARIABLE, declaration);
assert descriptor != null;
codegen.genToJVMStack(initializer);
@@ -238,7 +238,7 @@ public class NamespaceCodegen extends MemberCodegen {
for (JetFile file : files) {
for (JetDeclaration declaration : file.getDeclarations()) {
if (declaration instanceof JetProperty) {
final JetExpression initializer = ((JetProperty) declaration).getInitializer();
JetExpression initializer = ((JetProperty) declaration).getInitializer();
if (initializer != null && !(initializer instanceof JetConstantExpression)) {
return true;
}
@@ -94,7 +94,7 @@ public class PropertyCodegen extends GenerationStateAware {
}
Object value = null;
final JetExpression initializer = p instanceof JetProperty ? ((JetProperty) p).getInitializer() : null;
JetExpression initializer = p instanceof JetProperty ? ((JetProperty) p).getInitializer() : null;
if (initializer != null) {
if (initializer instanceof JetConstantExpression) {
CompileTimeConstant<?> compileTimeValue = bindingContext.get(BindingContext.COMPILE_TIME_VALUE, initializer);
@@ -177,8 +177,8 @@ public class PropertyCodegen extends GenerationStateAware {
}
JvmPropertyAccessorSignature signature = typeMapper.mapGetterSignature(propertyDescriptor, kind);
final JvmMethodSignature jvmMethodSignature = signature.getJvmMethodSignature();
final String descriptor = jvmMethodSignature.getAsmMethod().getDescriptor();
JvmMethodSignature jvmMethodSignature = signature.getJvmMethodSignature();
String descriptor = jvmMethodSignature.getAsmMethod().getDescriptor();
String getterName = getterName(propertyDescriptor.getName());
MethodVisitor mv = v.newMethod(origin, flags, getterName, descriptor, jvmMethodSignature.getGenericsSignature(), null);
PropertyGetterDescriptor getter = propertyDescriptor.getGetter();
@@ -208,7 +208,7 @@ public class PropertyCodegen extends GenerationStateAware {
if (kind != OwnerKind.NAMESPACE) {
iv.load(0, OBJECT_TYPE);
}
final Type type = typeMapper.mapType(propertyDescriptor);
Type type = typeMapper.mapType(propertyDescriptor);
iv.visitFieldInsn(
kind == OwnerKind.NAMESPACE ? GETSTATIC : GETFIELD,
@@ -261,8 +261,8 @@ public class PropertyCodegen extends GenerationStateAware {
JvmPropertyAccessorSignature signature = typeMapper.mapSetterSignature(propertyDescriptor, kind);
assert true;
final JvmMethodSignature jvmMethodSignature = signature.getJvmMethodSignature();
final String descriptor = jvmMethodSignature.getAsmMethod().getDescriptor();
JvmMethodSignature jvmMethodSignature = signature.getJvmMethodSignature();
String descriptor = jvmMethodSignature.getAsmMethod().getDescriptor();
MethodVisitor mv = v.newMethod(origin, flags, setterName(propertyDescriptor.getName()), descriptor, jvmMethodSignature.getGenericsSignature(), null);
PropertySetterDescriptor setter = propertyDescriptor.getSetter();
assert setter != null;
@@ -284,7 +284,7 @@ public class PropertyCodegen extends GenerationStateAware {
}
else {
InstructionAdapter iv = new InstructionAdapter(mv);
final Type type = typeMapper.mapType(propertyDescriptor);
Type type = typeMapper.mapType(propertyDescriptor);
int paramCode = 0;
if (kind != OwnerKind.NAMESPACE) {
iv.load(0, OBJECT_TYPE);
@@ -155,7 +155,7 @@ public abstract class StackValue {
return new Expression(type, expression, generator);
}
private static void box(final Type type, final Type toType, InstructionAdapter v) {
private static void box(Type type, Type toType, InstructionAdapter v) {
// TODO handle toType correctly
if (type == Type.INT_TYPE || (isIntPrimitive(type) && toType.getInternalName().equals("java/lang/Integer"))) {
v.invokestatic("java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;");
@@ -183,7 +183,7 @@ public abstract class StackValue {
}
}
private static void unbox(final Type type, InstructionAdapter v) {
private static void unbox(Type type, InstructionAdapter v) {
if (type == Type.INT_TYPE) {
v.invokevirtual("java/lang/Number", "intValue", "()I");
}
@@ -1142,7 +1142,7 @@ public abstract class StackValue {
@Override
public void put(Type type, InstructionAdapter v) {
final StackValue stackValue = codegen.generateThisOrOuter(descriptor, isSuper);
StackValue stackValue = codegen.generateThisOrOuter(descriptor, isSuper);
stackValue.put(coerceType ? type : stackValue.type, v);
}
}
@@ -111,7 +111,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
public void visitJetFile(JetFile file) {
if (file.isScript()) {
//noinspection ConstantConditions
final ClassDescriptor classDescriptor =
ClassDescriptor classDescriptor =
bindingContext.get(CLASS_FOR_FUNCTION, bindingContext.get(SCRIPT, file.getScript()));
classStack.push(classDescriptor);
//noinspection ConstantConditions
@@ -132,7 +132,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
ClassDescriptor descriptor = bindingContext.get(CLASS, enumEntry);
assert descriptor != null;
final boolean trivial = enumEntry.getDeclarations().isEmpty();
boolean trivial = enumEntry.getDeclarations().isEmpty();
if (!trivial) {
bindingTrace.record(ENUM_ENTRY_CLASS_NEED_SUBCLASS, descriptor);
super.visitEnumEntry(enumEntry);
@@ -211,7 +211,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
return;
}
final String name = inventAnonymousClassName(expression.getObjectDeclaration());
String name = inventAnonymousClassName(expression.getObjectDeclaration());
recordClosure(bindingTrace, expression.getObjectDeclaration(), classDescriptor, peekFromStack(classStack), JvmClassName.byInternalName(name), false);
classStack.push(classDescriptor);
@@ -75,7 +75,7 @@ public class CodegenBinding {
@NotNull
public static JvmClassName classNameForScriptDescriptor(BindingContext bindingContext, @NotNull ScriptDescriptor scriptDescriptor) {
final ClassDescriptor classDescriptor = bindingContext.get(CLASS_FOR_FUNCTION, scriptDescriptor);
ClassDescriptor classDescriptor = bindingContext.get(CLASS_FOR_FUNCTION, scriptDescriptor);
//noinspection ConstantConditions
return bindingContext.get(FQN, classDescriptor);
}
@@ -90,7 +90,7 @@ public class CodegenBinding {
}
public static ClassDescriptor enclosingClassDescriptor(BindingContext bindingContext, ClassDescriptor descriptor) {
final CalculatedClosure closure = bindingContext.get(CLOSURE, descriptor);
CalculatedClosure closure = bindingContext.get(CLOSURE, descriptor);
return closure == null ? null : closure.getEnclosingClass();
}
@@ -159,7 +159,7 @@ public class CodegenBinding {
}
public static boolean isSingleton(BindingContext bindingContext, @NotNull ClassDescriptor classDescriptor) {
final ClassKind kind = classDescriptor.getKind();
ClassKind kind = classDescriptor.getKind();
if (kind == ClassKind.CLASS_OBJECT) {
return true;
}
@@ -183,7 +183,7 @@ public class CodegenBinding {
JvmClassName name,
boolean functionLiteral
) {
final JetDelegatorToSuperCall superCall = findSuperCall(bindingTrace.getBindingContext(), element);
JetDelegatorToSuperCall superCall = findSuperCall(bindingTrace.getBindingContext(), element);
CallableDescriptor enclosingReceiver = null;
if (classDescriptor.getContainingDeclaration() instanceof CallableDescriptor) {
@@ -197,7 +197,7 @@ public class CodegenBinding {
}
}
final MutableClosure closure = new MutableClosure(superCall, enclosing, enclosingReceiver);
MutableClosure closure = new MutableClosure(superCall, enclosing, enclosingReceiver);
assert PsiCodegenPredictor.checkPredictedNameFromPsi(bindingTrace, classDescriptor, name);
bindingTrace.record(FQN, classDescriptor, name);
@@ -238,19 +238,19 @@ public class CodegenBinding {
// todo: we use Set and add given files but ignoring other scripts because something non-clear kept in binding
// for scripts especially in case of REPL
final HashSet<FqName> names = new HashSet<FqName>();
HashSet<FqName> names = new HashSet<FqName>();
for (JetFile file : files) {
if (!file.isScript()) {
names.add(JetPsiUtil.getFQName(file));
}
}
final HashSet<JetFile> answer = new HashSet<JetFile>();
HashSet<JetFile> answer = new HashSet<JetFile>();
answer.addAll(files);
for (FqName name : names) {
final NamespaceDescriptor namespaceDescriptor = bindingContext.get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, name);
final Collection<JetFile> jetFiles = bindingContext.get(NAMESPACE_TO_FILES, namespaceDescriptor);
NamespaceDescriptor namespaceDescriptor = bindingContext.get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, name);
Collection<JetFile> jetFiles = bindingContext.get(NAMESPACE_TO_FILES, namespaceDescriptor);
if (jetFiles != null)
answer.addAll(jetFiles);
}
@@ -274,8 +274,8 @@ public class CodegenBinding {
}
public static boolean isMultiFileNamespace(BindingContext bindingContext, FqName fqName) {
final NamespaceDescriptor namespaceDescriptor = bindingContext.get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, fqName);
final Collection<JetFile> jetFiles = bindingContext.get(NAMESPACE_TO_FILES, namespaceDescriptor);
NamespaceDescriptor namespaceDescriptor = bindingContext.get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, fqName);
Collection<JetFile> jetFiles = bindingContext.get(NAMESPACE_TO_FILES, namespaceDescriptor);
return jetFiles != null && jetFiles.size() > 1;
}
@@ -306,7 +306,7 @@ public class CodegenBinding {
public static boolean isLocalNamedFun(BindingContext bindingContext, DeclarationDescriptor fd) {
PsiElement psiElement = descriptorToDeclaration(bindingContext, fd);
if (psiElement instanceof JetNamedFunction) {
final DeclarationDescriptor declaration = fd.getContainingDeclaration();
DeclarationDescriptor declaration = fd.getContainingDeclaration();
return declaration instanceof FunctionDescriptor || declaration instanceof PropertyDescriptor;
}
return false;
@@ -385,7 +385,7 @@ public class CodegenBinding {
public static boolean hasThis0(BindingContext bindingContext, ClassDescriptor classDescriptor) {
//noinspection SuspiciousMethodCalls
final CalculatedClosure closure = bindingContext.get(CLOSURE, classDescriptor);
CalculatedClosure closure = bindingContext.get(CLOSURE, classDescriptor);
return closure != null && closure.getCaptureThis() != null;
}
@@ -105,7 +105,7 @@ public abstract class CodegenContext {
@Nullable
public final CallableDescriptor getCallableDescriptorWithReceiver() {
if (contextDescriptor instanceof CallableDescriptor) {
final CallableDescriptor callableDescriptor = (CallableDescriptor) getContextDescriptor();
CallableDescriptor callableDescriptor = (CallableDescriptor) getContextDescriptor();
return callableDescriptor.getReceiverParameter() != null ? callableDescriptor : null;
}
return null;
@@ -151,7 +151,7 @@ public abstract class CodegenContext {
ClassDescriptor descriptor,
ExpressionCodegen expressionCodegen
) {
final JetTypeMapper typeMapper = expressionCodegen.getState().getTypeMapper();
JetTypeMapper typeMapper = expressionCodegen.getState().getTypeMapper();
return new AnonymousClassContext(typeMapper, descriptor, OwnerKind.IMPLEMENTATION, this,
expressionCodegen);
}
@@ -177,7 +177,7 @@ public abstract class CodegenContext {
FunctionDescriptor funDescriptor,
ExpressionCodegen expressionCodegen
) {
final JetTypeMapper typeMapper = expressionCodegen.getState().getTypeMapper();
JetTypeMapper typeMapper = expressionCodegen.getState().getTypeMapper();
return new ClosureContext(typeMapper, funDescriptor,
typeMapper.getBindingContext().get(CLASS_FOR_FUNCTION, funDescriptor),
this, expressionCodegen);
@@ -275,7 +275,7 @@ public abstract class CodegenContext {
}
public StackValue lookupInContext(DeclarationDescriptor d, @Nullable StackValue result, GenerationState state, boolean ignoreNoOuter) {
final MutableClosure top = closure;
MutableClosure top = closure;
if (top != null) {
EnclosedValueDescriptor answer = closure.getCaptureVariables().get(d);
if (answer != null) {
@@ -33,7 +33,7 @@ public class ConstructorContext extends MethodContext {
) {
super(contextDescriptor, kind, parent);
final ClassDescriptor type = getEnclosingClass();
ClassDescriptor type = getEnclosingClass();
outerExpression = type != null ? local1 : null;
}
@@ -46,7 +46,7 @@ public final class EnclosedValueDescriptor {
}
public StackValue getOuterValue(ExpressionCodegen expressionCodegen) {
final GenerationState state = expressionCodegen.getState();
GenerationState state = expressionCodegen.getState();
for (LocalLookup.LocalLookupCase aCase : LocalLookup.LocalLookupCase.values()) {
if (aCase.isCase(descriptor, state)) {
return aCase.outerValue(this, expressionCodegen);
@@ -50,14 +50,14 @@ public interface LocalLookup {
) {
VariableDescriptor vd = (VariableDescriptor) d;
final boolean idx = localLookup != null && localLookup.lookupLocal(vd);
boolean idx = localLookup != null && localLookup.lookupLocal(vd);
if (!idx) return null;
final Type sharedVarType = state.getTypeMapper().getSharedVarType(vd);
Type sharedVarType = state.getTypeMapper().getSharedVarType(vd);
Type localType = state.getTypeMapper().mapType(vd);
final Type type = sharedVarType != null ? sharedVarType : localType;
Type type = sharedVarType != null ? sharedVarType : localType;
final String fieldName = "$" + vd.getName();
String fieldName = "$" + vd.getName();
StackValue innerValue = sharedVarType != null
? StackValue.fieldForSharedVar(localType, className, fieldName)
: StackValue.field(type, className, fieldName, false);
@@ -85,14 +85,14 @@ public interface LocalLookup {
) {
FunctionDescriptor vd = (FunctionDescriptor) d;
final boolean idx = localLookup.lookupLocal(vd);
boolean idx = localLookup.lookupLocal(vd);
if (!idx) return null;
JetElement expression = (JetElement) callableDescriptorToDeclaration(state.getBindingContext(), vd);
JvmClassName cn = classNameForAnonymousClass(state.getBindingContext(), expression);
Type localType = cn.getAsmType();
final String fieldName = "$" + vd.getName();
String fieldName = "$" + vd.getName();
StackValue innerValue = StackValue.field(localType, className, fieldName, false);
closure.recordField(fieldName, localType);
@@ -117,7 +117,7 @@ public interface LocalLookup {
) {
if (closure.getEnclosingReceiverDescriptor() != d) return null;
final JetType receiverType = ((CallableDescriptor) d).getReceiverParameter().getType();
JetType receiverType = ((CallableDescriptor) d).getReceiverParameter().getType();
Type type = state.getTypeMapper().mapType(receiverType);
StackValue innerValue = StackValue.field(type, className, CAPTURED_RECEIVER_FIELD, false);
closure.setCaptureReceiver();
@@ -143,7 +143,7 @@ public interface LocalLookup {
);
public StackValue outerValue(EnclosedValueDescriptor d, ExpressionCodegen expressionCodegen) {
final int idx = expressionCodegen.lookupLocalIndex(d.getDescriptor());
int idx = expressionCodegen.lookupLocalIndex(d.getDescriptor());
assert idx != -1;
return StackValue.local(idx, d.getType());
@@ -58,7 +58,7 @@ public class Increment implements IntrinsicMethod {
operand = ((JetParenthesizedExpression) operand).getExpression();
}
if (operand instanceof JetReferenceExpression) {
final int index = codegen.indexOfLocal((JetReferenceExpression) operand);
int index = codegen.indexOfLocal((JetReferenceExpression) operand);
if (index >= 0 && isIntPrimitive(expectedType)) {
return StackValue.preIncrement(index, myDelta);
}
@@ -38,7 +38,7 @@ public class Not implements IntrinsicMethod {
StackValue receiver,
@NotNull GenerationState state
) {
final StackValue stackValue;
StackValue stackValue;
if (arguments.size() == 1) {
stackValue = codegen.gen(arguments.get(0));
}
@@ -44,8 +44,8 @@ public class RangeTo implements IntrinsicMethod {
@NotNull GenerationState state
) {
if (arguments.size() == 1) {
final Type leftType = receiver.type;
final Type rightType = codegen.expressionType(arguments.get(0));
Type leftType = receiver.type;
Type rightType = codegen.expressionType(arguments.get(0));
receiver.put(leftType, v);
codegen.gen(arguments.get(0), rightType);
v.invokestatic("jet/runtime/Ranges", "rangeTo",
@@ -54,8 +54,8 @@ public class RangeTo implements IntrinsicMethod {
}
else {
JetBinaryExpression expression = (JetBinaryExpression) element;
final Type leftType = codegen.expressionType(expression.getLeft());
final Type rightType = codegen.expressionType(expression.getRight());
Type leftType = codegen.expressionType(expression.getLeft());
Type rightType = codegen.expressionType(expression.getRight());
// if (JetTypeMapper.isIntPrimitive(leftType)) {
codegen.gen(expression.getLeft(), leftType);
codegen.gen(expression.getRight(), rightType);
@@ -271,14 +271,14 @@ public class BothSignatureWriter {
pop();
}
public void writeTypeVariable(final Name name, boolean nullable, Type asmType) {
public void writeTypeVariable(Name name, boolean nullable, Type asmType) {
signatureVisitor().visitTypeVariable(name.getName());
jetSignatureWriter.visitTypeVariable(name.getName(), nullable);
generic = true;
writeAsmType0(asmType);
}
public void writeFormalTypeParameter(final String name, Variance variance, boolean reified) {
public void writeFormalTypeParameter(String name, Variance variance, boolean reified) {
checkTopLevel();
signatureVisitor().visitFormalTypeParameter(name);
@@ -169,12 +169,12 @@ public class JetTypeMapper extends BindingTraceAware {
}
@NotNull
public Type mapReturnType(@NotNull final JetType jetType) {
public Type mapReturnType(@NotNull JetType jetType) {
return mapReturnType(jetType, null);
}
@NotNull
private Type mapReturnType(@NotNull final JetType jetType, @Nullable BothSignatureWriter signatureVisitor) {
private Type mapReturnType(@NotNull JetType jetType, @Nullable BothSignatureWriter signatureVisitor) {
if (jetType.equals(KotlinBuiltIns.getInstance().getUnitType())) {
if (signatureVisitor != null) {
signatureVisitor.writeAsmType(Type.VOID_TYPE, false);
@@ -197,22 +197,22 @@ public class JetTypeMapper extends BindingTraceAware {
}
@NotNull
public Type mapType(@NotNull final JetType jetType, @NotNull JetTypeMapperMode kind) {
public Type mapType(@NotNull JetType jetType, @NotNull JetTypeMapperMode kind) {
return mapType(jetType, null, kind);
}
@NotNull
public Type mapType(@NotNull final JetType jetType) {
public Type mapType(@NotNull JetType jetType) {
return mapType(jetType, null, JetTypeMapperMode.VALUE);
}
@NotNull
public Type mapType(@NotNull final VariableDescriptor variableDescriptor) {
public Type mapType(@NotNull VariableDescriptor variableDescriptor) {
return mapType(variableDescriptor.getType(), null, JetTypeMapperMode.VALUE);
}
@NotNull
public Type mapType(@NotNull final ClassifierDescriptor classifierDescriptor) {
public Type mapType(@NotNull ClassifierDescriptor classifierDescriptor) {
return mapType(classifierDescriptor.getDefaultType());
}
@@ -260,7 +260,7 @@ public class JetTypeMapper extends BindingTraceAware {
}
}
final TypeConstructor constructor = jetType.getConstructor();
TypeConstructor constructor = jetType.getConstructor();
if (constructor instanceof IntersectionTypeConstructor) {
jetType = CommonSupertypes.commonSupertype(new ArrayList<JetType>(constructor.getSupertypes()));
}
@@ -452,7 +452,7 @@ public class JetTypeMapper extends BindingTraceAware {
boolean isInsideModule,
OwnerKind kind
) {
final DeclarationDescriptor functionParent = functionDescriptor.getOriginal().getContainingDeclaration();
DeclarationDescriptor functionParent = functionDescriptor.getOriginal().getContainingDeclaration();
functionDescriptor = unwrapFakeOverride(functionDescriptor);
@@ -575,8 +575,8 @@ public class JetTypeMapper extends BindingTraceAware {
writeFormalTypeParameters(f.getTypeParameters(), signatureVisitor);
final JetType receiverType = DescriptorUtils.getReceiverParameterType(f.getReceiverParameter());
final List<ValueParameterDescriptor> parameters = f.getValueParameters();
JetType receiverType = DescriptorUtils.getReceiverParameterType(f.getReceiverParameter());
List<ValueParameterDescriptor> parameters = f.getValueParameters();
signatureVisitor.writeParametersStart();
@@ -686,7 +686,7 @@ public class JetTypeMapper extends BindingTraceAware {
}
public JvmMethodSignature mapSignature(Name name, FunctionDescriptor f) {
final ReceiverParameterDescriptor receiver = f.getReceiverParameter();
ReceiverParameterDescriptor receiver = f.getReceiverParameter();
BothSignatureWriter signatureWriter = new BothSignatureWriter(BothSignatureWriter.Mode.METHOD, false);
@@ -696,7 +696,7 @@ public class JetTypeMapper extends BindingTraceAware {
writeThisForAccessorIfNeeded(f, signatureWriter);
final List<ValueParameterDescriptor> parameters = f.getValueParameters();
List<ValueParameterDescriptor> parameters = f.getValueParameters();
writeReceiverIfNeeded(receiver, signatureWriter);
for (ValueParameterDescriptor parameter : parameters) {
writeParameter(signatureWriter, parameter.getType());
@@ -723,7 +723,7 @@ public class JetTypeMapper extends BindingTraceAware {
public JvmPropertyAccessorSignature mapGetterSignature(PropertyDescriptor descriptor, OwnerKind kind) {
final DeclarationDescriptor parentDescriptor = descriptor.getContainingDeclaration();
DeclarationDescriptor parentDescriptor = descriptor.getContainingDeclaration();
boolean isAnnotation = parentDescriptor instanceof ClassDescriptor &&
((ClassDescriptor) parentDescriptor).getKind() == ClassKind.ANNOTATION_CLASS;
String name = isAnnotation ? descriptor.getName().getName() : PropertyCodegen.getterName(descriptor.getName());
@@ -821,14 +821,14 @@ public class JetTypeMapper extends BindingTraceAware {
signatureWriter.writeParametersStart();
ClassDescriptor containingDeclaration = descriptor.getContainingDeclaration();
final ClassDescriptor captureThis = closure != null ? closure.getCaptureThis() : null;
ClassDescriptor captureThis = closure != null ? closure.getCaptureThis() : null;
if (captureThis != null) {
signatureWriter.writeParameterType(JvmMethodParameterKind.OUTER);
mapType(captureThis.getDefaultType(), signatureWriter, JetTypeMapperMode.VALUE);
signatureWriter.writeParameterTypeEnd();
}
final ClassifierDescriptor captureReceiver = closure != null ? closure.getCaptureReceiver() : null;
ClassifierDescriptor captureReceiver = closure != null ? closure.getCaptureReceiver() : null;
if (captureReceiver != null) {
signatureWriter.writeParameterType(JvmMethodParameterKind.RECEIVER);
mapType(captureReceiver.getDefaultType(), signatureWriter, JetTypeMapperMode.VALUE);
@@ -858,7 +858,7 @@ public class JetTypeMapper extends BindingTraceAware {
}
}
final JetDelegatorToSuperCall superCall = closure.getSuperCall();
JetDelegatorToSuperCall superCall = closure.getSuperCall();
if (superCall != null) {
DeclarationDescriptor superDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET,
superCall
@@ -866,12 +866,12 @@ public class JetTypeMapper extends BindingTraceAware {
.getConstructorReferenceExpression());
if(superDescriptor instanceof ConstructorDescriptor) {
final ConstructorDescriptor superConstructor = (ConstructorDescriptor) superDescriptor;
ConstructorDescriptor superConstructor = (ConstructorDescriptor) superDescriptor;
if (isObjectLiteral(bindingContext, descriptor.getContainingDeclaration())) {
//noinspection SuspiciousMethodCalls
CallableMethod superCallable = mapToCallableMethod(superConstructor);
final List<JvmMethodParameterSignature> types = superCallable.getSignature().getKotlinParameterTypes();
List<JvmMethodParameterSignature> types = superCallable.getSignature().getKotlinParameterTypes();
if (types != null) {
for (JvmMethodParameterSignature type : types) {
signatureWriter.writeParameterType(JvmMethodParameterKind.SUPER_CALL_PARAM);
@@ -905,7 +905,7 @@ public class JetTypeMapper extends BindingTraceAware {
for (ScriptDescriptor importedScript : importedScripts) {
signatureWriter.writeParameterType(JvmMethodParameterKind.VALUE);
final ClassDescriptor descriptor = bindingContext.get(CLASS_FOR_FUNCTION, importedScript);
ClassDescriptor descriptor = bindingContext.get(CLASS_FOR_FUNCTION, importedScript);
assert descriptor != null;
mapType(descriptor.getDefaultType(), signatureWriter, JetTypeMapperMode.VALUE);
signatureWriter.writeParameterTypeEnd();
@@ -927,7 +927,7 @@ public class JetTypeMapper extends BindingTraceAware {
}
public CallableMethod mapToCallableMethod(ConstructorDescriptor descriptor, CalculatedClosure closure) {
final JvmMethodSignature method = mapConstructorSignature(descriptor, closure);
JvmMethodSignature method = mapConstructorSignature(descriptor, closure);
JetType defaultType = descriptor.getContainingDeclaration().getDefaultType();
Type mapped = mapType(defaultType, JetTypeMapperMode.IMPL);
if (mapped.getSort() != Type.OBJECT) {
@@ -78,7 +78,7 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
return INTERNAL_ERROR;
}
final List<String> argumentsSourceDirs = arguments.getSourceDirs();
List<String> argumentsSourceDirs = arguments.getSourceDirs();
if (!arguments.script &&
arguments.module == null &&
arguments.src == null &&
@@ -141,7 +141,7 @@ public class CompileEnvironmentUtil {
}
try {
Class namespaceClass = loader.loadClass(PackageClassUtils.getPackageClassName(FqName.ROOT));
final Method method = namespaceClass.getDeclaredMethod("project");
Method method = namespaceClass.getDeclaredMethod("project");
if (method == null) {
throw new CompileEnvironmentException("Module script " + moduleFile + " must define project() function");
}
@@ -162,10 +162,10 @@ public class CompileEnvironmentUtil {
}
// TODO: includeRuntime should be not a flag but a path to runtime
public static void writeToJar(ClassFileFactory factory, final OutputStream fos, @Nullable FqName mainClass, boolean includeRuntime) {
public static void writeToJar(ClassFileFactory factory, OutputStream fos, @Nullable FqName mainClass, boolean includeRuntime) {
try {
Manifest manifest = new Manifest();
final Attributes mainAttributes = manifest.getMainAttributes();
Attributes mainAttributes = manifest.getMainAttributes();
mainAttributes.putValue("Manifest-Version", "1.0");
mainAttributes.putValue("Created-By", "JetBrains Kotlin");
if (mainClass != null) {
@@ -193,7 +193,7 @@ public class CompileEnvironmentUtil {
@Override
public boolean process(File file) {
if (file.isDirectory()) return true;
final String relativePath = FileUtil.getRelativePath(unpackedRuntimePath, file);
String relativePath = FileUtil.getRelativePath(unpackedRuntimePath, file);
try {
stream.putNextEntry(new JarEntry(FileUtil.toSystemIndependentName(relativePath)));
FileInputStream fis = new FileInputStream(file);
@@ -198,7 +198,7 @@ public class JetCoreEnvironment {
projectEnvironment.addJarToClassPath(path);
}
else {
final VirtualFile root = applicationEnvironment.getLocalFileSystem().findFileByPath(path.getAbsolutePath());
VirtualFile root = applicationEnvironment.getLocalFileSystem().findFileByPath(path.getAbsolutePath());
if (root == null) {
report(WARNING, "Classpath entry points to a non-existent location: " + path);
return;
@@ -332,7 +332,7 @@ public class KotlinToJVMBytecodeCompiler {
@NotNull
private static GenerationState generate(
final JetCoreEnvironment environment,
JetCoreEnvironment environment,
AnalyzeExhaust exhaust,
boolean stubs) {
Project project = environment.getProject();
@@ -373,7 +373,7 @@ public class KotlinToJVMBytecodeCompiler {
@NotNull String scriptPath,
@Nullable List<AnalyzerScriptParameter> scriptParameters,
@Nullable List<JetScriptDefinition> scriptDefinitions) {
final MessageRenderer messageRenderer = MessageRenderer.PLAIN;
MessageRenderer messageRenderer = MessageRenderer.PLAIN;
GroupingMessageCollector messageCollector = new GroupingMessageCollector(new PrintingMessageCollector(System.err, messageRenderer, false));
Disposable rootDisposable = CompileEnvironmentUtil.createMockDisposable();
try {
@@ -269,7 +269,7 @@ public class ReplInterpreter {
@Nullable
private ScriptDescriptor doAnalyze(@NotNull JetFile psiFile, @NotNull MessageCollector messageCollector) {
final WritableScope scope = new WritableScopeImpl(
WritableScope scope = new WritableScopeImpl(
JetScope.EMPTY, module,
new TraceBasedRedeclarationHandler(trace), "Root scope in analyzeNamespace");
@@ -81,7 +81,7 @@ public enum AnalyzerFacadeForJVM implements AnalyzerFacade {
@NotNull
@Override
public ResolveSession getLazyResolveSession(@NotNull final Project fileProject, @NotNull Collection<JetFile> files) {
public ResolveSession getLazyResolveSession(@NotNull Project fileProject, @NotNull Collection<JetFile> files) {
ModuleDescriptor javaModule = new ModuleDescriptor(Name.special("<java module>"));
BindingTraceContext javaResolverTrace = new BindingTraceContext();
@@ -91,7 +91,7 @@ public enum AnalyzerFacadeForJVM implements AnalyzerFacade {
// TODO: Replace with stub declaration provider
LockBasedStorageManager storageManager = new LockBasedStorageManager();
final FileBasedDeclarationProviderFactory declarationProviderFactory = new FileBasedDeclarationProviderFactory(storageManager, files, new Predicate<FqName>() {
FileBasedDeclarationProviderFactory declarationProviderFactory = new FileBasedDeclarationProviderFactory(storageManager, files, new Predicate<FqName>() {
@Override
public boolean apply(FqName fqName) {
return psiClassFinder.findPsiPackage(fqName) != null || new FqName("jet").equals(fqName);
@@ -199,7 +199,7 @@ public enum AnalyzerFacadeForJVM implements AnalyzerFacade {
Predicate<PsiFile> filesToAnalyzeCompletely,
boolean storeContextForBodiesResolve
) {
final ModuleDescriptor owner = new ModuleDescriptor(Name.special("<module>"));
ModuleDescriptor owner = new ModuleDescriptor(Name.special("<module>"));
TopDownAnalysisParameters topDownAnalysisParameters = new TopDownAnalysisParameters(
filesToAnalyzeCompletely, false, false, scriptParameters);
@@ -82,7 +82,7 @@ public class JavaPsiFacadeKotlinHacks {
return psiPackage;
}
public PsiClass findClass(@NotNull final String qualifiedName, @NotNull GlobalSearchScope scope) {
public PsiClass findClass(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) {
ProgressIndicatorProvider.checkCanceled(); // We hope this method is being called often enough to cancel daemon processes smoothly
PsiClass aClass = javaFileManager.findClass(qualifiedName, scope);
@@ -55,7 +55,7 @@ public class JavaTypeTransformer {
}
@NotNull
private TypeProjection transformToTypeProjection(@NotNull final PsiType javaType,
private TypeProjection transformToTypeProjection(@NotNull PsiType javaType,
@NotNull final TypeParameterDescriptor typeParameterDescriptor,
@NotNull final TypeVariableResolver typeVariableByPsiResolver,
@NotNull final TypeUsage howThisTypeIsUsed
@@ -102,7 +102,7 @@ public class JavaTypeTransformer {
@NotNull
public JetType transformToType(@NotNull PsiType javaType,
@NotNull final TypeVariableResolver typeVariableResolver) {
@NotNull TypeVariableResolver typeVariableResolver) {
return transformToType(javaType, TypeUsage.MEMBER_SIGNATURE_INVARIANT, typeVariableResolver);
}
@@ -159,7 +159,7 @@ public class SignaturesPropagationData {
List<ValueParameterDescriptor> resultParameters = Lists.newArrayList();
for (final ValueParameterDescriptor originalParam : parameters.getDescriptors()) {
for (ValueParameterDescriptor originalParam : parameters.getDescriptors()) {
final int index = originalParam.getIndex();
List<TypeAndVariance> typesFromSuperMethods = ContainerUtil.map(superFunctions,
new Function<FunctionDescriptor, TypeAndVariance>() {
@@ -53,7 +53,7 @@ public class JetClassAnnotation extends PsiAnnotationWithAbiVersion {
@NotNull
public static JetClassAnnotation get(PsiClass psiClass) {
final PsiAnnotation annotation = JavaAnnotationResolver.findOwnAnnotation(psiClass,
PsiAnnotation annotation = JavaAnnotationResolver.findOwnAnnotation(psiClass,
JvmStdlibNames.JET_CLASS.getFqName().getFqName());
return annotation != null ? new JetClassAnnotation(annotation) : NULL_ANNOTATION;
}
@@ -47,7 +47,7 @@ public class JetConstructorAnnotation extends PsiAnnotationWithFlags {
}
public static JetConstructorAnnotation get(PsiMethod constructor) {
final PsiAnnotation annotation =
PsiAnnotation annotation =
JavaAnnotationResolver.findOwnAnnotation(constructor, JvmStdlibNames.JET_CONSTRUCTOR.getFqName().getFqName());
return annotation != null ? new JetConstructorAnnotation(annotation) : NULL_ANNOTATION;
}
@@ -68,7 +68,7 @@ public class JetMethodAnnotation extends PsiAnnotationWithFlags {
}
public static JetMethodAnnotation get(PsiMethod psiMethod) {
final PsiAnnotation annotation =
PsiAnnotation annotation =
JavaAnnotationResolver.findOwnAnnotation(psiMethod, JvmStdlibNames.JET_METHOD.getFqName().getFqName());
return annotation != null ? new JetMethodAnnotation(annotation) : NULL_ANNOTATION;
}
@@ -35,7 +35,7 @@ public class JetPackageClassAnnotation extends PsiAnnotationWithAbiVersion {
@NotNull
public static JetPackageClassAnnotation get(PsiClass psiClass) {
final PsiAnnotation annotation = JavaAnnotationResolver.findOwnAnnotation(psiClass,
PsiAnnotation annotation = JavaAnnotationResolver.findOwnAnnotation(psiClass,
JvmStdlibNames.JET_PACKAGE_CLASS.getFqName().getFqName());
return annotation != null ? new JetPackageClassAnnotation(annotation) : NULL_ANNOTATION;
}
@@ -39,7 +39,7 @@ public class JetTypeParameterAnnotation extends PsiAnnotationWrapper {
@NotNull
public static JetTypeParameterAnnotation get(@NotNull PsiParameter psiParameter) {
final PsiAnnotation annotation =
PsiAnnotation annotation =
JavaAnnotationResolver.findOwnAnnotation(psiParameter, JvmStdlibNames.JET_TYPE_PARAMETER.getFqName().getFqName());
return annotation != null ? new JetTypeParameterAnnotation(annotation) : NULL_ANNOTATION;
}
@@ -76,7 +76,7 @@ public class JetValueParameterAnnotation extends PsiAnnotationWrapper {
}
public static JetValueParameterAnnotation get(PsiParameter psiParameter) {
final PsiAnnotation annotation =
PsiAnnotation annotation =
JavaAnnotationResolver.findOwnAnnotation(psiParameter, JvmStdlibNames.JET_VALUE_PARAMETER.getFqName().getFqName());
return annotation != null ? new JetValueParameterAnnotation(annotation) : NULL_ANNOTATION;
}
@@ -49,7 +49,7 @@ public class KotlinSignatureAnnotation extends PsiAnnotationWrapper {
@NotNull
public static KotlinSignatureAnnotation get(PsiModifierListOwner psiModifierListOwner) {
final PsiAnnotation annotation =
PsiAnnotation annotation =
JavaAnnotationResolver.findAnnotationWithExternal(psiModifierListOwner, JvmStdlibNames.KOTLIN_SIGNATURE.getFqName().getFqName());
return annotation != null ? new KotlinSignatureAnnotation(annotation) : NULL_ANNOTATION;
}
@@ -263,7 +263,7 @@ public final class MembersCache {
}
// TODO: what if returnType == null?
final PsiType returnType = method.getReturnType();
PsiType returnType = method.getReturnType();
assert returnType != null;
TypeSource propertyType = new TypeSource(method.getJetMethodAnnotation().propertyType(), returnType, method.getPsiMethod());
@@ -190,7 +190,7 @@ public final class JavaClassResolver {
@NotNull
private ClassDescriptor createJavaClassDescriptor(
@NotNull FqName fqName, @NotNull final PsiClass psiClass,
@NotNull FqName fqName, @NotNull PsiClass psiClass,
@NotNull PostponedTasks taskList
) {
@@ -292,7 +292,7 @@ public final class JavaClassResolver {
}
void checkFqNamesAreConsistent(@NotNull PsiClass psiClass, @NotNull FqName desiredFqName) {
final String qualifiedName = psiClass.getQualifiedName();
String qualifiedName = psiClass.getQualifiedName();
assert qualifiedName != null;
FqName fqName = new FqName(qualifiedName);
@@ -315,7 +315,7 @@ public final class JavaClassResolver {
@NotNull
private static FqName getFqName(@NotNull PsiClass psiClass) {
final String qualifiedName = psiClass.getQualifiedName();
String qualifiedName = psiClass.getQualifiedName();
assert qualifiedName != null;
return new FqName(qualifiedName);
}
@@ -91,7 +91,7 @@ public final class JavaFunctionResolver {
@Nullable
private SimpleFunctionDescriptor resolveMethodToFunctionDescriptor(
@NotNull final PsiClass psiClass, final PsiMethodWrapper method,
@NotNull PsiClass psiClass, PsiMethodWrapper method,
@NotNull PsiDeclarationProvider scopeData, @NotNull ClassOrNamespaceDescriptor ownerDescriptor
) {
PsiType returnPsiType = method.getReturnType();
@@ -104,8 +104,8 @@ public final class JavaFunctionResolver {
return null;
}
final PsiMethod psiMethod = method.getPsiMethod();
final PsiClass containingClass = psiMethod.getContainingClass();
PsiMethod psiMethod = method.getPsiMethod();
PsiClass containingClass = psiMethod.getContainingClass();
if (scopeData.getDeclarationOrigin() == KOTLIN) {
// TODO: unless maybe class explicitly extends Object
assert containingClass != null;
@@ -119,7 +119,7 @@ public final class JavaFunctionResolver {
return trace.get(BindingContext.FUNCTION, psiMethod);
}
final SimpleFunctionDescriptorImpl functionDescriptorImpl = new SimpleFunctionDescriptorImpl(
SimpleFunctionDescriptorImpl functionDescriptorImpl = new SimpleFunctionDescriptorImpl(
ownerDescriptor,
annotationResolver.resolveAnnotations(psiMethod),
Name.identifier(method.getName()),
@@ -141,7 +141,7 @@ public final class JavaFunctionResolver {
.resolveParameterDescriptors(functionDescriptorImpl, method.getParameters(), methodTypeVariableResolver);
JetType returnType = makeReturnType(returnPsiType, method, methodTypeVariableResolver);
final List<String> signatureErrors = Lists.newArrayList();
List<String> signatureErrors = Lists.newArrayList();
List<FunctionDescriptor> superFunctions;
if (ownerDescriptor instanceof ClassDescriptor) {
@@ -58,7 +58,7 @@ class JavaMethodSignatureUtil {
) {
if (superReturnType == null) return false;
PsiType substitutedSuperReturnType;
final boolean isJdk15 = PsiUtil.isLanguageLevel5OrHigher(method);
boolean isJdk15 = PsiUtil.isLanguageLevel5OrHigher(method);
if (isJdk15 && !superMethodSignature.isRaw() && superMethodSignature.equals(methodSignature)) { //see 8.4.5
PsiSubstitutor unifyingSubstitutor = MethodSignatureUtil.getSuperMethodSignatureSubstitutor(methodSignature,
superMethodSignature);
@@ -198,7 +198,7 @@ public final class JavaSignatureResolver {
List<TypeParameterDescriptorInitialization> r = new ArrayList<TypeParameterDescriptorInitialization>();
@Override
public JetSignatureVisitor visitFormalTypeParameter(final String name, final TypeInfoVariance variance, boolean reified) {
public JetSignatureVisitor visitFormalTypeParameter(final String name, TypeInfoVariance variance, boolean reified) {
TypeParameterDescriptorImpl typeParameter = TypeParameterDescriptorImpl.createForFurtherModification(
containingDeclaration,
Collections.<AnnotationDescriptor>emptyList(), // TODO: wrong
@@ -274,7 +274,7 @@ public final class JavaSignatureResolver {
private void initializeTypeParameter(TypeParameterDescriptorInitialization typeParameter, TypeVariableResolver typeVariableByPsiResolver) {
TypeParameterDescriptorImpl typeParameterDescriptor = typeParameter.descriptor;
if (typeParameter.origin == TypeParameterDescriptorOrigin.KOTLIN) {
final List<JetType> upperBoundsForKotlin = typeParameter.upperBoundsForKotlin;
List<JetType> upperBoundsForKotlin = typeParameter.upperBoundsForKotlin;
assert upperBoundsForKotlin != null;
if (upperBoundsForKotlin.size() == 0){
typeParameterDescriptor.addUpperBound(KotlinBuiltIns.getInstance().getNullableAnyType());
@@ -344,7 +344,7 @@ public final class JavaSignatureResolver {
) {
List<TypeParameterDescriptorInitialization> typeParametersIntialization;
final PsiMethod psiMethod = method.getPsiMethod();
PsiMethod psiMethod = method.getPsiMethod();
if (method.getJetMethodAnnotation().typeParameters().length() > 0) {
typeParametersIntialization = resolveMethodTypeParametersFromJetSignature(
method.getJetMethodAnnotation().typeParameters(), psiMethod, functionDescriptor);
@@ -353,7 +353,7 @@ public final class JavaSignatureResolver {
typeParametersIntialization = makeUninitializedTypeParameters(functionDescriptor, psiMethod.getTypeParameters());
}
final PsiClass psiMethodContainingClass = psiMethod.getContainingClass();
PsiClass psiMethodContainingClass = psiMethod.getContainingClass();
assert psiMethodContainingClass != null;
String context = "method " + method.getName() + " in class " + psiMethodContainingClass.getQualifiedName();
initializeTypeParameters(typeParametersIntialization, functionDescriptor, context);
@@ -371,9 +371,9 @@ public final class JavaSignatureResolver {
* @see #resolveClassTypeParametersFromJetSignature(String, PsiClass, ClassDescriptor)
*/
private List<TypeParameterDescriptorInitialization> resolveMethodTypeParametersFromJetSignature(String jetSignature,
final PsiMethod method, final DeclarationDescriptor functionDescriptor)
PsiMethod method, DeclarationDescriptor functionDescriptor)
{
final PsiClass methodContainingClass = method.getContainingClass();
PsiClass methodContainingClass = method.getContainingClass();
assert methodContainingClass != null;
String context = "method " + method.getName() + " in class " + methodContainingClass.getQualifiedName();
JetSignatureTypeParametersVisitor jetSignatureTypeParametersVisitor = new JetSignatureTypeParametersVisitor(functionDescriptor, method, context);
@@ -79,7 +79,7 @@ public final class JavaSupertypeResolver {
@NotNull List<TypeParameterDescriptor> typeParameters
) {
final List<JetType> result = new ArrayList<JetType>();
List<JetType> result = new ArrayList<JetType>();
String context = "class " + psiClass.getQualifiedName();
@@ -179,7 +179,7 @@ public final class JavaSupertypeResolver {
for (PsiClassType type : extendsListTypes) {
PsiClass resolved = type.resolve();
if (resolved != null) {
final String qualifiedName = resolved.getQualifiedName();
String qualifiedName = resolved.getQualifiedName();
assert qualifiedName != null;
if (JvmStdlibNames.JET_OBJECT.getFqName().equalsTo(qualifiedName)) {
continue;
@@ -40,7 +40,7 @@ public final class ScopeUtils {
JavaSemanticServices javaSemanticServices
) {
Collection<DeclarationDescriptor> result = Sets.newHashSet();
final JavaDescriptorResolver descriptorResolver = javaSemanticServices.getDescriptorResolver();
JavaDescriptorResolver descriptorResolver = javaSemanticServices.getDescriptorResolver();
for (PsiPackage psiSubPackage : psiPackage.getSubPackages()) {
NamespaceDescriptor childNs = descriptorResolver.resolveNamespace(
@@ -74,7 +74,7 @@ public class CheckerTestUtil {
for (PsiErrorElement errorElement : AnalyzingUtils.getSyntaxErrorRanges(root)) {
diagnostics.add(new SyntaxErrorDiagnostic(errorElement));
}
final List<Diagnostic> debugAnnotations = getDebugInfoDiagnostics(root, bindingContext);
List<Diagnostic> debugAnnotations = getDebugInfoDiagnostics(root, bindingContext);
diagnostics.addAll(debugAnnotations);
return diagnostics;
}
@@ -370,7 +370,7 @@ public class JetControlFlowProcessor {
@Override
public void visitTryExpression(JetTryExpression expression) {
builder.read(expression);
final JetFinallySection finallyBlock = expression.getFinallyBlock();
JetFinallySection finallyBlock = expression.getFinallyBlock();
final FinallyBlockGenerator finallyBlockGenerator = new FinallyBlockGenerator(finallyBlock);
if (finallyBlock != null) {
builder.enterTryFinally(new GenerationTrigger() {
@@ -388,7 +388,7 @@ public class JetControlFlowProcessor {
}
List<JetCatchClause> catchClauses = expression.getCatchClauses();
final boolean hasCatches = !catchClauses.isEmpty();
boolean hasCatches = !catchClauses.isEmpty();
Label onException = null;
if (hasCatches) {
onException = builder.createUnboundLabel("onException");
@@ -786,7 +786,7 @@ public class JetControlFlowProcessor {
}
@Override
public void visitIsExpression(final JetIsExpression expression) {
public void visitIsExpression(JetIsExpression expression) {
generateInstructions(expression.getLeftHandSide(), inCondition);
// no CF for types
// TODO : builder.read(expression.getPattern());
@@ -130,7 +130,7 @@ public class PseudocodeVariablesData {
Set<VariableDescriptor> usedVariables = getUsedVariables(pseudocode);
Set<VariableDescriptor> declaredVariables = getDeclaredVariables(pseudocode, false);
Map<VariableDescriptor, VariableInitState> initialMap = Collections.emptyMap();
final Map<VariableDescriptor, VariableInitState> initialMapForStartInstruction = prepareInitializersMapForStartInstruction(
Map<VariableDescriptor, VariableInitState> initialMapForStartInstruction = prepareInitializersMapForStartInstruction(
usedVariables, declaredVariables);
Map<Instruction, Edges<Map<VariableDescriptor, VariableInitState>>> variableInitializersMap = PseudocodeTraverser.collectData(
@@ -134,7 +134,7 @@ import static org.jetbrains.jet.lexer.JetTokens.*;
myBuilder.advanceLexer();
}
protected void advanceAtSet(final TokenSet set) {
protected void advanceAtSet(TokenSet set) {
assert _atSet(set);
myBuilder.advanceLexer();
}
@@ -161,7 +161,7 @@ import static org.jetbrains.jet.lexer.JetTokens.*;
return false;
}
protected boolean at(final IElementType expectation) {
protected boolean at(IElementType expectation) {
if (_at(expectation)) return true;
IElementType token = tt();
if (token == IDENTIFIER && expectation instanceof JetKeywordToken) {
@@ -191,7 +191,7 @@ import static org.jetbrains.jet.lexer.JetTokens.*;
/**
* Side-effect-free version of atSet()
*/
protected boolean _atSet(final TokenSet set) {
protected boolean _atSet(TokenSet set) {
IElementType token = tt();
if (set.contains(token)) return true;
if (set.contains(EOL_OR_SEMICOLON)) {
@@ -206,7 +206,7 @@ import static org.jetbrains.jet.lexer.JetTokens.*;
return atSet(TokenSet.create(tokens));
}
protected boolean atSet(final TokenSet set) {
protected boolean atSet(TokenSet set) {
if (_atSet(set)) return true;
IElementType token = tt();
if (token == IDENTIFIER) {
@@ -57,7 +57,7 @@ public class JetParsing extends AbstractJetParsing {
return jetParsing;
}
private static JetParsing createForByClause(final SemanticWhitespaceAwarePsiBuilder builder) {
private static JetParsing createForByClause(SemanticWhitespaceAwarePsiBuilder builder) {
final SemanticWhitespaceAwarePsiBuilderForByClause builderForByClause = new SemanticWhitespaceAwarePsiBuilderForByClause(builder);
JetParsing jetParsing = new JetParsing(builderForByClause);
jetParsing.myExpressionParsing = new JetExpressionParsing(builderForByClause, jetParsing) {
@@ -753,7 +753,7 @@ public class JetParsing extends AbstractJetParsing {
advance(); // CLASS_KEYWORD
final PsiBuilder.Marker objectDeclaration = mark();
PsiBuilder.Marker objectDeclaration = mark();
parseObject(false, true);
objectDeclaration.done(OBJECT_DECLARATION);
@@ -35,7 +35,7 @@ public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter imp
private final Stack<Boolean> newlinesEnabled = new Stack<Boolean>();
public SemanticWhitespaceAwarePsiBuilderImpl(final PsiBuilder delegate) {
public SemanticWhitespaceAwarePsiBuilderImpl(PsiBuilder delegate) {
super(delegate);
newlinesEnabled.push(true);
joinComplexTokens.push(true);
@@ -43,7 +43,7 @@ public class JetClass extends JetTypeParameterListOwnerStub<PsiJetClassStub> imp
super(node);
}
public JetClass(@NotNull final PsiJetClassStub stub) {
public JetClass(@NotNull PsiJetClassStub stub) {
super(stub, JetStubElementTypes.CLASS);
}
@@ -231,13 +231,13 @@ public class JetClass extends JetTypeParameterListOwnerStub<PsiJetClassStub> imp
return stub.getSuperNames();
}
final List<JetDelegationSpecifier> specifiers = getDelegationSpecifiers();
List<JetDelegationSpecifier> specifiers = getDelegationSpecifiers();
if (specifiers.size() == 0) return Collections.emptyList();
List<String> result = new ArrayList<String>();
for (JetDelegationSpecifier specifier : specifiers) {
final JetUserType superType = specifier.getTypeAsUserType();
JetUserType superType = specifier.getTypeAsUserType();
if (superType != null) {
final String referencedName = superType.getReferencedName();
String referencedName = superType.getReferencedName();
if (referencedName != null) {
addSuperName(result, referencedName);
}
@@ -249,7 +249,7 @@ public class JetClass extends JetTypeParameterListOwnerStub<PsiJetClassStub> imp
private void addSuperName(List<String> result, String referencedName) {
result.add(referencedName);
if (getContainingFile() instanceof JetFile) {
final JetImportDirective directive = ((JetFile) getContainingFile()).findImportByAlias(referencedName);
JetImportDirective directive = ((JetFile) getContainingFile()).findImportByAlias(referencedName);
if (directive != null) {
JetExpression reference = directive.getImportedReference();
while (reference instanceof JetDotQualifiedExpression) {
@@ -65,13 +65,13 @@ public class JetClassBody extends JetElementImpl implements JetDeclarationContai
@Nullable
public PsiElement getRBrace() {
final ASTNode[] children = getNode().getChildren(TokenSet.create(JetTokens.RBRACE));
ASTNode[] children = getNode().getChildren(TokenSet.create(JetTokens.RBRACE));
return children.length == 1 ? children[0].getPsi() : null;
}
@Nullable
public PsiElement getLBrace() {
final ASTNode[] children = getNode().getChildren(TokenSet.create(JetTokens.LBRACE));
ASTNode[] children = getNode().getChildren(TokenSet.create(JetTokens.LBRACE));
return children.length == 1 ? children[0].getPsi() : null;
}
}
@@ -43,9 +43,9 @@ public class JetDelegationSpecifier extends JetElementImpl {
@Nullable
public JetUserType getTypeAsUserType() {
final JetTypeReference reference = getTypeReference();
JetTypeReference reference = getTypeReference();
if (reference != null) {
final JetTypeElement element = reference.getTypeElement();
JetTypeElement element = reference.getTypeElement();
if (element instanceof JetUserType) {
return ((JetUserType) element);
}
@@ -79,7 +79,7 @@ public class JetDelegatorToSuperCall extends JetDelegationSpecifier implements J
@Override
public JetTypeArgumentList getTypeArgumentList() {
final JetUserType userType = getTypeAsUserType();
JetUserType userType = getTypeAsUserType();
return userType != null ? userType.getTypeArgumentList() : null;
}
@@ -89,7 +89,7 @@ public class JetNamedFunction extends JetTypeParameterListOwnerStub<PsiJetFuncti
*/
@Nullable
public FqName getFqName() {
final PsiJetFunctionStub stub = getStub();
PsiJetFunctionStub stub = getStub();
if (stub != null) {
return stub.getTopFQName();
}
@@ -101,7 +101,7 @@ public class JetNamedFunction extends JetTypeParameterListOwnerStub<PsiJetFuncti
return null;
}
JetFile jetFile = (JetFile) parent;
final FqName fileFQN = JetPsiUtil.getFQName(jetFile);
FqName fileFQN = JetPsiUtil.getFQName(jetFile);
Name nameAsName = getNameAsName();
if (nameAsName != null) {
return fileFQN.child(nameAsName);
@@ -31,7 +31,7 @@ public class JetParameter extends JetNamedDeclarationStub<PsiJetParameterStub> {
public static final ArrayFactory<JetParameter> ARRAY_FACTORY = new ArrayFactory<JetParameter>() {
@Override
public JetParameter[] create(final int count) {
public JetParameter[] create(int count) {
return count == 0 ? EMPTY_ARRAY : new JetParameter[count];
}
};
@@ -32,7 +32,7 @@ public class JetTypeParameter extends JetNamedDeclarationStub<PsiJetTypeParamete
public static final ArrayFactory<JetTypeParameter> ARRAY_FACTORY = new ArrayFactory<JetTypeParameter>() {
@Override
public JetTypeParameter[] create(final int count) {
public JetTypeParameter[] create(int count) {
return count == 0 ? EMPTY_ARRAY : new JetTypeParameter[count];
}
};
@@ -57,31 +57,31 @@ public class JetFileElementType extends IStubFileElementType<PsiJetFileStub> {
}
@Override
public void serialize(final PsiJetFileStub stub, final StubOutputStream dataStream)
public void serialize(PsiJetFileStub stub, StubOutputStream dataStream)
throws IOException {
dataStream.writeName(stub.getPackageName());
dataStream.writeBoolean(stub.isScript());
}
@Override
public PsiJetFileStub deserialize(final StubInputStream dataStream, final StubElement parentStub) throws IOException {
public PsiJetFileStub deserialize(StubInputStream dataStream, StubElement parentStub) throws IOException {
StringRef packName = dataStream.readName();
boolean isScript = dataStream.readBoolean();
return new PsiJetFileStubImpl(null, packName, isScript);
}
@Override
protected ASTNode doParseContents(@NotNull final ASTNode chameleon, @NotNull final PsiElement psi) {
final Project project = psi.getProject();
protected ASTNode doParseContents(@NotNull ASTNode chameleon, @NotNull PsiElement psi) {
Project project = psi.getProject();
Language languageForParser = getLanguageForParser(psi);
final PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, null, languageForParser, chameleon.getChars());
final JetParser parser = (JetParser) LanguageParserDefinitions.INSTANCE.forLanguage(languageForParser).createParser(project);
PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, null, languageForParser, chameleon.getChars());
JetParser parser = (JetParser) LanguageParserDefinitions.INSTANCE.forLanguage(languageForParser).createParser(project);
return parser.parse(this, builder, psi.getContainingFile()).getFirstChildNode();
}
@Override
public void indexStub(final PsiJetFileStub stub, final IndexSink sink) {
public void indexStub(PsiJetFileStub stub, IndexSink sink) {
StubIndexServiceFactory.getInstance().indexFile(stub, sink);
}
}
@@ -64,8 +64,8 @@ public class JetFunctionElementType extends JetStubElementType<PsiJetFunctionStu
@Override
public PsiJetFunctionStub createStub(@NotNull JetNamedFunction psi, @NotNull StubElement parentStub) {
final boolean isTopLevel = psi.getParent() instanceof JetFile;
final boolean isExtension = psi.getReceiverTypeRef() != null;
boolean isTopLevel = psi.getParent() instanceof JetFile;
boolean isExtension = psi.getReceiverTypeRef() != null;
FqName qualifiedName = psi.getFqName();
@@ -25,7 +25,7 @@ final class StubIndexServiceFactory {
public static StubIndexService getInstance() {
// If executed in plugin service will be registered
final StubIndexService registeredService = ServiceManager.getService(StubIndexService.class);
StubIndexService registeredService = ServiceManager.getService(StubIndexService.class);
return registeredService != null ? registeredService : StubIndexService.NO_INDEX_SERVICE;
}
}
@@ -44,7 +44,7 @@ public class PsiJetClassStubImpl extends StubBase<JetClass> implements PsiJetCla
public PsiJetClassStubImpl(
JetClassElementType type,
StubElement parent,
@Nullable final String qualifiedName,
@Nullable String qualifiedName,
String name,
List<String> superNames,
boolean isTrait, boolean isEnumClass, boolean isEnumEntry, boolean isAnnotation, boolean isInner) {
@@ -24,7 +24,7 @@ import org.jetbrains.jet.lang.psi.JetTypeParameterList;
import org.jetbrains.jet.lang.psi.stubs.PsiJetTypeParameterListStub;
public class PsiJetTypeParameterListStubImpl extends StubBase<JetTypeParameterList> implements PsiJetTypeParameterListStub {
public PsiJetTypeParameterListStubImpl(@NotNull IStubElementType elementType, final StubElement parent) {
public PsiJetTypeParameterListStubImpl(@NotNull IStubElementType elementType, StubElement parent) {
super(parent, elementType);
}
@@ -29,7 +29,7 @@ public class PsiJetTypeParameterStubImpl extends StubBase<JetTypeParameter> impl
private final boolean isInVariance;
private final boolean isOutVariance;
public PsiJetTypeParameterStubImpl(JetTypeParameterElementType type, final StubElement parent,
public PsiJetTypeParameterStubImpl(JetTypeParameterElementType type, StubElement parent,
StringRef name, StringRef extendBoundTypeText, boolean isInVariance, boolean isOutVariance) {
super(parent, type);
@@ -39,7 +39,7 @@ public class PsiJetTypeParameterStubImpl extends StubBase<JetTypeParameter> impl
this.isOutVariance = isOutVariance;
}
public PsiJetTypeParameterStubImpl(JetTypeParameterElementType type, final StubElement parent,
public PsiJetTypeParameterStubImpl(JetTypeParameterElementType type, StubElement parent,
String name, String extendBoundTypeText, boolean isInVariance, boolean isOutVariance) {
this(type, parent, StringRef.fromString(name), StringRef.fromString(extendBoundTypeText), isInVariance, isOutVariance);
}
@@ -152,14 +152,14 @@ public class BodyResolver {
}
}
private void resolveDelegationSpecifierList(JetClassOrObject jetClass, final MutableClassDescriptor descriptor) {
private void resolveDelegationSpecifierList(JetClassOrObject jetClass, MutableClassDescriptor descriptor) {
resolveDelegationSpecifierList(jetClass, descriptor,
descriptor.getUnsubstitutedPrimaryConstructor(),
descriptor.getScopeForSupertypeResolution(),
descriptor.getScopeForMemberResolution());
}
public void resolveDelegationSpecifierList(@NotNull final JetClassOrObject jetClass, @NotNull final ClassDescriptor descriptor,
public void resolveDelegationSpecifierList(@NotNull JetClassOrObject jetClass, @NotNull final ClassDescriptor descriptor,
@Nullable final ConstructorDescriptor primaryConstructor,
@NotNull JetScope scopeForSupertypeResolution,
@NotNull final JetScope scopeForMemberResolution) {
@@ -378,7 +378,7 @@ public class BodyResolver {
MutableClassDescriptor classDescriptor = entry.getValue();
for (JetProperty property : jetClass.getProperties()) {
final PropertyDescriptor propertyDescriptor = this.context.getProperties().get(property);
PropertyDescriptor propertyDescriptor = this.context.getProperties().get(property);
assert propertyDescriptor != null;
computeDeferredType(propertyDescriptor.getReturnType());
@@ -403,7 +403,7 @@ public class BodyResolver {
if (!context.completeAnalysisNeeded(property)) continue;
if (processed.contains(property)) continue;
final PropertyDescriptor propertyDescriptor = entry.getValue();
PropertyDescriptor propertyDescriptor = entry.getValue();
computeDeferredType(propertyDescriptor.getReturnType());
@@ -60,7 +60,7 @@ public class ControlFlowAnalyzer {
JetNamedFunction function = entry.getKey();
SimpleFunctionDescriptor functionDescriptor = entry.getValue();
if (!bodiesResolveContext.completeAnalysisNeeded(function)) continue;
final JetType expectedReturnType = !function.hasBlockBody() && !function.hasDeclaredReturnType()
JetType expectedReturnType = !function.hasBlockBody() && !function.hasDeclaredReturnType()
? NO_EXPECTED_TYPE
: functionDescriptor.getReturnType();
checkFunction(function, expectedReturnType);
@@ -94,7 +94,7 @@ public class ControlFlowAnalyzer {
}
}
private void checkFunction(JetDeclarationWithBody function, final @NotNull JetType expectedReturnType) {
private void checkFunction(JetDeclarationWithBody function, @NotNull JetType expectedReturnType) {
assert function instanceof JetDeclaration;
JetExpression bodyExpression = function.getBodyExpression();
@@ -110,7 +110,7 @@ public class DelegationResolver {
private static boolean isNotTrait(DeclarationDescriptor descriptor) {
if (descriptor instanceof ClassDescriptor) {
final ClassKind kind = ((ClassDescriptor) descriptor).getKind();
ClassKind kind = ((ClassDescriptor) descriptor).getKind();
return kind != ClassKind.TRAIT;
}
return false;
@@ -289,7 +289,7 @@ public class DescriptorResolver {
returnType = KotlinBuiltIns.getInstance().getUnitType();
}
else {
final JetExpression bodyExpression = function.getBodyExpression();
JetExpression bodyExpression = function.getBodyExpression();
if (bodyExpression != null) {
returnType =
DeferredType.create(trace, new RecursionIntolerantLazyValueWithDefault<JetType>(ErrorUtils.createErrorType("Recursive dependency")) {
@@ -1024,7 +1024,7 @@ public class DescriptorResolver {
@NotNull DeclarationDescriptorWithVisibility descriptor,
@NotNull JetNamedDeclaration declaration,
@NotNull JetType type,
@NotNull final BindingTrace trace
@NotNull BindingTrace trace
) {
ClassifierDescriptor classifierDescriptor = type.getConstructor().getDeclarationDescriptor();
if (!DescriptorUtils.isAnonymous(classifierDescriptor)) {
@@ -1052,7 +1052,7 @@ public class DescriptorResolver {
private JetType resolveInitializerType(
@NotNull JetScope scope,
@NotNull JetExpression initializer,
@NotNull final DataFlowInfo dataFlowInfo,
@NotNull DataFlowInfo dataFlowInfo,
@NotNull BindingTrace trace
) {
return expressionTypingServices.safeGetType(scope, initializer, TypeUtils.NO_EXPECTED_TYPE, dataFlowInfo, trace);
@@ -47,8 +47,8 @@ import static org.jetbrains.jet.lang.descriptors.ReceiverParameterDescriptor.NO_
public class DescriptorUtils {
@NotNull
public static <D extends CallableDescriptor> D substituteBounds(@NotNull final D functionDescriptor) {
final List<TypeParameterDescriptor> typeParameters = functionDescriptor.getTypeParameters();
public static <D extends CallableDescriptor> D substituteBounds(@NotNull D functionDescriptor) {
List<TypeParameterDescriptor> typeParameters = functionDescriptor.getTypeParameters();
if (typeParameters.isEmpty()) return functionDescriptor;
// TODO: this does not handle any recursion in the bounds
@@ -95,7 +95,7 @@ public class OverrideResolver {
}
private void generateOverridesAndDelegationInAClass(
@NotNull final MutableClassDescriptor classDescriptor,
@NotNull MutableClassDescriptor classDescriptor,
@NotNull Set<ClassifierDescriptor> processed,
@NotNull Set<MutableClassDescriptor> classesBeingAnalyzed
// to filter out classes such as stdlib and others that come from dependencies
@@ -181,7 +181,7 @@ public class TopDownAnalyzer {
public static void processClassOrObject(
@NotNull Project project,
@NotNull final BindingTrace trace,
@NotNull BindingTrace trace,
@NotNull JetScope outerScope,
@NotNull final DeclarationDescriptor containingDeclaration,
@NotNull JetClassOrObject object
@@ -234,7 +234,7 @@ public class TopDownAnalyzer {
public void analyzeFiles(
@NotNull Collection<JetFile> files,
@NotNull List<AnalyzerScriptParameter> scriptParameters) {
final WritableScope scope = new WritableScopeImpl(
WritableScope scope = new WritableScopeImpl(
JetScope.EMPTY, moduleDescriptor,
new TraceBasedRedeclarationHandler(trace), "Root scope in analyzeNamespace");
@@ -183,11 +183,11 @@ public class TypeHierarchyResolver {
@Nullable
private Collection<JetDeclarationContainer> collectNamespacesAndClassifiers(
@NotNull final JetScope outerScope,
@NotNull final NamespaceLikeBuilder owner,
@NotNull JetScope outerScope,
@NotNull NamespaceLikeBuilder owner,
@NotNull Iterable<? extends PsiElement> declarations
) {
final Collection<JetDeclarationContainer> forDeferredResolve = new ArrayList<JetDeclarationContainer>();
Collection<JetDeclarationContainer> forDeferredResolve = new ArrayList<JetDeclarationContainer>();
ClassifierCollector collector = new ClassifierCollector(outerScope, owner, forDeferredResolve);
@@ -69,11 +69,11 @@ public class TypeResolver {
}
@NotNull
public JetType resolveType(@NotNull final JetScope scope, @NotNull final JetTypeReference typeReference, BindingTrace trace, boolean checkBounds) {
public JetType resolveType(@NotNull JetScope scope, @NotNull JetTypeReference typeReference, BindingTrace trace, boolean checkBounds) {
JetType cachedType = trace.getBindingContext().get(BindingContext.TYPE, typeReference);
if (cachedType != null) return cachedType;
final List<AnnotationDescriptor> annotations = annotationResolver.getResolvedAnnotations(typeReference.getAnnotations(), trace);
List<AnnotationDescriptor> annotations = annotationResolver.getResolvedAnnotations(typeReference.getAnnotations(), trace);
JetTypeElement typeElement = typeReference.getTypeElement();
JetType type = resolveTypeElement(scope, annotations, typeElement, trace, checkBounds);
@@ -276,7 +276,7 @@ public class TypeResolver {
}
private List<JetType> resolveTypes(JetScope scope, List<JetTypeReference> argumentElements, BindingTrace trace, boolean checkBounds) {
final List<JetType> arguments = new ArrayList<JetType>();
List<JetType> arguments = new ArrayList<JetType>();
for (JetTypeReference argumentElement : argumentElements) {
arguments.add(resolveType(scope, argumentElement, trace, checkBounds));
}
@@ -285,7 +285,7 @@ public class TypeResolver {
@NotNull
private List<TypeProjection> resolveTypeProjections(JetScope scope, TypeConstructor constructor, List<JetTypeProjection> argumentElements, BindingTrace trace, boolean checkBounds) {
final List<TypeProjection> arguments = new ArrayList<TypeProjection>();
List<TypeProjection> arguments = new ArrayList<TypeProjection>();
for (int i = 0, argumentElementsSize = argumentElements.size(); i < argumentElementsSize; i++) {
JetTypeProjection argumentElement = argumentElements.get(i);
@@ -113,7 +113,7 @@ public class CallResolver {
@NotNull
public OverloadResolutionResults<FunctionDescriptor> resolveCallWithGivenName(
@NotNull BasicCallResolutionContext context,
@NotNull final JetReferenceExpression functionReference,
@NotNull JetReferenceExpression functionReference,
@NotNull Name name) {
List<ResolutionTask<CallableDescriptor, FunctionDescriptor>> tasks =
TaskPrioritizer.<CallableDescriptor, FunctionDescriptor>computePrioritizedTasks(context, name, functionReference, CallableDescriptorCollectors.FUNCTIONS_AND_VARIABLES);
@@ -140,7 +140,7 @@ public class CallResolver {
List<ResolutionTask<CallableDescriptor, FunctionDescriptor>> prioritizedTasks;
JetExpression calleeExpression = context.call.getCalleeExpression();
final JetReferenceExpression functionReference;
JetReferenceExpression functionReference;
if (calleeExpression instanceof JetSimpleNameExpression) {
JetSimpleNameExpression expression = (JetSimpleNameExpression) calleeExpression;
functionReference = expression;
@@ -262,10 +262,10 @@ public class CallResolver {
private <D extends CallableDescriptor, F extends D> OverloadResolutionResultsImpl<F> doResolveCallOrGetCachedResults(
@NotNull WritableSlice<CallKey, OverloadResolutionResultsImpl<F>> resolutionResultsSlice,
@NotNull final BasicCallResolutionContext context,
@NotNull final List<ResolutionTask<D, F>> prioritizedTasks,
@NotNull BasicCallResolutionContext context,
@NotNull List<ResolutionTask<D, F>> prioritizedTasks,
@NotNull CallTransformer<D, F> callTransformer,
@NotNull final JetReferenceExpression reference
@NotNull JetReferenceExpression reference
) {
PsiElement element = context.call.getCallElement();
OverloadResolutionResultsImpl<F> results = null;
@@ -379,10 +379,10 @@ public class CallResolver {
@NotNull
private <D extends CallableDescriptor, F extends D> OverloadResolutionResultsImpl<F> doResolveCall(
@NotNull final BasicCallResolutionContext context,
@NotNull final List<ResolutionTask<D, F>> prioritizedTasks, // high to low priority
@NotNull BasicCallResolutionContext context,
@NotNull List<ResolutionTask<D, F>> prioritizedTasks, // high to low priority
@NotNull CallTransformer<D, F> callTransformer,
@NotNull final JetReferenceExpression reference) {
@NotNull JetReferenceExpression reference) {
ResolutionDebugInfo.Data debugInfo = ResolutionDebugInfo.create();
context.trace.record(ResolutionDebugInfo.RESOLUTION_DEBUG_INFO, context.call.getCallElement(), debugInfo);
@@ -435,7 +435,7 @@ public class CallResolver {
}
private <D extends CallableDescriptor> OverloadResolutionResults<D> resolveFunctionArguments(
@NotNull final BasicCallResolutionContext context,
@NotNull BasicCallResolutionContext context,
@NotNull OverloadResolutionResults<D> results
) {
if (results.isSingleResult()) {
@@ -173,10 +173,10 @@ public class CallTransformer<D extends CallableDescriptor, F extends D> {
@NotNull
@Override
public Collection<ResolvedCallWithTrace<FunctionDescriptor>> transformCall(@NotNull final CallCandidateResolutionContext<CallableDescriptor> context,
@NotNull CallResolver callResolver, @NotNull final ResolutionTask<CallableDescriptor, FunctionDescriptor> task) {
public Collection<ResolvedCallWithTrace<FunctionDescriptor>> transformCall(@NotNull CallCandidateResolutionContext<CallableDescriptor> context,
@NotNull CallResolver callResolver, @NotNull ResolutionTask<CallableDescriptor, FunctionDescriptor> task) {
final CallableDescriptor descriptor = context.candidateCall.getCandidateDescriptor();
CallableDescriptor descriptor = context.candidateCall.getCandidateDescriptor();
if (descriptor instanceof FunctionDescriptor) {
return super.transformCall(context, callResolver, task);
}
@@ -191,7 +191,7 @@ public class CallTransformer<D extends CallableDescriptor, F extends D> {
Call functionCall = createFunctionCall(context, task, returnType);
final DelegatingBindingTrace variableCallTrace = context.candidateCall.getTrace();
DelegatingBindingTrace variableCallTrace = context.candidateCall.getTrace();
BasicCallResolutionContext basicCallResolutionContext = BasicCallResolutionContext.create(
variableCallTrace, context.scope, functionCall, context.expectedType, context.dataFlowInfo, context.resolveMode, context.expressionPosition);
@@ -327,7 +327,7 @@ public class CandidateResolver {
JetElement statementExpression = JetPsiUtil.getLastStatementInABlock(((JetFunctionLiteralExpression) argumentExpression).getBodyExpression());
if (statementExpression == null) return;
final boolean[] mismatch = new boolean[1];
boolean[] mismatch = new boolean[1];
ObservableBindingTrace errorInterceptingTrace = ExpressionTypingUtils.makeTraceInterceptingTypeMismatch(
traceToResolveFunctionLiteral, statementExpression, mismatch);
CallCandidateResolutionContext<D> newContext =
@@ -87,7 +87,7 @@ public class TaskPrioritizer {
else {
scope = context.scope;
}
final Predicate<ResolutionCandidate<D>> visibleStrategy = new Predicate<ResolutionCandidate<D>>() {
Predicate<ResolutionCandidate<D>> visibleStrategy = new Predicate<ResolutionCandidate<D>>() {
@Override
public boolean apply(@Nullable ResolutionCandidate<D> call) {
if (call == null) return false;
@@ -115,10 +115,10 @@ public class ResolveSessionUtils {
}
public static @NotNull BindingContext resolveToExpression(
@NotNull final ResolveSession resolveSession,
@NotNull ResolveSession resolveSession,
@NotNull JetExpression expression
) {
final DelegatingBindingTrace trace = new DelegatingBindingTrace(
DelegatingBindingTrace trace = new DelegatingBindingTrace(
resolveSession.getBindingContext(), "trace to resolve expression", expression);
JetFile file = (JetFile) expression.getContainingFile();
@@ -158,8 +158,9 @@ public class ResolveSessionUtils {
return trace.getBindingContext();
}
private static void delegationSpecifierAdditionalResolve(final KotlinCodeAnalyzer analyzer,
final JetDelegationSpecifierList specifier, DelegatingBindingTrace trace, JetFile file) {
private static void delegationSpecifierAdditionalResolve(
KotlinCodeAnalyzer analyzer,
JetDelegationSpecifierList specifier, DelegatingBindingTrace trace, JetFile file) {
BodyResolver bodyResolver = createBodyResolverWithEmptyContext(trace, file, analyzer.getModuleConfiguration());
JetClassOrObject classOrObject = (JetClassOrObject) specifier.getParent();
@@ -174,7 +175,7 @@ public class ResolveSessionUtils {
descriptor.getScopeForMemberDeclarationResolution());
}
private static void propertyAdditionalResolve(final ResolveSession resolveSession, final JetProperty jetProperty, DelegatingBindingTrace trace, JetFile file) {
private static void propertyAdditionalResolve(ResolveSession resolveSession, final JetProperty jetProperty, DelegatingBindingTrace trace, JetFile file) {
final JetScope propertyResolutionScope = resolveSession.getInjector().getScopeProvider().getResolutionScopeForDeclaration(
jetProperty);
@@ -65,7 +65,7 @@ public class ScopeProvider {
}
@NotNull
public JetScope getFileScope(final JetFile file) {
public JetScope getFileScope(JetFile file) {
return fileScopes.fun(file);
}
@@ -73,7 +73,7 @@ public abstract class JetClassOrObjectInfo<E extends JetClassOrObject> implement
PsiFile file = element.getContainingFile();
if (file instanceof JetFile) {
JetFile jetFile = (JetFile) file;
final JetNamespaceHeader header = jetFile.getNamespaceHeader();
JetNamespaceHeader header = jetFile.getNamespaceHeader();
return header != null ? header.getFqName() : FqName.ROOT;
}
throw new IllegalArgumentException("Not in a JetFile: " + element);
@@ -145,7 +145,7 @@ public class LazyClassMemberScope extends AbstractLazyMemberScope<LazyClassDescr
}
@Override
protected void getNonDeclaredFunctions(@NotNull Name name, @NotNull final Set<FunctionDescriptor> result) {
protected void getNonDeclaredFunctions(@NotNull Name name, @NotNull Set<FunctionDescriptor> result) {
Collection<FunctionDescriptor> fromSupertypes = Lists.newArrayList();
for (JetType supertype : thisDescriptor.getTypeConstructor().getSupertypes()) {
fromSupertypes.addAll(supertype.getMemberScope().getFunctions(name));
@@ -229,7 +229,7 @@ public class LazyClassMemberScope extends AbstractLazyMemberScope<LazyClassDescr
@Override
@SuppressWarnings("unchecked")
protected void getNonDeclaredProperties(@NotNull Name name, @NotNull final Set<VariableDescriptor> result) {
protected void getNonDeclaredProperties(@NotNull Name name, @NotNull Set<VariableDescriptor> result) {
JetClassLikeInfo classInfo = declarationProvider.getOwnerInfo();
// From primary constructor parameters
@@ -44,7 +44,7 @@ public class LockBasedStorageManager implements StorageManager {
@NotNull
@Override
public <K, V> MemoizedFunctionToNotNull<K, V> createMemoizedFunction(
@NotNull final Function<K, V> compute, @NotNull final ReferenceKind valuesReferenceKind
@NotNull Function<K, V> compute, @NotNull ReferenceKind valuesReferenceKind
) {
ConcurrentMap<K, Object> map = createConcurrentMap(valuesReferenceKind);
return new MapBasedMemoizedFunctionToNotNull<K, V>(lock, map, compute);
@@ -53,7 +53,7 @@ public class LockBasedStorageManager implements StorageManager {
@NotNull
@Override
public <K, V> MemoizedFunctionToNullable<K, V> createMemoizedFunctionWithNullableValues(
@NotNull final Function<K, V> compute, @NotNull final ReferenceKind valuesReferenceKind
@NotNull Function<K, V> compute, @NotNull ReferenceKind valuesReferenceKind
) {
ConcurrentMap<K, Object> map = createConcurrentMap(valuesReferenceKind);
return new MapBasedMemoizedFunction<K, V>(lock, map, compute);
@@ -187,7 +187,7 @@ public class LockBasedStorageManager implements StorageManager {
@Override
@Nullable
public V fun(@NotNull final K input) {
public V fun(@NotNull K input) {
Object value = cache.get(input);
if (value != null) return Nulls.unescape(value);
@@ -54,7 +54,7 @@ public final class JetScopeUtils {
* @return extension descriptors.
*/
public static Collection<CallableDescriptor> getAllExtensions(@NotNull JetScope scope) {
final Set<CallableDescriptor> result = Sets.newHashSet();
Set<CallableDescriptor> result = Sets.newHashSet();
for (DeclarationDescriptor descriptor : scope.getAllDescriptors()) {
if (descriptor instanceof CallableDescriptor) {
@@ -88,7 +88,7 @@ public class CommonSupertypes {
private static Map<TypeConstructor, Set<JetType>> computeCommonRawSupertypes(@NotNull Collection<JetType> types) {
assert !types.isEmpty();
final Map<TypeConstructor, Set<JetType>> constructorToAllInstances = new HashMap<TypeConstructor, Set<JetType>>();
Map<TypeConstructor, Set<JetType>> constructorToAllInstances = new HashMap<TypeConstructor, Set<JetType>>();
Set<TypeConstructor> commonSuperclasses = null;
List<TypeConstructor> order = null;
@@ -97,7 +97,7 @@ public class DescriptorSubstitutor {
@NotNull
public static TypeSubstitutor createUpperBoundsSubstitutor(
@NotNull final List<TypeParameterDescriptor> typeParameters
@NotNull List<TypeParameterDescriptor> typeParameters
) {
Map<TypeConstructor, TypeProjection> mutableSubstitution = Maps.newHashMap();
TypeSubstitutor substitutor = TypeSubstitutor.create(mutableSubstitution);
@@ -128,7 +128,7 @@ public class ExpressionTypingServices {
}
@NotNull
public JetTypeInfo getTypeInfo(@NotNull final JetScope scope, @NotNull JetExpression expression, @NotNull JetType expectedType, @NotNull DataFlowInfo dataFlowInfo, @NotNull BindingTrace trace) {
public JetTypeInfo getTypeInfo(@NotNull JetScope scope, @NotNull JetExpression expression, @NotNull JetType expectedType, @NotNull DataFlowInfo dataFlowInfo, @NotNull BindingTrace trace) {
ExpressionTypingContext context = ExpressionTypingContext.newContext(
this, trace, scope, dataFlowInfo, expectedType, ExpressionPosition.FREE
);
@@ -136,7 +136,7 @@ public class ExpressionTypingServices {
}
@Nullable
public JetType getType(@NotNull final JetScope scope, @NotNull JetExpression expression, @NotNull JetType expectedType, @NotNull DataFlowInfo dataFlowInfo, @NotNull BindingTrace trace) {
public JetType getType(@NotNull JetScope scope, @NotNull JetExpression expression, @NotNull JetType expectedType, @NotNull DataFlowInfo dataFlowInfo, @NotNull BindingTrace trace) {
return getTypeInfo(scope, expression, expectedType, dataFlowInfo, trace).getType();
}
@@ -174,8 +174,8 @@ public class ExpressionTypingServices {
JetExpression bodyExpression = function.getBodyExpression();
if (bodyExpression == null) return;
final boolean blockBody = function.hasBlockBody();
final ExpressionTypingContext newContext =
boolean blockBody = function.hasBlockBody();
ExpressionTypingContext newContext =
blockBody
? context.replaceExpectedType(NO_EXPECTED_TYPE)
: context;
@@ -289,19 +289,19 @@ public class ExpressionTypingServices {
JetTypeInfo result = JetTypeInfo.create(null, context.dataFlowInfo);
for (Iterator<? extends JetElement> iterator = block.iterator(); iterator.hasNext(); ) {
final JetElement statement = iterator.next();
JetElement statement = iterator.next();
if (!(statement instanceof JetExpression)) {
continue;
}
trace.record(STATEMENT, statement);
final JetExpression statementExpression = (JetExpression) statement;
JetExpression statementExpression = (JetExpression) statement;
//TODO constructor assert context.expectedType != FORBIDDEN : ""
if (!iterator.hasNext()) {
if (context.expectedType != NO_EXPECTED_TYPE) {
if (coercionStrategyForLastExpression == CoercionStrategy.COERCION_TO_UNIT && KotlinBuiltIns.getInstance().isUnit(context.expectedType)) {
// This implements coercion to Unit
TemporaryBindingTrace temporaryTraceExpectingUnit = TemporaryBindingTrace.create(trace, "trace to resolve coercion to unit with expected type");
final boolean[] mismatch = new boolean[1];
boolean[] mismatch = new boolean[1];
ObservableBindingTrace errorInterceptingTrace = makeTraceInterceptingTypeMismatch(temporaryTraceExpectingUnit, statementExpression, mismatch);
newContext = createContext(newContext, errorInterceptingTrace, scope, newContext.dataFlowInfo, context.expectedType);
result = blockLevelVisitor.getTypeInfo(statementExpression, newContext, true);
@@ -286,7 +286,7 @@ public class ExpressionTypingUtils {
int index = 0;
List<JetExpression> fakeArguments = Lists.newArrayList();
for (JetType type : argumentTypes) {
final JetReferenceExpression fakeArgument = JetPsiFactory.createSimpleName(context.expressionTypingServices.getProject(), "fakeArgument" + index++);
JetReferenceExpression fakeArgument = JetPsiFactory.createSimpleName(context.expressionTypingServices.getProject(), "fakeArgument" + index++);
fakeArguments.add(fakeArgument);
traceWithFakeArgumentInfo.record(EXPRESSION_TYPE, fakeArgument, type);
}
@@ -336,7 +336,7 @@ public class ExpressionTypingUtils {
) {
int componentIndex = 1;
for (JetMultiDeclarationEntry entry : multiDeclaration.getEntries()) {
final Name componentName = Name.identifier(DescriptorResolver.COMPONENT_FUNCTION_NAME_PREFIX + componentIndex);
Name componentName = Name.identifier(DescriptorResolver.COMPONENT_FUNCTION_NAME_PREFIX + componentIndex);
componentIndex++;
JetType expectedType = getExpectedTypeForComponent(context, entry);
@@ -43,7 +43,7 @@ public class ExpressionTypingVisitorDispatcher extends JetVisitor<JetTypeInfo, E
}
@NotNull
public static ExpressionTypingInternals createForBlock(final WritableScope writableScope) {
public static ExpressionTypingInternals createForBlock(WritableScope writableScope) {
return new ExpressionTypingVisitorDispatcher(writableScope);
}
@@ -129,13 +129,13 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
}
@Override
public JetTypeInfo visitMultiDeclaration(JetMultiDeclaration multiDeclaration, final ExpressionTypingContext context) {
final JetExpression initializer = multiDeclaration.getInitializer();
public JetTypeInfo visitMultiDeclaration(JetMultiDeclaration multiDeclaration, ExpressionTypingContext context) {
JetExpression initializer = multiDeclaration.getInitializer();
if (initializer == null) {
context.trace.report(INITIALIZER_REQUIRED_FOR_MULTIDECLARATION.on(multiDeclaration));
return JetTypeInfo.create(null, context.dataFlowInfo);
}
final ExpressionReceiver expressionReceiver =
ExpressionReceiver expressionReceiver =
ExpressionTypingUtils.getExpressionReceiver(facade, initializer, context.replaceExpectedType(TypeUtils.NO_EXPECTED_TYPE));
DataFlowInfo dataFlowInfo = facade.getTypeInfo(initializer, context).getDataFlowInfo();
if (expressionReceiver == null) {
@@ -327,7 +327,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
}
@Override
public JetTypeInfo visitWhenExpression(final JetWhenExpression expression, ExpressionTypingContext context) {
public JetTypeInfo visitWhenExpression(JetWhenExpression expression, ExpressionTypingContext context) {
return patterns.visitWhenExpression(expression, context, true);
}
@@ -59,16 +59,16 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
}
@Override
public JetTypeInfo visitWhenExpression(final JetWhenExpression expression, ExpressionTypingContext context) {
public JetTypeInfo visitWhenExpression(JetWhenExpression expression, ExpressionTypingContext context) {
return visitWhenExpression(expression, context, false);
}
public JetTypeInfo visitWhenExpression(final JetWhenExpression expression, ExpressionTypingContext contextWithExpectedType, boolean isStatement) {
public JetTypeInfo visitWhenExpression(JetWhenExpression expression, ExpressionTypingContext contextWithExpectedType, boolean isStatement) {
ExpressionTypingContext context = contextWithExpectedType.replaceExpectedType(TypeUtils.NO_EXPECTED_TYPE);
// TODO :change scope according to the bound value in the when header
final JetExpression subjectExpression = expression.getSubjectExpression();
JetExpression subjectExpression = expression.getSubjectExpression();
final JetType subjectType;
JetType subjectType;
if (subjectExpression == null) {
subjectType = ErrorUtils.createErrorType("Unknown type");
}
@@ -77,7 +77,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
subjectType = typeInfo.getType();
context = context.replaceDataFlowInfo(typeInfo.getDataFlowInfo());
}
final DataFlowValue subjectDataFlowValue = subjectExpression != null
DataFlowValue subjectDataFlowValue = subjectExpression != null
? DataFlowValueFactory.INSTANCE.createDataFlowValue(subjectExpression, subjectType, context.trace.getBindingContext())
: DataFlowValue.NULL;
@@ -285,7 +285,7 @@ public class DescriptorRendererImpl implements DescriptorRenderer {
}
builder.append(" ").append(renderMessage("defined in")).append(" ");
final DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
if (containingDeclaration != null) {
FqNameUnsafe fqName = DescriptorUtils.getFQName(containingDeclaration);
builder.append(FqName.ROOT.equalsTo(fqName) ? "root package" : renderFqName(fqName));
@@ -30,7 +30,7 @@ public final class QualifiedNamesUtil {
private QualifiedNamesUtil() {
}
public static boolean isSubpackageOf(@NotNull final FqName subpackageName, @NotNull FqName packageName) {
public static boolean isSubpackageOf(@NotNull FqName subpackageName, @NotNull FqName packageName) {
if (subpackageName.equals(packageName)) {
return true;
}
@@ -45,7 +45,7 @@ public final class QualifiedNamesUtil {
return (subpackageNameStr.startsWith(packageNameStr) && subpackageNameStr.charAt(packageNameStr.length()) == '.');
}
public static boolean isOneSegmentFQN(@NotNull final String fqn) {
public static boolean isOneSegmentFQN(@NotNull String fqn) {
if (fqn.isEmpty()) {
return false;
}
@@ -114,7 +114,7 @@ public final class QualifiedNamesUtil {
return null;
}
final String nextSegment = getFirstSegment(tail(fqn, fullFQN));
String nextSegment = getFirstSegment(tail(fqn, fullFQN));
if (isOneSegmentFQN(nextSegment)) {
return combine(fqn, Name.guess(nextSegment));
@@ -26,7 +26,7 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase {
@Test
public void compileAndRunHelloApp() throws Exception {
final String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar";
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar";
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-src", "hello.kt", "-jar", jar));
runJava("hello.run", "-cp", jar, "Hello.HelloPackage");
@@ -34,7 +34,7 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase {
@Test
public void compileAndRunModule() throws Exception {
final String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "smoke.jar";
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "smoke.jar";
assertEquals("compilation failed", 0, runCompiler("Smoke.compile", "-module", "Smoke.kts", "-jar", jar));
runJava("Smoke.run", "-cp", jar + File.pathSeparator + getKotlinRuntimePath(), "Smoke.SmokePackage", "1", "2", "3");
@@ -42,14 +42,14 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase {
@Test
public void compilationFailed() throws Exception {
final String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "smoke.jar";
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "smoke.jar";
runCompiler("hello.compile", "-src", "hello.kt", "-jar", jar);
}
@Test
public void syntaxErrors() throws Exception {
final String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "smoke.jar";
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "smoke.jar";
runCompiler("test.compile", "-src", "test.kt", "-jar", jar);
}
@@ -56,7 +56,7 @@ public abstract class KotlinIntegrationTestBase {
public TestRule watchman = new TestWatcher() {
@Override
protected void starting(Description description) {
final File baseTestDataDir =
File baseTestDataDir =
new File(getKotlinProjectHome(), "compiler" + File.separator + "integration-tests" + File.separator + "testData");
testDataDir = new File(baseTestDataDir, description.getMethodName());
}
@@ -64,9 +64,9 @@ public abstract class KotlinIntegrationTestBase {
};
protected int runCompiler(String logName, String... arguments) throws Exception {
final File lib = getCompilerLib();
File lib = getCompilerLib();
final String classpath = lib.getAbsolutePath() + File.separator + "kotlin-compiler.jar";
String classpath = lib.getAbsolutePath() + File.separator + "kotlin-compiler.jar";
Collection<String> javaArgs = new ArrayList<String>();
javaArgs.add("-cp");
@@ -97,7 +97,7 @@ public abstract class KotlinIntegrationTestBase {
}
private static String replacePath(String content, File path, String pathId) {
final String absolutePath = path.getAbsolutePath();
String absolutePath = path.getAbsolutePath();
return content
.replace(absolutePath + "/", pathId + "/")
@@ -113,17 +113,17 @@ public abstract class KotlinIntegrationTestBase {
}
protected void check(String baseName, String content) throws IOException {
final File actualFile = new File(testDataDir, baseName + ".actual");
final File expectedFile = new File(testDataDir, baseName + ".expected");
File actualFile = new File(testDataDir, baseName + ".actual");
File expectedFile = new File(testDataDir, baseName + ".expected");
final String normalizedContent = normalizeOutput(content);
String normalizedContent = normalizeOutput(content);
if (!expectedFile.isFile()) {
Files.write(normalizedContent, actualFile, Charsets.UTF_8);
fail("No .expected file " + expectedFile);
}
else {
final String goldContent = FileUtil.loadFile(expectedFile, CharsetToolkit.UTF8, true);
String goldContent = FileUtil.loadFile(expectedFile, CharsetToolkit.UTF8, true);
try {
assertEquals(goldContent, normalizedContent);
actualFile.delete();
@@ -135,7 +135,7 @@ public abstract class KotlinIntegrationTestBase {
}
}
protected static int runProcess(final GeneralCommandLine commandLine, final StringBuilder executionLog) throws ExecutionException {
protected static int runProcess(GeneralCommandLine commandLine, StringBuilder executionLog) throws ExecutionException {
OSProcessHandler handler =
new OSProcessHandler(commandLine.createProcess(), commandLine.getCommandLineString(), commandLine.getCharset());
@@ -175,23 +175,23 @@ public abstract class KotlinIntegrationTestBase {
}
protected static File getJavaRuntime() {
final File javaHome = new File(System.getProperty("java.home"));
final String javaExe = SystemInfo.isWindows ? "java.exe" : "java";
File javaHome = new File(System.getProperty("java.home"));
String javaExe = SystemInfo.isWindows ? "java.exe" : "java";
final File runtime = new File(javaHome, "bin" + File.separator + javaExe);
File runtime = new File(javaHome, "bin" + File.separator + javaExe);
assertTrue("no java runtime at " + runtime, runtime.isFile());
return runtime;
}
protected static File getCompilerLib() {
final File file = new File(getKotlinProjectHome(), "dist" + File.separator + "kotlinc" + File.separator + "lib");
File file = new File(getKotlinProjectHome(), "dist" + File.separator + "kotlinc" + File.separator + "lib");
assertTrue("no kotlin compiler lib at " + file, file.isDirectory());
return file;
}
protected static String getKotlinRuntimePath() {
final File file = new File(getCompilerLib(), "kotlin-runtime.jar");
File file = new File(getCompilerLib(), "kotlin-runtime.jar");
assertTrue("no kotlin runtime at " + file, file.isFile());
return file.getAbsolutePath();
}

Some files were not shown because too many files have changed in this diff Show More