rename Jet* classes to Kt*

This commit is contained in:
Dmitry Jemerov
2015-10-19 18:43:17 +02:00
parent 660972b12d
commit 49033e0002
1965 changed files with 23732 additions and 23757 deletions
@@ -29,8 +29,8 @@ import org.jetbrains.kotlin.codegen.CodegenTestFiles;
import org.jetbrains.kotlin.codegen.GenerationUtils;
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime;
import org.jetbrains.kotlin.generators.tests.generator.TestGeneratorUtil;
import org.jetbrains.kotlin.idea.JetFileType;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.idea.KotlinFileType;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.test.ConfigurationKind;
import org.jetbrains.kotlin.test.JetTestUtils;
import org.jetbrains.kotlin.test.TestJdkKind;
@@ -133,7 +133,7 @@ public class CodegenTestsOnAndroidGenerator extends UsefulTestCase {
private class FilesWriter {
private final boolean isFullJdk;
public List<JetFile> files = new ArrayList<JetFile>();
public List<KtFile> files = new ArrayList<KtFile>();
private KotlinCoreEnvironment environment;
private FilesWriter(boolean isFullJdk) {
@@ -161,11 +161,11 @@ public class CodegenTestsOnAndroidGenerator extends UsefulTestCase {
public void writeFilesOnDisk() {
writeFiles(files);
files = new ArrayList<JetFile>();
files = new ArrayList<KtFile>();
environment = createEnvironment(isFullJdk);
}
private void writeFiles(List<JetFile> filesToCompile) {
private void writeFiles(List<KtFile> filesToCompile) {
System.out.println("Generating " + filesToCompile.size() + " files...");
OutputFileCollection outputFiles;
try {
@@ -207,7 +207,7 @@ public class CodegenTestsOnAndroidGenerator extends UsefulTestCase {
processFiles(printer, listFiles, holderFull, holderMock);
}
}
else if (!FileUtilRt.getExtension(file.getName()).equals(JetFileType.INSTANCE.getDefaultExtension())) {
else if (!FileUtilRt.getExtension(file.getName()).equals(KotlinFileType.INSTANCE.getDefaultExtension())) {
// skip non kotlin files
}
else {
@@ -32,9 +32,9 @@ import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilKt;
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.TypeUtils;
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
import java.util.*;
@@ -63,9 +63,9 @@ public class CodegenUtil {
}
@Nullable
public static PropertyDescriptor getDelegatePropertyIfAny(JetExpression expression, ClassDescriptor classDescriptor, BindingContext bindingContext) {
public static PropertyDescriptor getDelegatePropertyIfAny(KtExpression expression, ClassDescriptor classDescriptor, BindingContext bindingContext) {
PropertyDescriptor propertyDescriptor = null;
if (expression instanceof JetSimpleNameExpression) {
if (expression instanceof KtSimpleNameExpression) {
ResolvedCall<?> call = CallUtilKt.getResolvedCall(expression, bindingContext);
if (call != null) {
CallableDescriptor callResultingDescriptor = call.getResultingDescriptor();
@@ -140,8 +140,8 @@ public class CodegenUtil {
}
@NotNull
public static ClassDescriptor getSuperClassByDelegationSpecifier(@NotNull JetDelegationSpecifier specifier, @NotNull BindingContext bindingContext) {
JetType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference());
public static ClassDescriptor getSuperClassByDelegationSpecifier(@NotNull KtDelegationSpecifier specifier, @NotNull BindingContext bindingContext) {
KtType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference());
assert superType != null : "superType should not be null: " + specifier.getText();
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
@@ -164,16 +164,16 @@ public class CodegenUtil {
return true;
}
private static boolean rawTypeMatches(JetType type, ClassifierDescriptor classifier) {
private static boolean rawTypeMatches(KtType type, ClassifierDescriptor classifier) {
return type.getConstructor().equals(classifier.getTypeConstructor());
}
public static boolean isEnumValueOfMethod(@NotNull FunctionDescriptor functionDescriptor) {
List<ValueParameterDescriptor> methodTypeParameters = functionDescriptor.getValueParameters();
JetType nullableString = TypeUtils.makeNullable(DescriptorUtilsKt.getBuiltIns(functionDescriptor).getStringType());
KtType nullableString = TypeUtils.makeNullable(DescriptorUtilsKt.getBuiltIns(functionDescriptor).getStringType());
return DescriptorUtils.ENUM_VALUE_OF.equals(functionDescriptor.getName())
&& methodTypeParameters.size() == 1
&& JetTypeChecker.DEFAULT.isSubtypeOf(methodTypeParameters.get(0).getType(), nullableString);
&& KotlinTypeChecker.DEFAULT.isSubtypeOf(methodTypeParameters.get(0).getType(), nullableString);
}
public static boolean isEnumValuesProperty(@NotNull VariableDescriptor propertyDescriptor) {
@@ -183,8 +183,8 @@ public class CodegenUtil {
@Nullable
public static Integer getLineNumberForElement(@NotNull PsiElement statement, boolean markEndOffset) {
PsiFile file = statement.getContainingFile();
if (file instanceof JetFile) {
if (JetPsiFactoryKt.getDoNotAnalyze((JetFile) file) != null) {
if (file instanceof KtFile) {
if (KtPsiFactoryKt.getDoNotAnalyze((KtFile) file) != null) {
return null;
}
}
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.MemberComparator
import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.isDynamic
import org.jetbrains.kotlin.utils.keysToMapExceptNulls
import java.util.Comparator
@@ -38,7 +38,7 @@ public object CodegenUtilKt {
public fun getDelegates(
descriptor: ClassDescriptor,
toTrait: ClassDescriptor,
delegateExpressionType: JetType? = null
delegateExpressionType: KtType? = null
): Map<CallableMemberDescriptor, CallableDescriptor> {
if (delegateExpressionType?.isDynamic() ?: false) return mapOf();
@@ -22,9 +22,9 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.JetClass;
import org.jetbrains.kotlin.psi.JetClassOrObject;
import org.jetbrains.kotlin.psi.JetParameter;
import org.jetbrains.kotlin.psi.KtClass;
import org.jetbrains.kotlin.psi.KtClassOrObject;
import org.jetbrains.kotlin.psi.KtParameter;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.BindingContextUtils;
import org.jetbrains.kotlin.resolve.OverrideResolver;
@@ -39,12 +39,12 @@ import java.util.List;
* changed here with the platform backends adopted.
*/
public abstract class DataClassMethodGenerator {
private final JetClassOrObject declaration;
private final KtClassOrObject declaration;
private final BindingContext bindingContext;
private final ClassDescriptor classDescriptor;
private final KotlinBuiltIns builtIns;
public DataClassMethodGenerator(JetClassOrObject declaration, BindingContext bindingContext) {
public DataClassMethodGenerator(KtClassOrObject declaration, BindingContext bindingContext) {
this.declaration = declaration;
this.bindingContext = bindingContext;
this.classDescriptor = BindingContextUtils.getNotNull(bindingContext, BindingContext.CLASS, declaration);
@@ -66,7 +66,7 @@ public abstract class DataClassMethodGenerator {
protected abstract void generateComponentFunction(@NotNull FunctionDescriptor function, @NotNull ValueParameterDescriptor parameter);
protected abstract void generateCopyFunction(@NotNull FunctionDescriptor function, @NotNull List<JetParameter> constructorParameters);
protected abstract void generateCopyFunction(@NotNull FunctionDescriptor function, @NotNull List<KtParameter> constructorParameters);
protected abstract void generateToStringMethod(@NotNull FunctionDescriptor function, @NotNull List<PropertyDescriptor> properties);
@@ -93,7 +93,7 @@ public abstract class DataClassMethodGenerator {
}
}
private void generateCopyFunctionForDataClasses(List<JetParameter> constructorParameters) {
private void generateCopyFunctionForDataClasses(List<KtParameter> constructorParameters) {
FunctionDescriptor copyFunction = bindingContext.get(BindingContext.DATA_CLASS_COPY_FUNCTION, classDescriptor);
if (copyFunction != null) {
generateCopyFunction(copyFunction, constructorParameters);
@@ -123,7 +123,7 @@ public abstract class DataClassMethodGenerator {
private List<PropertyDescriptor> getDataProperties() {
List<PropertyDescriptor> result = Lists.newArrayList();
for (JetParameter parameter : getPrimaryConstructorParameters()) {
for (KtParameter parameter : getPrimaryConstructorParameters()) {
if (parameter.hasValOrVar()) {
result.add(bindingContext.get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, parameter));
}
@@ -132,8 +132,8 @@ public abstract class DataClassMethodGenerator {
}
@NotNull
private List<JetParameter> getPrimaryConstructorParameters() {
if (declaration instanceof JetClass) {
private List<KtParameter> getPrimaryConstructorParameters() {
if (declaration instanceof KtClass) {
return declaration.getPrimaryConstructorParameters();
}
return Collections.emptyList();
@@ -19,12 +19,12 @@ package org.jetbrains.kotlin.codegen;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor;
import org.jetbrains.kotlin.psi.JetSuperExpression;
import org.jetbrains.kotlin.psi.KtSuperExpression;
public interface AccessorForCallableDescriptor<T extends CallableMemberDescriptor> {
@NotNull
T getCalleeDescriptor();
@Nullable
JetSuperExpression getSuperCallExpression();
KtSuperExpression getSuperCallExpression();
}
@@ -18,14 +18,14 @@ package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.JetSuperExpression
import org.jetbrains.kotlin.psi.KtSuperExpression
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.KtType
public class AccessorForConstructorDescriptor(
private val calleeDescriptor: ConstructorDescriptor,
containingDeclaration: DeclarationDescriptor,
private val superCallExpression: JetSuperExpression?
private val superCallExpression: KtSuperExpression?
) : AbstractAccessorForFunctionDescriptor(containingDeclaration, Name.special("<init>")),
ConstructorDescriptor,
AccessorForCallableDescriptor<ConstructorDescriptor> {
@@ -35,9 +35,9 @@ public class AccessorForConstructorDescriptor(
override fun isPrimary(): Boolean = false
override fun getReturnType(): JetType = super.getReturnType()!!
override fun getReturnType(): KtType = super.getReturnType()!!
override fun getSuperCallExpression(): JetSuperExpression? = superCallExpression
override fun getSuperCallExpression(): KtSuperExpression? = superCallExpression
init {
initialize(
@@ -20,18 +20,18 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.JetSuperExpression;
import org.jetbrains.kotlin.psi.KtSuperExpression;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.annotations.AnnotationUtilKt;
public class AccessorForFunctionDescriptor extends AbstractAccessorForFunctionDescriptor implements AccessorForCallableDescriptor<FunctionDescriptor> {
private final FunctionDescriptor calleeDescriptor;
private final JetSuperExpression superCallExpression;
private final KtSuperExpression superCallExpression;
public AccessorForFunctionDescriptor(
@NotNull FunctionDescriptor descriptor,
@NotNull DeclarationDescriptor containingDeclaration,
@Nullable JetSuperExpression superCallExpression,
@Nullable KtSuperExpression superCallExpression,
@NotNull String nameSuffix
) {
super(containingDeclaration,
@@ -57,7 +57,7 @@ public class AccessorForFunctionDescriptor extends AbstractAccessorForFunctionDe
}
@Override
public JetSuperExpression getSuperCallExpression() {
public KtSuperExpression getSuperCallExpression() {
return superCallExpression;
}
}
@@ -20,13 +20,13 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
public class AccessorForPropertyBackingFieldInOuterClass extends AccessorForPropertyDescriptor {
public AccessorForPropertyBackingFieldInOuterClass(
@NotNull PropertyDescriptor property,
@NotNull DeclarationDescriptor containingDeclaration,
@Nullable JetType delegationType,
@Nullable KtType delegationType,
@NotNull String nameSuffix
) {
super(property, delegationType != null ? delegationType : property.getType(), null, null, containingDeclaration, null, nameSuffix);
@@ -25,21 +25,21 @@ import org.jetbrains.kotlin.descriptors.impl.PropertyGetterDescriptorImpl;
import org.jetbrains.kotlin.descriptors.impl.PropertySetterDescriptorImpl;
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.JetSuperExpression;
import org.jetbrains.kotlin.psi.KtSuperExpression;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import java.util.Collections;
public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl implements AccessorForCallableDescriptor<PropertyDescriptor> {
private final PropertyDescriptor calleeDescriptor;
private final JetSuperExpression superCallExpression;
private final KtSuperExpression superCallExpression;
@NotNull private final String nameSuffix;
public AccessorForPropertyDescriptor(
@NotNull PropertyDescriptor property,
@NotNull DeclarationDescriptor containingDeclaration,
@Nullable JetSuperExpression superCallExpression,
@Nullable KtSuperExpression superCallExpression,
@NotNull String nameSuffix
) {
this(property, property.getType(), DescriptorUtils.getReceiverParameterType(property.getExtensionReceiverParameter()),
@@ -48,11 +48,11 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl implem
protected AccessorForPropertyDescriptor(
@NotNull PropertyDescriptor original,
@NotNull JetType propertyType,
@Nullable JetType receiverType,
@NotNull KtType propertyType,
@Nullable KtType receiverType,
@Nullable ReceiverParameterDescriptor dispatchReceiverParameter,
@NotNull DeclarationDescriptor containingDeclaration,
@Nullable JetSuperExpression superCallExpression,
@Nullable KtSuperExpression superCallExpression,
@NotNull String nameSuffix
) {
super(containingDeclaration, null, Annotations.Companion.getEMPTY(), Modality.FINAL, Visibilities.LOCAL,
@@ -84,7 +84,7 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl implem
@Nullable
@Override
public JetSuperExpression getSuperCallExpression() {
public KtSuperExpression getSuperCallExpression() {
return ((AccessorForPropertyDescriptor) getCorrespondingProperty()).getSuperCallExpression();
}
@@ -108,7 +108,7 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl implem
@Nullable
@Override
public JetSuperExpression getSuperCallExpression() {
public KtSuperExpression getSuperCallExpression() {
return ((AccessorForPropertyDescriptor) getCorrespondingProperty()).getSuperCallExpression();
}
}
@@ -120,7 +120,7 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl implem
}
@Override
public JetSuperExpression getSuperCallExpression() {
public KtSuperExpression getSuperCallExpression() {
return superCallExpression;
}
@@ -157,7 +157,7 @@ public abstract class AnnotationCodegen {
return false;
}
private void generateNullabilityAnnotation(@Nullable JetType type, @NotNull Set<String> annotationDescriptorsAlreadyPresent) {
private void generateNullabilityAnnotation(@Nullable KtType type, @NotNull Set<String> annotationDescriptorsAlreadyPresent) {
if (type == null) return;
if (isBareTypeParameterWithNullableUpperBound(type)) {
@@ -253,12 +253,12 @@ public abstract class AnnotationCodegen {
}
}
private static boolean isBareTypeParameterWithNullableUpperBound(@NotNull JetType type) {
private static boolean isBareTypeParameterWithNullableUpperBound(@NotNull KtType type) {
ClassifierDescriptor classifier = type.getConstructor().getDeclarationDescriptor();
return !type.isMarkedNullable() && classifier instanceof TypeParameterDescriptor && TypeUtils.hasNullableSuperType(type);
}
public void generateAnnotationDefaultValue(@NotNull ConstantValue<?> value, @NotNull JetType expectedType) {
public void generateAnnotationDefaultValue(@NotNull ConstantValue<?> value, @NotNull KtType expectedType) {
AnnotationVisitor visitor = visitAnnotation(null, false); // Parameters are unimportant
genCompileTimeValue(null, value, visitor);
visitor.visitEnd();
@@ -418,7 +418,7 @@ public abstract class AnnotationCodegen {
for (ConstantValue<?> value : values) {
if (value instanceof EnumValue) {
ClassDescriptor enumEntry = ((EnumValue) value).getValue();
JetType classObjectType = DescriptorUtilsKt.getClassObjectType(enumEntry);
KtType classObjectType = DescriptorUtilsKt.getClassObjectType(enumEntry);
if (classObjectType != null) {
if ("java/lang/annotation/ElementType".equals(typeMapper.mapType(classObjectType).getInternalName())) {
result.add(ElementType.valueOf(enumEntry.getName().asString()));
@@ -446,7 +446,7 @@ public abstract class AnnotationCodegen {
ConstantValue<?> compileTimeConstant = valueArguments.iterator().next();
if (compileTimeConstant instanceof EnumValue) {
ClassDescriptor enumEntry = ((EnumValue) compileTimeConstant).getValue();
JetType classObjectType = DescriptorUtilsKt.getClassObjectType(enumEntry);
KtType classObjectType = DescriptorUtilsKt.getClassObjectType(enumEntry);
if (classObjectType != null) {
if ("java/lang/annotation/RetentionPolicy".equals(typeMapper.mapType(classObjectType).getInternalName())) {
return RetentionPolicy.valueOf(enumEntry.getName().asString());
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.state.JetTypeMapper;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.jvm.RuntimeAssertionInfo;
import org.jetbrains.kotlin.lexer.JetTokens;
import org.jetbrains.kotlin.lexer.KtTokens;
import org.jetbrains.kotlin.load.java.JavaVisibilities;
import org.jetbrains.kotlin.load.java.JvmAnnotationNames;
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor;
@@ -52,7 +52,7 @@ import org.jetbrains.kotlin.serialization.DescriptorSerializer;
import org.jetbrains.kotlin.serialization.jvm.BitEncoding;
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor;
import org.jetbrains.kotlin.types.FlexibleTypesKt;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.org.objectweb.asm.*;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import org.jetbrains.org.objectweb.asm.commons.Method;
@@ -432,7 +432,7 @@ public class AsmUtil {
allFields.add(Pair.create(CAPTURED_THIS_FIELD, typeMapper.mapType(captureThis)));
}
JetType captureReceiverType = closure.getCaptureReceiverType();
KtType captureReceiverType = closure.getCaptureReceiverType();
if (captureReceiverType != null) {
allFields.add(Pair.create(CAPTURED_RECEIVER_FIELD, typeMapper.mapType(captureReceiverType)));
}
@@ -558,7 +558,7 @@ public class AsmUtil {
right.put(rightType, v);
genAreEqualCall(v);
if (opToken == JetTokens.EXCLEQ || opToken == JetTokens.EXCLEQEQEQ) {
if (opToken == KtTokens.EXCLEQ || opToken == KtTokens.EXCLEQEQEQ) {
genInvertBoolean(v);
}
return Unit.INSTANCE$;
@@ -638,7 +638,7 @@ public class AsmUtil {
@NotNull CallableDescriptor parameter,
@NotNull String name
) {
JetType type = parameter.getReturnType();
KtType type = parameter.getReturnType();
if (type == null || isNullableType(type)) return;
int index = frameMap.getIndex(parameter);
@@ -672,7 +672,7 @@ public class AsmUtil {
if (!isDeclaredInJava(descriptor)) return false;
JetType type = descriptor.getReturnType();
KtType type = descriptor.getReturnType();
if (type == null || isNullableType(FlexibleTypesKt.lowerIfFlexible(type))) return false;
Type asmType = state.getTypeMapper().mapReturnType(descriptor);
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen
import com.intellij.psi.tree.IElementType
import org.jetbrains.kotlin.codegen.pseudoInsns.fakeAlwaysFalseIfeq
import org.jetbrains.kotlin.codegen.pseudoInsns.fakeAlwaysTrueIfeq
import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.org.objectweb.asm.Label
import org.jetbrains.org.objectweb.asm.Opcodes.*
import org.jetbrains.org.objectweb.asm.Type
@@ -214,7 +214,7 @@ class NumberCompare(
override fun patchOpcode(opcode: Int, v: InstructionAdapter): Int {
when (operandType) {
Type.FLOAT_TYPE, Type.DOUBLE_TYPE -> {
if (opToken == JetTokens.GT || opToken == JetTokens.GTEQ) {
if (opToken == KtTokens.GT || opToken == KtTokens.GTEQ) {
v.cmpl(operandType)
}
else {
@@ -234,12 +234,12 @@ class NumberCompare(
companion object {
fun getNumberCompareOpcode(opToken: IElementType): Int {
return when (opToken) {
JetTokens.EQEQ, JetTokens.EQEQEQ -> IFNE
JetTokens.EXCLEQ, JetTokens.EXCLEQEQEQ -> IFEQ
JetTokens.GT -> IFLE
JetTokens.GTEQ -> IFLT
JetTokens.LT -> IFGE
JetTokens.LTEQ -> IFGT
KtTokens.EQEQ, KtTokens.EQEQEQ -> IFNE
KtTokens.EXCLEQ, KtTokens.EXCLEQEQEQ -> IFEQ
KtTokens.GT -> IFLE
KtTokens.GTEQ -> IFLT
KtTokens.LT -> IFGE
KtTokens.LTEQ -> IFGT
else -> {
throw UnsupportedOperationException("Don't know how to generate this condJump: " + opToken)
}
@@ -258,8 +258,8 @@ class ObjectCompare(
companion object {
fun getObjectCompareOpcode(opToken: IElementType): Int {
return when (opToken) {
JetTokens.EQEQEQ -> IF_ACMPNE
JetTokens.EXCLEQEQEQ -> IF_ACMPEQ
KtTokens.EQEQEQ -> IF_ACMPNE
KtTokens.EXCLEQEQEQ -> IF_ACMPEQ
else -> throw UnsupportedOperationException("don't know how to generate this condjump")
}
}
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.codegen;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor;
import org.jetbrains.kotlin.psi.JetExpression;
import org.jetbrains.kotlin.psi.KtExpression;
import org.jetbrains.kotlin.psi.ValueArgument;
import org.jetbrains.kotlin.resolve.calls.model.*;
import org.jetbrains.org.objectweb.asm.Type;
@@ -68,7 +68,7 @@ public class CallBasedArgumentGenerator extends ArgumentGenerator {
Type type = valueParameterTypes.get(i);
ValueArgument valueArgument = argument.getValueArgument();
assert valueArgument != null;
JetExpression argumentExpression = valueArgument.getArgumentExpression();
KtExpression argumentExpression = valueArgument.getArgumentExpression();
assert argumentExpression != null : valueArgument.asElement().getText();
callGenerator.genValueAndPut(parameter, argumentExpression, type, i);
}
@@ -17,7 +17,7 @@
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.psi.JetExpression
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.org.objectweb.asm.Type
@@ -57,7 +57,7 @@ abstract class CallGenerator {
override fun genValueAndPut(
valueParameterDescriptor: ValueParameterDescriptor,
argumentExpression: JetExpression,
argumentExpression: KtExpression,
parameterType: Type,
parameterIndex: Int) {
val value = codegen.gen(argumentExpression)
@@ -118,7 +118,7 @@ abstract class CallGenerator {
abstract fun genValueAndPut(
valueParameterDescriptor: ValueParameterDescriptor,
argumentExpression: JetExpression,
argumentExpression: KtExpression,
parameterType: Type,
parameterIndex: Int)
@@ -31,13 +31,13 @@ import java.util.List;
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.enumEntryNeedSubclass;
public abstract class ClassBodyCodegen extends MemberCodegen<JetClassOrObject> {
protected final JetClassOrObject myClass;
public abstract class ClassBodyCodegen extends MemberCodegen<KtClassOrObject> {
protected final KtClassOrObject myClass;
protected final OwnerKind kind;
protected final ClassDescriptor descriptor;
protected ClassBodyCodegen(
@NotNull JetClassOrObject myClass,
@NotNull KtClassOrObject myClass,
@NotNull ClassContext context,
@NotNull ClassBuilder v,
@NotNull GenerationState state,
@@ -53,14 +53,14 @@ public abstract class ClassBodyCodegen extends MemberCodegen<JetClassOrObject> {
protected void generateBody() {
if (kind != OwnerKind.DEFAULT_IMPLS) {
//generate nested classes first and only then generate class body. It necessary to access to nested CodegenContexts
for (JetDeclaration declaration : myClass.getDeclarations()) {
for (KtDeclaration declaration : myClass.getDeclarations()) {
if (shouldProcessFirst(declaration)) {
generateDeclaration(declaration);
}
}
}
for (JetDeclaration declaration : myClass.getDeclarations()) {
for (KtDeclaration declaration : myClass.getDeclarations()) {
if (!shouldProcessFirst(declaration)) {
generateDeclaration(declaration);
}
@@ -92,26 +92,26 @@ public abstract class ClassBodyCodegen extends MemberCodegen<JetClassOrObject> {
generatePrimaryConstructorProperties();
}
private static boolean shouldProcessFirst(JetDeclaration declaration) {
return !(declaration instanceof JetProperty || declaration instanceof JetNamedFunction);
private static boolean shouldProcessFirst(KtDeclaration declaration) {
return !(declaration instanceof KtProperty || declaration instanceof KtNamedFunction);
}
protected void generateDeclaration(JetDeclaration declaration) {
if (declaration instanceof JetProperty || declaration instanceof JetNamedFunction) {
protected void generateDeclaration(KtDeclaration declaration) {
if (declaration instanceof KtProperty || declaration instanceof KtNamedFunction) {
genFunctionOrProperty(declaration);
}
else if (declaration instanceof JetClassOrObject) {
if (declaration instanceof JetEnumEntry && !enumEntryNeedSubclass(bindingContext, (JetEnumEntry) declaration)) {
else if (declaration instanceof KtClassOrObject) {
if (declaration instanceof KtEnumEntry && !enumEntryNeedSubclass(bindingContext, (KtEnumEntry) declaration)) {
return;
}
genClassOrObject((JetClassOrObject) declaration);
genClassOrObject((KtClassOrObject) declaration);
}
}
private void generatePrimaryConstructorProperties() {
boolean isAnnotation = descriptor.getKind() == ClassKind.ANNOTATION_CLASS;
for (JetParameter p : getPrimaryConstructorParameters()) {
for (KtParameter p : getPrimaryConstructorParameters()) {
if (p.hasValOrVar()) {
PropertyDescriptor propertyDescriptor = bindingContext.get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, p);
if (propertyDescriptor != null) {
@@ -127,9 +127,9 @@ public abstract class ClassBodyCodegen extends MemberCodegen<JetClassOrObject> {
}
@NotNull
protected List<JetParameter> getPrimaryConstructorParameters() {
if (myClass instanceof JetClass) {
return ((JetClass) myClass).getPrimaryConstructorParameters();
protected List<KtParameter> getPrimaryConstructorParameters() {
if (myClass instanceof KtClass) {
return ((KtClass) myClass).getPrimaryConstructorParameters();
}
return Collections.emptyList();
}
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.load.java.JvmAbi;
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils;
import org.jetbrains.kotlin.load.kotlin.PackageParts;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
import org.jetbrains.kotlin.serialization.jvm.JvmPackageTable;
import org.jetbrains.org.objectweb.asm.Type;
@@ -223,7 +223,7 @@ public class ClassFileFactory implements OutputFileCollection {
}
@NotNull
public PackageCodegen forPackage(@NotNull FqName fqName, @NotNull Collection<JetFile> files) {
public PackageCodegen forPackage(@NotNull FqName fqName, @NotNull Collection<KtFile> files) {
assert !isDone : "Already done!";
PackageCodegen codegen = package2codegen.get(fqName);
if (codegen == null) {
@@ -235,7 +235,7 @@ public class ClassFileFactory implements OutputFileCollection {
}
@NotNull
public MultifileClassCodegen forMultifileClass(@NotNull FqName facadeFqName, @NotNull Collection<JetFile> files) {
public MultifileClassCodegen forMultifileClass(@NotNull FqName facadeFqName, @NotNull Collection<KtFile> files) {
assert !isDone : "Already done!";
MultifileClassCodegen codegen = multifileClass2codegen.get(facadeFqName);
if (codegen == null) {
@@ -341,7 +341,7 @@ public class ClassFileFactory implements OutputFileCollection {
}
@TestOnly
public List<JetFile> getInputFiles() {
public List<KtFile> getInputFiles() {
return state.getFiles();
}
}
@@ -35,15 +35,15 @@ import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.load.java.JvmAbi;
import org.jetbrains.kotlin.load.java.JvmAnnotationNames;
import org.jetbrains.kotlin.psi.JetElement;
import org.jetbrains.kotlin.psi.KtElement;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.KtScope;
import org.jetbrains.kotlin.serialization.DescriptorSerializer;
import org.jetbrains.kotlin.serialization.ProtoBuf;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.util.OperatorNameConventions;
import org.jetbrains.kotlin.utils.FunctionsKt;
import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
@@ -66,12 +66,12 @@ import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.*;
import static org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin.NO_ORIGIN;
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
public class ClosureCodegen extends MemberCodegen<JetElement> {
public class ClosureCodegen extends MemberCodegen<KtElement> {
private final FunctionDescriptor funDescriptor;
private final ClassDescriptor classDescriptor;
private final SamType samType;
private final JetType superClassType;
private final List<JetType> superInterfaceTypes;
private final KtType superClassType;
private final List<KtType> superInterfaceTypes;
private final FunctionDescriptor functionReferenceTarget;
private final FunctionGenerationStrategy strategy;
private final CalculatedClosure closure;
@@ -83,7 +83,7 @@ public class ClosureCodegen extends MemberCodegen<JetElement> {
public ClosureCodegen(
@NotNull GenerationState state,
@NotNull JetElement element,
@NotNull KtElement element,
@Nullable SamType samType,
@NotNull ClosureContext context,
@Nullable FunctionDescriptor functionReferenceTarget,
@@ -100,10 +100,10 @@ public class ClosureCodegen extends MemberCodegen<JetElement> {
this.strategy = strategy;
if (samType == null) {
this.superInterfaceTypes = new ArrayList<JetType>();
this.superInterfaceTypes = new ArrayList<KtType>();
JetType superClassType = null;
for (JetType supertype : classDescriptor.getTypeConstructor().getSupertypes()) {
KtType superClassType = null;
for (KtType supertype : classDescriptor.getTypeConstructor().getSupertypes()) {
ClassifierDescriptor classifier = supertype.getConstructor().getDeclarationDescriptor();
if (DescriptorUtils.isInterface(classifier)) {
superInterfaceTypes.add(supertype);
@@ -141,7 +141,7 @@ public class ClosureCodegen extends MemberCodegen<JetElement> {
sw.writeSuperclassEnd();
String[] superInterfaceAsmTypes = new String[superInterfaceTypes.size()];
for (int i = 0; i < superInterfaceTypes.size(); i++) {
JetType superInterfaceType = superInterfaceTypes.get(i);
KtType superInterfaceType = superInterfaceTypes.get(i);
sw.writeInterface();
superInterfaceAsmTypes[i] = typeMapper.mapSupertype(superInterfaceType, sw).getInternalName();
sw.writeInterfaceEnd();
@@ -428,7 +428,7 @@ public class ClosureCodegen extends MemberCodegen<JetElement> {
Type type = typeMapper.mapType(captureThis);
args.add(FieldInfo.createForHiddenField(ownerType, type, CAPTURED_THIS_FIELD));
}
JetType captureReceiverType = closure.getCaptureReceiverType();
KtType captureReceiverType = closure.getCaptureReceiverType();
if (captureReceiverType != null) {
args.add(FieldInfo.createForHiddenField(ownerType, typeMapper.mapType(captureReceiverType), CAPTURED_RECEIVER_FIELD));
}
@@ -467,7 +467,7 @@ public class ClosureCodegen extends MemberCodegen<JetElement> {
ClassDescriptor elementClass = elementDescriptor.getExtensionReceiverParameter() == null
? DescriptorUtilsKt.getBuiltIns(elementDescriptor).getFunction(arity)
: DescriptorUtilsKt.getBuiltIns(elementDescriptor).getExtensionFunction(arity);
JetScope scope = elementClass.getDefaultType().getMemberScope();
KtScope scope = elementClass.getDefaultType().getMemberScope();
return scope.getFunctions(OperatorNameConventions.INVOKE, NoLookupLocation.FROM_BACKEND).iterator().next();
}
}
@@ -19,9 +19,9 @@ package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.fileClasses.JvmFileClassInfo
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider
import org.jetbrains.kotlin.psi.JetFile
import org.jetbrains.kotlin.psi.KtFile
public class CodegenFileClassesProvider : JvmFileClassesProvider {
override public fun getFileClassInfo(file: JetFile): JvmFileClassInfo =
override public fun getFileClassInfo(file: KtFile): JvmFileClassInfo =
JvmFileClassUtil.getFileClassInfoNoResolve(file)
}
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.psi.*;
public class CodegenStatementVisitor extends JetVisitor<StackValue, StackValue> {
public class CodegenStatementVisitor extends KtVisitor<StackValue, StackValue> {
private final ExpressionCodegen codegen;
public CodegenStatementVisitor(ExpressionCodegen codegen) {
@@ -27,38 +27,38 @@ public class CodegenStatementVisitor extends JetVisitor<StackValue, StackValue>
}
@Override
public StackValue visitJetElement(@NotNull JetElement element, StackValue receiver) {
public StackValue visitJetElement(@NotNull KtElement element, StackValue receiver) {
return element.accept(codegen, receiver);
}
@Override
public StackValue visitIfExpression(@NotNull JetIfExpression expression, StackValue receiver) {
public StackValue visitIfExpression(@NotNull KtIfExpression expression, StackValue receiver) {
return codegen.generateIfExpression(expression, true);
}
@Override
public StackValue visitTryExpression(@NotNull JetTryExpression expression, StackValue data) {
public StackValue visitTryExpression(@NotNull KtTryExpression expression, StackValue data) {
return codegen.generateTryExpression(expression, true);
}
@Override
public StackValue visitNamedFunction(@NotNull JetNamedFunction function, StackValue data) {
public StackValue visitNamedFunction(@NotNull KtNamedFunction function, StackValue data) {
return codegen.visitNamedFunction(function, data, true);
}
@Override
public StackValue visitWhenExpression(@NotNull JetWhenExpression expression, StackValue data) {
public StackValue visitWhenExpression(@NotNull KtWhenExpression expression, StackValue data) {
return codegen.generateWhenExpression(expression, true);
}
@Override
public StackValue visitBlockExpression(@NotNull JetBlockExpression expression, StackValue data) {
public StackValue visitBlockExpression(@NotNull KtBlockExpression expression, StackValue data) {
return codegen.generateBlock(expression, true);
}
@Override
public StackValue visitLabeledExpression(@NotNull JetLabeledExpression expression, StackValue receiver) {
JetExpression baseExpression = expression.getBaseExpression();
public StackValue visitLabeledExpression(@NotNull KtLabeledExpression expression, StackValue receiver) {
KtExpression baseExpression = expression.getBaseExpression();
assert baseExpression != null : "Label expression should have base one: " + expression.getText();
return baseExpression.accept(this, receiver);
}
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.checker.JetTypeChecker
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
import org.jetbrains.org.objectweb.asm.Opcodes.*
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
import java.util.ArrayList
@@ -187,7 +187,7 @@ class CollectionStubMethodGenerator(
return ourSuperCollectionClasses.filter { klass -> klass.readOnlyClass !in redundantClasses }
}
private fun Collection<JetType>.classes(): Collection<ClassDescriptor> =
private fun Collection<KtType>.classes(): Collection<ClassDescriptor> =
this.map { it.getConstructor().getDeclarationDescriptor() as ClassDescriptor }
private fun findFakeOverridesForMethodsFromMutableCollection(
@@ -213,13 +213,13 @@ class CollectionStubMethodGenerator(
return result
}
private fun Collection<JetType>.findMostSpecificTypeForClass(klass: ClassDescriptor): JetType {
private fun Collection<KtType>.findMostSpecificTypeForClass(klass: ClassDescriptor): KtType {
val types = this.filter { it.getConstructor().getDeclarationDescriptor() == klass }
if (types.isEmpty()) error("No supertype of $klass in $this")
if (types.size() == 1) return types.first()
// Find the first type in the list such that it's a subtype of every other type in that list
return types.first { type ->
types.all { other -> JetTypeChecker.DEFAULT.isSubtypeOf(type, other) }
types.all { other -> KotlinTypeChecker.DEFAULT.isSubtypeOf(type, other) }
}
}
@@ -239,8 +239,8 @@ class CollectionStubMethodGenerator(
return this.getOverriddenDescriptors().firstOrNull { it.getContainingDeclaration() == classDescriptor }
}
private fun newType(classDescriptor: ClassDescriptor, typeArguments: List<TypeProjection>): JetType {
return JetTypeImpl.create(Annotations.EMPTY, classDescriptor, false, typeArguments)
private fun newType(classDescriptor: ClassDescriptor, typeArguments: List<TypeProjection>): KtType {
return KtTypeImpl.create(Annotations.EMPTY, classDescriptor, false, typeArguments)
}
private fun FunctionDescriptor.signature(): JvmMethodSignature = typeMapper.mapSignature(this)
@@ -17,7 +17,7 @@
package org.jetbrains.kotlin.codegen;
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor;
import org.jetbrains.kotlin.psi.JetParameter;
import org.jetbrains.kotlin.psi.KtParameter;
import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.descriptorToDeclaration;
@@ -31,7 +31,7 @@ public interface DefaultParameterValueLoader {
ValueParameterDescriptor descriptor,
ExpressionCodegen codegen
) {
JetParameter jetParameter = (JetParameter) descriptorToDeclaration(descriptor);
KtParameter jetParameter = (KtParameter) descriptorToDeclaration(descriptor);
assert jetParameter != null;
return codegen.gen(jetParameter.getDefaultValue());
}
@@ -19,9 +19,9 @@ package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.codegen.binding.CodegenBinding
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.psi.JetClass
import org.jetbrains.kotlin.psi.JetClassOrObject
import org.jetbrains.kotlin.psi.JetElement
import org.jetbrains.kotlin.psi.KtClass
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.jvm.annotations.hasJvmOverloadsAnnotation
@@ -42,7 +42,7 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) {
constructorDescriptor: ConstructorDescriptor,
classBuilder: ClassBuilder,
contextKind: OwnerKind,
classOrObject: JetClassOrObject
classOrObject: KtClassOrObject
) {
if (generateOverloadsIfNeeded(classOrObject, constructorDescriptor, constructorDescriptor, contextKind, classBuilder)) {
return
@@ -70,7 +70,7 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) {
* @return true if the overloads annotation was found on the element, false otherwise
*/
fun generateOverloadsIfNeeded(
methodElement: JetElement?,
methodElement: KtElement?,
functionDescriptor: FunctionDescriptor,
delegateFunctionDescriptor: FunctionDescriptor,
contextKind: OwnerKind,
@@ -109,7 +109,7 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) {
functionDescriptor: FunctionDescriptor,
delegateFunctionDescriptor: FunctionDescriptor,
classBuilder: ClassBuilder,
methodElement: JetElement?,
methodElement: KtElement?,
contextKind: OwnerKind,
substituteCount: Int
) {
@@ -208,7 +208,7 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) {
return functionDescriptor.getValueParameters().filter { !it.declaresDefaultValue() || --remainingCount >= 0 }
}
private fun isEmptyConstructorNeeded(constructorDescriptor: ConstructorDescriptor, classOrObject: JetClassOrObject): Boolean {
private fun isEmptyConstructorNeeded(constructorDescriptor: ConstructorDescriptor, classOrObject: KtClassOrObject): Boolean {
val classDescriptor = constructorDescriptor.getContainingDeclaration()
if (classDescriptor.getKind() != ClassKind.CLASS) return false
@@ -220,12 +220,12 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) {
return false
if (constructorDescriptor.getValueParameters().isEmpty()) return false
if (classOrObject is JetClass && hasSecondaryConstructorsWithNoParameters(classOrObject)) return false
if (classOrObject is KtClass && hasSecondaryConstructorsWithNoParameters(classOrObject)) return false
return constructorDescriptor.getValueParameters().all { it.declaresDefaultValue() }
}
private fun hasSecondaryConstructorsWithNoParameters(klass: JetClass) =
private fun hasSecondaryConstructorsWithNoParameters(klass: KtClass) =
klass.getSecondaryConstructors().any { it.getValueParameters().isEmpty() }
}
File diff suppressed because it is too large Load Diff
@@ -43,7 +43,7 @@ import org.jetbrains.kotlin.load.java.JvmAnnotationNames;
import org.jetbrains.kotlin.load.java.SpecialBuiltinMembers;
import org.jetbrains.kotlin.load.kotlin.nativeDeclarations.NativeKt;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.psi.JetNamedFunction;
import org.jetbrains.kotlin.psi.KtNamedFunction;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
@@ -57,7 +57,7 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.org.objectweb.asm.*;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import org.jetbrains.org.objectweb.asm.commons.Method;
@@ -102,7 +102,7 @@ public class FunctionCodegen {
this.memberCodegen = memberCodegen;
}
public void gen(@NotNull JetNamedFunction function) {
public void gen(@NotNull KtNamedFunction function) {
SimpleFunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, function);
assert functionDescriptor != null : "No descriptor for function " + function.getText() + "\n" +
"in " + function.getContainingFile().getVirtualFile();
@@ -119,7 +119,7 @@ public class FunctionCodegen {
}
public void generateOverloadsWithDefaultValues(
@Nullable JetNamedFunction function,
@Nullable KtNamedFunction function,
@NotNull FunctionDescriptor functionDescriptor,
@NotNull FunctionDescriptor delegateFunctionDescriptor
) {
@@ -650,7 +650,7 @@ public class FunctionCodegen {
@NotNull FunctionDescriptor functionDescriptor,
@NotNull OwnerKind kind,
@NotNull DefaultParameterValueLoader loadStrategy,
@Nullable JetNamedFunction function
@Nullable KtNamedFunction function
) {
DeclarationDescriptor contextClass = owner.getContextDescriptor().getContainingDeclaration();
@@ -704,7 +704,7 @@ public class FunctionCodegen {
@NotNull FunctionDescriptor functionDescriptor,
@NotNull MethodVisitor mv,
@NotNull DefaultParameterValueLoader loadStrategy,
@Nullable JetNamedFunction function,
@Nullable KtNamedFunction function,
@NotNull MemberCodegen<?> parentCodegen
) {
GenerationState state = parentCodegen.state;
@@ -887,7 +887,7 @@ public class FunctionCodegen {
iv.load(1, OBJECT_TYPE);
JetType jetType = descriptor.getValueParameters().get(0).getType();
KtType jetType = descriptor.getValueParameters().get(0).getType();
// TODO: reuse logic from ExpressionCodegen
if (jetType.isMarkedNullable()) {
@@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.codegen.context.MethodContext;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
import org.jetbrains.kotlin.psi.JetDeclarationWithBody;
import org.jetbrains.kotlin.psi.KtDeclarationWithBody;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
import org.jetbrains.org.objectweb.asm.MethodVisitor;
@@ -34,12 +34,12 @@ public abstract class FunctionGenerationStrategy {
);
public static class FunctionDefault extends CodegenBased<CallableDescriptor> {
private final JetDeclarationWithBody declaration;
private final KtDeclarationWithBody declaration;
public FunctionDefault(
@NotNull GenerationState state,
@NotNull CallableDescriptor descriptor,
@NotNull JetDeclarationWithBody declaration
@NotNull KtDeclarationWithBody declaration
) {
super(state, descriptor);
this.declaration = declaration;
@@ -61,7 +61,7 @@ public class FunctionReferenceGenerationStrategy extends FunctionGenerationStrat
every argument boils down to calling LOAD with the corresponding index
*/
JetCallExpression fakeExpression = constructFakeFunctionCall();
KtCallExpression fakeExpression = constructFakeFunctionCall();
final List<? extends ValueArgument> fakeArguments = fakeExpression.getValueArguments();
final ReceiverValue dispatchReceiver = computeAndSaveReceiver(signature, codegen, referencedFunction.getDispatchReceiverParameter());
@@ -128,7 +128,7 @@ public class FunctionReferenceGenerationStrategy extends FunctionGenerationStrat
}
@NotNull
private JetCallExpression constructFakeFunctionCall() {
private KtCallExpression constructFakeFunctionCall() {
StringBuilder fakeFunctionCall = new StringBuilder("callableReferenceFakeCall(");
for (Iterator<ValueParameterDescriptor> iterator = referencedFunction.getValueParameters().iterator(); iterator.hasNext(); ) {
ValueParameterDescriptor descriptor = iterator.next();
@@ -138,7 +138,7 @@ public class FunctionReferenceGenerationStrategy extends FunctionGenerationStrat
}
}
fakeFunctionCall.append(")");
return (JetCallExpression) JetPsiFactoryKt.JetPsiFactory(state.getProject()).createExpression(fakeFunctionCall.toString());
return (KtCallExpression) KtPsiFactoryKt.KtPsiFactory(state.getProject()).createExpression(fakeFunctionCall.toString());
}
private void computeAndSaveArguments(@NotNull List<? extends ValueArgument> fakeArguments, @NotNull ExpressionCodegen codegen) {
@@ -164,8 +164,8 @@ public class FunctionReferenceGenerationStrategy extends FunctionGenerationStrat
) {
if (receiver == null) return NO_RECEIVER;
JetExpression receiverExpression = JetPsiFactoryKt
.JetPsiFactory(state.getProject()).createExpression("callableReferenceFakeReceiver");
KtExpression receiverExpression = KtPsiFactoryKt
.KtPsiFactory(state.getProject()).createExpression("callableReferenceFakeReceiver");
codegen.tempVariables.put(receiverExpression, receiverParameterStackValue(signature));
return new ExpressionReceiver(receiverExpression, receiver.getType());
}
@@ -39,7 +39,7 @@ import org.jetbrains.kotlin.codegen.signature.BothSignatureWriter;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.lexer.JetTokens;
import org.jetbrains.kotlin.lexer.KtTokens;
import org.jetbrains.kotlin.load.java.JvmAbi;
import org.jetbrains.kotlin.load.java.JvmAnnotationNames;
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor;
@@ -66,8 +66,8 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver;
import org.jetbrains.kotlin.serialization.DescriptorSerializer;
import org.jetbrains.kotlin.serialization.ProtoBuf;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
import org.jetbrains.org.objectweb.asm.*;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import org.jetbrains.org.objectweb.asm.commons.Method;
@@ -91,7 +91,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private static final String ENUM_VALUES_FIELD_NAME = "$VALUES";
private Type superClassAsmType;
@Nullable // null means java/lang/Object
private JetType superClassType;
private KtType superClassType;
private final Type classAsmType;
private final boolean isLocal;
@@ -101,7 +101,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
new ArrayList<Function2<ImplementationBodyCodegen, ClassBuilder, Unit>>();
public ImplementationBodyCodegen(
@NotNull JetClassOrObject aClass,
@NotNull KtClassOrObject aClass,
@NotNull ClassContext context,
@NotNull ClassBuilder v,
@NotNull GenerationState state,
@@ -126,12 +126,12 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
boolean isAnnotation = false;
boolean isEnum = false;
if (myClass instanceof JetClass) {
JetClass jetClass = (JetClass) myClass;
if (jetClass.hasModifier(JetTokens.ABSTRACT_KEYWORD) || jetClass.isSealed()) {
if (myClass instanceof KtClass) {
KtClass ktClass = (KtClass) myClass;
if (ktClass.hasModifier(KtTokens.ABSTRACT_KEYWORD) || ktClass.isSealed()) {
isAbstract = true;
}
if (jetClass.isInterface()) {
if (ktClass.isInterface()) {
isAbstract = true;
isInterface = true;
}
@@ -140,7 +140,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
isInterface = true;
isAnnotation = true;
}
else if (jetClass.isEnum()) {
else if (ktClass.isEnum()) {
isAbstract = hasAbstractMembers(descriptor);
isEnum = true;
}
@@ -149,11 +149,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
isFinal = true;
}
if (!jetClass.hasModifier(JetTokens.OPEN_KEYWORD) && !isAbstract) {
if (!ktClass.hasModifier(KtTokens.OPEN_KEYWORD) && !isAbstract) {
// Light-class mode: Do not make enum classes final since PsiClass corresponding to enum is expected to be inheritable from
isFinal = !(jetClass.isEnum() && state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES);
isFinal = !(ktClass.isEnum() && state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES);
}
isStatic = !jetClass.isInner();
isStatic = !ktClass.isInner();
}
else {
isStatic = isCompanionObject(descriptor);
@@ -195,9 +195,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
access |= ACC_DEPRECATED;
}
if (isEnum) {
for (JetDeclaration declaration : myClass.getDeclarations()) {
if (declaration instanceof JetEnumEntry) {
if (enumEntryNeedSubclass(bindingContext, (JetEnumEntry) declaration)) {
for (KtDeclaration declaration : myClass.getDeclarations()) {
if (declaration instanceof KtEnumEntry) {
if (enumEntryNeedSubclass(bindingContext, (KtEnumEntry) declaration)) {
access &= ~ACC_FINAL;
}
}
@@ -316,7 +316,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
LinkedHashSet<String> superInterfaces = new LinkedHashSet<String>();
Set<String> kotlinMarkerInterfaces = new LinkedHashSet<String>();
for (JetType supertype : descriptor.getTypeConstructor().getSupertypes()) {
for (KtType supertype : descriptor.getTypeConstructor().getSupertypes()) {
if (isJvmInterface(supertype.getConstructor().getDeclarationDescriptor())) {
sw.writeInterface();
Type jvmInterfaceType = typeMapper.mapSupertype(supertype, sw);
@@ -352,7 +352,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
return;
}
for (JetType supertype : descriptor.getTypeConstructor().getSupertypes()) {
for (KtType supertype : descriptor.getTypeConstructor().getSupertypes()) {
ClassifierDescriptor superClass = supertype.getConstructor().getDeclarationDescriptor();
if (superClass != null && !isJvmInterface(superClass)) {
superClassAsmType = typeMapper.mapClass(superClass);
@@ -421,13 +421,13 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
continue;
}
JetType returnType = function.getReturnType();
KtType returnType = function.getReturnType();
assert returnType != null : function.toString();
JetType paramType = function.getValueParameters().get(0).getType();
KtType paramType = function.getValueParameters().get(0).getType();
if (KotlinBuiltIns.isArray(returnType) && KotlinBuiltIns.isArray(paramType)) {
JetType elementType = function.getTypeParameters().get(0).getDefaultType();
if (JetTypeChecker.DEFAULT.equalTypes(elementType, DescriptorUtilsKt.getBuiltIns(descriptor).getArrayElementType(returnType))
&& JetTypeChecker.DEFAULT.equalTypes(elementType, DescriptorUtilsKt
KtType elementType = function.getTypeParameters().get(0).getDefaultType();
if (KotlinTypeChecker.DEFAULT.equalTypes(elementType, DescriptorUtilsKt.getBuiltIns(descriptor).getArrayElementType(returnType))
&& KotlinTypeChecker.DEFAULT.equalTypes(elementType, DescriptorUtilsKt
.getBuiltIns(descriptor).getArrayElementType(paramType))) {
return true;
}
@@ -486,7 +486,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private class DataClassMethodGeneratorImpl extends DataClassMethodGenerator {
DataClassMethodGeneratorImpl(
JetClassOrObject klass,
KtClassOrObject klass,
BindingContext bindingContext
) {
super(klass, bindingContext);
@@ -532,7 +532,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
iv.ifne(ne);
}
else {
StackValue value = genEqualsForExpressionsOnStack(JetTokens.EQEQ, StackValue.onStack(asmType), StackValue.onStack(asmType));
StackValue value = genEqualsForExpressionsOnStack(KtTokens.EQEQ, StackValue.onStack(asmType), StackValue.onStack(asmType));
value.put(Type.BOOLEAN_TYPE, iv);
iv.ifeq(ne);
}
@@ -689,7 +689,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
@Override
public void generateCopyFunction(@NotNull final FunctionDescriptor function, @NotNull List<JetParameter> constructorParameters) {
public void generateCopyFunction(@NotNull final FunctionDescriptor function, @NotNull List<KtParameter> constructorParameters) {
final Type thisDescriptorType = typeMapper.mapType(descriptor);
functionCodegen.generateMethod(JvmDeclarationOriginKt.OtherOrigin(myClass, function), function, new FunctionGenerationStrategy() {
@@ -738,7 +738,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
iv.getfield(classAsmType.getInternalName(), CAPTURED_THIS_FIELD, type.getDescriptor());
}
JetType captureReceiver = closure.getCaptureReceiverType();
KtType captureReceiver = closure.getCaptureReceiverType();
if (captureReceiver != null) {
iv.load(0, classAsmType);
Type type = typeMapper.mapType(captureReceiver);
@@ -865,7 +865,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
return;
}
JetObjectDeclaration companionObject = CollectionsKt.firstOrNull(((JetClass) myClass).getCompanionObjects());
KtObjectDeclaration companionObject = CollectionsKt.firstOrNull(((KtClass) myClass).getCompanionObjects());
assert companionObject != null : "Companion object not found: " + myClass.getText();
StackValue.Field field = StackValue.singletonForCompanion(companionObjectDescriptor, typeMapper);
@@ -939,7 +939,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
ConstructorContext constructorContext = context.intoConstructor(constructorDescriptor);
JetPrimaryConstructor primaryConstructor = myClass.getPrimaryConstructor();
KtPrimaryConstructor primaryConstructor = myClass.getPrimaryConstructor();
JvmDeclarationOrigin origin = JvmDeclarationOriginKt
.OtherOrigin(primaryConstructor != null ? primaryConstructor : myClass, constructorDescriptor);
functionCodegen.generateMethod(origin, constructorDescriptor, constructorContext,
@@ -1004,15 +1004,15 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
}
for (JetDelegationSpecifier specifier : myClass.getDelegationSpecifiers()) {
if (specifier instanceof JetDelegatorByExpressionSpecifier) {
genCallToDelegatorByExpressionSpecifier(iv, codegen, (JetDelegatorByExpressionSpecifier) specifier, fieldsInfo);
for (KtDelegationSpecifier specifier : myClass.getDelegationSpecifiers()) {
if (specifier instanceof KtDelegatorByExpressionSpecifier) {
genCallToDelegatorByExpressionSpecifier(iv, codegen, (KtDelegatorByExpressionSpecifier) specifier, fieldsInfo);
}
}
int curParam = 0;
List<ValueParameterDescriptor> parameters = constructorDescriptor.getValueParameters();
for (JetParameter parameter : getPrimaryConstructorParameters()) {
for (KtParameter parameter : getPrimaryConstructorParameters()) {
if (parameter.hasValOrVar()) {
VariableDescriptor descriptor = parameters.get(curParam);
Type type = typeMapper.mapType(descriptor);
@@ -1060,8 +1060,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
generateInitializers(codegen);
}
JetSecondaryConstructor constructor =
(JetSecondaryConstructor) DescriptorToSourceUtils.descriptorToDeclaration(constructorDescriptor);
KtSecondaryConstructor constructor =
(KtSecondaryConstructor) DescriptorToSourceUtils.descriptorToDeclaration(constructorDescriptor);
assert constructor != null;
if (constructor.hasBody()) {
codegen.gen(constructor.getBodyExpression(), Type.VOID_TYPE);
@@ -1119,41 +1119,41 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
return StackValue.field(type, classAsmType, name, false, StackValue.none());
}
}
private final Map<JetDelegatorByExpressionSpecifier, Field> fields = new HashMap<JetDelegatorByExpressionSpecifier, Field>();
private final Map<KtDelegatorByExpressionSpecifier, Field> fields = new HashMap<KtDelegatorByExpressionSpecifier, Field>();
@NotNull
public Field getInfo(JetDelegatorByExpressionSpecifier specifier) {
public Field getInfo(KtDelegatorByExpressionSpecifier specifier) {
return fields.get(specifier);
}
private void addField(JetDelegatorByExpressionSpecifier specifier, PropertyDescriptor propertyDescriptor) {
private void addField(KtDelegatorByExpressionSpecifier specifier, PropertyDescriptor propertyDescriptor) {
fields.put(specifier,
new Field(typeMapper.mapType(propertyDescriptor), propertyDescriptor.getName().asString(), false));
}
private void addField(JetDelegatorByExpressionSpecifier specifier, Type type, String name) {
private void addField(KtDelegatorByExpressionSpecifier specifier, Type type, String name) {
fields.put(specifier, new Field(type, name, true));
}
}
@NotNull
private DelegationFieldsInfo getDelegationFieldsInfo(@NotNull List<JetDelegationSpecifier> delegationSpecifiers) {
private DelegationFieldsInfo getDelegationFieldsInfo(@NotNull List<KtDelegationSpecifier> delegationSpecifiers) {
DelegationFieldsInfo result = new DelegationFieldsInfo();
int n = 0;
for (JetDelegationSpecifier specifier : delegationSpecifiers) {
if (specifier instanceof JetDelegatorByExpressionSpecifier) {
JetExpression expression = ((JetDelegatorByExpressionSpecifier) specifier).getDelegateExpression();
for (KtDelegationSpecifier specifier : delegationSpecifiers) {
if (specifier instanceof KtDelegatorByExpressionSpecifier) {
KtExpression expression = ((KtDelegatorByExpressionSpecifier) specifier).getDelegateExpression();
PropertyDescriptor propertyDescriptor = CodegenUtil.getDelegatePropertyIfAny(expression, descriptor, bindingContext);
if (CodegenUtil.isFinalPropertyWithBackingField(propertyDescriptor, bindingContext)) {
result.addField((JetDelegatorByExpressionSpecifier) specifier, propertyDescriptor);
result.addField((KtDelegatorByExpressionSpecifier) specifier, propertyDescriptor);
}
else {
JetType expressionType = expression != null ? bindingContext.getType(expression) : null;
KtType expressionType = expression != null ? bindingContext.getType(expression) : null;
Type asmType =
expressionType != null ? typeMapper.mapType(expressionType) : typeMapper.mapType(getSuperClass(specifier));
result.addField((JetDelegatorByExpressionSpecifier) specifier, asmType, "$delegate_" + n);
result.addField((KtDelegatorByExpressionSpecifier) specifier, asmType, "$delegate_" + n);
}
n++;
}
@@ -1162,17 +1162,17 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
@NotNull
private ClassDescriptor getSuperClass(@NotNull JetDelegationSpecifier specifier) {
private ClassDescriptor getSuperClass(@NotNull KtDelegationSpecifier specifier) {
return CodegenUtil.getSuperClassByDelegationSpecifier(specifier, bindingContext);
}
private void genCallToDelegatorByExpressionSpecifier(
InstructionAdapter iv,
ExpressionCodegen codegen,
JetDelegatorByExpressionSpecifier specifier,
KtDelegatorByExpressionSpecifier specifier,
DelegationFieldsInfo fieldsInfo
) {
JetExpression expression = specifier.getDelegateExpression();
KtExpression expression = specifier.getDelegateExpression();
DelegationFieldsInfo.Field fieldInfo = fieldsInfo.getInfo(specifier);
if (fieldInfo.generateField) {
@@ -1184,14 +1184,14 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private void lookupConstructorExpressionsInClosureIfPresent() {
if (state.getClassBuilderMode() != ClassBuilderMode.FULL || descriptor.getConstructors().isEmpty()) return;
JetVisitorVoid visitor = new JetVisitorVoid() {
KtVisitorVoid visitor = new KtVisitorVoid() {
@Override
public void visitJetElement(@NotNull JetElement e) {
public void visitJetElement(@NotNull KtElement e) {
e.acceptChildren(this);
}
@Override
public void visitSimpleNameExpression(@NotNull JetSimpleNameExpression expr) {
public void visitSimpleNameExpression(@NotNull KtSimpleNameExpression expr) {
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, expr);
if (isLocalFunction(descriptor)) {
@@ -1234,7 +1234,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
@Override
public void visitThisExpression(@NotNull JetThisExpression expression) {
public void visitThisExpression(@NotNull KtThisExpression expression) {
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getInstanceReference());
assert descriptor instanceof CallableDescriptor ||
descriptor instanceof ClassDescriptor : "'This' reference target should be class or callable descriptor but was " + descriptor;
@@ -1251,27 +1251,27 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
};
for (JetDeclaration declaration : myClass.getDeclarations()) {
if (declaration instanceof JetProperty) {
JetProperty property = (JetProperty) declaration;
JetExpression initializer = property.getInitializer();
for (KtDeclaration declaration : myClass.getDeclarations()) {
if (declaration instanceof KtProperty) {
KtProperty property = (KtProperty) declaration;
KtExpression initializer = property.getInitializer();
if (initializer != null) {
initializer.accept(visitor);
}
}
else if (declaration instanceof JetClassInitializer) {
JetClassInitializer initializer = (JetClassInitializer) declaration;
else if (declaration instanceof KtClassInitializer) {
KtClassInitializer initializer = (KtClassInitializer) declaration;
initializer.accept(visitor);
}
else if (declaration instanceof JetSecondaryConstructor) {
JetSecondaryConstructor constructor = (JetSecondaryConstructor) declaration;
else if (declaration instanceof KtSecondaryConstructor) {
KtSecondaryConstructor constructor = (KtSecondaryConstructor) declaration;
constructor.accept(visitor);
}
}
for (JetDelegationSpecifier specifier : myClass.getDelegationSpecifiers()) {
if (specifier instanceof JetDelegatorByExpressionSpecifier) {
JetExpression delegateExpression = ((JetDelegatorByExpressionSpecifier) specifier).getDelegateExpression();
for (KtDelegationSpecifier specifier : myClass.getDelegationSpecifiers()) {
if (specifier instanceof KtDelegatorByExpressionSpecifier) {
KtExpression delegateExpression = ((KtDelegatorByExpressionSpecifier) specifier).getDelegateExpression();
assert delegateExpression != null;
delegateExpression.accept(visitor);
}
@@ -1286,7 +1286,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
ConstructorDescriptor primaryConstructor = descriptor.getUnsubstitutedPrimaryConstructor();
if (primaryConstructor != null && !isAnonymousObject(descriptor)) {
ResolvedCall<ConstructorDescriptor> delegationCall = getDelegationConstructorCall(bindingContext, primaryConstructor);
JetValueArgumentList argumentList = delegationCall != null ? delegationCall.getCall().getValueArgumentList() : null;
KtValueArgumentList argumentList = delegationCall != null ? delegationCall.getCall().getValueArgumentList() : null;
if (argumentList != null) {
argumentList.accept(visitor);
}
@@ -1318,8 +1318,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
DeclarationDescriptor declarationInheritedFun = inheritedFun.getContainingDeclaration();
PsiElement classForInheritedFun = descriptorToDeclaration(declarationInheritedFun);
if (classForInheritedFun instanceof JetDeclaration) {
codegen.markLineNumber((JetElement) classForInheritedFun, false);
if (classForInheritedFun instanceof KtDeclaration) {
codegen.markLineNumber((KtElement) classForInheritedFun, false);
}
ClassDescriptor containingTrait = (ClassDescriptor) containingDeclaration;
@@ -1535,9 +1535,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private void generateEnumEntries() {
if (descriptor.getKind() != ClassKind.ENUM_CLASS) return;
List<JetEnumEntry> enumEntries = CollectionsKt.filterIsInstance(element.getDeclarations(), JetEnumEntry.class);
List<KtEnumEntry> enumEntries = CollectionsKt.filterIsInstance(element.getDeclarations(), KtEnumEntry.class);
for (JetEnumEntry enumEntry : enumEntries) {
for (KtEnumEntry enumEntry : enumEntries) {
ClassDescriptor descriptor = getNotNull(bindingContext, BindingContext.CLASS, enumEntry);
FieldVisitor fv = v.newField(JvmDeclarationOriginKt.OtherOrigin(enumEntry, descriptor), ACC_PUBLIC | ACC_ENUM | ACC_STATIC | ACC_FINAL,
descriptor.getName().asString(), classAsmType.getDescriptor(), null, null);
@@ -1547,7 +1547,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
initializeEnumConstants(enumEntries);
}
private void initializeEnumConstants(@NotNull List<JetEnumEntry> enumEntries) {
private void initializeEnumConstants(@NotNull List<KtEnumEntry> enumEntries) {
if (state.getClassBuilderMode() != ClassBuilderMode.FULL) return;
ExpressionCodegen codegen = createOrGetClInitCodegen();
@@ -1570,10 +1570,10 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
iv.putstatic(classAsmType.getInternalName(), ENUM_VALUES_FIELD_NAME, arrayAsmType.getDescriptor());
}
private void initializeEnumConstant(@NotNull List<JetEnumEntry> enumEntries, int ordinal) {
private void initializeEnumConstant(@NotNull List<KtEnumEntry> enumEntries, int ordinal) {
ExpressionCodegen codegen = createOrGetClInitCodegen();
InstructionAdapter iv = codegen.v;
JetEnumEntry enumEntry = enumEntries.get(ordinal);
KtEnumEntry enumEntry = enumEntries.get(ordinal);
iv.dup();
iv.iconst(ordinal);
@@ -1587,7 +1587,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
iv.aconst(enumEntry.getName());
iv.iconst(ordinal);
List<JetDelegationSpecifier> delegationSpecifiers = enumEntry.getDelegationSpecifiers();
List<KtDelegationSpecifier> delegationSpecifiers = enumEntry.getDelegationSpecifiers();
if (delegationSpecifiers.size() == 1 && !enumEntryNeedSubclass(bindingContext, enumEntry)) {
ResolvedCall<?> resolvedCall = CallUtilKt.getResolvedCallWithAssert(delegationSpecifiers.get(0), bindingContext);
@@ -1605,12 +1605,12 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
private void generateDelegates(DelegationFieldsInfo delegationFieldsInfo) {
for (JetDelegationSpecifier specifier : myClass.getDelegationSpecifiers()) {
if (specifier instanceof JetDelegatorByExpressionSpecifier) {
DelegationFieldsInfo.Field field = delegationFieldsInfo.getInfo((JetDelegatorByExpressionSpecifier) specifier);
for (KtDelegationSpecifier specifier : myClass.getDelegationSpecifiers()) {
if (specifier instanceof KtDelegatorByExpressionSpecifier) {
DelegationFieldsInfo.Field field = delegationFieldsInfo.getInfo((KtDelegatorByExpressionSpecifier) specifier);
generateDelegateField(field);
JetExpression delegateExpression = ((JetDelegatorByExpressionSpecifier) specifier).getDelegateExpression();
JetType delegateExpressionType = delegateExpression != null ? bindingContext.getType(delegateExpression) : null;
KtExpression delegateExpression = ((KtDelegatorByExpressionSpecifier) specifier).getDelegateExpression();
KtType delegateExpressionType = delegateExpression != null ? bindingContext.getType(delegateExpression) : null;
generateDelegates(getSuperClass(specifier), delegateExpressionType, field);
}
}
@@ -1623,7 +1623,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
fieldInfo.name, fieldInfo.type.getDescriptor(), /*TODO*/null, null);
}
protected void generateDelegates(ClassDescriptor toTrait, JetType delegateExpressionType, DelegationFieldsInfo.Field field) {
protected void generateDelegates(ClassDescriptor toTrait, KtType delegateExpressionType, DelegationFieldsInfo.Field field) {
for (Map.Entry<CallableMemberDescriptor, CallableDescriptor> entry : CodegenUtilKt.getDelegates(descriptor, toTrait, delegateExpressionType).entrySet()) {
CallableMemberDescriptor callableMemberDescriptor = entry.getKey();
CallableDescriptor delegateTo = entry.getValue();
@@ -28,12 +28,12 @@ import org.jetbrains.kotlin.load.java.JvmAnnotationNames
import org.jetbrains.kotlin.load.java.JvmAnnotationNames.KOTLIN_INTERFACE_DEFAULT_IMPLS
import org.jetbrains.kotlin.load.java.descriptors.JavaMethodDescriptor
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.JetClassOrObject
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.jvm.diagnostics.DelegationToTraitImpl
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.resolve.scopes.KtScope
import org.jetbrains.org.objectweb.asm.Opcodes.ACC_FINAL
import org.jetbrains.org.objectweb.asm.Opcodes.ACC_PUBLIC
import org.jetbrains.org.objectweb.asm.Opcodes.ACC_STATIC
@@ -41,7 +41,7 @@ import org.jetbrains.org.objectweb.asm.Opcodes.V1_6
import java.util.*
public class InterfaceImplBodyCodegen(
aClass: JetClassOrObject,
aClass: KtClassOrObject,
context: ClassContext,
v: ClassBuilder,
state: GenerationState,
@@ -63,7 +63,7 @@ public class InterfaceImplBodyCodegen(
descriptor, Name.identifier(JvmAbi.DEFAULT_IMPLS_CLASS_NAME),
Modality.FINAL, Collections.emptyList(), SourceElement.NO_SOURCE)
classDescriptorImpl.initialize(JetScope.Empty, emptySet(), null)
classDescriptorImpl.initialize(KtScope.Empty, emptySet(), null)
return classDescriptorImpl
}
@@ -35,15 +35,15 @@ import org.jetbrains.kotlin.load.java.JvmAbi;
import org.jetbrains.kotlin.load.java.JvmAnnotationNames;
import org.jetbrains.kotlin.load.kotlin.ModuleMapping;
import org.jetbrains.kotlin.load.kotlin.ModuleVisibilityUtilsKt;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.JetFunction;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.psi.KtFunction;
import org.jetbrains.kotlin.psi.codeFragmentUtil.CodeFragmentUtilKt;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.inline.InlineUtil;
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
import java.io.File;
@@ -64,7 +64,7 @@ public class JvmCodegenUtil {
return false;
}
public static boolean isJvmInterface(JetType type) {
public static boolean isJvmInterface(KtType type) {
return isJvmInterface(type.getConstructor().getDeclarationDescriptor());
}
@@ -86,7 +86,7 @@ public class JvmCodegenUtil {
}
private static boolean isWithinSameFile(
@Nullable JetFile callerFile,
@Nullable KtFile callerFile,
@NotNull CallableMemberDescriptor descriptor
) {
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration().getOriginal();
@@ -165,7 +165,7 @@ public class JvmCodegenUtil {
}
private static boolean isDebuggerContext(@NotNull MethodContext context) {
JetFile file = DescriptorToSourceUtils.getContainingFile(context.getContextDescriptor());
KtFile file = DescriptorToSourceUtils.getContainingFile(context.getContextDescriptor());
return file != null && CodeFragmentUtilKt.getSuppressDiagnosticsInDebugMode(file);
}
@@ -203,7 +203,7 @@ public class JvmCodegenUtil {
public static boolean isArgumentWhichWillBeInlined(@NotNull BindingContext bindingContext, @NotNull DeclarationDescriptor descriptor) {
PsiElement declaration = DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
return InlineUtil.canBeInlineArgument(declaration) &&
InlineUtil.isInlinedArgument((JetFunction) declaration, bindingContext, false);
InlineUtil.isInlinedArgument((KtFunction) declaration, bindingContext, false);
}
@NotNull
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.resolve.TargetPlatformKt;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform;
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils;
import java.util.*;
@@ -72,11 +72,11 @@ public class JvmRuntimeTypes {
}
@NotNull
public Collection<JetType> getSupertypesForClosure(@NotNull FunctionDescriptor descriptor) {
public Collection<KtType> getSupertypesForClosure(@NotNull FunctionDescriptor descriptor) {
ReceiverParameterDescriptor receiverParameter = descriptor.getExtensionReceiverParameter();
//noinspection ConstantConditions
JetType functionType = DescriptorUtilsKt.getBuiltIns(descriptor).getFunctionType(
KtType functionType = DescriptorUtilsKt.getBuiltIns(descriptor).getFunctionType(
Annotations.Companion.getEMPTY(),
receiverParameter == null ? null : receiverParameter.getType(),
ExpressionTypingUtils.getValueParametersTypes(descriptor.getValueParameters()),
@@ -87,15 +87,15 @@ public class JvmRuntimeTypes {
}
@NotNull
public Collection<JetType> getSupertypesForFunctionReference(@NotNull FunctionDescriptor descriptor) {
public Collection<KtType> getSupertypesForFunctionReference(@NotNull FunctionDescriptor descriptor) {
ReceiverParameterDescriptor extensionReceiver = descriptor.getExtensionReceiverParameter();
ReceiverParameterDescriptor dispatchReceiver = descriptor.getDispatchReceiverParameter();
JetType receiverType =
KtType receiverType =
extensionReceiver != null ? extensionReceiver.getType() : dispatchReceiver != null ? dispatchReceiver.getType() : null;
//noinspection ConstantConditions
JetType functionType = DescriptorUtilsKt.getBuiltIns(descriptor).getFunctionType(
KtType functionType = DescriptorUtilsKt.getBuiltIns(descriptor).getFunctionType(
Annotations.Companion.getEMPTY(),
receiverType,
ExpressionTypingUtils.getValueParametersTypes(descriptor.getValueParameters()),
@@ -106,7 +106,7 @@ public class JvmRuntimeTypes {
}
@NotNull
public JetType getSupertypeForPropertyReference(@NotNull PropertyDescriptor descriptor) {
public KtType getSupertypeForPropertyReference(@NotNull PropertyDescriptor descriptor) {
int arity = (descriptor.getExtensionReceiverParameter() != null ? 1 : 0) +
(descriptor.getDispatchReceiverParameter() != null ? 1 : 0);
return (descriptor.isVar() ? mutablePropertyReferences : propertyReferences).get(arity).getDefaultType();
@@ -21,11 +21,10 @@ import com.intellij.util.containers.MultiMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.fileClasses.JvmFileClassInfo;
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils;
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.JetScript;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.psi.KtScript;
import org.jetbrains.kotlin.resolve.ScriptNameUtil;
import org.jetbrains.org.objectweb.asm.Type;
@@ -36,10 +35,10 @@ import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.registerClassN
public class KotlinCodegenFacade {
public static void prepareForCompilation(@NotNull GenerationState state) {
for (JetFile file : state.getFiles()) {
for (KtFile file : state.getFiles()) {
if (file.isScript()) {
// SCRIPT: register class name for scripting from this file, move outside of this function
JetScript script = file.getScript();
KtScript script = file.getScript();
assert script != null;
FqName name = ScriptNameUtil.classNameForScript(script);
@@ -65,14 +64,14 @@ public class KotlinCodegenFacade {
}
public static void doGenerateFiles(
@NotNull Collection<JetFile> files,
@NotNull Collection<KtFile> files,
@NotNull GenerationState state,
@NotNull CompilationErrorHandler errorHandler
) {
MultiMap<FqName, JetFile> filesInPackages = new MultiMap<FqName, JetFile>();
MultiMap<FqName, JetFile> filesInMultifileClasses = new MultiMap<FqName, JetFile>();
MultiMap<FqName, KtFile> filesInPackages = new MultiMap<FqName, KtFile>();
MultiMap<FqName, KtFile> filesInMultifileClasses = new MultiMap<FqName, KtFile>();
for (JetFile file : files) {
for (KtFile file : files) {
if (file == null) throw new IllegalArgumentException("A null file given for compilation");
JvmFileClassInfo fileClassInfo = state.getFileClassesProvider().getFileClassInfo(file);
@@ -110,7 +109,7 @@ public class KotlinCodegenFacade {
public static void generatePackage(
@NotNull GenerationState state,
@NotNull FqName packageFqName,
@NotNull Collection<JetFile> jetFiles,
@NotNull Collection<KtFile> jetFiles,
@NotNull CompilationErrorHandler errorHandler
) {
// We do not really generate package class, but use old package fqName to identify package in module-info.
@@ -122,7 +121,7 @@ public class KotlinCodegenFacade {
private static void generateMultifileClass(
@NotNull GenerationState state,
@NotNull FqName multifileClassFqName,
@NotNull Collection<JetFile> files,
@NotNull Collection<KtFile> files,
@NotNull CompilationErrorHandler handler
) {
MultifileClassCodegen codegen = state.getFactory().forMultifileClass(multifileClassFqName, files);
@@ -51,7 +51,7 @@ import org.jetbrains.kotlin.resolve.source.KotlinSourceElementKt;
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import org.jetbrains.kotlin.storage.NotNullLazyValue;
import org.jetbrains.kotlin.types.ErrorUtils;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.org.objectweb.asm.Label;
import org.jetbrains.org.objectweb.asm.MethodVisitor;
import org.jetbrains.org.objectweb.asm.Type;
@@ -72,7 +72,7 @@ import static org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin.
import static org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt.Synthetic;
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclarationContainer*/> {
public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclarationContainer*/> {
protected final GenerationState state;
protected final T element;
protected final FieldOwnerContext context;
@@ -179,10 +179,10 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
v.done();
}
public void genFunctionOrProperty(@NotNull JetDeclaration functionOrProperty) {
if (functionOrProperty instanceof JetNamedFunction) {
public void genFunctionOrProperty(@NotNull KtDeclaration functionOrProperty) {
if (functionOrProperty instanceof KtNamedFunction) {
try {
functionCodegen.gen((JetNamedFunction) functionOrProperty);
functionCodegen.gen((KtNamedFunction) functionOrProperty);
}
catch (ProcessCanceledException e) {
throw e;
@@ -194,9 +194,9 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
throw new CompilationException("Failed to generate function " + functionOrProperty.getName(), e, functionOrProperty);
}
}
else if (functionOrProperty instanceof JetProperty) {
else if (functionOrProperty instanceof KtProperty) {
try {
propertyCodegen.gen((JetProperty) functionOrProperty);
propertyCodegen.gen((KtProperty) functionOrProperty);
}
catch (ProcessCanceledException e) {
throw e;
@@ -215,7 +215,7 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
public static void genClassOrObject(
@NotNull CodegenContext parentContext,
@NotNull JetClassOrObject aClass,
@NotNull KtClassOrObject aClass,
@NotNull GenerationState state,
@Nullable MemberCodegen<?> parentCodegen
) {
@@ -242,7 +242,7 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
}
}
public void genClassOrObject(JetClassOrObject aClass) {
public void genClassOrObject(KtClassOrObject aClass) {
genClassOrObject(context, aClass, state, this);
}
@@ -367,14 +367,14 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
protected void generateInitializers(@NotNull Function0<ExpressionCodegen> createCodegen) {
NotNullLazyValue<ExpressionCodegen> codegen = LockBasedStorageManager.NO_LOCKS.createLazyValue(createCodegen);
for (JetDeclaration declaration : ((JetDeclarationContainer) element).getDeclarations()) {
if (declaration instanceof JetProperty) {
if (shouldInitializeProperty((JetProperty) declaration)) {
initializeProperty(codegen.invoke(), (JetProperty) declaration);
for (KtDeclaration declaration : ((KtDeclarationContainer) element).getDeclarations()) {
if (declaration instanceof KtProperty) {
if (shouldInitializeProperty((KtProperty) declaration)) {
initializeProperty(codegen.invoke(), (KtProperty) declaration);
}
}
else if (declaration instanceof JetClassInitializer) {
JetExpression body = ((JetClassInitializer) declaration).getBody();
else if (declaration instanceof KtClassInitializer) {
KtExpression body = ((KtClassInitializer) declaration).getBody();
if (body != null) {
codegen.invoke().gen(body, Type.VOID_TYPE);
}
@@ -382,11 +382,11 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
}
}
private void initializeProperty(@NotNull ExpressionCodegen codegen, @NotNull JetProperty property) {
private void initializeProperty(@NotNull ExpressionCodegen codegen, @NotNull KtProperty property) {
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) bindingContext.get(VARIABLE, property);
assert propertyDescriptor != null;
JetExpression initializer = property.getDelegateExpressionOrInitializer();
KtExpression initializer = property.getDelegateExpressionOrInitializer();
assert initializer != null : "shouldInitializeProperty must return false if initializer is null";
StackValue.Property propValue = codegen.intermediateValueForProperty(propertyDescriptor, true, null, true, StackValue.LOCAL_0);
@@ -394,7 +394,7 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
propValue.store(codegen.gen(initializer), codegen.v);
}
private boolean shouldInitializeProperty(@NotNull JetProperty property) {
private boolean shouldInitializeProperty(@NotNull KtProperty property) {
if (!property.hasDelegateExpressionOrInitializer()) return false;
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) bindingContext.get(VARIABLE, property);
@@ -405,7 +405,7 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
return false;
}
JetExpression initializer = property.getInitializer();
KtExpression initializer = property.getInitializer();
ConstantValue<?> initializerValue = computeInitializerValue(property, propertyDescriptor, initializer);
// we must write constant values for fields in light classes,
@@ -413,16 +413,16 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
if (initializerValue == null) return state.getClassBuilderMode() != ClassBuilderMode.LIGHT_CLASSES;
//TODO: OPTIMIZATION: don't initialize static final fields
JetType jetType = getPropertyOrDelegateType(property, propertyDescriptor);
KtType jetType = getPropertyOrDelegateType(property, propertyDescriptor);
Type type = typeMapper.mapType(jetType);
return !skipDefaultValue(propertyDescriptor, initializerValue.getValue(), type);
}
@Nullable
private ConstantValue<?> computeInitializerValue(
@NotNull JetProperty property,
@NotNull KtProperty property,
@NotNull PropertyDescriptor propertyDescriptor,
@Nullable JetExpression initializer
@Nullable KtExpression initializer
) {
if (property.isVar() && initializer != null) {
BindingTrace tempTrace = TemporaryBindingTrace.create(state.getBindingTrace(), "property initializer");
@@ -432,10 +432,10 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
}
@NotNull
private JetType getPropertyOrDelegateType(@NotNull JetProperty property, @NotNull PropertyDescriptor descriptor) {
JetExpression delegateExpression = property.getDelegateExpression();
private KtType getPropertyOrDelegateType(@NotNull KtProperty property, @NotNull PropertyDescriptor descriptor) {
KtExpression delegateExpression = property.getDelegateExpression();
if (delegateExpression != null) {
JetType delegateType = bindingContext.getType(delegateExpression);
KtType delegateType = bindingContext.getType(delegateExpression);
assert delegateType != null : "Type of delegate expression should be recorded";
return delegateType;
}
@@ -488,10 +488,10 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
}
protected void generatePropertyMetadataArrayFieldIfNeeded(@NotNull Type thisAsmType) {
List<JetProperty> delegatedProperties = new ArrayList<JetProperty>();
for (JetDeclaration declaration : ((JetDeclarationContainer) element).getDeclarations()) {
if (declaration instanceof JetProperty) {
JetProperty property = (JetProperty) declaration;
List<KtProperty> delegatedProperties = new ArrayList<KtProperty>();
for (KtDeclaration declaration : ((KtDeclarationContainer) element).getDeclarations()) {
if (declaration instanceof KtProperty) {
KtProperty property = (KtProperty) declaration;
if (property.hasDelegate()) {
delegatedProperties.add(property);
}
@@ -44,7 +44,7 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.MultifileClassPart
import org.jetbrains.kotlin.resolve.jvm.diagnostics.OtherOrigin
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.resolve.scopes.KtScope
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPropertyDescriptor
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedSimpleFunctionDescriptor
@@ -55,7 +55,7 @@ import java.util.*
public class MultifileClassCodegen(
private val state: GenerationState,
public val files: Collection<JetFile>,
public val files: Collection<KtFile>,
private val facadeFqName: FqName
) {
private val facadeClassType = AsmUtil.asmTypeByFqNameWithoutInnerClasses(facadeFqName)
@@ -71,7 +71,7 @@ public class MultifileClassCodegen(
getDeserializedCallables(compiledPackageFragment)
private fun getDeserializedCallables(compiledPackageFragment: PackageFragmentDescriptor) =
compiledPackageFragment.getMemberScope().getDescriptors(DescriptorKindFilter.CALLABLES, JetScope.ALL_NAME_FILTER).filterIsInstance<DeserializedCallableMemberDescriptor>()
compiledPackageFragment.getMemberScope().getDescriptors(DescriptorKindFilter.CALLABLES, KtScope.ALL_NAME_FILTER).filterIsInstance<DeserializedCallableMemberDescriptor>()
public val packageParts = PackageParts(facadeFqName.parent().asString())
@@ -83,7 +83,7 @@ public class MultifileClassCodegen(
val declarationOrigin = MultifileClass(originFile, actualPackageFragment, facadeFqName)
val classBuilder = state.factory.newVisitor(declarationOrigin, facadeClassType, files)
val filesWithCallables = files.filter { it.declarations.any { it is JetNamedFunction || it is JetProperty } }
val filesWithCallables = files.filter { it.declarations.any { it is KtNamedFunction || it is KtProperty } }
val singleSourceFile = if (previouslyCompiledCallables.isNotEmpty()) null else filesWithCallables.singleOrNull()
@@ -147,12 +147,12 @@ public class MultifileClassCodegen(
writeKotlinMultifileFacadeAnnotationIfNeeded(partFqNames)
}
public fun generateClassOrObject(classOrObject: JetClassOrObject, packagePartContext: FieldOwnerContext<PackageFragmentDescriptor>) {
public fun generateClassOrObject(classOrObject: KtClassOrObject, packagePartContext: FieldOwnerContext<PackageFragmentDescriptor>) {
MemberCodegen.genClassOrObject(packagePartContext, classOrObject, state, null)
}
private fun generatePart(
file: JetFile,
file: KtFile,
generateCallableMemberTasks: MutableMap<CallableMemberDescriptor, () -> Unit>,
partFqNames: MutableList<FqName>
) {
@@ -165,15 +165,15 @@ public class MultifileClassCodegen(
val partContext = state.rootContext.intoMultifileClassPart(packageFragment, facadeClassType, partType, file)
for (declaration in file.declarations) {
if (declaration is JetProperty || declaration is JetNamedFunction) {
if (declaration is KtProperty || declaration is KtNamedFunction) {
generatePart = true
}
else if (declaration is JetClassOrObject) {
else if (declaration is KtClassOrObject) {
if (state.generateDeclaredClassFilter.shouldGenerateClass(declaration)) {
generateClassOrObject(declaration, partContext)
}
}
else if (declaration is JetScript) {
else if (declaration is KtScript) {
// SCRIPT: generate script code, should be separate execution branch
if (state.generateDeclaredClassFilter.shouldGenerateScript(declaration)) {
ScriptCodegen.createScriptCodegen(declaration, state, partContext).generate()
@@ -196,7 +196,7 @@ public class MultifileClassCodegen(
val facadeContext = state.rootContext.intoMultifileClass(packageFragment, facadeClassType, partType)
val memberCodegen = createCodegenForPartOfMultifileFacade(facadeContext)
for (declaration in file.declarations) {
if (declaration is JetNamedFunction || declaration is JetProperty) {
if (declaration is KtNamedFunction || declaration is KtProperty) {
val descriptor = state.bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration)
assert(descriptor is CallableMemberDescriptor) { "Expected callable member, was " + descriptor + " for " + declaration.text }
if (!Visibilities.isPrivate((descriptor as CallableMemberDescriptor).visibility)) {
@@ -273,8 +273,8 @@ public class MultifileClassCodegen(
av.visitEnd()
}
private fun createCodegenForPartOfMultifileFacade(facadeContext: FieldOwnerContext<*>): MemberCodegen<JetFile> =
object : MemberCodegen<JetFile>(state, null, facadeContext, null, classBuilder) {
private fun createCodegenForPartOfMultifileFacade(facadeContext: FieldOwnerContext<*>): MemberCodegen<KtFile> =
object : MemberCodegen<KtFile>(state, null, facadeContext, null, classBuilder) {
override fun generateDeclaration() = throw UnsupportedOperationException()
override fun generateBody() = throw UnsupportedOperationException()
override fun generateKotlinAnnotation() = throw UnsupportedOperationException()
@@ -287,7 +287,7 @@ public class MultifileClassCodegen(
companion object {
private val FACADE_CLASS_ATTRIBUTES = Opcodes.ACC_PUBLIC or Opcodes.ACC_FINAL
private fun getOnlyPackageFragment(packageFqName: FqName, files: Collection<JetFile>, bindingContext: BindingContext): PackageFragmentDescriptor? {
private fun getOnlyPackageFragment(packageFqName: FqName, files: Collection<KtFile>, bindingContext: BindingContext): PackageFragmentDescriptor? {
val fragments = SmartList<PackageFragmentDescriptor>()
for (file in files) {
val fragment = bindingContext.get(BindingContext.FILE_TO_PACKAGE_FRAGMENT, file)
@@ -22,9 +22,9 @@ import org.jetbrains.kotlin.codegen.serialization.JvmSerializerExtension
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
import org.jetbrains.kotlin.psi.JetFile
import org.jetbrains.kotlin.psi.JetNamedFunction
import org.jetbrains.kotlin.psi.JetProperty
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtNamedFunction
import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.serialization.DescriptorSerializer
import org.jetbrains.org.objectweb.asm.Opcodes
@@ -33,12 +33,12 @@ import java.util.*
public class MultifileClassPartCodegen(
v: ClassBuilder,
file: JetFile,
file: KtFile,
private val filePartType: Type,
private val multifileClassType: Type,
partContext: FieldOwnerContext<*>,
state: GenerationState
) : MemberCodegen<JetFile>(state, null, partContext, file, v) {
) : MemberCodegen<KtFile>(state, null, partContext, file, v) {
override fun generate() {
if (state.classBuilderMode == ClassBuilderMode.LIGHT_CLASSES) return
super.generate()
@@ -58,7 +58,7 @@ public class MultifileClassPartCodegen(
override fun generateBody() {
for (declaration in element.declarations) {
if (declaration is JetNamedFunction || declaration is JetProperty) {
if (declaration is KtNamedFunction || declaration is KtProperty) {
genFunctionOrProperty(declaration)
}
}
@@ -72,11 +72,11 @@ public class MultifileClassPartCodegen(
val members = ArrayList<DeclarationDescriptor>()
for (declaration in element.declarations) {
when (declaration) {
is JetNamedFunction -> {
is KtNamedFunction -> {
val functionDescriptor = bindingContext.get(BindingContext.FUNCTION, declaration)
members.add(functionDescriptor ?: throw AssertionError("Function ${declaration.name} is not bound in ${element.name}"))
}
is JetProperty -> {
is KtProperty -> {
val property = bindingContext.get(BindingContext.VARIABLE, declaration)
members.add(property ?: throw AssertionError("Property ${declaration.name} is not bound in ${element.name}"))
}
@@ -24,9 +24,9 @@ import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorBase;
import org.jetbrains.kotlin.descriptors.impl.ConstructorDescriptorImpl;
import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorImpl;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.KtScope;
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.TypeConstructor;
import org.jetbrains.kotlin.types.TypeConstructorImpl;
import org.jetbrains.kotlin.types.TypeUtils;
@@ -41,7 +41,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
private Visibility visibility;
private TypeConstructor typeConstructor;
private List<TypeParameterDescriptor> typeParameters;
private final Collection<JetType> supertypes = new ArrayList<JetType>();
private final Collection<KtType> supertypes = new ArrayList<KtType>();
public MutableClassDescriptor(
@NotNull DeclarationDescriptor containingDeclaration,
@@ -116,7 +116,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
return typeConstructor;
}
public void addSupertype(@NotNull JetType supertype) {
public void addSupertype(@NotNull KtType supertype) {
assert !supertype.isError() : "Error types must be filtered out in DescriptorResolver";
if (TypeUtils.getClassDescriptor(supertype) != null) {
// See the Errors.SUPERTYPE_NOT_A_CLASS_OR_INTERFACE
@@ -160,14 +160,14 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
@Override
@NotNull
public JetScope getUnsubstitutedMemberScope() {
return JetScope.Empty.INSTANCE$; // used for getDefaultType
public KtScope getUnsubstitutedMemberScope() {
return KtScope.Empty.INSTANCE$; // used for getDefaultType
}
@NotNull
@Override
public JetScope getStaticScope() {
return JetScope.Empty.INSTANCE$;
public KtScope getStaticScope() {
return KtScope.Empty.INSTANCE$;
}
@Override
@@ -22,13 +22,10 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.SmartList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.context.CodegenContext;
import org.jetbrains.kotlin.codegen.context.PackageContext;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor;
import org.jetbrains.kotlin.descriptors.Visibilities;
import org.jetbrains.kotlin.diagnostics.DiagnosticUtils;
import org.jetbrains.kotlin.fileClasses.FileClasses;
import org.jetbrains.kotlin.fileClasses.JvmFileClassInfo;
import org.jetbrains.kotlin.load.kotlin.PackageParts;
import org.jetbrains.kotlin.name.FqName;
@@ -42,13 +39,13 @@ import java.util.Collection;
public class PackageCodegen {
private final GenerationState state;
private final Collection<JetFile> files;
private final Collection<KtFile> files;
private final PackageFragmentDescriptor packageFragment;
private final PackageParts packageParts;
public PackageCodegen(
@NotNull GenerationState state,
@NotNull Collection<JetFile> files,
@NotNull Collection<KtFile> files,
@NotNull FqName packageFqName
) {
this.state = state;
@@ -58,7 +55,7 @@ public class PackageCodegen {
}
public void generate(@NotNull CompilationErrorHandler errorHandler) {
for (JetFile file : files) {
for (KtFile file : files) {
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled();
try {
generateFile(file);
@@ -79,7 +76,7 @@ public class PackageCodegen {
}
@Nullable
private ClassBuilder generateFile(@NotNull JetFile file) {
private ClassBuilder generateFile(@NotNull KtFile file) {
JvmFileClassInfo fileClassInfo = state.getFileClassesProvider().getFileClassInfo(file);
if (fileClassInfo.getWithJvmMultifileClass()) {
@@ -91,18 +88,18 @@ public class PackageCodegen {
boolean generatePackagePart = false;
for (JetDeclaration declaration : file.getDeclarations()) {
if (declaration instanceof JetProperty || declaration instanceof JetNamedFunction) {
for (KtDeclaration declaration : file.getDeclarations()) {
if (declaration instanceof KtProperty || declaration instanceof KtNamedFunction) {
generatePackagePart = true;
}
else if (declaration instanceof JetClassOrObject) {
JetClassOrObject classOrObject = (JetClassOrObject) declaration;
else if (declaration instanceof KtClassOrObject) {
KtClassOrObject classOrObject = (KtClassOrObject) declaration;
if (state.getGenerateDeclaredClassFilter().shouldGenerateClass(classOrObject)) {
generateClassOrObject(classOrObject, packagePartContext);
}
}
else if (declaration instanceof JetScript) {
JetScript script = (JetScript) declaration;
else if (declaration instanceof KtScript) {
KtScript script = (KtScript) declaration;
// SCRIPT: generate script code, should be separate execution branch
if (state.getGenerateDeclaredClassFilter().shouldGenerateScript(script)) {
@@ -126,7 +123,7 @@ public class PackageCodegen {
@Nullable
private PackageFragmentDescriptor getOnlyPackageFragment(@NotNull FqName expectedPackageFqName) {
SmartList<PackageFragmentDescriptor> fragments = new SmartList<PackageFragmentDescriptor>();
for (JetFile file : files) {
for (KtFile file : files) {
PackageFragmentDescriptor fragment = state.getBindingContext().get(BindingContext.FILE_TO_PACKAGE_FRAGMENT, file);
assert fragment != null : "package fragment is null for " + file + "\n" + file.getText();
@@ -147,7 +144,7 @@ public class PackageCodegen {
return fragments.get(0);
}
public void generateClassOrObject(@NotNull JetClassOrObject classOrObject, @NotNull PackageContext packagePartContext) {
public void generateClassOrObject(@NotNull KtClassOrObject classOrObject, @NotNull PackageContext packagePartContext) {
MemberCodegen.genClassOrObject(packagePartContext, classOrObject, state, null);
}
@@ -155,7 +152,7 @@ public class PackageCodegen {
return packageParts;
}
public Collection<JetFile> getFiles() {
public Collection<KtFile> getFiles() {
return files;
}
@@ -46,12 +46,12 @@ import static org.jetbrains.kotlin.codegen.AsmUtil.writeAnnotationData;
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.writeModuleName;
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
public class PackagePartCodegen extends MemberCodegen<JetFile> {
public class PackagePartCodegen extends MemberCodegen<KtFile> {
private final Type packagePartType;
public PackagePartCodegen(
@NotNull ClassBuilder v,
@NotNull JetFile file,
@NotNull KtFile file,
@NotNull Type packagePartType,
@NotNull FieldOwnerContext context,
@NotNull GenerationState state
@@ -78,7 +78,7 @@ public class PackagePartCodegen extends MemberCodegen<JetFile> {
private void generateAnnotationsForPartClass() {
List<AnnotationDescriptor> fileAnnotationDescriptors = new ArrayList<AnnotationDescriptor>();
for (JetAnnotationEntry annotationEntry : element.getAnnotationEntries()) {
for (KtAnnotationEntry annotationEntry : element.getAnnotationEntries()) {
AnnotationDescriptor annotationDescriptor = state.getBindingContext().get(BindingContext.ANNOTATION, annotationEntry);
if (annotationDescriptor != null) {
fileAnnotationDescriptors.add(annotationDescriptor);
@@ -90,8 +90,8 @@ public class PackagePartCodegen extends MemberCodegen<JetFile> {
@Override
protected void generateBody() {
for (JetDeclaration declaration : element.getDeclarations()) {
if (declaration instanceof JetNamedFunction || declaration instanceof JetProperty) {
for (KtDeclaration declaration : element.getDeclarations()) {
if (declaration instanceof KtNamedFunction || declaration instanceof KtProperty) {
genFunctionOrProperty(declaration);
}
}
@@ -109,11 +109,11 @@ public class PackagePartCodegen extends MemberCodegen<JetFile> {
@Override
protected void generateKotlinAnnotation() {
List<DeclarationDescriptor> members = new ArrayList<DeclarationDescriptor>();
for (JetDeclaration declaration : element.getDeclarations()) {
if (declaration instanceof JetNamedFunction) {
for (KtDeclaration declaration : element.getDeclarations()) {
if (declaration instanceof KtNamedFunction) {
SimpleFunctionDescriptor functionDescriptor = bindingContext.get(BindingContext.FUNCTION, declaration);
members.add(functionDescriptor);
} else if (declaration instanceof JetProperty) {
} else if (declaration instanceof KtProperty) {
VariableDescriptor property = bindingContext.get(BindingContext.VARIABLE, declaration);
members.add(property);
}
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor
import org.jetbrains.kotlin.psi.JetNamedFunction
import org.jetbrains.kotlin.psi.KtNamedFunction
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
import org.jetbrains.kotlin.resolve.jvm.diagnostics.Synthetic
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
@@ -73,7 +73,7 @@ class PlatformStaticGenerator(
}
)
if (originElement is JetNamedFunction) {
if (originElement is KtNamedFunction) {
codegen.functionCodegen.generateOverloadsWithDefaultValues(originElement, staticFunctionDescriptor, descriptor)
}
}
@@ -44,7 +44,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPropertyDescriptor;
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import org.jetbrains.kotlin.types.ErrorUtils;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.org.objectweb.asm.FieldVisitor;
import org.jetbrains.org.objectweb.asm.MethodVisitor;
import org.jetbrains.org.objectweb.asm.Opcodes;
@@ -88,7 +88,7 @@ public class PropertyCodegen {
this.kind = context.getContextKind();
}
public void gen(@NotNull JetProperty property) {
public void gen(@NotNull KtProperty property) {
VariableDescriptor variableDescriptor = bindingContext.get(BindingContext.VARIABLE, property);
assert variableDescriptor instanceof PropertyDescriptor : "Property " + property.getText() + " should have a property descriptor: " + variableDescriptor;
@@ -102,10 +102,10 @@ public class PropertyCodegen {
}
private void gen(
@Nullable JetProperty declaration,
@Nullable KtProperty declaration,
@NotNull PropertyDescriptor descriptor,
@Nullable JetPropertyAccessor getter,
@Nullable JetPropertyAccessor setter
@Nullable KtPropertyAccessor getter,
@Nullable KtPropertyAccessor setter
) {
assert kind == OwnerKind.PACKAGE || kind == OwnerKind.IMPLEMENTATION || kind == OwnerKind.DEFAULT_IMPLS
: "Generating property with a wrong kind (" + kind + "): " + descriptor;
@@ -147,9 +147,9 @@ public class PropertyCodegen {
* @see JvmCodegenUtil#couldUseDirectAccessToProperty
*/
private boolean isAccessorNeeded(
@Nullable JetProperty declaration,
@Nullable KtProperty declaration,
@NotNull PropertyDescriptor descriptor,
@Nullable JetPropertyAccessor accessor
@Nullable KtPropertyAccessor accessor
) {
if (hasJvmFieldAnnotation(descriptor)) return false;
@@ -174,7 +174,7 @@ public class PropertyCodegen {
return true;
}
public void generatePrimaryConstructorProperty(JetParameter p, PropertyDescriptor descriptor) {
public void generatePrimaryConstructorProperty(KtParameter p, PropertyDescriptor descriptor) {
AnnotationSplitter annotationSplitter = AnnotationSplitter.create(LockBasedStorageManager.NO_LOCKS,
descriptor.getAnnotations(), AnnotationSplitter.getTargetSet(true, descriptor.isVar(), hasBackingField(p, descriptor)));
@@ -192,7 +192,7 @@ public class PropertyCodegen {
}
}
public void generateConstructorPropertyAsMethodForAnnotationClass(JetParameter p, PropertyDescriptor descriptor) {
public void generateConstructorPropertyAsMethodForAnnotationClass(KtParameter p, PropertyDescriptor descriptor) {
JvmMethodSignature signature = typeMapper.mapAnnotationParameterSignature(descriptor);
String name = p.getName();
if (name == null) return;
@@ -204,7 +204,7 @@ public class PropertyCodegen {
);
if (state.getClassBuilderMode() == ClassBuilderMode.FULL) {
JetExpression defaultValue = p.getDefaultValue();
KtExpression defaultValue = p.getDefaultValue();
if (defaultValue != null) {
ConstantValue<?> constant = ExpressionCodegen.getCompileTimeConstant(defaultValue, bindingContext);
assert constant != null : "Default value for annotation parameter should be compile time value: " + defaultValue.getText();
@@ -216,14 +216,14 @@ public class PropertyCodegen {
mv.visitEnd();
}
private boolean hasBackingField(@NotNull JetNamedDeclaration p, @NotNull PropertyDescriptor descriptor) {
private boolean hasBackingField(@NotNull KtNamedDeclaration p, @NotNull PropertyDescriptor descriptor) {
return !isJvmInterface(descriptor.getContainingDeclaration()) &&
kind != OwnerKind.DEFAULT_IMPLS &&
!Boolean.FALSE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor));
}
private boolean generateBackingField(
@NotNull JetNamedDeclaration p,
@NotNull KtNamedDeclaration p,
@NotNull PropertyDescriptor descriptor,
@NotNull Annotations annotations
) {
@@ -231,8 +231,8 @@ public class PropertyCodegen {
return false;
}
if (p instanceof JetProperty && ((JetProperty) p).hasDelegate()) {
generatePropertyDelegateAccess((JetProperty) p, descriptor, annotations);
if (p instanceof KtProperty && ((KtProperty) p).hasDelegate()) {
generatePropertyDelegateAccess((KtProperty) p, descriptor, annotations);
}
else if (Boolean.TRUE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor))) {
generateBackingFieldAccess(p, descriptor, annotations);
@@ -272,10 +272,10 @@ public class PropertyCodegen {
}
private void generateBackingField(
JetNamedDeclaration element,
KtNamedDeclaration element,
PropertyDescriptor propertyDescriptor,
boolean isDelegate,
JetType jetType,
KtType jetType,
Object defaultValue,
Annotations annotations
) {
@@ -360,9 +360,9 @@ public class PropertyCodegen {
AnnotationCodegen.forField(fv, typeMapper).genAnnotations(fieldAnnotated, type, AnnotationUseSiteTarget.FIELD);
}
private void generatePropertyDelegateAccess(JetProperty p, PropertyDescriptor propertyDescriptor, Annotations annotations) {
JetExpression delegateExpression = p.getDelegateExpression();
JetType delegateType = delegateExpression != null ? bindingContext.getType(p.getDelegateExpression()) : null;
private void generatePropertyDelegateAccess(KtProperty p, PropertyDescriptor propertyDescriptor, Annotations annotations) {
KtExpression delegateExpression = p.getDelegateExpression();
KtType delegateType = delegateExpression != null ? bindingContext.getType(p.getDelegateExpression()) : null;
if (delegateType == null) {
// If delegate expression is unresolved reference
delegateType = ErrorUtils.createErrorType("Delegate type");
@@ -371,7 +371,7 @@ public class PropertyCodegen {
generateBackingField(p, propertyDescriptor, true, delegateType, null, annotations);
}
private void generateBackingFieldAccess(JetNamedDeclaration p, PropertyDescriptor propertyDescriptor, Annotations annotations) {
private void generateBackingFieldAccess(KtNamedDeclaration p, PropertyDescriptor propertyDescriptor, Annotations annotations) {
Object value = null;
if (shouldWriteFieldInitializer(propertyDescriptor)) {
@@ -393,13 +393,13 @@ public class PropertyCodegen {
return false;
}
private void generateGetter(@Nullable JetNamedDeclaration p, @NotNull PropertyDescriptor descriptor, @Nullable JetPropertyAccessor getter) {
private void generateGetter(@Nullable KtNamedDeclaration p, @NotNull PropertyDescriptor descriptor, @Nullable KtPropertyAccessor getter) {
generateAccessor(p, getter, descriptor.getGetter() != null
? descriptor.getGetter()
: DescriptorFactory.createDefaultGetter(descriptor, Annotations.Companion.getEMPTY()));
}
private void generateSetter(@Nullable JetNamedDeclaration p, @NotNull PropertyDescriptor descriptor, @Nullable JetPropertyAccessor setter) {
private void generateSetter(@Nullable KtNamedDeclaration p, @NotNull PropertyDescriptor descriptor, @Nullable KtPropertyAccessor setter) {
if (!descriptor.isVar()) return;
generateAccessor(p, setter, descriptor.getSetter() != null
@@ -408,8 +408,8 @@ public class PropertyCodegen {
}
private void generateAccessor(
@Nullable JetNamedDeclaration p,
@Nullable JetPropertyAccessor accessor,
@Nullable KtNamedDeclaration p,
@Nullable KtPropertyAccessor accessor,
@NotNull PropertyAccessorDescriptor accessorDescriptor
) {
if (context instanceof MultifileClassFacadeContext && Visibilities.isPrivate(accessorDescriptor.getVisibility())) {
@@ -418,8 +418,8 @@ public class PropertyCodegen {
FunctionGenerationStrategy strategy;
if (accessor == null || !accessor.hasBody()) {
if (p instanceof JetProperty && ((JetProperty) p).hasDelegate()) {
strategy = new DelegatedPropertyAccessorStrategy(state, accessorDescriptor, indexOfDelegatedProperty((JetProperty) p));
if (p instanceof KtProperty && ((KtProperty) p).hasDelegate()) {
strategy = new DelegatedPropertyAccessorStrategy(state, accessorDescriptor, indexOfDelegatedProperty((KtProperty) p));
}
else {
strategy = new DefaultPropertyAccessorStrategy(state, accessorDescriptor);
@@ -432,22 +432,22 @@ public class PropertyCodegen {
functionCodegen.generateMethod(JvmDeclarationOriginKt.OtherOrigin(accessor != null ? accessor : p, accessorDescriptor), accessorDescriptor, strategy);
}
public static int indexOfDelegatedProperty(@NotNull JetProperty property) {
public static int indexOfDelegatedProperty(@NotNull KtProperty property) {
PsiElement parent = property.getParent();
JetDeclarationContainer container;
if (parent instanceof JetClassBody) {
container = ((JetClassOrObject) parent.getParent());
KtDeclarationContainer container;
if (parent instanceof KtClassBody) {
container = ((KtClassOrObject) parent.getParent());
}
else if (parent instanceof JetFile) {
container = (JetFile) parent;
else if (parent instanceof KtFile) {
container = (KtFile) parent;
}
else {
throw new UnsupportedOperationException("Unknown delegated property container: " + parent);
}
int index = 0;
for (JetDeclaration declaration : container.getDeclarations()) {
if (declaration instanceof JetProperty && ((JetProperty) declaration).hasDelegate()) {
for (KtDeclaration declaration : container.getDeclarations()) {
if (declaration instanceof KtProperty && ((KtProperty) declaration).hasDelegate()) {
if (declaration == property) {
return index;
}
@@ -471,8 +471,8 @@ public class PropertyCodegen {
StackValue property = codegen.intermediateValueForProperty(propertyDescriptor, true, null, StackValue.LOCAL_0);
PsiElement jetProperty = DescriptorToSourceUtils.descriptorToDeclaration(propertyDescriptor);
if (jetProperty instanceof JetProperty || jetProperty instanceof JetParameter) {
codegen.markLineNumber((JetElement) jetProperty, false);
if (jetProperty instanceof KtProperty || jetProperty instanceof KtParameter) {
codegen.markLineNumber((KtElement) jetProperty, false);
}
if (callableDescriptor instanceof PropertyGetterDescriptor) {
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.JetElement
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.resolve.DescriptorFactory
import org.jetbrains.kotlin.resolve.PropertyImportedFromObject
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
@@ -47,12 +47,12 @@ public class PropertyReferenceCodegen(
state: GenerationState,
parentCodegen: MemberCodegen<*>,
context: ClassContext,
expression: JetElement,
expression: KtElement,
classBuilder: ClassBuilder,
private val classDescriptor: ClassDescriptor,
private val target: VariableDescriptor,
dispatchReceiver: ReceiverValue
) : MemberCodegen<JetElement>(state, parentCodegen, context, expression, classBuilder) {
) : MemberCodegen<KtElement>(state, parentCodegen, context, expression, classBuilder) {
private val asmType = typeMapper.mapClass(classDescriptor)
private val dispatchReceiverType =
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.name.FqNameUnsafe;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import java.util.List;
@@ -53,27 +53,27 @@ public class RangeCodegenUtil {
private RangeCodegenUtil() {}
public static boolean isRange(JetType rangeType) {
public static boolean isRange(KtType rangeType) {
return !rangeType.isMarkedNullable() && getPrimitiveRangeElementType(rangeType) != null;
}
public static boolean isProgression(JetType rangeType) {
public static boolean isProgression(KtType rangeType) {
return !rangeType.isMarkedNullable() && getPrimitiveProgressionElementType(rangeType) != null;
}
@Nullable
public static BinaryCall getRangeAsBinaryCall(@NotNull JetForExpression forExpression) {
public static BinaryCall getRangeAsBinaryCall(@NotNull KtForExpression forExpression) {
// We are looking for rangeTo() calls
// Other binary operations will succeed too, but will be filtered out later (by examining a resolvedCall)
JetExpression rangeExpression = forExpression.getLoopRange();
KtExpression rangeExpression = forExpression.getLoopRange();
assert rangeExpression != null;
JetExpression loopRange = JetPsiUtil.deparenthesize(rangeExpression);
if (loopRange instanceof JetQualifiedExpression) {
KtExpression loopRange = KtPsiUtil.deparenthesize(rangeExpression);
if (loopRange instanceof KtQualifiedExpression) {
// a.rangeTo(b)
JetQualifiedExpression qualifiedExpression = (JetQualifiedExpression) loopRange;
JetExpression selector = qualifiedExpression.getSelectorExpression();
if (selector instanceof JetCallExpression) {
JetCallExpression callExpression = (JetCallExpression) selector;
KtQualifiedExpression qualifiedExpression = (KtQualifiedExpression) loopRange;
KtExpression selector = qualifiedExpression.getSelectorExpression();
if (selector instanceof KtCallExpression) {
KtCallExpression callExpression = (KtCallExpression) selector;
List<? extends ValueArgument> arguments = callExpression.getValueArguments();
if (arguments.size() == 1) {
return new BinaryCall(qualifiedExpression.getReceiverExpression(), callExpression.getCalleeExpression(),
@@ -81,10 +81,10 @@ public class RangeCodegenUtil {
}
}
}
else if (loopRange instanceof JetBinaryExpression) {
else if (loopRange instanceof KtBinaryExpression) {
// a rangeTo b
// a .. b
JetBinaryExpression binaryExpression = (JetBinaryExpression) loopRange;
KtBinaryExpression binaryExpression = (KtBinaryExpression) loopRange;
return new BinaryCall(binaryExpression.getLeft(), binaryExpression.getOperationReference(), binaryExpression.getRight());
}
@@ -92,18 +92,18 @@ public class RangeCodegenUtil {
}
@Nullable
private static PrimitiveType getPrimitiveRangeElementType(JetType rangeType) {
private static PrimitiveType getPrimitiveRangeElementType(KtType rangeType) {
return getPrimitiveRangeOrProgressionElementType(rangeType, RANGE_TO_ELEMENT_TYPE);
}
@Nullable
private static PrimitiveType getPrimitiveProgressionElementType(JetType rangeType) {
private static PrimitiveType getPrimitiveProgressionElementType(KtType rangeType) {
return getPrimitiveRangeOrProgressionElementType(rangeType, PROGRESSION_TO_ELEMENT_TYPE);
}
@Nullable
private static PrimitiveType getPrimitiveRangeOrProgressionElementType(
@NotNull JetType rangeOrProgression,
@NotNull KtType rangeOrProgression,
@NotNull ImmutableMap<FqName, PrimitiveType> map
) {
ClassifierDescriptor declarationDescriptor = rangeOrProgression.getConstructor().getDeclarationDescriptor();
@@ -133,11 +133,11 @@ public class RangeCodegenUtil {
}
public static class BinaryCall {
public final JetExpression left;
public final JetExpression op;
public final JetExpression right;
public final KtExpression left;
public final KtExpression op;
public final KtExpression right;
private BinaryCall(JetExpression left, JetExpression op, JetExpression right) {
private BinaryCall(KtExpression left, KtExpression op, KtExpression right) {
this.left = left;
this.op = op;
this.right = right;
@@ -21,22 +21,22 @@ import org.jetbrains.kotlin.descriptors.ClassifierDescriptor;
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor;
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor;
import org.jetbrains.kotlin.load.java.sam.SingleAbstractMethodUtils;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
public class SamType {
public static SamType create(@NotNull JetType originalType) {
public static SamType create(@NotNull KtType originalType) {
if (!SingleAbstractMethodUtils.isSamType(originalType)) return null;
return new SamType(originalType);
}
private final JetType type;
private final KtType type;
private SamType(@NotNull JetType type) {
private SamType(@NotNull KtType type) {
this.type = type;
}
@NotNull
public JetType getType() {
public KtType getType() {
return type;
}
@@ -48,7 +48,7 @@ public class SamType {
}
@NotNull
public JetType getKotlinFunctionType() {
public KtType getKotlinFunctionType() {
//noinspection ConstantConditions
return getJavaClassDescriptor().getFunctionTypeForSamInterface();
}
@@ -22,7 +22,7 @@ import com.intellij.openapi.util.Pair;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.org.objectweb.asm.Type;
import java.util.Map;
@@ -30,14 +30,14 @@ import java.util.Map;
public class SamWrapperClasses {
private final GenerationState state;
private final Map<Pair<SamType, JetFile>, Type> samInterfaceToWrapperClass = Maps.newHashMap();
private final Map<Pair<SamType, KtFile>, Type> samInterfaceToWrapperClass = Maps.newHashMap();
public SamWrapperClasses(@NotNull GenerationState state) {
this.state = state;
}
@NotNull
public Type getSamWrapperClass(@NotNull final SamType samType, @NotNull final JetFile file, @NotNull final MemberCodegen<?> parentCodegen) {
public Type getSamWrapperClass(@NotNull final SamType samType, @NotNull final KtFile file, @NotNull final MemberCodegen<?> parentCodegen) {
return ContainerUtil.getOrCreate(samInterfaceToWrapperClass, Pair.create(samType, file),
new Factory<Type>() {
@Override
@@ -28,10 +28,10 @@ import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor;
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.util.OperatorNameConventions;
import org.jetbrains.org.objectweb.asm.MethodVisitor;
import org.jetbrains.org.objectweb.asm.Type;
@@ -58,13 +58,13 @@ public class SamWrapperCodegen {
this.parentCodegen = parentCodegen;
}
public Type genWrapper(@NotNull JetFile file) {
public Type genWrapper(@NotNull KtFile file) {
// Name for generated class, in form of whatever$1
FqName fqName = getWrapperName(file);
Type asmType = asmTypeByFqNameWithoutInnerClasses(fqName);
// e.g. (T, T) -> Int
JetType functionType = samType.getKotlinFunctionType();
KtType functionType = samType.getKotlinFunctionType();
ClassDescriptor classDescriptor = new ClassDescriptorImpl(
samType.getJavaClassDescriptor().getContainingDeclaration(),
@@ -140,7 +140,7 @@ public class SamWrapperCodegen {
Type functionType,
ClassBuilder cv,
SimpleFunctionDescriptor erasedInterfaceFunction,
JetType functionJetType
KtType functionJetType
) {
// using root context to avoid creating ClassDescriptor and everything else
FunctionCodegen codegen = new FunctionCodegen(state.getRootContext().intoClass(
@@ -168,7 +168,7 @@ public class SamWrapperCodegen {
}
@NotNull
private FqName getWrapperName(@NotNull JetFile containingFile) {
private FqName getWrapperName(@NotNull KtFile containingFile) {
FqName fileClassFqName = JvmFileClassUtil.getFileClassInfoNoResolve(containingFile).getFileClassFqName();
JavaClassDescriptor descriptor = samType.getJavaClassDescriptor();
int hash = PackagePartClassUtils.getPathHashCode(containingFile.getVirtualFile()) * 31 +
@@ -45,10 +45,10 @@ import static org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin.
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
// SCRIPT: script code generator
public class ScriptCodegen extends MemberCodegen<JetScript> {
public class ScriptCodegen extends MemberCodegen<KtScript> {
public static ScriptCodegen createScriptCodegen(
@NotNull JetScript declaration,
@NotNull KtScript declaration,
@NotNull GenerationState state,
@NotNull CodegenContext parentContext
) {
@@ -72,12 +72,12 @@ public class ScriptCodegen extends MemberCodegen<JetScript> {
return new ScriptCodegen(declaration, state, scriptContext, builder);
}
private final JetScript scriptDeclaration;
private final KtScript scriptDeclaration;
private final ScriptContext context;
private final ScriptDescriptor scriptDescriptor;
private ScriptCodegen(
@NotNull JetScript scriptDeclaration,
@NotNull KtScript scriptDeclaration,
@NotNull GenerationState state,
@NotNull ScriptContext context,
@NotNull ClassBuilder builder
@@ -221,12 +221,12 @@ public class ScriptCodegen extends MemberCodegen<JetScript> {
}
private void genMembers() {
for (JetDeclaration declaration : scriptDeclaration.getDeclarations()) {
if (declaration instanceof JetProperty || declaration instanceof JetNamedFunction) {
for (KtDeclaration declaration : scriptDeclaration.getDeclarations()) {
if (declaration instanceof KtProperty || declaration instanceof KtNamedFunction) {
genFunctionOrProperty(declaration);
}
else if (declaration instanceof JetClassOrObject) {
genClassOrObject((JetClassOrObject) declaration);
else if (declaration instanceof KtClassOrObject) {
genClassOrObject((KtClassOrObject) declaration);
}
}
}
@@ -17,21 +17,21 @@
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.psi.JetElement
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.backend.common.CodegenUtil
import org.jetbrains.kotlin.psi.JetFile
import org.jetbrains.kotlin.psi.JetNamedFunction
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtNamedFunction
data public class SourceInfo(val source: String, val pathOrCleanFQN: String, val linesInFile: Int) {
companion object {
fun createInfo(element: JetElement?, internalClassName: String): SourceInfo {
fun createInfo(element: KtElement?, internalClassName: String): SourceInfo {
assert(element != null) { "Couldn't create source mapper for null element " + internalClassName }
val lineNumbers = CodegenUtil.getLineNumberForElement(element!!.getContainingFile(), true)
assert(lineNumbers != null) { "Couldn't extract line count in " + element.getContainingFile() }
//TODO hack condition for package parts cleaning
val isTopLevel = element is JetFile || (element is JetNamedFunction && element.getParent() is JetFile)
val isTopLevel = element is KtFile || (element is KtNamedFunction && element.getParent() is KtFile)
val cleanedClassFqName = if (!isTopLevel) internalClassName else internalClassName.substringBefore('$')
return SourceInfo(element.getContainingJetFile().getName(), cleanedClassFqName, lineNumbers!!)
@@ -29,7 +29,7 @@ import org.jetbrains.kotlin.codegen.state.JetTypeMapper;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.load.java.JvmAbi;
import org.jetbrains.kotlin.load.java.descriptors.JavaPropertyDescriptor;
import org.jetbrains.kotlin.psi.JetExpression;
import org.jetbrains.kotlin.psi.KtExpression;
import org.jetbrains.kotlin.resolve.ImportedFromObjectCallableDescriptor;
import org.jetbrains.kotlin.resolve.annotations.AnnotationUtilKt;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
@@ -266,7 +266,7 @@ public abstract class StackValue {
}
@NotNull
public static StackValue expression(Type type, JetExpression expression, ExpressionCodegen generator) {
public static StackValue expression(Type type, KtExpression expression, ExpressionCodegen generator) {
return new Expression(type, expression, generator);
}
@@ -1124,10 +1124,10 @@ public abstract class StackValue {
}
private static class Expression extends StackValue {
private final JetExpression expression;
private final KtExpression expression;
private final ExpressionCodegen generator;
public Expression(Type type, JetExpression expression, ExpressionCodegen generator) {
public Expression(Type type, KtExpression expression, ExpressionCodegen generator) {
super(type);
this.expression = expression;
this.generator = generator;
@@ -24,8 +24,8 @@ import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor;
import org.jetbrains.kotlin.psi.JetExpression;
import org.jetbrains.kotlin.psi.JetSimpleNameExpression;
import org.jetbrains.kotlin.psi.KtExpression;
import org.jetbrains.kotlin.psi.KtSimpleNameExpression;
import org.jetbrains.kotlin.psi.ValueArgument;
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
import org.jetbrains.kotlin.resolve.calls.model.*;
@@ -104,9 +104,9 @@ public class TailRecursionCodegen {
if (arg instanceof ExpressionValueArgument) {
ExpressionValueArgument ev = (ExpressionValueArgument) arg;
ValueArgument argument = ev.getValueArgument();
JetExpression argumentExpression = argument == null ? null : argument.getArgumentExpression();
KtExpression argumentExpression = argument == null ? null : argument.getArgumentExpression();
if (argumentExpression instanceof JetSimpleNameExpression) {
if (argumentExpression instanceof KtSimpleNameExpression) {
ResolvedCall<?> resolvedCall = CallUtilKt.getResolvedCall(argumentExpression, state.getBindingContext());
if (resolvedCall != null && resolvedCall.getResultingDescriptor().equals(parameterDescriptor.getOriginal())) {
// do nothing: we shouldn't store argument to itself again
@@ -21,10 +21,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.context.EnclosedValueDescriptor;
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor;
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.org.objectweb.asm.Type;
import java.util.List;
@@ -35,7 +33,7 @@ public interface CalculatedClosure {
ClassDescriptor getCaptureThis();
@Nullable
JetType getCaptureReceiverType();
KtType getCaptureReceiverType();
@NotNull
Map<DeclarationDescriptor, EnclosedValueDescriptor> getCaptureVariables();
@@ -49,19 +49,19 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument;
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
import org.jetbrains.kotlin.resolve.constants.EnumValue;
import org.jetbrains.kotlin.resolve.constants.NullValue;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.KtScope;
import org.jetbrains.kotlin.resolve.source.KotlinSourceElementKt;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.org.objectweb.asm.Type;
import java.util.*;
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.*;
import static org.jetbrains.kotlin.lexer.JetTokens.*;
import static org.jetbrains.kotlin.lexer.KtTokens.*;
import static org.jetbrains.kotlin.name.SpecialNames.safeIdentifier;
import static org.jetbrains.kotlin.resolve.BindingContext.*;
class CodegenAnnotatingVisitor extends JetVisitorVoid {
class CodegenAnnotatingVisitor extends KtVisitorVoid {
private static final TokenSet BINARY_OPERATIONS = TokenSet.orSet(
AUGMENTED_ASSIGNMENTS,
TokenSet.create(PLUS, MINUS, MUL, DIV, PERC, RANGE, LT, GT, LTEQ, GTEQ, IDENTIFIER)
@@ -88,9 +88,9 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
@NotNull
private ClassDescriptor recordClassForCallable(
@NotNull JetElement element,
@NotNull KtElement element,
@NotNull CallableDescriptor callableDescriptor,
@NotNull Collection<JetType> supertypes,
@NotNull Collection<KtType> supertypes,
@NotNull String name
) {
String simpleName = name.substring(name.lastIndexOf('/') + 1);
@@ -101,7 +101,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
supertypes,
KotlinSourceElementKt.toSourceElement(element)
);
classDescriptor.initialize(JetScope.Empty.INSTANCE$, Collections.<ConstructorDescriptor>emptySet(), null);
classDescriptor.initialize(KtScope.Empty.INSTANCE$, Collections.<ConstructorDescriptor>emptySet(), null);
bindingTrace.record(CLASS_FOR_CALLABLE, callableDescriptor, classDescriptor);
return classDescriptor;
@@ -109,7 +109,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
@NotNull
@SuppressWarnings("ConstantConditions")
private DeclarationDescriptor correctContainerForLambda(@NotNull CallableDescriptor descriptor, @NotNull JetElement function) {
private DeclarationDescriptor correctContainerForLambda(@NotNull CallableDescriptor descriptor, @NotNull KtElement function) {
DeclarationDescriptor container = descriptor.getContainingDeclaration();
// In almost all cases the function's direct container is the correct container to consider in JVM back-end
@@ -126,9 +126,9 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
if (bindingContext.get(DECLARATION_TO_DESCRIPTOR, element) == container) return container;
if (element instanceof JetObjectDeclaration &&
element.getParent() instanceof JetObjectLiteralExpression &&
child instanceof JetDelegationSpecifierList) {
if (element instanceof KtObjectDeclaration &&
element.getParent() instanceof KtObjectLiteralExpression &&
child instanceof KtDelegationSpecifierList) {
// If we're passing an anonymous object's super call, it means "container" is ConstructorDescriptor of that object.
// To reach outer context, we should call getContainingDeclaration() twice
// TODO: this is probably not entirely correct, mostly because DECLARATION_TO_DESCRIPTOR can return null
@@ -153,13 +153,13 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
}
@Override
public void visitJetElement(@NotNull JetElement element) {
public void visitJetElement(@NotNull KtElement element) {
super.visitJetElement(element);
element.acceptChildren(this);
}
@Override
public void visitJetFile(@NotNull JetFile file) {
public void visitJetFile(@NotNull KtFile file) {
if (file.isScript()) {
// SCRIPT: should be replaced with VisitScript override
//noinspection ConstantConditions
@@ -179,9 +179,9 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
}
@Override
public void visitEnumEntry(@NotNull JetEnumEntry enumEntry) {
public void visitEnumEntry(@NotNull KtEnumEntry enumEntry) {
if (enumEntry.getDeclarations().isEmpty()) {
for (JetDelegationSpecifier specifier : enumEntry.getDelegationSpecifiers()) {
for (KtDelegationSpecifier specifier : enumEntry.getDelegationSpecifiers()) {
specifier.accept(this);
}
return;
@@ -196,7 +196,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
}
@Override
public void visitObjectDeclaration(@NotNull JetObjectDeclaration declaration) {
public void visitObjectDeclaration(@NotNull KtObjectDeclaration declaration) {
if (!filter.shouldAnnotateClass(declaration)) return;
ClassDescriptor classDescriptor = bindingContext.get(CLASS, declaration);
@@ -214,7 +214,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
}
@Override
public void visitClass(@NotNull JetClass klass) {
public void visitClass(@NotNull KtClass klass) {
if (!filter.shouldAnnotateClass(klass)) return;
ClassDescriptor classDescriptor = bindingContext.get(CLASS, klass);
@@ -239,8 +239,8 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
}
@Override
public void visitObjectLiteralExpression(@NotNull JetObjectLiteralExpression expression) {
JetObjectDeclaration object = expression.getObjectDeclaration();
public void visitObjectLiteralExpression(@NotNull KtObjectLiteralExpression expression) {
KtObjectDeclaration object = expression.getObjectDeclaration();
ClassDescriptor classDescriptor = bindingContext.get(CLASS, object);
if (classDescriptor == null) {
// working around a problem with shallow analysis
@@ -251,14 +251,14 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
String name = inventAnonymousClassName();
recordClosure(classDescriptor, name);
JetDelegationSpecifierList delegationSpecifierList = object.getDelegationSpecifierList();
KtDelegationSpecifierList delegationSpecifierList = object.getDelegationSpecifierList();
if (delegationSpecifierList != null) {
delegationSpecifierList.accept(this);
}
classStack.push(classDescriptor);
nameStack.push(CodegenBinding.getAsmType(bindingContext, classDescriptor).getInternalName());
JetClassBody body = object.getBody();
KtClassBody body = object.getBody();
if (body != null) {
super.visitClassBody(body);
}
@@ -267,15 +267,15 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
}
@Override
public void visitFunctionLiteralExpression(@NotNull JetFunctionLiteralExpression expression) {
JetFunctionLiteral functionLiteral = expression.getFunctionLiteral();
public void visitFunctionLiteralExpression(@NotNull KtFunctionLiteralExpression expression) {
KtFunctionLiteral functionLiteral = expression.getFunctionLiteral();
FunctionDescriptor functionDescriptor =
(FunctionDescriptor) bindingContext.get(DECLARATION_TO_DESCRIPTOR, functionLiteral);
// working around a problem with shallow analysis
if (functionDescriptor == null) return;
String name = inventAnonymousClassName();
Collection<JetType> supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor);
Collection<KtType> supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor);
ClassDescriptor classDescriptor = recordClassForCallable(functionLiteral, functionDescriptor, supertypes, name);
recordClosure(classDescriptor, name);
@@ -287,13 +287,13 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
}
@Override
public void visitCallableReferenceExpression(@NotNull JetCallableReferenceExpression expression) {
public void visitCallableReferenceExpression(@NotNull KtCallableReferenceExpression expression) {
ResolvedCall<?> referencedFunction = CallUtilKt.getResolvedCall(expression.getCallableReference(), bindingContext);
if (referencedFunction == null) return;
CallableDescriptor target = referencedFunction.getResultingDescriptor();
CallableDescriptor callableDescriptor;
Collection<JetType> supertypes;
Collection<KtType> supertypes;
if (target instanceof FunctionDescriptor) {
callableDescriptor = bindingContext.get(FUNCTION, expression);
@@ -328,7 +328,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
}
@Override
public void visitProperty(@NotNull JetProperty property) {
public void visitProperty(@NotNull KtProperty property) {
DeclarationDescriptor descriptor = bindingContext.get(DECLARATION_TO_DESCRIPTOR, property);
// working around a problem with shallow analysis
if (descriptor == null) return;
@@ -341,11 +341,11 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
nameStack.push(peekFromStack(nameStack) + '$' + safeIdentifier(property.getNameAsSafeName()).asString());
}
JetPropertyDelegate delegate = property.getDelegate();
KtPropertyDelegate delegate = property.getDelegate();
if (delegate != null && descriptor instanceof PropertyDescriptor) {
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
String name = inventAnonymousClassName();
JetType supertype = runtimeTypes.getSupertypeForPropertyReference(propertyDescriptor);
KtType supertype = runtimeTypes.getSupertypeForPropertyReference(propertyDescriptor);
ClassDescriptor classDescriptor = recordClassForCallable(delegate, propertyDescriptor, Collections.singleton(supertype), name);
recordClosure(classDescriptor, name);
}
@@ -355,7 +355,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
}
@Override
public void visitNamedFunction(@NotNull JetNamedFunction function) {
public void visitNamedFunction(@NotNull KtNamedFunction function) {
FunctionDescriptor functionDescriptor = (FunctionDescriptor) bindingContext.get(DECLARATION_TO_DESCRIPTOR, function);
// working around a problem with shallow analysis
if (functionDescriptor == null) return;
@@ -368,7 +368,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
}
else {
String name = inventAnonymousClassName();
Collection<JetType> supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor);
Collection<KtType> supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor);
ClassDescriptor classDescriptor = recordClassForCallable(function, functionDescriptor, supertypes, name);
recordClosure(classDescriptor, name);
@@ -390,7 +390,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
return peek + '$' + name;
}
else if (containingDeclaration instanceof PackageFragmentDescriptor) {
JetFile containingFile = DescriptorToSourceUtils.getContainingFile(descriptor);
KtFile containingFile = DescriptorToSourceUtils.getContainingFile(descriptor);
assert containingFile != null : "File not found for " + descriptor;
return FileClasses.getFileClassInternalName(fileClassesProvider, containingFile) + '$' + name;
}
@@ -399,12 +399,12 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
}
@Override
public void visitCallExpression(@NotNull JetCallExpression expression) {
public void visitCallExpression(@NotNull KtCallExpression expression) {
super.visitCallExpression(expression);
checkSamCall(expression);
}
private void checkSamCall(@NotNull JetCallElement expression) {
private void checkSamCall(@NotNull KtCallElement expression) {
ResolvedCall<?> call = CallUtilKt.getResolvedCall(expression, bindingContext);
if (call == null) return;
@@ -427,7 +427,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
assert resolvedValueArgument instanceof ExpressionValueArgument : resolvedValueArgument;
ValueArgument valueArgument = ((ExpressionValueArgument) resolvedValueArgument).getValueArgument();
assert valueArgument != null;
JetExpression argumentExpression = valueArgument.getArgumentExpression();
KtExpression argumentExpression = valueArgument.getArgumentExpression();
assert argumentExpression != null : valueArgument.asElement().getText();
bindingTrace.record(CodegenBinding.SAM_VALUE, argumentExpression, samType);
@@ -435,12 +435,12 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
}
@Override
public void visitDelegationToSuperCallSpecifier(@NotNull JetDelegatorToSuperCall call) {
public void visitDelegationToSuperCallSpecifier(@NotNull KtDelegatorToSuperCall call) {
super.visitDelegationToSuperCallSpecifier(call);
checkSamCall(call);
}
private void recordSamConstructorIfNeeded(@NotNull JetCallElement expression, @NotNull ResolvedCall<?> call) {
private void recordSamConstructorIfNeeded(@NotNull KtCallElement expression, @NotNull ResolvedCall<?> call) {
CallableDescriptor callableDescriptor = call.getResultingDescriptor();
if (!(callableDescriptor.getOriginal() instanceof SamConstructorDescriptor)) return;
@@ -452,7 +452,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
ValueArgument argument = ((ExpressionValueArgument) valueArgument).getValueArgument();
if (argument == null) return;
JetExpression argumentExpression = argument.getArgumentExpression();
KtExpression argumentExpression = argument.getArgumentExpression();
bindingTrace.record(SAM_CONSTRUCTOR_TO_ARGUMENT, expression, argumentExpression);
//noinspection ConstantConditions
@@ -461,7 +461,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
}
@Override
public void visitBinaryExpression(@NotNull JetBinaryExpression expression) {
public void visitBinaryExpression(@NotNull KtBinaryExpression expression) {
super.visitBinaryExpression(expression);
DeclarationDescriptor operationDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, expression.getOperationReference());
@@ -483,7 +483,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
}
@Override
public void visitArrayAccessExpression(@NotNull JetArrayAccessExpression expression) {
public void visitArrayAccessExpression(@NotNull KtArrayAccessExpression expression) {
super.visitArrayAccessExpression(expression);
DeclarationDescriptor operationDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, expression);
@@ -493,7 +493,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
FunctionDescriptor original = SamCodegenUtil.getOriginalIfSamAdapter((FunctionDescriptor) operationDescriptor);
if (original == null) return;
List<JetExpression> indexExpressions = expression.getIndexExpressions();
List<KtExpression> indexExpressions = expression.getIndexExpressions();
List<ValueParameterDescriptor> parameters = original.getValueParameters();
for (ValueParameterDescriptor valueParameter : parameters) {
SamType samType = SamType.create(valueParameter.getType());
@@ -501,20 +501,20 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
if (isSetter && valueParameter.getIndex() == parameters.size() - 1) {
PsiElement parent = expression.getParent();
if (parent instanceof JetBinaryExpression && ((JetBinaryExpression) parent).getOperationToken() == EQ) {
JetExpression right = ((JetBinaryExpression) parent).getRight();
if (parent instanceof KtBinaryExpression && ((KtBinaryExpression) parent).getOperationToken() == EQ) {
KtExpression right = ((KtBinaryExpression) parent).getRight();
bindingTrace.record(CodegenBinding.SAM_VALUE, right, samType);
}
}
else {
JetExpression indexExpression = indexExpressions.get(valueParameter.getIndex());
KtExpression indexExpression = indexExpressions.get(valueParameter.getIndex());
bindingTrace.record(CodegenBinding.SAM_VALUE, indexExpression, samType);
}
}
}
@Override
public void visitWhenExpression(@NotNull JetWhenExpression expression) {
public void visitWhenExpression(@NotNull KtWhenExpression expression) {
super.visitWhenExpression(expression);
if (!isWhenWithEnums(expression)) return;
@@ -530,7 +530,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
int fieldNumber = mappings.size();
assert expression.getSubjectExpression() != null : "subject expression should be not null in a valid when by enums";
JetType type = bindingContext.getType(expression.getSubjectExpression());
KtType type = bindingContext.getType(expression.getSubjectExpression());
assert type != null : "should not be null in a valid when by enums";
ClassDescriptor classDescriptor = (ClassDescriptor) type.getConstructor().getDeclarationDescriptor();
assert classDescriptor != null : "because it's enum";
@@ -549,7 +549,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
bindingTrace.record(MAPPING_FOR_WHEN_BY_ENUM, expression, mapping);
}
private boolean isWhenWithEnums(@NotNull JetWhenExpression expression) {
private boolean isWhenWithEnums(@NotNull KtWhenExpression expression) {
return WhenChecker.isWhenByEnum(expression, bindingContext) &&
SwitchCodegenUtil.checkAllItemsAreConstantsSatisfying(
expression,
@@ -564,7 +564,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid {
}
@NotNull
private String getCurrentTopLevelClassOrPackagePartInternalName(@NotNull JetFile file) {
private String getCurrentTopLevelClassOrPackagePartInternalName(@NotNull KtFile file) {
ListIterator<ClassDescriptor> iterator = classStack.listIterator(classStack.size());
while (iterator.hasPrevious()) {
ClassDescriptor previous = iterator.previous();
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.BindingTrace;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.KtScope;
import org.jetbrains.kotlin.resolve.source.KotlinSourceElementKt;
import org.jetbrains.kotlin.util.slicedMap.BasicWritableSlice;
import org.jetbrains.kotlin.util.slicedMap.Slices;
@@ -58,11 +58,11 @@ public class CodegenBinding {
public static final WritableSlice<ClassDescriptor, Collection<ClassDescriptor>> INNER_CLASSES = Slices.createSimpleSlice();
public static final WritableSlice<JetExpression, SamType> SAM_VALUE = Slices.createSimpleSlice();
public static final WritableSlice<KtExpression, SamType> SAM_VALUE = Slices.createSimpleSlice();
public static final WritableSlice<JetCallElement, JetExpression> SAM_CONSTRUCTOR_TO_ARGUMENT = Slices.createSimpleSlice();
public static final WritableSlice<KtCallElement, KtExpression> SAM_CONSTRUCTOR_TO_ARGUMENT = Slices.createSimpleSlice();
public static final WritableSlice<JetWhenExpression, WhenByEnumsMapping> MAPPING_FOR_WHEN_BY_ENUM = Slices.createSimpleSlice();
public static final WritableSlice<KtWhenExpression, WhenByEnumsMapping> MAPPING_FOR_WHEN_BY_ENUM = Slices.createSimpleSlice();
public static final WritableSlice<String, List<WhenByEnumsMapping>> MAPPINGS_FOR_WHENS_BY_ENUM_IN_CLASS_FILE =
Slices.createSimpleSlice();
@@ -76,12 +76,12 @@ public class CodegenBinding {
public static void initTrace(@NotNull GenerationState state) {
CodegenAnnotatingVisitor visitor = new CodegenAnnotatingVisitor(state);
for (JetFile file : allFilesInPackages(state.getBindingContext(), state.getFiles())) {
for (KtFile file : allFilesInPackages(state.getBindingContext(), state.getFiles())) {
file.accept(visitor);
}
}
public static boolean enumEntryNeedSubclass(BindingContext bindingContext, JetEnumEntry enumEntry) {
public static boolean enumEntryNeedSubclass(BindingContext bindingContext, KtEnumEntry enumEntry) {
return enumEntryNeedSubclass(bindingContext, bindingContext.get(CLASS, enumEntry));
}
@@ -99,7 +99,7 @@ public class CodegenBinding {
// SCRIPT: Generate asmType for script, move to ScriptingUtil
@NotNull
public static Type asmTypeForScriptPsi(BindingContext bindingContext, @NotNull JetScript script) {
public static Type asmTypeForScriptPsi(BindingContext bindingContext, @NotNull KtScript script) {
ScriptDescriptor scriptDescriptor = bindingContext.get(SCRIPT, script);
if (scriptDescriptor == null) {
throw new IllegalStateException("Script descriptor not found by PSI " + script);
@@ -117,9 +117,9 @@ public class CodegenBinding {
}
@NotNull
public static Type asmTypeForAnonymousClass(@NotNull BindingContext bindingContext, @NotNull JetElement expression) {
if (expression instanceof JetObjectLiteralExpression) {
expression = ((JetObjectLiteralExpression) expression).getObjectDeclaration();
public static Type asmTypeForAnonymousClass(@NotNull BindingContext bindingContext, @NotNull KtElement expression) {
if (expression instanceof KtObjectLiteralExpression) {
expression = ((KtObjectLiteralExpression) expression).getObjectDeclaration();
}
ClassDescriptor descriptor = bindingContext.get(CLASS, expression);
@@ -165,7 +165,7 @@ public class CodegenBinding {
@NotNull Type asmType,
@NotNull JvmFileClassesProvider fileClassesManager
) {
JetElement element = (JetElement) descriptorToDeclaration(classDescriptor);
KtElement element = (KtElement) descriptorToDeclaration(classDescriptor);
assert element != null : "No source element for " + classDescriptor;
MutableClosure closure = new MutableClosure(classDescriptor, enclosing);
@@ -201,7 +201,7 @@ public class CodegenBinding {
// SCRIPT: register asmType for script, move to ScriptingUtil
public static void registerClassNameForScript(
@NotNull BindingTrace trace,
@NotNull JetScript script,
@NotNull KtScript script,
@NotNull Type asmType,
@NotNull JvmFileClassesProvider fileClassesManager
) {
@@ -215,7 +215,7 @@ public class CodegenBinding {
new ClassDescriptorImpl(descriptor, Name.special("<script-" + simpleName + ">"), Modality.FINAL,
Collections.singleton(DescriptorUtilsKt.getBuiltIns(descriptor).getAnyType()),
KotlinSourceElementKt.toSourceElement(script));
classDescriptor.initialize(JetScope.Empty.INSTANCE$, Collections.<ConstructorDescriptor>emptySet(), null);
classDescriptor.initialize(KtScope.Empty.INSTANCE$, Collections.<ConstructorDescriptor>emptySet(), null);
recordClosure(trace, classDescriptor, null, asmType, fileClassesManager);
@@ -223,39 +223,39 @@ public class CodegenBinding {
}
@NotNull
private static Collection<JetFile> allFilesInPackages(BindingContext bindingContext, Collection<JetFile> files) {
private static Collection<KtFile> allFilesInPackages(BindingContext bindingContext, Collection<KtFile> files) {
// 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
// SCRIPT: collect fq names for files that are not scripts
HashSet<FqName> names = new HashSet<FqName>();
for (JetFile file : files) {
for (KtFile file : files) {
if (!file.isScript()) {
names.add(file.getPackageFqName());
}
}
HashSet<JetFile> answer = new HashSet<JetFile>();
HashSet<KtFile> answer = new HashSet<KtFile>();
answer.addAll(files);
for (FqName name : names) {
Collection<JetFile> jetFiles = bindingContext.get(PACKAGE_TO_FILES, name);
Collection<KtFile> jetFiles = bindingContext.get(PACKAGE_TO_FILES, name);
if (jetFiles != null) {
answer.addAll(jetFiles);
}
}
List<JetFile> sortedAnswer = new ArrayList<JetFile>(answer);
Collections.sort(sortedAnswer, new Comparator<JetFile>() {
List<KtFile> sortedAnswer = new ArrayList<KtFile>(answer);
Collections.sort(sortedAnswer, new Comparator<KtFile>() {
@NotNull
private String path(JetFile file) {
private String path(KtFile file) {
VirtualFile virtualFile = file.getVirtualFile();
assert virtualFile != null : "VirtualFile is null for JetFile: " + file.getName();
return virtualFile.getPath();
}
@Override
public int compare(@NotNull JetFile first, @NotNull JetFile second) {
public int compare(@NotNull KtFile first, @NotNull KtFile second) {
return path(first).compareTo(path(second));
}
});
@@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.context.EnclosedValueDescriptor;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.org.objectweb.asm.Type;
import java.util.*;
@@ -71,7 +71,7 @@ public final class MutableClosure implements CalculatedClosure {
}
@Override
public JetType getCaptureReceiverType() {
public KtType getCaptureReceiverType() {
if (captureReceiver) {
ReceiverParameterDescriptor parameter = getEnclosingReceiverDescriptor();
assert parameter != null : "Receiver parameter should exist in " + enclosingFunWithReceiverDescriptor;
@@ -40,8 +40,8 @@ public final class PsiCodegenPredictor {
@NotNull JvmFileClassesProvider fileClassesManager
) {
PsiElement element = descriptorToDeclaration(descriptor);
if (element instanceof JetDeclaration) {
String classNameFromPsi = getPredefinedJvmInternalName((JetDeclaration) element, fileClassesManager);
if (element instanceof KtDeclaration) {
String classNameFromPsi = getPredefinedJvmInternalName((KtDeclaration) element, fileClassesManager);
assert classNameFromPsi == null || Type.getObjectType(classNameFromPsi).equals(nameFromDescriptors) :
String.format("Invalid algorithm for getting qualified name from psi! Predicted: %s, actual %s\n" +
"Element: %s", classNameFromPsi, nameFromDescriptors, element.getText());
@@ -55,13 +55,13 @@ public final class PsiCodegenPredictor {
*/
@Nullable
public static String getPredefinedJvmInternalName(
@NotNull JetDeclaration declaration,
@NotNull KtDeclaration declaration,
@NotNull JvmFileClassesProvider fileClassesProvider
) {
// TODO: Method won't work for declarations inside companion objects
// TODO: Method won't give correct class name for traits implementations
JetDeclaration parentDeclaration = JetStubbedPsiUtil.getContainingDeclaration(declaration);
KtDeclaration parentDeclaration = KtStubbedPsiUtil.getContainingDeclaration(declaration);
String parentInternalName;
if (parentDeclaration != null) {
@@ -71,30 +71,30 @@ public final class PsiCodegenPredictor {
}
}
else {
JetFile containingFile = declaration.getContainingJetFile();
KtFile containingFile = declaration.getContainingJetFile();
if (declaration instanceof JetNamedFunction) {
Name name = ((JetNamedFunction) declaration).getNameAsName();
if (declaration instanceof KtNamedFunction) {
Name name = ((KtNamedFunction) declaration).getNameAsName();
return name == null ? null : FileClasses.getFileClassInternalName(fileClassesProvider, containingFile) + "$" + name.asString();
}
parentInternalName = AsmUtil.internalNameByFqNameWithoutInnerClasses(containingFile.getPackageFqName());
}
if (!PsiTreeUtil.instanceOf(declaration, JetClass.class, JetObjectDeclaration.class, JetNamedFunction.class, JetProperty.class) ||
isEnumEntryWithoutBody(declaration)) {
if (!PsiTreeUtil.instanceOf(declaration, KtClass.class, KtObjectDeclaration.class, KtNamedFunction.class, KtProperty.class) ||
isEnumEntryWithoutBody(declaration)) {
// Other subclasses are not valid for class name prediction.
// For example JetFunctionLiteral
return null;
}
Name name = ((JetNamedDeclaration) declaration).getNameAsName();
Name name = ((KtNamedDeclaration) declaration).getNameAsName();
if (name == null) {
return null;
}
if (declaration instanceof JetNamedFunction) {
if (!(parentDeclaration instanceof JetClass || parentDeclaration instanceof JetObjectDeclaration)) {
if (declaration instanceof KtNamedFunction) {
if (!(parentDeclaration instanceof KtClass || parentDeclaration instanceof KtObjectDeclaration)) {
// Can't generate predefined name for internal functions
return null;
}
@@ -102,7 +102,7 @@ public final class PsiCodegenPredictor {
// NOTE: looks like a bug - for class in getter of top level property class name will be $propertyName$ClassName but not
// PackageClassName$propertyName$ClassName
if (declaration instanceof JetProperty) {
if (declaration instanceof KtProperty) {
return parentInternalName + "$" + name.asString();
}
@@ -113,11 +113,11 @@ public final class PsiCodegenPredictor {
return parentInternalName + (parentDeclaration == null ? "/" : "$") + name.asString();
}
private static boolean isEnumEntryWithoutBody(JetDeclaration declaration) {
if (!(declaration instanceof JetEnumEntry)) {
private static boolean isEnumEntryWithoutBody(KtDeclaration declaration) {
if (!(declaration instanceof KtEnumEntry)) {
return false;
}
JetClassBody body = ((JetEnumEntry) declaration).getBody();
KtClassBody body = ((KtEnumEntry) declaration).getBody();
return body == null || body.getDeclarations().size() == 0;
}
}
@@ -22,10 +22,10 @@ import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.getSpecialSignatureInfo
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
import org.jetbrains.kotlin.load.java.getOverriddenBuiltinWithDifferentJvmDescriptor
import org.jetbrains.kotlin.psi.JetCallElement
import org.jetbrains.kotlin.psi.JetElement
import org.jetbrains.kotlin.psi.JetPsiUtil
import org.jetbrains.kotlin.psi.JetValueArgument
import org.jetbrains.kotlin.psi.KtCallElement
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.KtPsiUtil
import org.jetbrains.kotlin.psi.KtValueArgument
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorUtils
@@ -145,13 +145,13 @@ private fun needGenerateSpecialBridge(
}
public fun isValueArgumentForCallToMethodWithTypeCheckBarrier(
element: JetElement,
element: KtElement,
bindingContext: BindingContext
): Boolean {
val parentCall = element.getParentCall(bindingContext, strict = true) ?: return false
val argumentExpression = parentCall.valueArguments.singleOrNull()?.getArgumentExpression() ?: return false
if (JetPsiUtil.deparenthesize(argumentExpression) !== element) return false
if (KtPsiUtil.deparenthesize(argumentExpression) !== element) return false
val candidateDescriptor = parentCall.getResolvedCall(bindingContext)?.candidateDescriptor as CallableMemberDescriptor?
?: return false
@@ -24,13 +24,13 @@ import org.jetbrains.kotlin.codegen.binding.MutableClosure;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.state.JetTypeMapper;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.JetSuperExpression;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.psi.KtSuperExpression;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import org.jetbrains.kotlin.storage.NullableLazyValue;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.org.objectweb.asm.Type;
import java.util.*;
@@ -181,7 +181,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
}
@NotNull
public PackageContext intoPackagePart(@NotNull PackageFragmentDescriptor descriptor, Type packagePartType, @Nullable JetFile sourceFile) {
public PackageContext intoPackagePart(@NotNull PackageFragmentDescriptor descriptor, Type packagePartType, @Nullable KtFile sourceFile) {
return new PackageContext(descriptor, this, packagePartType, sourceFile);
}
@@ -190,7 +190,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
@NotNull PackageFragmentDescriptor descriptor,
@NotNull Type multifileClassType,
@NotNull Type filePartType,
@NotNull JetFile sourceFile
@NotNull KtFile sourceFile
) {
return new MultifileClassPartContext(descriptor, this, multifileClassType, filePartType, sourceFile);
}
@@ -273,7 +273,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
}
@NotNull
public <D extends CallableMemberDescriptor> D getAccessor(@NotNull D descriptor, @Nullable JetSuperExpression superCallExpression) {
public <D extends CallableMemberDescriptor> D getAccessor(@NotNull D descriptor, @Nullable KtSuperExpression superCallExpression) {
return getAccessor(descriptor, false, null, superCallExpression);
}
@@ -282,8 +282,8 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
public <D extends CallableMemberDescriptor> D getAccessor(
@NotNull D possiblySubstitutedDescriptor,
boolean isForBackingFieldInOuterClass,
@Nullable JetType delegateType,
@Nullable JetSuperExpression superCallExpression
@Nullable KtType delegateType,
@Nullable KtSuperExpression superCallExpression
) {
if (accessors == null) {
accessors = new LinkedHashMap<AccessorKey, AccessorForCallableDescriptor<?>>();
@@ -379,7 +379,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
@NotNull
public <D extends CallableMemberDescriptor> D accessibleDescriptor(
@NotNull D descriptor,
@Nullable JetSuperExpression superCallExpression
@Nullable KtSuperExpression superCallExpression
) {
DeclarationDescriptor enclosing = descriptor.getContainingDeclaration();
if (!isInlineMethodContext() && (
@@ -417,7 +417,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
@NotNull
private <D extends CallableMemberDescriptor> D accessibleDescriptorIfNeeded(
@NotNull D descriptor,
@Nullable JetSuperExpression superCallExpression
@Nullable KtSuperExpression superCallExpression
) {
CallableMemberDescriptor unwrappedDescriptor = DescriptorUtils.unwrapFakeOverride(descriptor);
int flag = getAccessFlags(unwrappedDescriptor);
@@ -17,10 +17,10 @@
package org.jetbrains.kotlin.codegen.context;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.KtFile;
public interface FacadePartWithSourceFile {
@Nullable
JetFile getSourceFile();
KtFile getSourceFile();
}
@@ -25,7 +25,7 @@ import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.load.java.JvmAbi;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.org.objectweb.asm.Type;
import static org.jetbrains.kotlin.codegen.AsmUtil.CAPTURED_RECEIVER_FIELD;
@@ -139,7 +139,7 @@ public interface LocalLookup {
return null;
}
JetType receiverType = closure.getEnclosingReceiverDescriptor().getType();
KtType receiverType = closure.getEnclosingReceiverDescriptor().getType();
Type type = state.getTypeMapper().mapType(receiverType);
StackValue.StackValueWithSimpleReceiver innerValue = StackValue.field(type, classType, CAPTURED_RECEIVER_FIELD, false,
StackValue.LOCAL_0, d);
@@ -19,18 +19,18 @@ package org.jetbrains.kotlin.codegen.context;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.org.objectweb.asm.Type;
public class MultifileClassPartContext extends MultifileClassContextBase implements DelegatingToPartContext, FacadePartWithSourceFile {
private final JetFile sourceFile;
private final KtFile sourceFile;
public MultifileClassPartContext(
PackageFragmentDescriptor descriptor,
CodegenContext parent,
Type multifileClassType,
Type filePartType,
@NotNull JetFile sourceFile
@NotNull KtFile sourceFile
) {
super(descriptor, parent, multifileClassType, filePartType);
this.sourceFile = sourceFile;
@@ -44,7 +44,7 @@ public class MultifileClassPartContext extends MultifileClassContextBase impleme
@NotNull
@Override
public JetFile getSourceFile() {
public KtFile getSourceFile() {
return sourceFile;
}
}
@@ -20,18 +20,18 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.OwnerKind;
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.org.objectweb.asm.Type;
public class PackageContext extends FieldOwnerContext<PackageFragmentDescriptor> implements DelegatingToPartContext, FacadePartWithSourceFile {
private final Type packagePartType;
@Nullable private JetFile sourceFile;
@Nullable private KtFile sourceFile;
public PackageContext(
@NotNull PackageFragmentDescriptor contextDescriptor,
@NotNull CodegenContext parent,
@Nullable Type packagePartType,
@Nullable JetFile sourceFile
@Nullable KtFile sourceFile
) {
super(contextDescriptor, OwnerKind.PACKAGE, parent, null, null, null);
this.packagePartType = packagePartType;
@@ -56,7 +56,7 @@ public class PackageContext extends FieldOwnerContext<PackageFragmentDescriptor>
@Nullable
@Override
public JetFile getSourceFile() {
public KtFile getSourceFile() {
return sourceFile;
}
}
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.codegen.StackValue
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.codegen.ClassBuilder
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.psi.JetClassOrObject
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.resolve.*
@@ -50,7 +50,7 @@ public interface ExpressionCodegenExtension {
public fun generateClassSyntheticParts(
classBuilder: ClassBuilder,
state: GenerationState,
classOrObject: JetClassOrObject,
classOrObject: KtClassOrObject,
descriptor: ClassDescriptor
) {}
}
@@ -73,7 +73,7 @@ public class InlineCodegen extends CallGenerator {
private final SimpleFunctionDescriptor functionDescriptor;
private final JvmMethodSignature jvmSignature;
private final JetElement callElement;
private final KtElement callElement;
private final MethodContext context;
private final ExpressionCodegen codegen;
@@ -94,7 +94,7 @@ public class InlineCodegen extends CallGenerator {
@NotNull ExpressionCodegen codegen,
@NotNull GenerationState state,
@NotNull SimpleFunctionDescriptor functionDescriptor,
@NotNull JetElement callElement,
@NotNull KtElement callElement,
@Nullable ReifiedTypeParameterMappings typeParameterMappings
) {
assert InlineUtil.isInline(functionDescriptor) : "InlineCodegen could inline only inline function: " + functionDescriptor;
@@ -110,7 +110,7 @@ public class InlineCodegen extends CallGenerator {
initialFrameSize = codegen.getFrameMap().getCurrentSize();
PsiElement element = DescriptorToSourceUtils.descriptorToDeclaration(functionDescriptor);
context = (MethodContext) getContext(functionDescriptor, state, element != null ? (JetFile) element.getContainingFile() : null);
context = (MethodContext) getContext(functionDescriptor, state, element != null ? (KtFile) element.getContainingFile() : null);
jvmSignature = typeMapper.mapSignature(functionDescriptor, context.getContextKind());
// TODO: implement AS_FUNCTION inline strategy
@@ -205,10 +205,10 @@ public class InlineCodegen extends CallGenerator {
else {
PsiElement element = DescriptorToSourceUtils.descriptorToDeclaration(functionDescriptor);
if (element == null || !(element instanceof JetNamedFunction)) {
if (element == null || !(element instanceof KtNamedFunction)) {
throw new RuntimeException("Couldn't find declaration for function " + descriptorName(functionDescriptor));
}
JetNamedFunction inliningFunction = (JetNamedFunction) element;
KtNamedFunction inliningFunction = (KtNamedFunction) element;
MethodNode node = new MethodNode(InlineCodegenUtil.API,
getMethodAsmFlags(functionDescriptor, context.getContextKind()) | (callDefault ? Opcodes.ACC_STATIC : 0),
@@ -305,7 +305,7 @@ public class InlineCodegen extends CallGenerator {
}
private SMAPAndMethodNode generateLambdaBody(LambdaInfo info) {
JetExpression declaration = info.getFunctionWithBodyOrCallableReference();
KtExpression declaration = info.getFunctionWithBodyOrCallableReference();
FunctionDescriptor descriptor = info.getFunctionDescriptor();
MethodContext parentContext = codegen.getContext();
@@ -327,7 +327,7 @@ public class InlineCodegen extends CallGenerator {
@NotNull MethodVisitor adapter,
@NotNull FunctionDescriptor descriptor,
@NotNull MethodContext context,
@NotNull JetExpression expression,
@NotNull KtExpression expression,
@NotNull JvmMethodSignature jvmMethodSignature,
boolean isLambda
) {
@@ -338,14 +338,14 @@ public class InlineCodegen extends CallGenerator {
: typeMapper.mapOwner(descriptor).getInternalName());
FunctionGenerationStrategy strategy =
expression instanceof JetCallableReferenceExpression ?
expression instanceof KtCallableReferenceExpression ?
new FunctionReferenceGenerationStrategy(
state,
descriptor,
CallUtilKt.getResolvedCallWithAssert(((JetCallableReferenceExpression) expression).getCallableReference(),
CallUtilKt.getResolvedCallWithAssert(((KtCallableReferenceExpression) expression).getCallableReference(),
codegen.getBindingContext()
)) :
new FunctionGenerationStrategy.FunctionDefault(state, descriptor, (JetDeclarationWithBody) expression);
new FunctionGenerationStrategy.FunctionDefault(state, descriptor, (KtDeclarationWithBody) expression);
FunctionCodegen.generateMethodBody(
adapter, descriptor, context, jvmMethodSignature,
@@ -358,7 +358,7 @@ public class InlineCodegen extends CallGenerator {
}
private static SMAP createSMAPWithDefaultMapping(
@NotNull JetExpression declaration,
@NotNull KtExpression declaration,
@NotNull List<FileMapping> mappings
) {
PsiFile containingFile = declaration.getContainingFile();
@@ -373,7 +373,7 @@ public class InlineCodegen extends CallGenerator {
private final MemberCodegen delegate;
@NotNull private final String className;
public FakeMemberCodegen(@NotNull MemberCodegen wrapped, @NotNull JetElement declaration, @NotNull FieldOwnerContext codegenContext, @NotNull String className) {
public FakeMemberCodegen(@NotNull MemberCodegen wrapped, @NotNull KtElement declaration, @NotNull FieldOwnerContext codegenContext, @NotNull String className) {
super(wrapped, declaration, codegenContext);
delegate = wrapped;
this.className = className;
@@ -535,21 +535,21 @@ public class InlineCodegen extends CallGenerator {
}
/*lambda or callable reference*/
public static boolean isInliningParameter(JetExpression expression, ValueParameterDescriptor valueParameterDescriptor) {
public static boolean isInliningParameter(KtExpression expression, ValueParameterDescriptor valueParameterDescriptor) {
//TODO deparenthisise typed
JetExpression deparenthesized = JetPsiUtil.deparenthesize(expression);
KtExpression deparenthesized = KtPsiUtil.deparenthesize(expression);
return InlineUtil.isInlineLambdaParameter(valueParameterDescriptor) &&
isInlinableParameterExpression(deparenthesized);
}
protected static boolean isInlinableParameterExpression(JetExpression deparenthesized) {
return deparenthesized instanceof JetFunctionLiteralExpression ||
deparenthesized instanceof JetNamedFunction ||
deparenthesized instanceof JetCallableReferenceExpression;
protected static boolean isInlinableParameterExpression(KtExpression deparenthesized) {
return deparenthesized instanceof KtFunctionLiteralExpression ||
deparenthesized instanceof KtNamedFunction ||
deparenthesized instanceof KtCallableReferenceExpression;
}
public void rememberClosure(JetExpression expression, Type type, int parameterIndex) {
JetExpression lambda = JetPsiUtil.deparenthesize(expression);
public void rememberClosure(KtExpression expression, Type type, int parameterIndex) {
KtExpression lambda = KtPsiUtil.deparenthesize(expression);
assert isInlinableParameterExpression(lambda) : "Couldn't find inline expression in " + expression.getText();
LambdaInfo info = new LambdaInfo(lambda, typeMapper);
@@ -587,7 +587,7 @@ public class InlineCodegen extends CallGenerator {
activeLambda = null;
}
public static CodegenContext getContext(@NotNull DeclarationDescriptor descriptor, @NotNull GenerationState state, @Nullable JetFile sourceFile) {
public static CodegenContext getContext(@NotNull DeclarationDescriptor descriptor, @NotNull GenerationState state, @Nullable KtFile sourceFile) {
if (descriptor instanceof PackageFragmentDescriptor) {
return new PackageContext((PackageFragmentDescriptor) descriptor, state.getRootContext(), null, sourceFile);
}
@@ -624,7 +624,7 @@ public class InlineCodegen extends CallGenerator {
@Override
public void genValueAndPut(
@NotNull ValueParameterDescriptor valueParameterDescriptor,
@NotNull JetExpression argumentExpression,
@NotNull KtExpression argumentExpression,
@NotNull Type parameterType,
int parameterIndex
) {
@@ -37,17 +37,13 @@ import org.jetbrains.kotlin.fileClasses.FileClasses;
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider;
import org.jetbrains.kotlin.load.java.JvmAbi;
import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinder;
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils;
import org.jetbrains.kotlin.name.ClassId;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
import org.jetbrains.kotlin.resolve.jvm.AsmTypes;
import org.jetbrains.kotlin.resolve.jvm.JvmClassName;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.util.OperatorNameConventions;
import org.jetbrains.org.objectweb.asm.*;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
@@ -60,9 +56,6 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ListIterator;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.getFqName;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isInterface;
public class InlineCodegenUtil {
public static final boolean GENERATE_SMAP = true;
public static final int API = Opcodes.ASM5;
@@ -185,7 +178,7 @@ public class InlineCodegenUtil {
if (file == null) {
implementationOwnerType = CodegenContextUtil.getImplementationOwnerClassType(codegenContext);
} else {
implementationOwnerType = FileClasses.getFileClassType(fileClassesProvider, (JetFile) file);
implementationOwnerType = FileClasses.getFileClassType(fileClassesProvider, (KtFile) file);
}
if (implementationOwnerType == null) {
@@ -24,8 +24,8 @@ import org.jetbrains.kotlin.codegen.context.EnclosedValueDescriptor;
import org.jetbrains.kotlin.codegen.state.JetTypeMapper;
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
import org.jetbrains.kotlin.psi.JetExpression;
import org.jetbrains.kotlin.psi.JetFunctionLiteralExpression;
import org.jetbrains.kotlin.psi.KtExpression;
import org.jetbrains.kotlin.psi.KtFunctionLiteralExpression;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.jvm.AsmTypes;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
@@ -41,7 +41,7 @@ import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.*;
public class LambdaInfo implements CapturedParamOwner, LabelOwner {
public final JetExpression expression;
public final KtExpression expression;
private final JetTypeMapper typeMapper;
@@ -60,9 +60,9 @@ public class LambdaInfo implements CapturedParamOwner, LabelOwner {
private final Type closureClassType;
LambdaInfo(@NotNull JetExpression expr, @NotNull JetTypeMapper typeMapper) {
this.expression = expr instanceof JetFunctionLiteralExpression ?
((JetFunctionLiteralExpression) expr).getFunctionLiteral() : expr;
LambdaInfo(@NotNull KtExpression expr, @NotNull JetTypeMapper typeMapper) {
this.expression = expr instanceof KtFunctionLiteralExpression ?
((KtFunctionLiteralExpression) expr).getFunctionLiteral() : expr;
this.typeMapper = typeMapper;
BindingContext bindingContext = typeMapper.getBindingContext();
@@ -91,7 +91,7 @@ public class LambdaInfo implements CapturedParamOwner, LabelOwner {
return functionDescriptor;
}
public JetExpression getFunctionWithBodyOrCallableReference() {
public KtExpression getFunctionWithBodyOrCallableReference() {
return expression;
}
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.codegen.context.MethodContext
import org.jetbrains.kotlin.codegen.intrinsics.IntrinsicMethods
import org.jetbrains.kotlin.codegen.intrinsics.TypeIntrinsics
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.org.objectweb.asm.MethodVisitor
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Type
@@ -159,14 +159,14 @@ public class ReifiedTypeInliner(private val parametersMapping: ReifiedTypeParame
private fun processNewArray(insn: MethodInsnNode, parameter: Type) =
processNextTypeInsn(insn, parameter, Opcodes.ANEWARRAY)
private fun processCheckcast(insn: MethodInsnNode, instructions: InsnList, jetType: JetType, asmType: Type, safe: Boolean) =
private fun processCheckcast(insn: MethodInsnNode, instructions: InsnList, jetType: KtType, asmType: Type, safe: Boolean) =
rewriteNextTypeInsn(insn, Opcodes.CHECKCAST) { instanceofInsn: AbstractInsnNode ->
if (instanceofInsn !is TypeInsnNode) return false
TypeIntrinsics.checkcast(instanceofInsn, instructions, jetType, asmType, safe)
return true
}
private fun processInstanceof(insn: MethodInsnNode, instructions: InsnList, jetType: JetType, asmType: Type) =
private fun processInstanceof(insn: MethodInsnNode, instructions: InsnList, jetType: KtType, asmType: Type) =
rewriteNextTypeInsn(insn, Opcodes.INSTANCEOF) { instanceofInsn: AbstractInsnNode ->
if (instanceofInsn !is TypeInsnNode) return false
TypeIntrinsics.instanceOf(instanceofInsn, instructions, jetType, asmType)
@@ -213,7 +213,7 @@ public class ReifiedTypeInliner(private val parametersMapping: ReifiedTypeParame
public class ReifiedTypeParameterMappings() {
private val mappingsByName = hashMapOf<String, ReifiedTypeParameterMapping>()
public fun addParameterMappingToType(name: String, type: JetType, asmType: Type, signature: String) {
public fun addParameterMappingToType(name: String, type: KtType, asmType: Type, signature: String) {
mappingsByName[name] = ReifiedTypeParameterMapping(name, type, asmType, newName = null, signature = signature)
}
@@ -227,7 +227,7 @@ public class ReifiedTypeParameterMappings() {
}
public class ReifiedTypeParameterMapping(
val name: String, val type: JetType?, val asmType: Type?, val newName: String?, val signature: String?
val name: String, val type: KtType?, val asmType: Type?, val newName: String?, val signature: String?
)
public class ReifiedTypeParametersUsages {
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen.inline;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.codegen.context.CodegenContext;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.psi.JetElement;
import org.jetbrains.kotlin.psi.KtElement;
import java.util.Collections;
import java.util.Map;
@@ -27,14 +27,14 @@ import java.util.Map;
public class RootInliningContext extends InliningContext {
public final CodegenContext startContext;
private final String classNameToInline;
public final JetElement callElement;
public final KtElement callElement;
public RootInliningContext(
@NotNull Map<Integer, LambdaInfo> map,
@NotNull GenerationState state,
@NotNull NameGenerator nameGenerator,
@NotNull CodegenContext startContext,
@NotNull JetElement callElement,
@NotNull KtElement callElement,
@NotNull String classNameToInline,
@NotNull ReifiedTypeInliner inliner
) {
@@ -23,9 +23,9 @@ import org.jetbrains.kotlin.codegen.Callable
import org.jetbrains.kotlin.codegen.CallableMethod
import org.jetbrains.kotlin.codegen.ExpressionCodegen
import org.jetbrains.kotlin.codegen.StackValue
import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.psi.JetBinaryExpression
import org.jetbrains.kotlin.psi.JetExpression
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtBinaryExpression
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.JAVA_STRING_TYPE
@@ -38,10 +38,10 @@ public class Concat : IntrinsicMethod() {
v: InstructionAdapter,
returnType: Type,
element: PsiElement?,
arguments: List<JetExpression>,
arguments: List<KtExpression>,
receiver: StackValue
): Type {
if (element is JetBinaryExpression && element.getOperationReference().getReferencedNameElementType() == JetTokens.PLUS) {
if (element is KtBinaryExpression && element.getOperationReference().getReferencedNameElementType() == KtTokens.PLUS) {
// LHS + RHS
genStringBuilderConstructor(v)
codegen.invokeAppend(element.getLeft())
@@ -20,9 +20,9 @@ import org.jetbrains.kotlin.codegen.Callable
import org.jetbrains.kotlin.codegen.CallableMethod
import org.jetbrains.kotlin.codegen.ExpressionCodegen
import org.jetbrains.kotlin.codegen.StackValue
import org.jetbrains.kotlin.lexer.JetTokens
import org.jetbrains.kotlin.psi.JetBinaryExpression
import org.jetbrains.kotlin.psi.JetCallExpression
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtBinaryExpression
import org.jetbrains.kotlin.psi.KtCallExpression
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE
@@ -37,16 +37,16 @@ public class IdentityEquals : IntrinsicMethod() {
val element = resolvedCall.getCall().getCallElement()
val left: StackValue
val right: StackValue
if (element is JetCallExpression) {
if (element is KtCallExpression) {
left = StackValue.receiver(resolvedCall, receiver, codegen, this)
right = codegen.gen(resolvedCall.getValueArgumentsByIndex()!!.single().getArguments().single().getArgumentExpression())
}
else {
element as JetBinaryExpression
element as KtBinaryExpression
left = codegen.gen(element.getLeft())
right = codegen.gen(element.getRight())
}
return StackValue.cmp(JetTokens.EQEQEQ, OBJECT_TYPE, left, right)
return StackValue.cmp(KtTokens.EQEQEQ, OBJECT_TYPE, left, right)
}
}
}
@@ -19,14 +19,14 @@ package org.jetbrains.kotlin.codegen.intrinsics
import org.jetbrains.kotlin.codegen.AsmUtil.genIncrement
import org.jetbrains.kotlin.codegen.Callable
import org.jetbrains.kotlin.codegen.CallableMethod
import org.jetbrains.kotlin.psi.JetPrefixExpression
import org.jetbrains.kotlin.psi.KtPrefixExpression
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
public class Increment(private val myDelta: Int) : IntrinsicMethod() {
override fun toCallable(method: CallableMethod, isSuper: Boolean, resolvedCall: ResolvedCall<*>): Callable =
createIntrinsicCallable(method) {
val jetExpression = resolvedCall.getCall().getCalleeExpression()
assert(jetExpression !is JetPrefixExpression) { "There should be postfix increment ${jetExpression!!.getText()}" }
assert(jetExpression !is KtPrefixExpression) { "There should be postfix increment ${jetExpression!!.getText()}" }
genIncrement(returnType, myDelta, it)
}
}
@@ -21,11 +21,11 @@ import org.jetbrains.kotlin.codegen.ExpressionCodegen
import org.jetbrains.kotlin.codegen.StackValue
import org.jetbrains.kotlin.codegen.inline.ReifiedTypeInliner
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.psi.JetClassLiteralExpression
import org.jetbrains.kotlin.psi.KtClassLiteralExpression
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
@@ -57,14 +57,14 @@ public class KClassJavaProperty : IntrinsicPropertyGetter() {
}
}
private fun isReifiedTypeParameter(type: JetType): Boolean {
private fun isReifiedTypeParameter(type: KtType): Boolean {
val typeDescriptor = type.constructor.declarationDescriptor
return typeDescriptor is TypeParameterDescriptor && typeDescriptor.isReified
}
private fun isWithClassLiteralArgument(resolvedCall: ResolvedCall<*>): Boolean {
val extensionReceiver = resolvedCall.extensionReceiver
return extensionReceiver is ExpressionReceiver && extensionReceiver.expression is JetClassLiteralExpression
return extensionReceiver is ExpressionReceiver && extensionReceiver.expression is KtClassLiteralExpression
}
private fun coerceToJavaLangClass(iv: InstructionAdapter, returnType: Type) {
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.codegen.Callable
import org.jetbrains.kotlin.codegen.CallableMethod
import org.jetbrains.kotlin.codegen.ExpressionCodegen
import org.jetbrains.kotlin.codegen.StackValue
import org.jetbrains.kotlin.psi.JetPrefixExpression
import org.jetbrains.kotlin.psi.KtPrefixExpression
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
public class Not : IntrinsicMethod() {
@@ -33,7 +33,7 @@ public class Not : IntrinsicMethod() {
): StackValue {
val element = resolvedCall.getCall().getCallElement()
val stackValue =
if (element is JetPrefixExpression) {
if (element is KtPrefixExpression) {
codegen.gen(element.getBaseExpression())
}
else {
@@ -17,7 +17,7 @@
package org.jetbrains.kotlin.codegen.intrinsics
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Type
@@ -26,7 +26,7 @@ import org.jetbrains.org.objectweb.asm.tree.*
import kotlin.text.Regex
public object TypeIntrinsics {
public @JvmStatic fun instanceOf(v: InstructionAdapter, jetType: JetType, boxedAsmType: Type) {
public @JvmStatic fun instanceOf(v: InstructionAdapter, jetType: KtType, boxedAsmType: Type) {
val functionTypeArity = getFunctionTypeArity(jetType)
if (functionTypeArity >= 0) {
v.iconst(functionTypeArity)
@@ -57,7 +57,7 @@ public object TypeIntrinsics {
LdcInsnNode(Integer(value))
}
public @JvmStatic fun instanceOf(instanceofInsn: TypeInsnNode, instructions: InsnList, jetType: JetType, asmType: Type) {
public @JvmStatic fun instanceOf(instanceofInsn: TypeInsnNode, instructions: InsnList, jetType: KtType, asmType: Type) {
val functionTypeArity = getFunctionTypeArity(jetType)
if (functionTypeArity >= 0) {
instructions.insertBefore(instanceofInsn, iconstNode(functionTypeArity))
@@ -78,7 +78,7 @@ public object TypeIntrinsics {
instanceofInsn.desc = asmType.internalName
}
public @JvmStatic fun checkcast(v: InstructionAdapter, jetType: JetType, asmType: Type, safe: Boolean) {
public @JvmStatic fun checkcast(v: InstructionAdapter, jetType: KtType, asmType: Type, safe: Boolean) {
if (safe) {
v.checkcast(asmType)
return
@@ -106,7 +106,7 @@ public object TypeIntrinsics {
v.checkcast(asmType)
}
public @JvmStatic fun checkcast(checkcastInsn: TypeInsnNode, instructions: InsnList, jetType: JetType, asmType: Type, safe: Boolean) {
public @JvmStatic fun checkcast(checkcastInsn: TypeInsnNode, instructions: InsnList, jetType: KtType, asmType: Type, safe: Boolean) {
if (safe) {
checkcastInsn.desc = asmType.internalName
return
@@ -159,7 +159,7 @@ public object TypeIntrinsics {
private val IS_MUTABLE_COLLECTION_METHOD_DESCRIPTOR =
Type.getMethodDescriptor(Type.BOOLEAN_TYPE, Type.getObjectType("java/lang/Object"))
private fun getClassFqName(jetType: JetType): String? {
private fun getClassFqName(jetType: KtType): String? {
val classDescriptor = TypeUtils.getClassDescriptor(jetType) ?: return null
return DescriptorUtils.getFqName(classDescriptor).asString()
}
@@ -169,7 +169,7 @@ public object TypeIntrinsics {
/**
* @return function type arity (non-negative), or -1 if the given type is not a function type
*/
private fun getFunctionTypeArity(jetType: JetType): Int {
private fun getFunctionTypeArity(jetType: KtType): Int {
val classFqName = getClassFqName(jetType) ?: return -1
val match = KOTLIN_FUNCTION_INTERFACE_REGEX.match(classFqName) ?: return -1
return Integer.valueOf(match.groups[1]!!.value)
@@ -182,7 +182,7 @@ public object TypeIntrinsics {
invokestatic(INTRINSICS_CLASS, methodName, methodDescriptor, false)
}
private fun getIsMutableCollectionMethodName(jetType: JetType): String? =
private fun getIsMutableCollectionMethodName(jetType: KtType): String? =
IS_MUTABLE_COLLECTION_METHOD_NAME[getClassFqName(jetType)]
private val CHECKCAST_METHOD_NAME = hashMapOf(
@@ -196,7 +196,7 @@ public object TypeIntrinsics {
"kotlin.MutableMap.MutableEntry" to "asMutableMapEntry"
)
private fun getAsMutableCollectionMethodName(jetType: JetType): String? {
private fun getAsMutableCollectionMethodName(jetType: KtType): String? {
val classDescriptor = TypeUtils.getClassDescriptor(jetType) ?: return null
val classFqName = DescriptorUtils.getFqName(classDescriptor).asString()
return CHECKCAST_METHOD_NAME[classFqName]
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.serialization.SerializerExtension;
import org.jetbrains.kotlin.serialization.StringTable;
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBuf;
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.Method;
@@ -70,7 +70,7 @@ public class JvmSerializerExtension extends SerializerExtension {
}
@Override
public void serializeType(@NotNull JetType type, @NotNull ProtoBuf.Type.Builder proto) {
public void serializeType(@NotNull KtType type, @NotNull ProtoBuf.Type.Builder proto) {
// TODO: don't store type annotations in our binary metadata on Java 8, use *TypeAnnotations attributes instead
for (AnnotationDescriptor annotation : type.getAnnotations()) {
proto.addExtension(JvmProtoBuf.typeAnnotation, annotationSerializer.serializeAnnotation(annotation));
@@ -200,7 +200,7 @@ public class JvmSerializerExtension extends SerializerExtension {
sb.append(")");
JetType returnType = descriptor.getReturnType();
KtType returnType = descriptor.getReturnType();
String returnTypeDesc = returnType == null ? "V" : mapTypeDefault(returnType);
if (returnTypeDesc == null) return true;
sb.append(returnTypeDesc);
@@ -213,7 +213,7 @@ public class JvmSerializerExtension extends SerializerExtension {
}
@Nullable
private String mapTypeDefault(@NotNull JetType type) {
private String mapTypeDefault(@NotNull KtType type) {
ClassifierDescriptor classifier = type.getConstructor().getDeclarationDescriptor();
if (!(classifier instanceof ClassDescriptor)) return null;
ClassId classId = classId((ClassDescriptor) classifier);
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.idea.MainFunctionDetector
import org.jetbrains.kotlin.load.java.descriptors.SamAdapterDescriptor
import org.jetbrains.kotlin.load.java.descriptors.getParentJavaStaticClassScope
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
import org.jetbrains.kotlin.psi.JetNamedFunction
import org.jetbrains.kotlin.psi.KtNamedFunction
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.resolve.jvm.diagnostics.*
@@ -71,7 +71,7 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
var element = origin.element
// TODO Remove this code after dropping package facades
if (element is JetNamedFunction && mainFunctionDetector.isMain(element) && !element.isInsideJvmMultifileClassFile()) return
if (element is KtNamedFunction && mainFunctionDetector.isMain(element) && !element.isInsideJvmMultifileClassFile()) return
if (element == null || origin.originKind in EXTERNAL_SOURCES_KINDS) {
element = data.classOrigin.element
@@ -32,9 +32,9 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
import org.jetbrains.kotlin.modules.TargetId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.JetClassOrObject
import org.jetbrains.kotlin.psi.JetFile
import org.jetbrains.kotlin.psi.JetScript
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtScript
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.DelegatingBindingTrace
@@ -45,7 +45,7 @@ public class GenerationState @JvmOverloads constructor(
builderFactory: ClassBuilderFactory,
public val module: ModuleDescriptor,
bindingContext: BindingContext,
public val files: List<JetFile>,
public val files: List<KtFile>,
disableCallAssertions: Boolean = true,
disableParamAssertions: Boolean = true,
public val generateDeclaredClassFilter: GenerationState.GenerateClassFilter = GenerationState.GenerateClassFilter.GENERATE_ALL,
@@ -66,20 +66,20 @@ public class GenerationState @JvmOverloads constructor(
public val progress: Progress = Progress.DEAF
) {
public abstract class GenerateClassFilter {
public abstract fun shouldAnnotateClass(classOrObject: JetClassOrObject): Boolean
public abstract fun shouldGenerateClass(classOrObject: JetClassOrObject): Boolean
public abstract fun shouldGeneratePackagePart(jetFile: JetFile): Boolean
public abstract fun shouldGenerateScript(script: JetScript): Boolean
public abstract fun shouldAnnotateClass(classOrObject: KtClassOrObject): Boolean
public abstract fun shouldGenerateClass(classOrObject: KtClassOrObject): Boolean
public abstract fun shouldGeneratePackagePart(jetFile: KtFile): Boolean
public abstract fun shouldGenerateScript(script: KtScript): Boolean
companion object {
public val GENERATE_ALL: GenerateClassFilter = object : GenerateClassFilter() {
override fun shouldAnnotateClass(classOrObject: JetClassOrObject): Boolean = true
override fun shouldAnnotateClass(classOrObject: KtClassOrObject): Boolean = true
override fun shouldGenerateClass(classOrObject: JetClassOrObject): Boolean = true
override fun shouldGenerateClass(classOrObject: KtClassOrObject): Boolean = true
override fun shouldGenerateScript(script: JetScript): Boolean = true
override fun shouldGenerateScript(script: KtScript): Boolean = true
override fun shouldGeneratePackagePart(jetFile: JetFile): Boolean = true
override fun shouldGeneratePackagePart(jetFile: KtFile): Boolean = true
}
}
}
@@ -42,15 +42,14 @@ import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor;
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor;
import org.jetbrains.kotlin.load.java.lazy.descriptors.LazyJavaPackageScope;
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils;
import org.jetbrains.kotlin.load.kotlin.incremental.IncrementalPackageFragmentProvider;
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache;
import org.jetbrains.kotlin.name.*;
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap;
import org.jetbrains.kotlin.psi.JetExpression;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.JetFunctionLiteral;
import org.jetbrains.kotlin.psi.JetFunctionLiteralExpression;
import org.jetbrains.kotlin.psi.KtExpression;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.psi.KtFunctionLiteral;
import org.jetbrains.kotlin.psi.KtFunctionLiteralExpression;
import org.jetbrains.kotlin.resolve.*;
import org.jetbrains.kotlin.resolve.annotations.AnnotationUtilKt;
import org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument;
@@ -64,7 +63,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
import org.jetbrains.kotlin.resolve.scopes.AbstractScopeAdapter;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.KtScope;
import org.jetbrains.kotlin.serialization.deserialization.DeserializedType;
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor;
import org.jetbrains.kotlin.types.*;
@@ -182,7 +181,7 @@ public class JetTypeMapper {
if (isAccessor) {
descriptor = ((AccessorForCallableDescriptor) descriptor).getCalleeDescriptor();
}
JetFile file = DescriptorToSourceUtils.getContainingFile(descriptor);
KtFile file = DescriptorToSourceUtils.getContainingFile(descriptor);
if (file != null) {
Visibility visibility = descriptor.getVisibility();
if (!publicFacade ||
@@ -307,7 +306,7 @@ public class JetTypeMapper {
String facadeSimpleName;
JetScope scope = packageFragmentDescriptor.getMemberScope();
KtScope scope = packageFragmentDescriptor.getMemberScope();
if (scope instanceof AbstractScopeAdapter) {
scope = ((AbstractScopeAdapter) scope).getActualScope();
}
@@ -343,7 +342,7 @@ public class JetTypeMapper {
@NotNull
private Type mapReturnType(@NotNull CallableDescriptor descriptor, @Nullable BothSignatureWriter sw) {
JetType returnType = descriptor.getReturnType();
KtType returnType = descriptor.getReturnType();
assert returnType != null : "Function has no return type: " + descriptor;
if (descriptor instanceof ConstructorDescriptor) {
@@ -371,17 +370,17 @@ public class JetTypeMapper {
}
@NotNull
private Type mapType(@NotNull JetType jetType, @NotNull JetTypeMapperMode mode) {
private Type mapType(@NotNull KtType jetType, @NotNull JetTypeMapperMode mode) {
return mapType(jetType, null, mode);
}
@NotNull
public Type mapSupertype(@NotNull JetType jetType, @Nullable BothSignatureWriter signatureVisitor) {
public Type mapSupertype(@NotNull KtType jetType, @Nullable BothSignatureWriter signatureVisitor) {
return mapType(jetType, signatureVisitor, JetTypeMapperMode.SUPER_TYPE);
}
@NotNull
public Type mapTypeParameter(@NotNull JetType jetType, @Nullable BothSignatureWriter signatureVisitor) {
public Type mapTypeParameter(@NotNull KtType jetType, @Nullable BothSignatureWriter signatureVisitor) {
return mapType(jetType, signatureVisitor, JetTypeMapperMode.TYPE_PARAMETER);
}
@@ -391,7 +390,7 @@ public class JetTypeMapper {
}
@NotNull
public Type mapType(@NotNull JetType jetType) {
public Type mapType(@NotNull KtType jetType) {
return mapType(jetType, null, JetTypeMapperMode.VALUE);
}
@@ -416,13 +415,13 @@ public class JetTypeMapper {
}
@NotNull
private Type mapType(@NotNull JetType jetType, @Nullable BothSignatureWriter signatureVisitor, @NotNull JetTypeMapperMode mode) {
private Type mapType(@NotNull KtType jetType, @Nullable BothSignatureWriter signatureVisitor, @NotNull JetTypeMapperMode mode) {
return mapType(jetType, signatureVisitor, mode, Variance.INVARIANT);
}
@NotNull
private Type mapType(
@NotNull JetType jetType,
@NotNull KtType jetType,
@Nullable BothSignatureWriter signatureVisitor,
@NotNull JetTypeMapperMode kind,
@NotNull Variance howThisTypeIsUsed
@@ -451,7 +450,7 @@ public class JetTypeMapper {
TypeConstructor constructor = jetType.getConstructor();
DeclarationDescriptor descriptor = constructor.getDeclarationDescriptor();
if (constructor instanceof IntersectionTypeConstructor) {
jetType = CommonSupertypes.commonSupertype(new ArrayList<JetType>(constructor.getSupertypes()));
jetType = CommonSupertypes.commonSupertype(new ArrayList<KtType>(constructor.getSupertypes()));
}
if (descriptor == null) {
@@ -474,7 +473,7 @@ public class JetTypeMapper {
throw new UnsupportedOperationException("arrays must have one type argument");
}
TypeProjection memberProjection = jetType.getArguments().get(0);
JetType memberType = memberProjection.getType();
KtType memberType = memberProjection.getType();
Type arrayElementType;
if (memberProjection.getProjectionKind() == Variance.IN_VARIANCE) {
@@ -521,7 +520,7 @@ public class JetTypeMapper {
}
@Nullable
private static Type mapBuiltinType(@NotNull JetType type) {
private static Type mapBuiltinType(@NotNull KtType type) {
DeclarationDescriptor descriptor = type.getConstructor().getDeclarationDescriptor();
if (!(descriptor instanceof ClassDescriptor)) return null;
@@ -584,7 +583,7 @@ public class JetTypeMapper {
}
@NotNull
private static String generateErrorMessageForErrorType(@NotNull JetType type, @NotNull DeclarationDescriptor descriptor) {
private static String generateErrorMessageForErrorType(@NotNull KtType type, @NotNull DeclarationDescriptor descriptor) {
PsiElement declarationElement = DescriptorToSourceUtils.descriptorToDeclaration(descriptor);
if (declarationElement == null) {
@@ -617,7 +616,7 @@ public class JetTypeMapper {
private void writeGenericType(
BothSignatureWriter signatureVisitor,
Type asmType,
JetType jetType,
KtType jetType,
Variance howThisTypeIsUsed,
boolean projectionsAllowed
) {
@@ -654,7 +653,7 @@ public class JetTypeMapper {
}
}
private static boolean hasNothingInArguments(JetType jetType) {
private static boolean hasNothingInArguments(KtType jetType) {
boolean hasNothingInArguments = CollectionsKt.any(jetType.getArguments(), new Function1<TypeProjection, Boolean>() {
@Override
public Boolean invoke(TypeProjection projection) {
@@ -692,7 +691,7 @@ public class JetTypeMapper {
}
private Type mapKnownAsmType(
JetType jetType,
KtType jetType,
Type asmType,
@Nullable BothSignatureWriter signatureVisitor,
@NotNull Variance howThisTypeIsUsed
@@ -701,7 +700,7 @@ public class JetTypeMapper {
}
private Type mapKnownAsmType(
JetType jetType,
KtType jetType,
Type asmType,
@Nullable BothSignatureWriter signatureVisitor,
@NotNull Variance howThisTypeIsUsed,
@@ -887,10 +886,10 @@ public class JetTypeMapper {
}
else if (isFunctionLiteral(descriptor)) {
PsiElement element = DescriptorToSourceUtils.getSourceFromDescriptor(descriptor);
if (element instanceof JetFunctionLiteral) {
if (element instanceof KtFunctionLiteral) {
PsiElement expression = element.getParent();
if (expression instanceof JetFunctionLiteralExpression) {
SamType samType = bindingContext.get(SAM_VALUE, (JetExpression) expression);
if (expression instanceof KtFunctionLiteralExpression) {
SamType samType = bindingContext.get(SAM_VALUE, (KtExpression) expression);
if (samType != null) {
return samType.getAbstractMethod().getName().asString();
}
@@ -1093,7 +1092,7 @@ public class JetTypeMapper {
}
@Nullable
public String mapFieldSignature(@NotNull JetType backingFieldType) {
public String mapFieldSignature(@NotNull KtType backingFieldType) {
BothSignatureWriter sw = new BothSignatureWriter(BothSignatureWriter.Mode.TYPE);
mapType(backingFieldType, sw, JetTypeMapperMode.VALUE);
return sw.makeJavaGenericSignature();
@@ -1144,7 +1143,7 @@ public class JetTypeMapper {
{
sw.writeClassBound();
for (JetType jetType : typeParameterDescriptor.getUpperBounds()) {
for (KtType jetType : typeParameterDescriptor.getUpperBounds()) {
if (jetType.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor) {
if (!isJvmInterface(jetType)) {
mapType(jetType, sw, JetTypeMapperMode.TYPE_PARAMETER);
@@ -1160,7 +1159,7 @@ public class JetTypeMapper {
}
sw.writeClassBoundEnd();
for (JetType jetType : typeParameterDescriptor.getUpperBounds()) {
for (KtType jetType : typeParameterDescriptor.getUpperBounds()) {
ClassifierDescriptor classifier = jetType.getConstructor().getDeclarationDescriptor();
if (classifier instanceof ClassDescriptor) {
if (isJvmInterface(jetType)) {
@@ -1180,11 +1179,11 @@ public class JetTypeMapper {
}
}
private void writeParameter(@NotNull BothSignatureWriter sw, @NotNull JetType type) {
private void writeParameter(@NotNull BothSignatureWriter sw, @NotNull KtType type) {
writeParameter(sw, JvmMethodParameterKind.VALUE, type);
}
private void writeParameter(@NotNull BothSignatureWriter sw, @NotNull JvmMethodParameterKind kind, @NotNull JetType type) {
private void writeParameter(@NotNull BothSignatureWriter sw, @NotNull JvmMethodParameterKind kind, @NotNull KtType type) {
sw.writeParameterType(kind);
mapType(type, sw, JetTypeMapperMode.VALUE);
sw.writeParameterTypeEnd();
@@ -1204,7 +1203,7 @@ public class JetTypeMapper {
writeParameter(sw, JvmMethodParameterKind.OUTER, captureThis.getDefaultType());
}
JetType captureReceiverType = closure != null ? closure.getCaptureReceiverType() : null;
KtType captureReceiverType = closure != null ? closure.getCaptureReceiverType() : null;
if (captureReceiverType != null) {
writeParameter(sw, JvmMethodParameterKind.RECEIVER, captureReceiverType);
}
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.codegen.when;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.codegen.ExpressionCodegen;
import org.jetbrains.kotlin.psi.JetWhenExpression;
import org.jetbrains.kotlin.psi.KtWhenExpression;
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
import org.jetbrains.kotlin.resolve.constants.EnumValue;
import org.jetbrains.org.objectweb.asm.Label;
@@ -28,7 +28,7 @@ public class EnumSwitchCodegen extends SwitchCodegen {
private final WhenByEnumsMapping mapping;
public EnumSwitchCodegen(
@NotNull JetWhenExpression expression,
@NotNull KtWhenExpression expression,
boolean isStatement,
@NotNull ExpressionCodegen codegen,
@NotNull WhenByEnumsMapping mapping
@@ -18,13 +18,13 @@ package org.jetbrains.kotlin.codegen.when;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.codegen.ExpressionCodegen;
import org.jetbrains.kotlin.psi.JetWhenExpression;
import org.jetbrains.kotlin.psi.KtWhenExpression;
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
import org.jetbrains.org.objectweb.asm.Label;
public class IntegralConstantsSwitchCodegen extends SwitchCodegen {
public IntegralConstantsSwitchCodegen(
@NotNull JetWhenExpression expression,
@NotNull KtWhenExpression expression,
boolean isStatement,
@NotNull ExpressionCodegen codegen
) {
@@ -20,7 +20,7 @@ import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.codegen.ClassBuilder;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.resolve.constants.EnumValue;
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
import org.jetbrains.org.objectweb.asm.MethodVisitor;
@@ -42,7 +42,7 @@ public class MappingClassesForWhenByEnumCodegen {
this.state = state;
}
public void generate(@NotNull List<WhenByEnumsMapping> mappings, @NotNull Type mappingsClass, @NotNull JetFile srcFile) {
public void generate(@NotNull List<WhenByEnumsMapping> mappings, @NotNull Type mappingsClass, @NotNull KtFile srcFile) {
ClassBuilder cb = state.getFactory().newVisitor(JvmDeclarationOrigin.NO_ORIGIN, mappingsClass, srcFile);
cb.defineClass(
srcFile,
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.codegen.when;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.codegen.binding.CodegenBinding;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.psi.JetWhenExpression;
import org.jetbrains.kotlin.psi.KtWhenExpression;
import org.jetbrains.org.objectweb.asm.Type;
import java.util.HashSet;
@@ -36,7 +36,7 @@ public class MappingsClassesForWhenByEnum {
this.mappingsCodegen = new MappingClassesForWhenByEnumCodegen(state);
}
public void generateMappingsClassForExpression(@NotNull JetWhenExpression expression) {
public void generateMappingsClassForExpression(@NotNull KtWhenExpression expression) {
WhenByEnumsMapping mapping = state.getBindingContext().get(CodegenBinding.MAPPING_FOR_WHEN_BY_ENUM, expression);
assert mapping != null : "mapping class should not be requested for non enum when";
@@ -20,7 +20,7 @@ import com.google.common.collect.Maps;
import com.intellij.openapi.util.Pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.codegen.ExpressionCodegen;
import org.jetbrains.kotlin.psi.JetWhenExpression;
import org.jetbrains.kotlin.psi.KtWhenExpression;
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
import org.jetbrains.kotlin.resolve.constants.StringValue;
import org.jetbrains.org.objectweb.asm.Label;
@@ -38,7 +38,7 @@ public class StringSwitchCodegen extends SwitchCodegen {
private int tempVarIndex;
public StringSwitchCodegen(
@NotNull JetWhenExpression expression,
@NotNull KtWhenExpression expression,
boolean isStatement,
@NotNull ExpressionCodegen codegen
) {
@@ -19,12 +19,12 @@ package org.jetbrains.kotlin.codegen.when;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.codegen.ExpressionCodegen;
import org.jetbrains.kotlin.codegen.FrameMap;
import org.jetbrains.kotlin.psi.JetWhenEntry;
import org.jetbrains.kotlin.psi.JetWhenExpression;
import org.jetbrains.kotlin.psi.KtWhenEntry;
import org.jetbrains.kotlin.psi.KtWhenExpression;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
import org.jetbrains.kotlin.resolve.constants.NullValue;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.types.TypeUtils;
import org.jetbrains.org.objectweb.asm.Label;
import org.jetbrains.org.objectweb.asm.Type;
@@ -33,7 +33,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import java.util.*;
abstract public class SwitchCodegen {
protected final JetWhenExpression expression;
protected final KtWhenExpression expression;
protected final boolean isStatement;
protected final ExpressionCodegen codegen;
protected final BindingContext bindingContext;
@@ -48,7 +48,7 @@ abstract public class SwitchCodegen {
protected Label defaultLabel;
public SwitchCodegen(
@NotNull JetWhenExpression expression, boolean isStatement,
@NotNull KtWhenExpression expression, boolean isStatement,
@NotNull ExpressionCodegen codegen
) {
this.expression = expression;
@@ -93,7 +93,7 @@ abstract public class SwitchCodegen {
* Behaviour may be changed by overriding processConstant
*/
private void prepareConfiguration() {
for (JetWhenEntry entry : expression.getEntries()) {
for (KtWhenEntry entry : expression.getEntries()) {
Label entryLabel = new Label();
for (ConstantValue<?> constant : SwitchCodegenUtil.getConstantsFromEntry(entry, bindingContext)) {
@@ -131,7 +131,7 @@ abstract public class SwitchCodegen {
protected void generateNullCheckIfNeeded() {
assert expression.getSubjectExpression() != null : "subject expression can't be null";
JetType subjectJetType = bindingContext.getType(expression.getSubjectExpression());
KtType subjectJetType = bindingContext.getType(expression.getSubjectExpression());
assert subjectJetType != null : "subject type can't be null (i.e. void)";
@@ -151,9 +151,9 @@ abstract public class SwitchCodegen {
}
}
private int findNullEntryIndex(@NotNull JetWhenExpression expression) {
private int findNullEntryIndex(@NotNull KtWhenExpression expression) {
int entryIndex = 0;
for (JetWhenEntry entry : expression.getEntries()) {
for (KtWhenEntry entry : expression.getEntries()) {
for (ConstantValue<?> constant : SwitchCodegenUtil.getConstantsFromEntry(entry, bindingContext)) {
if (constant instanceof NullValue) {
return entryIndex;
@@ -214,7 +214,7 @@ abstract public class SwitchCodegen {
protected void generateEntries() {
// resolving entries' entryLabels and generating entries' code
Iterator<Label> entryLabelsIterator = entryLabels.iterator();
for (JetWhenEntry entry : expression.getEntries()) {
for (KtWhenEntry entry : expression.getEntries()) {
v.visitLabel(entryLabelsIterator.next());
FrameMap.Mark mark = codegen.myFrameMap.mark();
@@ -34,18 +34,18 @@ import java.util.List;
public class SwitchCodegenUtil {
public static boolean checkAllItemsAreConstantsSatisfying(
@NotNull JetWhenExpression expression,
@NotNull KtWhenExpression expression,
@NotNull BindingContext bindingContext,
Function1<ConstantValue<?>, Boolean> predicate
) {
for (JetWhenEntry entry : expression.getEntries()) {
for (JetWhenCondition condition : entry.getConditions()) {
if (!(condition instanceof JetWhenConditionWithExpression)) {
for (KtWhenEntry entry : expression.getEntries()) {
for (KtWhenCondition condition : entry.getConditions()) {
if (!(condition instanceof KtWhenConditionWithExpression)) {
return false;
}
// ensure that expression is constant
JetExpression patternExpression = ((JetWhenConditionWithExpression) condition).getExpression();
KtExpression patternExpression = ((KtWhenConditionWithExpression) condition).getExpression();
if (patternExpression == null) return false;
@@ -61,12 +61,12 @@ public class SwitchCodegenUtil {
@NotNull
public static Iterable<ConstantValue<?>> getAllConstants(
@NotNull JetWhenExpression expression,
@NotNull KtWhenExpression expression,
@NotNull BindingContext bindingContext
) {
List<ConstantValue<?>> result = new ArrayList<ConstantValue<?>>();
for (JetWhenEntry entry : expression.getEntries()) {
for (KtWhenEntry entry : expression.getEntries()) {
addConstantsFromEntry(result, entry, bindingContext);
}
@@ -75,13 +75,13 @@ public class SwitchCodegenUtil {
private static void addConstantsFromEntry(
@NotNull List<ConstantValue<?>> result,
@NotNull JetWhenEntry entry,
@NotNull KtWhenEntry entry,
@NotNull BindingContext bindingContext
) {
for (JetWhenCondition condition : entry.getConditions()) {
if (!(condition instanceof JetWhenConditionWithExpression)) continue;
for (KtWhenCondition condition : entry.getConditions()) {
if (!(condition instanceof KtWhenConditionWithExpression)) continue;
JetExpression patternExpression = ((JetWhenConditionWithExpression) condition).getExpression();
KtExpression patternExpression = ((KtWhenConditionWithExpression) condition).getExpression();
assert patternExpression != null : "expression in when should not be null";
result.add(ExpressionCodegen.getCompileTimeConstant(patternExpression, bindingContext));
@@ -90,7 +90,7 @@ public class SwitchCodegenUtil {
@NotNull
public static Iterable<ConstantValue<?>> getConstantsFromEntry(
@NotNull JetWhenEntry entry,
@NotNull KtWhenEntry entry,
@NotNull BindingContext bindingContext
) {
List<ConstantValue<?>> result = new ArrayList<ConstantValue<?>>();
@@ -100,7 +100,7 @@ public class SwitchCodegenUtil {
@Nullable
public static SwitchCodegen buildAppropriateSwitchCodegenIfPossible(
@NotNull JetWhenExpression expression,
@NotNull KtWhenExpression expression,
boolean isStatement,
@NotNull ExpressionCodegen codegen
) {
@@ -129,7 +129,7 @@ public class SwitchCodegenUtil {
}
private static boolean isThereConstantEntriesButNulls(
@NotNull JetWhenExpression expression,
@NotNull KtWhenExpression expression,
@NotNull BindingContext bindingContext
) {
for (ConstantValue<?> constant : getAllConstants(expression, bindingContext)) {
@@ -140,7 +140,7 @@ public class SwitchCodegenUtil {
}
private static boolean isIntegralConstantsSwitch(
@NotNull JetWhenExpression expression,
@NotNull KtWhenExpression expression,
@NotNull Type subjectType,
@NotNull BindingContext bindingContext
) {
@@ -161,7 +161,7 @@ public class SwitchCodegenUtil {
}
private static boolean isStringConstantsSwitch(
@NotNull JetWhenExpression expression,
@NotNull KtWhenExpression expression,
@NotNull Type subjectType,
@NotNull BindingContext bindingContext
) {
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.resolve.constants.NullValue
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.serialization.*
import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.KtType
public class BuiltInsSerializerExtension : SerializerExtension() {
private val stringTable = StringTableImpl()
@@ -75,7 +75,7 @@ public class BuiltInsSerializerExtension : SerializerExtension() {
}
}
override fun serializeType(type: JetType, proto: ProtoBuf.Type.Builder) {
override fun serializeType(type: KtType, proto: ProtoBuf.Type.Builder) {
for (annotation in type.annotations) {
proto.addExtension(BuiltInsProtoBuf.typeAnnotation, annotationSerializer.serializeAnnotation(annotation))
}
@@ -18,14 +18,14 @@ package org.jetbrains.kotlin.cli.common;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.resolve.BindingContext;
import java.util.List;
/**
* Represents the context of available state in which a {@link CompilerPlugin} runs such as
* the {@link Project}, the {@link BindingContext} and the underlying {@link JetFile} files.
* the {@link Project}, the {@link BindingContext} and the underlying {@link KtFile} files.
*/
public class CompilerPluginContext {
@NotNull
@@ -34,9 +34,9 @@ public class CompilerPluginContext {
@NotNull
private final BindingContext context;
@NotNull
private final List<JetFile> files;
private final List<KtFile> files;
public CompilerPluginContext(Project project, BindingContext context, List<JetFile> files) {
public CompilerPluginContext(Project project, BindingContext context, List<KtFile> files) {
this.project = project;
this.context = context;
this.files = files;
@@ -48,7 +48,7 @@ public class CompilerPluginContext {
}
@NotNull
public List<JetFile> getFiles() {
public List<KtFile> getFiles() {
return files;
}
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.load.java.JavaBindingContext;
import org.jetbrains.kotlin.load.java.JvmAbi;
import org.jetbrains.kotlin.load.java.components.TraceBasedErrorReporter;
import org.jetbrains.kotlin.load.java.components.TraceBasedErrorReporter.AbiVersionErrorData;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.resolve.AnalyzingUtils;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
@@ -195,8 +195,8 @@ public final class AnalyzerWithCompilerReport {
return reportDiagnostics(diagnostics, new DefaultDiagnosticReporter(messageCollector), false);
}
private void reportSyntaxErrors(@NotNull Collection<JetFile> files) {
for (JetFile file : files) {
private void reportSyntaxErrors(@NotNull Collection<KtFile> files) {
for (KtFile file : files) {
reportSyntaxErrors(file, messageCollector);
}
}
@@ -262,7 +262,7 @@ public final class AnalyzerWithCompilerReport {
return messageCollector.anyReported(CompilerMessageSeverity.ERROR);
}
public void analyzeAndReport(@NotNull Collection<JetFile> files, @NotNull Function0<AnalysisResult> analyzer) {
public void analyzeAndReport(@NotNull Collection<KtFile> files, @NotNull Function0<AnalysisResult> analyzer) {
analysisResult = analyzer.invoke();
reportSyntaxErrors(files);
List<AbiVersionErrorData> abiVersionErrors = getAbiVersionErrors();
@@ -54,7 +54,7 @@ import org.jetbrains.kotlin.js.config.LibrarySourcesConfig;
import org.jetbrains.kotlin.js.facade.K2JSTranslator;
import org.jetbrains.kotlin.js.facade.MainCallParameters;
import org.jetbrains.kotlin.js.facade.TranslationResult;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.utils.PathUtil;
import java.io.File;
@@ -105,7 +105,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
KotlinCoreEnvironment.createForProduction(rootDisposable, configuration, EnvironmentConfigFiles.JS_CONFIG_FILES);
Project project = environmentForJS.getProject();
List<JetFile> sourcesFiles = environmentForJS.getSourceFiles();
List<KtFile> sourcesFiles = environmentForJS.getSourceFiles();
if (arguments.outputFile == null) {
messageSeverityCollector.report(CompilerMessageSeverity.ERROR, "Specify output file via -output", CompilerMessageLocation.NO_LOCATION);
@@ -210,10 +210,10 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
return OK;
}
private static void reportCompiledSourcesList(@NotNull MessageCollector messageCollector, @NotNull List<JetFile> sourceFiles) {
Iterable<String> fileNames = ContainerUtil.map(sourceFiles, new Function<JetFile, String>() {
private static void reportCompiledSourcesList(@NotNull MessageCollector messageCollector, @NotNull List<KtFile> sourceFiles) {
Iterable<String> fileNames = ContainerUtil.map(sourceFiles, new Function<KtFile, String>() {
@Override
public String fun(@Nullable JetFile file) {
public String fun(@Nullable KtFile file) {
assert file != null;
VirtualFile virtualFile = file.getVirtualFile();
if (virtualFile != null) {
@@ -227,7 +227,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
}
private static AnalyzerWithCompilerReport analyzeAndReportErrors(@NotNull MessageCollector messageCollector,
@NotNull final List<JetFile> sources, @NotNull final Config config) {
@NotNull final List<KtFile> sources, @NotNull final Config config) {
AnalyzerWithCompilerReport analyzerWithCompilerReport = new AnalyzerWithCompilerReport(messageCollector);
analyzerWithCompilerReport.analyzeAndReport(sources, new Function0<AnalysisResult>() {
@Override
@@ -36,15 +36,15 @@ import org.jetbrains.kotlin.descriptors.PackageViewDescriptor
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.JetClassOrObject
import org.jetbrains.kotlin.psi.JetDeclaration
import org.jetbrains.kotlin.psi.JetFile
import org.jetbrains.kotlin.psi.JetPsiUtil
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtPsiUtil
import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer
import org.jetbrains.kotlin.resolve.lazy.ResolveSessionUtils
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.JetScope
import org.jetbrains.kotlin.resolve.scopes.KtScope
import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice
import org.jetbrains.kotlin.util.slicedMap.WritableSlice
import org.jetbrains.kotlin.utils.emptyOrSingletonList
@@ -79,11 +79,11 @@ public class CliLightClassGenerationSupport(project: Project) : LightClassGenera
trace.setKotlinCodeAnalyzer(codeAnalyzer)
}
override fun getContextForPackage(files: Collection<JetFile>): LightClassConstructionContext {
override fun getContextForPackage(files: Collection<KtFile>): LightClassConstructionContext {
return getContext()
}
override fun getContextForClassOrObject(classOrObject: JetClassOrObject): LightClassConstructionContext {
override fun getContextForClassOrObject(classOrObject: KtClassOrObject): LightClassConstructionContext {
return getContext()
}
@@ -91,29 +91,29 @@ public class CliLightClassGenerationSupport(project: Project) : LightClassGenera
return LightClassConstructionContext(bindingContext, module)
}
override fun findClassOrObjectDeclarations(fqName: FqName, searchScope: GlobalSearchScope): Collection<JetClassOrObject> {
override fun findClassOrObjectDeclarations(fqName: FqName, searchScope: GlobalSearchScope): Collection<KtClassOrObject> {
return ResolveSessionUtils.getClassDescriptorsByFqName(module, fqName).map {
val element = DescriptorToSourceUtils.getSourceFromDescriptor(it)
if (element is JetClassOrObject && PsiSearchScopeUtil.isInScope(searchScope, element)) {
if (element is KtClassOrObject && PsiSearchScopeUtil.isInScope(searchScope, element)) {
element
}
else null
}.filterNotNull()
}
override fun findFilesForPackage(fqName: FqName, searchScope: GlobalSearchScope): Collection<JetFile> {
override fun findFilesForPackage(fqName: FqName, searchScope: GlobalSearchScope): Collection<KtFile> {
return bindingContext.get(BindingContext.PACKAGE_TO_FILES, fqName)?.filter {
PsiSearchScopeUtil.isInScope(searchScope, it)
} ?: emptyList()
}
override fun findClassOrObjectDeclarationsInPackage(
packageFqName: FqName, searchScope: GlobalSearchScope): Collection<JetClassOrObject> {
packageFqName: FqName, searchScope: GlobalSearchScope): Collection<KtClassOrObject> {
val files = findFilesForPackage(packageFqName, searchScope)
val result = SmartList<JetClassOrObject>()
val result = SmartList<KtClassOrObject>()
for (file in files) {
for (declaration in file.declarations) {
if (declaration is JetClassOrObject) {
if (declaration is KtClassOrObject) {
result.add(declaration)
}
}
@@ -127,7 +127,7 @@ public class CliLightClassGenerationSupport(project: Project) : LightClassGenera
override fun getSubPackages(fqn: FqName, scope: GlobalSearchScope): Collection<FqName> {
val packageView = module.getPackage(fqn)
val members = packageView.memberScope.getDescriptors(DescriptorKindFilter.PACKAGES, JetScope.ALL_NAME_FILTER)
val members = packageView.memberScope.getDescriptors(DescriptorKindFilter.PACKAGES, KtScope.ALL_NAME_FILTER)
return ContainerUtil.mapNotNull(members, object : Function<DeclarationDescriptor, FqName> {
override fun `fun`(member: DeclarationDescriptor): FqName? {
if (member is PackageViewDescriptor) {
@@ -138,11 +138,11 @@ public class CliLightClassGenerationSupport(project: Project) : LightClassGenera
})
}
override fun getPsiClass(classOrObject: JetClassOrObject): PsiClass? {
override fun getPsiClass(classOrObject: KtClassOrObject): PsiClass? {
return KotlinLightClassForExplicitDeclaration.create(psiManager, classOrObject)
}
override fun resolveClassToDescriptor(classOrObject: JetClassOrObject): ClassDescriptor? {
override fun resolveClassToDescriptor(classOrObject: KtClassOrObject): ClassDescriptor? {
return bindingContext.get(BindingContext.CLASS, classOrObject)
}
@@ -154,7 +154,7 @@ public class CliLightClassGenerationSupport(project: Project) : LightClassGenera
KotlinLightClassForFacade.createForFacade(psiManager, facadeFqName, scope, filesForFacade))
}
override fun findFilesForFacade(facadeFqName: FqName, scope: GlobalSearchScope): Collection<JetFile> {
override fun findFilesForFacade(facadeFqName: FqName, scope: GlobalSearchScope): Collection<KtFile> {
if (facadeFqName.isRoot) return emptyList()
return PackagePartClassUtils.getFilesWithCallables(findFilesForPackage(facadeFqName.parent(), scope)).filter {
@@ -162,7 +162,7 @@ public class CliLightClassGenerationSupport(project: Project) : LightClassGenera
}
}
override fun getContextForFacade(files: Collection<JetFile>): LightClassConstructionContext {
override fun getContextForFacade(files: Collection<KtFile>): LightClassConstructionContext {
return getContext()
}
@@ -200,8 +200,8 @@ public class CliLightClassGenerationSupport(project: Project) : LightClassGenera
if (value == null) {
if (BindingContext.FUNCTION === slice || BindingContext.VARIABLE === slice) {
if (key is JetDeclaration) {
if (!JetPsiUtil.isLocal(key)) {
if (key is KtDeclaration) {
if (!KtPsiUtil.isLocal(key)) {
kotlinCodeAnalyzer!!.resolveToDescriptor(key)
return super.get<K, V>(slice, key)
}
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.AnalyzerScriptParameter;
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.KtType;
import java.util.Collections;
import java.util.List;
@@ -35,7 +35,7 @@ public class CommandLineScriptUtils {
public static List<AnalyzerScriptParameter> scriptParameters() {
KotlinBuiltIns builtIns = JvmPlatform.INSTANCE$.getBuiltIns();
JetType arrayOfStrings = builtIns.getArrayType(INVARIANT, builtIns.getStringType());
KtType arrayOfStrings = builtIns.getArrayType(INVARIANT, builtIns.getStringType());
AnalyzerScriptParameter argsParameter = new AnalyzerScriptParameter(ARGS_NAME, arrayOfStrings);
return Collections.singletonList(argsParameter);
}
@@ -37,9 +37,9 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollector;
import org.jetbrains.kotlin.cli.common.modules.ModuleScriptData;
import org.jetbrains.kotlin.cli.common.modules.ModuleXmlParser;
import org.jetbrains.kotlin.codegen.ClassFileFactory;
import org.jetbrains.kotlin.idea.JetFileType;
import org.jetbrains.kotlin.idea.KotlinFileType;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
import org.jetbrains.kotlin.utils.PathUtil;
@@ -137,7 +137,7 @@ public class CompileEnvironmentUtil {
}
@NotNull
public static List<JetFile> getJetFiles(
public static List<KtFile> getJetFiles(
@NotNull final Project project,
@NotNull Collection<String> sourceRoots,
@NotNull Function1<String, Unit> reportError
@@ -145,7 +145,7 @@ public class CompileEnvironmentUtil {
final VirtualFileSystem localFileSystem = VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.FILE_PROTOCOL);
final Set<VirtualFile> processedFiles = Sets.newHashSet();
final List<JetFile> result = Lists.newArrayList();
final List<KtFile> result = Lists.newArrayList();
for (String sourceRootPath : sourceRoots) {
if (sourceRootPath == null) {
@@ -157,7 +157,7 @@ public class CompileEnvironmentUtil {
reportError.invoke("Source file or directory not found: " + sourceRootPath);
continue;
}
if (!vFile.isDirectory() && vFile.getFileType() != JetFileType.INSTANCE) {
if (!vFile.isDirectory() && vFile.getFileType() != KotlinFileType.INSTANCE) {
reportError.invoke("Source entry is not a Kotlin file: " + sourceRootPath);
continue;
}
@@ -170,8 +170,8 @@ public class CompileEnvironmentUtil {
if (virtualFile != null && !processedFiles.contains(virtualFile)) {
processedFiles.add(virtualFile);
PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
if (psiFile instanceof JetFile) {
result.add((JetFile) psiFile);
if (psiFile instanceof KtFile) {
result.add((KtFile) psiFile);
}
}
}
@@ -70,13 +70,13 @@ import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.kotlinSourceRoots
import org.jetbrains.kotlin.extensions.ExternalDeclarationsProvider
import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
import org.jetbrains.kotlin.idea.JetFileType
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.load.kotlin.JvmVirtualFileFinderFactory
import org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache
import org.jetbrains.kotlin.load.kotlin.ModuleVisibilityManager
import org.jetbrains.kotlin.parsing.JetParserDefinition
import org.jetbrains.kotlin.parsing.JetScriptDefinitionProvider
import org.jetbrains.kotlin.psi.JetFile
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.CodeAnalyzerInitializer
import org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade
import org.jetbrains.kotlin.resolve.jvm.extensions.AnalysisCompletedHandlerExtension
@@ -97,7 +97,7 @@ public class KotlinCoreEnvironment private constructor(
registerProjectExtensionPoints(Extensions.getArea(getProject()))
}
}
private val sourceFiles = ArrayList<JetFile>()
private val sourceFiles = ArrayList<KtFile>()
private val javaRoots = ArrayList<JavaRoot>()
public val configuration: CompilerConfiguration = configuration.copy().let {
@@ -122,8 +122,8 @@ public class KotlinCoreEnvironment private constructor(
message ->
report(ERROR, message)
}))
sourceFiles.sortedWith(object : Comparator<JetFile> {
override fun compare(o1: JetFile, o2: JetFile): Int {
sourceFiles.sortedWith(object : Comparator<KtFile> {
override fun compare(o1: KtFile, o2: KtFile): Int {
return o1.getVirtualFile().getPath().compareTo(o2.getVirtualFile().getPath(), ignoreCase = true)
}
})
@@ -154,7 +154,7 @@ public class KotlinCoreEnvironment private constructor(
public val sourceLinesOfCode: Int by lazy { countLinesOfCode(sourceFiles) }
public fun countLinesOfCode(sourceFiles: List<JetFile>): Int =
public fun countLinesOfCode(sourceFiles: List<KtFile>): Int =
sourceFiles.sumBy {
val text = it.getText()
StringUtil.getLineBreakCount(it.getText()) + (if (StringUtil.endsWithLineBreak(text)) 0 else 1)
@@ -219,7 +219,7 @@ public class KotlinCoreEnvironment private constructor(
return uniqueSourceRoots
}
public fun getSourceFiles(): List<JetFile> = sourceFiles
public fun getSourceFiles(): List<KtFile> = sourceFiles
private fun report(severity: CompilerMessageSeverity, message: String) {
val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
@@ -351,8 +351,8 @@ public class KotlinCoreEnvironment private constructor(
@JvmStatic
public fun registerApplicationServices(applicationEnvironment: JavaCoreApplicationEnvironment) {
with(applicationEnvironment) {
registerFileType(JetFileType.INSTANCE, "kt")
registerFileType(JetFileType.INSTANCE, JetParserDefinition.STD_SCRIPT_SUFFIX)
registerFileType(KotlinFileType.INSTANCE, "kt")
registerFileType(KotlinFileType.INSTANCE, JetParserDefinition.STD_SCRIPT_SUFFIX)
registerParserDefinition(JetParserDefinition())
getApplication().registerService(javaClass<KotlinBinaryClassCache>(), KotlinBinaryClassCache())
getApplication().registerService(javaClass<JavaClassSupers>(), javaClass<JavaClassSupersImpl>())
@@ -47,7 +47,6 @@ import org.jetbrains.kotlin.context.ModuleContext;
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil;
import org.jetbrains.kotlin.idea.MainFunctionDetector;
import org.jetbrains.kotlin.load.kotlin.ModuleVisibilityManager;
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils;
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache;
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents;
import org.jetbrains.kotlin.modules.Module;
@@ -57,7 +56,7 @@ import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.parsing.JetScriptDefinition;
import org.jetbrains.kotlin.parsing.JetScriptDefinitionProvider;
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.resolve.AnalyzerScriptParameter;
import org.jetbrains.kotlin.resolve.BindingTrace;
import org.jetbrains.kotlin.resolve.BindingTraceContext;
@@ -142,7 +141,7 @@ public class KotlinToJVMBytecodeCompiler {
for (Module module : chunk) {
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled();
List<JetFile> jetFiles = CompileEnvironmentUtil.getJetFiles(
List<KtFile> jetFiles = CompileEnvironmentUtil.getJetFiles(
environment.getProject(), getAbsolutePaths(directory, module), new Function1<String, Unit>() {
@Override
public Unit invoke(String s) {
@@ -196,10 +195,10 @@ public class KotlinToJVMBytecodeCompiler {
}
@Nullable
private static FqName findMainClass(@NotNull GenerationState generationState, @NotNull List<JetFile> files) {
private static FqName findMainClass(@NotNull GenerationState generationState, @NotNull List<KtFile> files) {
MainFunctionDetector mainFunctionDetector = new MainFunctionDetector(generationState.getBindingContext());
FqName mainClass = null;
for (JetFile file : files) {
for (KtFile file : files) {
if (mainFunctionDetector.hasMain(file.getDeclarations())) {
if (mainClass != null) {
// more than one main
@@ -357,7 +356,7 @@ public class KotlinToJVMBytecodeCompiler {
private static GenerationState generate(
@NotNull KotlinCoreEnvironment environment,
@NotNull AnalysisResult result,
@NotNull List<JetFile> sourceFiles,
@NotNull List<KtFile> sourceFiles,
@Nullable Module module,
File outputDirectory,
String moduleName
@@ -58,8 +58,8 @@ import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl;
import org.jetbrains.kotlin.idea.KotlinLanguage;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.parsing.JetParserDefinition;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.psi.JetScript;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.psi.KtScript;
import org.jetbrains.kotlin.resolve.*;
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
import org.jetbrains.kotlin.resolve.jvm.JvmClassName;
@@ -68,8 +68,8 @@ import org.jetbrains.kotlin.resolve.lazy.FileScopeProvider;
import org.jetbrains.kotlin.resolve.lazy.ResolveSession;
import org.jetbrains.kotlin.resolve.lazy.data.JetClassLikeInfo;
import org.jetbrains.kotlin.resolve.lazy.declarations.*;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.resolve.scopes.KtScope;
import org.jetbrains.kotlin.types.KtType;
import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
import org.jetbrains.org.objectweb.asm.Type;
@@ -93,7 +93,7 @@ public class ReplInterpreter {
private int lineNumber = 0;
@Nullable
private JetScope lastLineScope;
private KtScope lastLineScope;
private final List<EarlierLine> earlierLines = Lists.newArrayList();
private final List<String> previousIncompleteLines = Lists.newArrayList();
private final ReplClassLoader classLoader;
@@ -130,8 +130,8 @@ public class ReplInterpreter {
FileScopeProvider.AdditionalScopes scopeProvider = new FileScopeProvider.AdditionalScopes() {
@NotNull
@Override
public List<JetScope> getScopes() {
return lastLineScope != null ? new SmartList<JetScope>(lastLineScope) : Collections.<JetScope>emptyList();
public List<KtScope> getScopes() {
return lastLineScope != null ? new SmartList<KtScope>(lastLineScope) : Collections.<KtScope>emptyList();
}
};
@@ -275,7 +275,7 @@ public class ReplInterpreter {
LightVirtualFile virtualFile = new LightVirtualFile("line" + lineNumber + JetParserDefinition.STD_SCRIPT_EXT, KotlinLanguage.INSTANCE, fullText.toString());
virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET);
JetFile psiFile = (JetFile) psiFileFactory.trySetupPsiForFile(virtualFile, KotlinLanguage.INSTANCE, true, false);
KtFile psiFile = (KtFile) psiFileFactory.trySetupPsiForFile(virtualFile, KotlinLanguage.INSTANCE, true, false);
assert psiFile != null : "Script file not analyzed at line " + lineNumber + ": " + fullText;
DiagnosticMessageHolder errorHolder = createDiagnosticHolder();
@@ -356,7 +356,7 @@ public class ReplInterpreter {
earlierLines.add(new EarlierLine(line, scriptDescriptor, scriptClass, scriptInstance, scriptClassType));
JetType returnType = scriptDescriptor.getScriptCodeDescriptor().getReturnType();
KtType returnType = scriptDescriptor.getScriptCodeDescriptor().getReturnType();
return LineResult.successful(rv, returnType != null && KotlinBuiltIns.isUnit(returnType));
}
catch (Throwable e) {
@@ -400,7 +400,7 @@ public class ReplInterpreter {
}
@Nullable
private ScriptDescriptor doAnalyze(@NotNull JetFile psiFile, @NotNull DiagnosticMessageReporter errorReporter) {
private ScriptDescriptor doAnalyze(@NotNull KtFile psiFile, @NotNull DiagnosticMessageReporter errorReporter) {
scriptDeclarationFactory.setDelegateFactory(
new FileBasedDeclarationProviderFactory(resolveSession.getStorageManager(), Collections.singletonList(psiFile)));
@@ -442,7 +442,7 @@ public class ReplInterpreter {
PsiElement jetScript = descriptorToDeclaration(earlierDescriptor);
if (jetScript != null) {
registerClassNameForScript(state.getBindingTrace(), (JetScript) jetScript, earlierClassType, state.getFileClassesProvider());
registerClassNameForScript(state.getBindingTrace(), (KtScript) jetScript, earlierClassType, state.getFileClassesProvider());
earlierScriptDescriptors.add(earlierDescriptor);
}
}
@@ -450,7 +450,7 @@ public class ReplInterpreter {
}
public static void compileScript(
@NotNull JetScript script,
@NotNull KtScript script,
@NotNull Type classType,
@NotNull List<Pair<ScriptDescriptor, Type>> earlierScripts,
@NotNull GenerationState state,
@@ -51,13 +51,13 @@ interface Conditional {
}
}
fun JetAnnotated.parseConditionalAnnotations(): List<Conditional> =
fun KtAnnotated.parseConditionalAnnotations(): List<Conditional> =
annotationEntries.map {
val parser = Conditional.ANNOTATIONS.get(it.typeReferenceName)
parser?.parse?.invoke(it.valueArguments.splitToPositionalAndNamed())
}.filterNotNull()
val JetAnnotationEntry.typeReferenceName: String? get() =
(typeReference?.typeElement as? JetUserType)?.referencedName
val KtAnnotationEntry.typeReferenceName: String? get() =
(typeReference?.typeElement as? KtUserType)?.referencedName
@@ -22,16 +22,16 @@ import org.jetbrains.kotlin.psi.*
data class Modification(val range: TextRange, val apply: (String) -> String)
class CollectModificationsVisitor(evaluators: List<Evaluator>) : JetTreeVisitorVoid() {
class CollectModificationsVisitor(evaluators: List<Evaluator>) : KtTreeVisitorVoid() {
val elementModifications: Map<Evaluator, MutableList<Modification>> =
evaluators.toMap(selector = { it }, transform = { arrayListOf<Modification>() })
override fun visitDeclaration(declaration: JetDeclaration) {
override fun visitDeclaration(declaration: KtDeclaration) {
super.visitDeclaration(declaration)
val annotations = declaration.parseConditionalAnnotations()
val name = (declaration as? JetNamedDeclaration)?.nameAsSafeName ?: declaration.name
val name = (declaration as? KtNamedDeclaration)?.nameAsSafeName ?: declaration.name
val declResults = arrayListOf<Pair<Evaluator, Boolean>>()
for ((evaluator, modifications) in elementModifications) {
@@ -48,7 +48,7 @@ class CollectModificationsVisitor(evaluators: List<Evaluator>) : JetTreeVisitorV
else {
val targetName = annotations.filterIsInstance<Conditional.TargetName>().singleOrNull()
if (targetName != null) {
val placeholderName = (declaration as JetNamedDeclaration).nameAsName!!.asString()
val placeholderName = (declaration as KtNamedDeclaration).nameAsName!!.asString()
val realName = targetName.name
modifications.add(Modification(declaration.textRange) { it.replace(placeholderName, realName) })
}
@@ -22,7 +22,7 @@ import com.intellij.openapi.util.io.FileUtil
import com.intellij.openapi.util.text.StringUtil
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.idea.JetFileType
import org.jetbrains.kotlin.idea.KotlinFileType
import org.jetbrains.kotlin.psi.*
import java.io.File
import java.io.IOException
@@ -46,15 +46,15 @@ public fun createProfile(name: String, targetRoot: File): Profile {
public class Preprocessor(val logger: Logger = SystemOutLogger) {
val fileType = JetFileType.INSTANCE
val jetPsiFactory: JetPsiFactory
val fileType = KotlinFileType.INSTANCE
val jetPsiFactory: KtPsiFactory
init {
val configuration = CompilerConfiguration()
val environment = KotlinCoreEnvironment.createForProduction(Disposable { }, configuration, emptyList())
val project = environment.project
jetPsiFactory = JetPsiFactory(project)
jetPsiFactory = KtPsiFactory(project)
}
sealed class FileProcessingResult {
@@ -16,7 +16,7 @@
package org.jetbrains.kotlin.preprocessor
import org.jetbrains.kotlin.psi.JetStringTemplateEntry
import org.jetbrains.kotlin.psi.KtStringTemplateEntry
import org.jetbrains.kotlin.psi.ValueArgument
import org.jetbrains.kotlin.psi.psiUtil.getChildrenOfType
@@ -32,4 +32,4 @@ fun List<ValueArgument>.splitToPositionalAndNamed(): PositionalAndNamedArguments
}
fun ValueArgument.parseIntegerValue(): Int = getArgumentExpression()!!.text.toInt()
fun ValueArgument.parseStringValue(): String = getArgumentExpression()!!.getChildrenOfType<JetStringTemplateEntry>().joinToString("") { it.text }
fun ValueArgument.parseStringValue(): String = getArgumentExpression()!!.getChildrenOfType<KtStringTemplateEntry>().joinToString("") { it.text }
@@ -41,14 +41,14 @@ public object JvmFileClassUtil {
public val JVM_MULTIFILE_CLASS_SHORT = JVM_MULTIFILE_CLASS.shortName().asString()
@JvmStatic
public fun getFileClassInfo(file: JetFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations?): JvmFileClassInfo =
public fun getFileClassInfo(file: KtFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations?): JvmFileClassInfo =
if (jvmFileClassAnnotations != null)
getFileClassInfoForAnnotation(file, jvmFileClassAnnotations)
else
getDefaultFileClassInfo(file)
@JvmStatic
public fun getFileClassInfoForAnnotation(file: JetFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations): JvmFileClassInfo =
public fun getFileClassInfoForAnnotation(file: KtFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations): JvmFileClassInfo =
if (jvmFileClassAnnotations.multipleFiles)
JvmMultifileClassPartInfo(getHiddenPartFqName(file, jvmFileClassAnnotations),
getFacadeFqName(file, jvmFileClassAnnotations))
@@ -56,11 +56,11 @@ public object JvmFileClassUtil {
JvmSimpleFileClassInfo(getFacadeFqName(file, jvmFileClassAnnotations), true)
@JvmStatic
public fun getDefaultFileClassInfo(file: JetFile): JvmFileClassInfo =
public fun getDefaultFileClassInfo(file: KtFile): JvmFileClassInfo =
JvmSimpleFileClassInfo(PackagePartClassUtils.getPackagePartFqName(file.packageFqName, file.name), false)
@JvmStatic
public fun getFacadeFqName(file: JetFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations): FqName =
public fun getFacadeFqName(file: KtFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations): FqName =
file.packageFqName.child(Name.identifier(jvmFileClassAnnotations.name))
@JvmStatic
@@ -79,7 +79,7 @@ public object JvmFileClassUtil {
getImplClassNameForProto(proto, nameResolver)
@JvmStatic
public fun getHiddenPartFqName(file: JetFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations): FqName =
public fun getHiddenPartFqName(file: KtFile, jvmFileClassAnnotations: ParsedJmvFileClassAnnotations): FqName =
file.packageFqName.child(Name.identifier(manglePartName(jvmFileClassAnnotations.name, file.name)))
@JvmStatic
@@ -87,11 +87,11 @@ public object JvmFileClassUtil {
"${facadeName}__${PackagePartClassUtils.getFilePartShortName(fileName)}"
@JvmStatic
public fun getFileClassInfoNoResolve(file: JetFile): JvmFileClassInfo =
public fun getFileClassInfoNoResolve(file: KtFile): JvmFileClassInfo =
getFileClassInfo(file, parseJvmNameOnFileNoResolve(file))
@JvmStatic
public fun parseJvmNameOnFileNoResolve(file: JetFile): ParsedJmvFileClassAnnotations? {
public fun parseJvmNameOnFileNoResolve(file: KtFile): ParsedJmvFileClassAnnotations? {
val jvmName = findAnnotationEntryOnFileNoResolve(file, JVM_NAME_SHORT) ?: return null
val nameExpr = jvmName.valueArguments.firstOrNull()?.getArgumentExpression() ?: return null
val name = getLiteralStringFromRestrictedConstExpression(nameExpr) ?: return null
@@ -101,16 +101,16 @@ public object JvmFileClassUtil {
}
@JvmStatic
public fun findAnnotationEntryOnFileNoResolve(file: JetFile, shortName: String): JetAnnotationEntry? =
public fun findAnnotationEntryOnFileNoResolve(file: KtFile, shortName: String): KtAnnotationEntry? =
file.fileAnnotationList?.annotationEntries?.firstOrNull {
it.calleeExpression?.constructorReferenceExpression?.getReferencedName() == shortName
}
private @JvmStatic fun getLiteralStringFromRestrictedConstExpression(argumentExpression: JetExpression?): String? {
val stringTemplate = argumentExpression as? JetStringTemplateExpression ?: return null
private @JvmStatic fun getLiteralStringFromRestrictedConstExpression(argumentExpression: KtExpression?): String? {
val stringTemplate = argumentExpression as? KtStringTemplateExpression ?: return null
val stringTemplateEntries = stringTemplate.entries
if (stringTemplateEntries.size() != 1) return null
val singleEntry = stringTemplateEntries[0] as? JetLiteralStringTemplateEntry ?: return null
val singleEntry = stringTemplateEntries[0] as? KtLiteralStringTemplateEntry ?: return null
return singleEntry.text
}
@@ -118,7 +118,7 @@ public object JvmFileClassUtil {
public class ParsedJmvFileClassAnnotations(public val name: String, public val multipleFiles: Boolean)
public val JetFile.javaFileFacadeFqName: FqName
public val KtFile.javaFileFacadeFqName: FqName
get() {
return CachedValuesManager.getCachedValue(this) {
val facadeFqName =
@@ -128,7 +128,7 @@ public val JetFile.javaFileFacadeFqName: FqName
}
}
public fun JetDeclaration.isInsideJvmMultifileClassFile() = JvmFileClassUtil.findAnnotationEntryOnFileNoResolve(
public fun KtDeclaration.isInsideJvmMultifileClassFile() = JvmFileClassUtil.findAnnotationEntryOnFileNoResolve(
getContainingJetFile(),
JvmFileClassUtil.JVM_MULTIFILE_CLASS_SHORT
) != null
@@ -18,12 +18,12 @@
package org.jetbrains.kotlin.fileClasses
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.JetFile
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import org.jetbrains.org.objectweb.asm.Type
public interface JvmFileClassesProvider {
public fun getFileClassInfo(file: JetFile): JvmFileClassInfo
public fun getFileClassInfo(file: KtFile): JvmFileClassInfo
}
public fun FqName.getInternalName(): String =
@@ -32,20 +32,20 @@ public fun FqName.getInternalName(): String =
public fun FqName.getClassType(): Type =
Type.getObjectType(getInternalName())
public fun JvmFileClassesProvider.getFileClassFqName(file: JetFile): FqName =
public fun JvmFileClassesProvider.getFileClassFqName(file: KtFile): FqName =
getFileClassInfo(file).fileClassFqName
public fun JvmFileClassesProvider.getFileClassInternalName(file: JetFile): String =
public fun JvmFileClassesProvider.getFileClassInternalName(file: KtFile): String =
getFileClassFqName(file).getInternalName()
public fun JvmFileClassesProvider.getFileClassType(file: JetFile): Type =
public fun JvmFileClassesProvider.getFileClassType(file: KtFile): Type =
getFileClassFqName(file).getClassType()
public fun JvmFileClassesProvider.getFacadeClassFqName(file: JetFile): FqName =
public fun JvmFileClassesProvider.getFacadeClassFqName(file: KtFile): FqName =
getFileClassInfo(file).facadeClassFqName
public fun JvmFileClassesProvider.getFacadeClassInternalName(file: JetFile): String =
public fun JvmFileClassesProvider.getFacadeClassInternalName(file: KtFile): String =
getFacadeClassFqName(file).getInternalName()
public fun JvmFileClassesProvider.getFacadeClassType(file: JetFile): Type =
public fun JvmFileClassesProvider.getFacadeClassType(file: KtFile): Type =
getFacadeClassFqName(file).getClassType()
@@ -17,10 +17,10 @@
package org.jetbrains.kotlin.fileClasses
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.JetFile
import org.jetbrains.kotlin.psi.KtFile
public object NoResolveFileClassesProvider : JvmFileClassesProvider {
override fun getFileClassInfo(file: JetFile): JvmFileClassInfo =
override fun getFileClassInfo(file: KtFile): JvmFileClassInfo =
JvmFileClassUtil.getFileClassInfo(file, JvmFileClassUtil.parseJvmNameOnFileNoResolve(file))
}
@@ -20,36 +20,36 @@ import com.intellij.openapi.util.text.StringUtil
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
import org.jetbrains.kotlin.jvm.bindingContextSlices.RUNTIME_ASSERTION_INFO
import org.jetbrains.kotlin.psi.JetExpression
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.calls.checkers.AdditionalTypeChecker
import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.KtType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.checker.JetTypeChecker
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
import org.jetbrains.kotlin.types.upperIfFlexible
public class RuntimeAssertionInfo(public val needNotNullAssertion: Boolean, public val message: String) {
public interface DataFlowExtras {
class OnlyMessage(message: String) : DataFlowExtras {
override val canBeNull: Boolean get() = true
override val possibleTypes: Set<JetType> get() = setOf()
override val possibleTypes: Set<KtType> get() = setOf()
override val presentableText: String = message
}
val canBeNull: Boolean
val possibleTypes: Set<JetType>
val possibleTypes: Set<KtType>
val presentableText: String
}
companion object {
@JvmStatic
public fun create(
expectedType: JetType,
expressionType: JetType,
expectedType: KtType,
expressionType: KtType,
dataFlowExtras: DataFlowExtras
): RuntimeAssertionInfo? {
fun assertNotNull(): Boolean {
@@ -78,13 +78,13 @@ public class RuntimeAssertionInfo(public val needNotNullAssertion: Boolean, publ
null
}
private fun JetType.hasEnhancedNullability()
private fun KtType.hasEnhancedNullability()
= getAnnotations().findAnnotation(JvmAnnotationNames.ENHANCED_NULLABILITY_ANNOTATION) != null
}
}
public object RuntimeAssertionsTypeChecker : AdditionalTypeChecker {
override fun checkType(expression: JetExpression, expressionType: JetType, expressionTypeWithSmartCast: JetType, c: ResolutionContext<*>) {
override fun checkType(expression: KtExpression, expressionType: KtType, expressionTypeWithSmartCast: KtType, c: ResolutionContext<*>) {
if (TypeUtils.noExpectedType(c.expectedType)) return
val assertionInfo = RuntimeAssertionInfo.create(
@@ -93,7 +93,7 @@ public object RuntimeAssertionsTypeChecker : AdditionalTypeChecker {
object : RuntimeAssertionInfo.DataFlowExtras {
override val canBeNull: Boolean
get() = c.dataFlowInfo.getNullability(dataFlowValue).canBeNull()
override val possibleTypes: Set<JetType>
override val possibleTypes: Set<KtType>
get() = c.dataFlowInfo.getPossibleTypes(dataFlowValue)
override val presentableText: String
get() = StringUtil.trimMiddle(expression.getText(), 50)

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