Copy to interface just companion object public const properties

This commit is contained in:
Michael Bogdanov
2015-10-07 18:02:02 +03:00
parent a9aa2bc147
commit 12afbffb09
33 changed files with 111 additions and 79 deletions
@@ -758,14 +758,8 @@ public class AsmUtil {
} }
public static int getVisibilityForSpecialPropertyBackingField(@NotNull PropertyDescriptor propertyDescriptor, boolean isDelegate) { public static int getVisibilityForSpecialPropertyBackingField(@NotNull PropertyDescriptor propertyDescriptor, boolean isDelegate) {
return getVisibilityForSpecialPropertyBackingField(propertyDescriptor, isDelegate, false);
}
public static int getVisibilityForSpecialPropertyBackingField(@NotNull PropertyDescriptor propertyDescriptor, boolean isDelegate, boolean skipInterfaceCheck) {
boolean isExtensionProperty = propertyDescriptor.getExtensionReceiverParameter() != null; boolean isExtensionProperty = propertyDescriptor.getExtensionReceiverParameter() != null;
if (isDelegate || if (isDelegate || isExtensionProperty) {
isExtensionProperty ||
(!skipInterfaceCheck && isInterfaceCompanionObject(propertyDescriptor.getContainingDeclaration()))) {
return ACC_PRIVATE; return ACC_PRIVATE;
} }
else { else {
@@ -785,13 +779,10 @@ public class AsmUtil {
} }
public static boolean isPropertyWithBackingFieldCopyInOuterClass(@NotNull PropertyDescriptor propertyDescriptor) { public static boolean isPropertyWithBackingFieldCopyInOuterClass(@NotNull PropertyDescriptor propertyDescriptor) {
boolean isExtensionProperty = propertyDescriptor.getExtensionReceiverParameter() != null;
DeclarationDescriptor propertyContainer = propertyDescriptor.getContainingDeclaration(); DeclarationDescriptor propertyContainer = propertyDescriptor.getContainingDeclaration();
return !propertyDescriptor.isVar() return propertyDescriptor.isConst()
&& !isExtensionProperty && isInterfaceCompanionObject(propertyContainer)
&& isCompanionObject(propertyContainer) && isInterface(propertyContainer.getContainingDeclaration()) && propertyDescriptor.getVisibility() == Visibilities.PUBLIC;
&& areBothAccessorDefault(propertyDescriptor)
&& getVisibilityForSpecialPropertyBackingField(propertyDescriptor, false, true) == ACC_PUBLIC;
} }
public static boolean isCompanionObjectWithBackingFieldsInOuter(@NotNull DeclarationDescriptor companionObject) { public static boolean isCompanionObjectWithBackingFieldsInOuter(@NotNull DeclarationDescriptor companionObject) {
@@ -59,6 +59,7 @@ import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isJvmInterface;
import static org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings.*; import static org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings.*;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isCompanionObject; import static org.jetbrains.kotlin.resolve.DescriptorUtils.isCompanionObject;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isInterface; import static org.jetbrains.kotlin.resolve.DescriptorUtils.isInterface;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isInterfaceCompanionObject;
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.PROPERTY_METADATA_TYPE; import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.PROPERTY_METADATA_TYPE;
import static org.jetbrains.kotlin.resolve.jvm.diagnostics.DiagnosticsPackage.OtherOrigin; import static org.jetbrains.kotlin.resolve.jvm.diagnostics.DiagnosticsPackage.OtherOrigin;
import static org.jetbrains.org.objectweb.asm.Opcodes.*; import static org.jetbrains.org.objectweb.asm.Opcodes.*;
@@ -315,7 +316,9 @@ public class PropertyCodegen {
else if (hasPublicFieldAnnotation && !isDelegate) { else if (hasPublicFieldAnnotation && !isDelegate) {
modifiers |= ACC_PUBLIC; modifiers |= ACC_PUBLIC;
} }
else { else if (isInterfaceCompanionObject(propertyDescriptor.getContainingDeclaration())) {
modifiers |= ACC_PRIVATE;
} else {
modifiers |= getVisibilityForSpecialPropertyBackingField(propertyDescriptor, isDelegate); modifiers |= getVisibilityForSpecialPropertyBackingField(propertyDescriptor, isDelegate);
} }
@@ -66,14 +66,14 @@ public class GenerationState @JvmOverloads constructor(
public val incrementalCompilationComponents: IncrementalCompilationComponents? = null, public val incrementalCompilationComponents: IncrementalCompilationComponents? = null,
public val progress: Progress = Progress.DEAF public val progress: Progress = Progress.DEAF
) { ) {
public interface GenerateClassFilter { public abstract class GenerateClassFilter {
public fun shouldAnnotateClass(classOrObject: JetClassOrObject): Boolean public abstract fun shouldAnnotateClass(classOrObject: JetClassOrObject): Boolean
public fun shouldGenerateClass(classOrObject: JetClassOrObject): Boolean public abstract fun shouldGenerateClass(classOrObject: JetClassOrObject): Boolean
public fun shouldGeneratePackagePart(jetFile: JetFile): Boolean public abstract fun shouldGeneratePackagePart(jetFile: JetFile): Boolean
public fun shouldGenerateScript(script: JetScript): Boolean public abstract fun shouldGenerateScript(script: JetScript): Boolean
companion object { companion object {
public val GENERATE_ALL: GenerateClassFilter = object : GenerateClassFilter { public val GENERATE_ALL: GenerateClassFilter = object : GenerateClassFilter() {
override fun shouldAnnotateClass(classOrObject: JetClassOrObject): Boolean = true override fun shouldAnnotateClass(classOrObject: JetClassOrObject): Boolean = true
override fun shouldGenerateClass(classOrObject: JetClassOrObject): Boolean = true override fun shouldGenerateClass(classOrObject: JetClassOrObject): Boolean = true
@@ -97,7 +97,7 @@ public enum TopDownAnalyzerFacadeForJVM {
new FileBasedDeclarationProviderFactory(moduleContext.getStorageManager(), allFiles); new FileBasedDeclarationProviderFactory(moduleContext.getStorageManager(), allFiles);
LookupTracker lookupTracker = LookupTracker lookupTracker =
incrementalCompilationComponents != null ? incrementalCompilationComponents.getLookupTracker() : LookupTracker.DO_NOTHING; incrementalCompilationComponents != null ? incrementalCompilationComponents.getLookupTracker() : LookupTracker.Companion.getDO_NOTHING();
List<TargetId> targetIds = null; List<TargetId> targetIds = null;
if (modules != null) { if (modules != null) {
@@ -54,7 +54,7 @@ public interface BindingContext {
@NotNull @NotNull
@Override @Override
public Diagnostics getDiagnostics() { public Diagnostics getDiagnostics() {
return Diagnostics.EMPTY; return Diagnostics.Companion.getEMPTY();
} }
@Override @Override
@@ -85,7 +85,7 @@ public class BindingTraceContext implements BindingTrace {
private BindingTraceContext(@NotNull MutableSlicedMap map) { private BindingTraceContext(@NotNull MutableSlicedMap map) {
this.map = map; this.map = map;
this.mutableDiagnostics = new MutableDiagnosticsWithSuppression(bindingContext, Diagnostics.EMPTY); this.mutableDiagnostics = new MutableDiagnosticsWithSuppression(bindingContext, Diagnostics.Companion.getEMPTY());
} }
@TestOnly @TestOnly
@@ -8,6 +8,9 @@ public interface TraitClassObjectField {
private final java.lang.String x = ""; private final java.lang.String x = "";
private final java.lang.String y = ""; private final java.lang.String y = "";
/**
* @deprecated
*/
@org.jetbrains.annotations.Nullable @org.jetbrains.annotations.Nullable
public final java.lang.String getX() { /* compiled code */ } public final java.lang.String getX() { /* compiled code */ }
@@ -2,7 +2,7 @@
interface TraitClassObjectField { interface TraitClassObjectField {
companion object { companion object {
val x: String? = "" const val x: String? = ""
private val y: String? = "" private val y: String? = ""
} }
} }
@@ -6,14 +6,14 @@ class Klass {
interface Trait { interface Trait {
companion object { companion object {
val NAME = "Trait" const val NAME = "Trait"
} }
} }
enum class Enoom { enum class Enoom {
; ;
companion object { companion object {
val NAME = "Enoom" const val NAME = "Enoom"
} }
} }
@@ -17,9 +17,6 @@ public class ErrorsJvmClass {
} }
fun box(): String { fun box(): String {
val genericTypeInTrait = javaClass<ErrorsJvmTrait>().getField("param").getGenericType()
if (genericTypeInTrait.toString() != "test.G<java.lang.String>") return "fail1: $genericTypeInTrait"
val genericTypeInClassObject = ErrorsJvmTrait.javaClass.getDeclaredField("param").getGenericType() val genericTypeInClassObject = ErrorsJvmTrait.javaClass.getDeclaredField("param").getGenericType()
if (genericTypeInClassObject.toString() != "test.G<java.lang.String>") return "fail1: $genericTypeInClassObject" if (genericTypeInClassObject.toString() != "test.G<java.lang.String>") return "fail1: $genericTypeInClassObject"
@@ -11,13 +11,13 @@ annotation class AFloat(val value: Float)
interface Test { interface Test {
companion object { companion object {
val vstring: String = "Test" const val vstring: String = "Test"
val vchar: Char = 'c' const val vchar: Char = 'c'
val vint: Int = 10 const val vint: Int = 10
val vbyte: Byte = 11 const val vbyte: Byte = 11
val vlong: Long = 12 const val vlong: Long = 12
val vdouble: Double = 1.2 const val vdouble: Double = 1.2
val vfloat: Float = 1.3.toFloat() const val vfloat: Float = 1.3.toFloat()
} }
} }
@@ -43,12 +43,12 @@ public interface Test {
public companion object Companion { public companion object Companion {
private constructor Companion() private constructor Companion()
public final val vbyte: kotlin.Byte public const final val vbyte: kotlin.Byte
public final val vchar: kotlin.Char public const final val vchar: kotlin.Char
public final val vdouble: kotlin.Double public const final val vdouble: kotlin.Double
public final val vfloat: kotlin.Float public const final val vfloat: kotlin.Float
public final val vint: kotlin.Int public const final val vint: kotlin.Int
public final val vlong: kotlin.Long public const final val vlong: kotlin.Long
public final val vstring: kotlin.String public const final val vstring: kotlin.String
} }
} }
@@ -3,7 +3,7 @@ package test
interface Test { interface Test {
companion object { companion object {
public val valProp: Int = 10 public const val valProp: Int = 10
} }
} }
@@ -4,7 +4,7 @@ public interface Test {
public companion object Companion { public companion object Companion {
private constructor Companion() private constructor Companion()
public final val valProp: kotlin.Int public const final val valProp: kotlin.Int
} }
} }
@@ -0,0 +1,13 @@
interface Test {
companion object {
internal const val prop: Int = 0;
}
}
// TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test, prop
// ABSENT: TRUE
// TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop
// FLAGS: ACC_PUBLIC, ACC_FINAL, ACC_STATIC, ACC_SYNTHETIC
@@ -1,13 +1,13 @@
interface Test { interface Test {
companion object { companion object {
val prop: Int = 0; internal val prop: Int = 0;
} }
} }
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test, prop // TESTED_OBJECTS: Test, prop
// FLAGS: ACC_STATIC, ACC_PUBLIC, ACC_FINAL // ABSENT: TRUE
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop // TESTED_OBJECTS: Test$Companion, prop
// FLAGS: ACC_PRIVATE, ACC_FINAL, ACC_STATIC // FLAGS: ACC_PRIVATE, ACC_FINAL, ACC_STATIC, ACC_SYNTHETIC
@@ -1,6 +1,6 @@
interface Test { interface Test {
companion object { companion object {
var prop: Int = 0; internal var prop: Int = 0;
} }
} }
@@ -10,4 +10,4 @@ interface Test {
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop // TESTED_OBJECTS: Test$Companion, prop
// FLAGS: ACC_PRIVATE, ACC_STATIC // FLAGS: ACC_PRIVATE, ACC_STATIC, ACC_SYNTHETIC
@@ -1,6 +1,6 @@
interface Test { interface Test {
companion object { companion object {
var prop: Int = 0 internal var prop: Int = 0
private set private set
} }
} }
@@ -11,4 +11,4 @@ interface Test {
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop // TESTED_OBJECTS: Test$Companion, prop
// FLAGS: ACC_PRIVATE, ACC_STATIC // FLAGS: ACC_PRIVATE, ACC_STATIC, ACC_SYNTHETIC
@@ -0,0 +1,13 @@
interface Test {
companion object {
public const val prop: Int = 0;
}
}
// TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test, prop
// FLAGS: ACC_STATIC, ACC_PUBLIC, ACC_FINAL
// TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop
// FLAGS: ACC_PUBLIC, ACC_FINAL, ACC_STATIC
@@ -6,7 +6,7 @@ interface Test {
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test, prop // TESTED_OBJECTS: Test, prop
// FLAGS: ACC_STATIC, ACC_PUBLIC, ACC_FINAL // ABSENT: TRUE
// TESTED_OBJECT_KIND: property // TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test$Companion, prop // TESTED_OBJECTS: Test$Companion, prop
@@ -72,8 +72,8 @@ public abstract class BaseDiagnosticsTest extends
public static final String CHECK_TYPE_IMPORT = "import " + CHECK_TYPE_PACKAGE + ".*"; public static final String CHECK_TYPE_IMPORT = "import " + CHECK_TYPE_PACKAGE + ".*";
public static final String EXPLICIT_FLEXIBLE_TYPES_DIRECTIVE = "EXPLICIT_FLEXIBLE_TYPES"; public static final String EXPLICIT_FLEXIBLE_TYPES_DIRECTIVE = "EXPLICIT_FLEXIBLE_TYPES";
public static final String EXPLICIT_FLEXIBLE_PACKAGE = Flexibility.FLEXIBLE_TYPE_CLASSIFIER.getPackageFqName().asString(); public static final String EXPLICIT_FLEXIBLE_PACKAGE = Flexibility.Companion.getFLEXIBLE_TYPE_CLASSIFIER().getPackageFqName().asString();
public static final String EXPLICIT_FLEXIBLE_CLASS_NAME = Flexibility.FLEXIBLE_TYPE_CLASSIFIER.getRelativeClassName().asString(); public static final String EXPLICIT_FLEXIBLE_CLASS_NAME = Flexibility.Companion.getFLEXIBLE_TYPE_CLASSIFIER().getRelativeClassName().asString();
private static final String EXPLICIT_FLEXIBLE_TYPES_DECLARATIONS private static final String EXPLICIT_FLEXIBLE_TYPES_DECLARATIONS
= "\npackage " + EXPLICIT_FLEXIBLE_PACKAGE + = "\npackage " + EXPLICIT_FLEXIBLE_PACKAGE +
"\npublic class " + EXPLICIT_FLEXIBLE_CLASS_NAME + "<L, U>"; "\npublic class " + EXPLICIT_FLEXIBLE_CLASS_NAME + "<L, U>";
@@ -54,7 +54,7 @@ public class GenerationUtils {
@NotNull @NotNull
public static GenerationState compileManyFilesGetGenerationStateForTest(@NotNull Project project, @NotNull List<JetFile> files) { public static GenerationState compileManyFilesGetGenerationStateForTest(@NotNull Project project, @NotNull List<JetFile> files) {
return compileManyFilesGetGenerationStateForTest(project, files, PackagePartProvider.EMPTY); return compileManyFilesGetGenerationStateForTest(project, files, PackagePartProvider.Companion.getEMPTY());
} }
@NotNull @NotNull
@@ -779,6 +779,12 @@ public class WriteFlagsTestGenerated extends AbstractWriteFlagsTest {
doTest(fileName); doTest(fileName);
} }
@TestMetadata("internalConstVal.kt")
public void testInternalConstVal() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/writeFlags/property/classObject/trait/internalConstVal.kt");
doTest(fileName);
}
@TestMetadata("internalVal.kt") @TestMetadata("internalVal.kt")
public void testInternalVal() throws Exception { public void testInternalVal() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/writeFlags/property/classObject/trait/internalVal.kt"); String fileName = JetTestUtils.navigationMetadata("compiler/testData/writeFlags/property/classObject/trait/internalVal.kt");
@@ -827,6 +833,12 @@ public class WriteFlagsTestGenerated extends AbstractWriteFlagsTest {
doTest(fileName); doTest(fileName);
} }
@TestMetadata("publicConstVal.kt")
public void testPublicConstVal() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/writeFlags/property/classObject/trait/publicConstVal.kt");
doTest(fileName);
}
@TestMetadata("publicVal.kt") @TestMetadata("publicVal.kt")
public void testPublicVal() throws Exception { public void testPublicVal() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/writeFlags/property/classObject/trait/publicVal.kt"); String fileName = JetTestUtils.navigationMetadata("compiler/testData/writeFlags/property/classObject/trait/publicVal.kt");
@@ -37,7 +37,7 @@ public class JvmResolveUtil {
public static String TEST_MODULE_NAME = "java-integration-test"; public static String TEST_MODULE_NAME = "java-integration-test";
@NotNull @NotNull
public static AnalysisResult analyzeOneFileWithJavaIntegrationAndCheckForErrors(@NotNull JetFile file) { public static AnalysisResult analyzeOneFileWithJavaIntegrationAndCheckForErrors(@NotNull JetFile file) {
return analyzeOneFileWithJavaIntegrationAndCheckForErrors(file, PackagePartProvider.EMPTY); return analyzeOneFileWithJavaIntegrationAndCheckForErrors(file, PackagePartProvider.Companion.getEMPTY());
} }
@NotNull @NotNull
@@ -63,7 +63,7 @@ public class JvmResolveUtil {
@NotNull @NotNull
public static AnalysisResult analyzeOneFileWithJavaIntegration(@NotNull JetFile file) { public static AnalysisResult analyzeOneFileWithJavaIntegration(@NotNull JetFile file) {
return analyzeOneFileWithJavaIntegration(file, PackagePartProvider.EMPTY); return analyzeOneFileWithJavaIntegration(file, PackagePartProvider.Companion.getEMPTY());
} }
@NotNull @NotNull
@@ -71,7 +71,7 @@ public class JvmResolveUtil {
@NotNull Project project, @NotNull Project project,
@NotNull Collection<JetFile> files @NotNull Collection<JetFile> files
) { ) {
return analyzeFilesWithJavaIntegrationAndCheckForErrors(project, files, PackagePartProvider.EMPTY); return analyzeFilesWithJavaIntegrationAndCheckForErrors(project, files, PackagePartProvider.Companion.getEMPTY());
} }
@NotNull @NotNull
@@ -125,7 +125,7 @@ public class JetTestUtils {
@NotNull @NotNull
@Override @Override
public Diagnostics getDiagnostics() { public Diagnostics getDiagnostics() {
return Diagnostics.EMPTY; return Diagnostics.Companion.getEMPTY();
} }
@Override @Override
@@ -26,36 +26,36 @@ import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.TypeConstructor import org.jetbrains.kotlin.types.TypeConstructor
import org.jetbrains.kotlin.types.TypeProjection import org.jetbrains.kotlin.types.TypeProjection
public interface DescriptorRenderer : Renderer<DeclarationDescriptor> { public abstract class DescriptorRenderer : Renderer<DeclarationDescriptor> {
public fun withOptions(changeOptions: DescriptorRendererOptions.() -> Unit): DescriptorRenderer { public fun withOptions(changeOptions: DescriptorRendererOptions.() -> Unit): DescriptorRenderer {
val options = (this as DescriptorRendererImpl).options.copy() val options = (this as DescriptorRendererImpl).options.copy()
options.changeOptions() options.changeOptions()
options.lock() options.lock()
return DescriptorRendererImpl(options) return DescriptorRendererImpl(options)
} }
public fun renderType(type: JetType): String
public fun renderTypeArguments(typeArguments: List<TypeProjection>): String public abstract fun renderType(type: JetType): String
public fun renderTypeProjection(typeProjection: TypeProjection): String public abstract fun renderTypeArguments(typeArguments: List<TypeProjection>): String
public fun renderTypeConstructor(typeConstructor: TypeConstructor): String public abstract fun renderTypeProjection(typeProjection: TypeProjection): String
public fun renderClassifierName(klass: ClassifierDescriptor): String public abstract fun renderTypeConstructor(typeConstructor: TypeConstructor): String
public fun renderAnnotation(annotation: AnnotationDescriptor, target: AnnotationUseSiteTarget? = null): String public abstract fun renderClassifierName(klass: ClassifierDescriptor): String
override fun render(declarationDescriptor: DeclarationDescriptor): String public abstract fun renderAnnotation(annotation: AnnotationDescriptor, target: AnnotationUseSiteTarget? = null): String
public fun renderValueParameters(parameters: Collection<ValueParameterDescriptor>, synthesizedParameterNames: Boolean): String override abstract fun render(declarationDescriptor: DeclarationDescriptor): String
public abstract fun renderValueParameters(parameters: Collection<ValueParameterDescriptor>, synthesizedParameterNames: Boolean): String
public fun renderFunctionParameters(functionDescriptor: FunctionDescriptor): String public fun renderFunctionParameters(functionDescriptor: FunctionDescriptor): String
= renderValueParameters(functionDescriptor.valueParameters, functionDescriptor.hasSynthesizedParameterNames()) = renderValueParameters(functionDescriptor.valueParameters, functionDescriptor.hasSynthesizedParameterNames())
public fun renderName(name: Name): String public abstract fun renderName(name: Name): String
public fun renderFqName(fqName: FqNameBase): String public abstract fun renderFqName(fqName: FqNameBase): String
public interface ValueParametersHandler { public interface ValueParametersHandler {
public fun appendBeforeValueParameters(parameterCount: Int, builder: StringBuilder) public fun appendBeforeValueParameters(parameterCount: Int, builder: StringBuilder)
@@ -40,7 +40,7 @@ import java.util.*
internal class DescriptorRendererImpl( internal class DescriptorRendererImpl(
val options: DescriptorRendererOptionsImpl val options: DescriptorRendererOptionsImpl
) : DescriptorRenderer, DescriptorRendererOptions by options/* this gives access to options without qualifier */ { ) : DescriptorRenderer(), DescriptorRendererOptions by options/* this gives access to options without qualifier */ {
init { init {
assert(options.isLocked) assert(options.isLocked)
@@ -306,7 +306,7 @@ public class DescriptorUtils {
} }
public static boolean isInterfaceCompanionObject(@NotNull DeclarationDescriptor descriptor) { public static boolean isInterfaceCompanionObject(@NotNull DeclarationDescriptor descriptor) {
return isCompanionObject(descriptor) && isKindOf(descriptor.getContainingDeclaration(), ClassKind.INTERFACE); return isCompanionObject(descriptor) && isInterface(descriptor.getContainingDeclaration());
} }
public static boolean isObject(@NotNull DeclarationDescriptor descriptor) { public static boolean isObject(@NotNull DeclarationDescriptor descriptor) {
@@ -352,7 +352,7 @@ class KotlinEvaluator(val codeFragment: JetCodeFragment,
val (bindingContext, moduleDescriptor, files) = jetFile.checkForErrors(true) val (bindingContext, moduleDescriptor, files) = jetFile.checkForErrors(true)
val generateClassFilter = object : GenerationState.GenerateClassFilter { val generateClassFilter = object : GenerationState.GenerateClassFilter() {
override fun shouldGeneratePackagePart(file: JetFile) = file == jetFile override fun shouldGeneratePackagePart(file: JetFile) = file == jetFile
override fun shouldAnnotateClass(classOrObject: JetClassOrObject) = true override fun shouldAnnotateClass(classOrObject: JetClassOrObject) = true
override fun shouldGenerateClass(classOrObject: JetClassOrObject) = classOrObject.getContainingJetFile() == jetFile override fun shouldGenerateClass(classOrObject: JetClassOrObject) = classOrObject.getContainingJetFile() == jetFile
@@ -102,7 +102,7 @@ public class JetAnonymousSuperMacro extends Macro {
List<PsiNamedElement> result = new ArrayList<PsiNamedElement>(); List<PsiNamedElement> result = new ArrayList<PsiNamedElement>();
for (DeclarationDescriptor descriptor : scope.getDescriptors(DescriptorKindFilter.NON_SINGLETON_CLASSIFIERS, JetScope.ALL_NAME_FILTER)) { for (DeclarationDescriptor descriptor : scope.getDescriptors(DescriptorKindFilter.NON_SINGLETON_CLASSIFIERS, JetScope.Companion.getALL_NAME_FILTER())) {
if (!(descriptor instanceof ClassDescriptor)) continue; if (!(descriptor instanceof ClassDescriptor)) continue;
ClassDescriptor classDescriptor = (ClassDescriptor) descriptor; ClassDescriptor classDescriptor = (ClassDescriptor) descriptor;
if (!classDescriptor.getModality().isOverridable()) continue; if (!classDescriptor.getModality().isOverridable()) continue;
@@ -4,7 +4,7 @@ package server
interface Some { interface Some {
companion object { companion object {
val <caret>XX = 1 const val <caret>XX = 1
} }
} }
+1 -1
View File
@@ -27,7 +27,7 @@ public object KotlinObject {
public interface StaticFieldInClassObjectInTrait { public interface StaticFieldInClassObjectInTrait {
companion object { companion object {
public val XX: String = "xx" public const val XX: String = "xx"
} }
} }
@@ -3,6 +3,6 @@ package test
interface Trait { interface Trait {
companion object { companion object {
// Old and new constant values are different, but their hashes are the same // Old and new constant values are different, but their hashes are the same
val CONST = "BF" const val CONST = "BF"
} }
} }