Support platform/impl modifiers for properties
Do not allow platform properties to have backing fields, initializers, be delegated, lateinit or const, or have accessors with bodies
This commit is contained in:
+2
-1
@@ -77,7 +77,8 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl implem
|
||||
) {
|
||||
super(containingDeclaration, null, Annotations.Companion.getEMPTY(), Modality.FINAL, Visibilities.LOCAL,
|
||||
original.isVar(), Name.identifier("access$" + nameSuffix),
|
||||
Kind.DECLARATION, SourceElement.NO_SOURCE, /* lateInit = */ false, /* isConst = */ false);
|
||||
Kind.DECLARATION, SourceElement.NO_SOURCE, /* lateInit = */ false, /* isConst = */ false,
|
||||
/* isPlatform = */ false, /* isImpl = */ false);
|
||||
|
||||
this.calleeDescriptor = original;
|
||||
this.superCallTarget = superCallTarget;
|
||||
|
||||
+4
-3
@@ -278,9 +278,10 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l
|
||||
name: Name,
|
||||
kind: CallableMemberDescriptor.Kind,
|
||||
source: SourceElement
|
||||
) : SyntheticJavaPropertyDescriptor, PropertyDescriptorImpl(containingDeclaration, original, annotations,
|
||||
modality, visibility, isVar, name, kind, source,
|
||||
/* lateInit = */ false, /* isConst = */ false) {
|
||||
) : SyntheticJavaPropertyDescriptor, PropertyDescriptorImpl(
|
||||
containingDeclaration, original, annotations, modality, visibility, isVar, name, kind, source,
|
||||
/* lateInit = */ false, /* isConst = */ false, /* isPlatform = */ false, /* isImpl = */ false
|
||||
) {
|
||||
|
||||
override var getMethod: FunctionDescriptor by Delegates.notNull()
|
||||
private set
|
||||
|
||||
@@ -494,6 +494,8 @@ public interface Errors {
|
||||
DiagnosticFactory0<KtDeclaration> PLATFORM_DECLARATION_WITH_BODY = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtParameter> PLATFORM_DECLARATION_WITH_DEFAULT_PARAMETER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<KtExpression> PLATFORM_PROPERTY_INITIALIZER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Errors/warnings inside code blocks
|
||||
|
||||
+2
@@ -260,6 +260,8 @@ public class DefaultErrorMessages {
|
||||
MAP.put(PLATFORM_DECLARATION_WITH_BODY, "Platform declaration must not have a body");
|
||||
MAP.put(PLATFORM_DECLARATION_WITH_DEFAULT_PARAMETER, "Platform declaration cannot have parameters with default values");
|
||||
|
||||
MAP.put(PLATFORM_PROPERTY_INITIALIZER, "Platform property cannot have an initializer");
|
||||
|
||||
MAP.put(PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT, "Projections are not allowed on type arguments of functions and properties");
|
||||
MAP.put(SUPERTYPE_NOT_INITIALIZED, "This type has a constructor, and thus must be initialized here");
|
||||
MAP.put(NOTHING_TO_OVERRIDE, "''{0}'' overrides nothing", NAME);
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.resolve
|
||||
|
||||
import com.google.common.collect.ImmutableSet
|
||||
import com.google.common.collect.Sets
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
@@ -650,17 +649,19 @@ class DeclarationsChecker(
|
||||
|
||||
val initializer = property.initializer
|
||||
val delegate = property.delegate
|
||||
val isPlatform = propertyDescriptor.isPlatform
|
||||
if (initializer != null) {
|
||||
if (inTrait) {
|
||||
trace.report(PROPERTY_INITIALIZER_IN_INTERFACE.on(initializer))
|
||||
}
|
||||
else {
|
||||
if (!backingFieldRequired) {
|
||||
trace.report(PROPERTY_INITIALIZER_NO_BACKING_FIELD.on(initializer))
|
||||
}
|
||||
else if (property.receiverTypeReference != null) {
|
||||
trace.report(EXTENSION_PROPERTY_WITH_BACKING_FIELD.on(initializer))
|
||||
}
|
||||
else if (isPlatform) {
|
||||
trace.report(PLATFORM_PROPERTY_INITIALIZER.on(initializer))
|
||||
}
|
||||
else if (!backingFieldRequired) {
|
||||
trace.report(PROPERTY_INITIALIZER_NO_BACKING_FIELD.on(initializer))
|
||||
}
|
||||
else if (property.receiverTypeReference != null) {
|
||||
trace.report(EXTENSION_PROPERTY_WITH_BACKING_FIELD.on(initializer))
|
||||
}
|
||||
}
|
||||
else if (delegate != null) {
|
||||
@@ -670,7 +671,7 @@ class DeclarationsChecker(
|
||||
}
|
||||
else {
|
||||
val isUninitialized = trace.bindingContext.get(BindingContext.IS_UNINITIALIZED, propertyDescriptor) ?: false
|
||||
if (backingFieldRequired && !inTrait && !propertyDescriptor.isLateInit && isUninitialized) {
|
||||
if (backingFieldRequired && !inTrait && !propertyDescriptor.isLateInit && !isPlatform && isUninitialized) {
|
||||
if (containingDeclaration !is ClassDescriptor || hasAccessorImplementation) {
|
||||
trace.report(MUST_BE_INITIALIZED.on(property))
|
||||
}
|
||||
@@ -681,11 +682,9 @@ class DeclarationsChecker(
|
||||
else if (noExplicitTypeOrGetterType(property)) {
|
||||
trace.report(PROPERTY_WITH_NO_TYPE_NO_INITIALIZER.on(property))
|
||||
}
|
||||
if (backingFieldRequired && !inTrait && propertyDescriptor.isLateInit && !isUninitialized) {
|
||||
if (trace[MUST_BE_LATEINIT, propertyDescriptor] ?: false) {}
|
||||
else {
|
||||
trace.report(UNNECESSARY_LATEINIT.on(property))
|
||||
}
|
||||
if (backingFieldRequired && !inTrait && propertyDescriptor.isLateInit && !isUninitialized &&
|
||||
trace[MUST_BE_LATEINIT, propertyDescriptor] != true) {
|
||||
trace.report(UNNECESSARY_LATEINIT.on(property))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -800,11 +799,18 @@ class DeclarationsChecker(
|
||||
private fun checkAccessor(
|
||||
propertyDescriptor: PropertyDescriptor,
|
||||
accessor: KtPropertyAccessor?,
|
||||
accessorDescriptor: PropertyAccessorDescriptor?) {
|
||||
accessorDescriptor: PropertyAccessorDescriptor?
|
||||
) {
|
||||
if (accessor == null || accessorDescriptor == null) return
|
||||
if (propertyDescriptor.isPlatform && accessor.hasBody()) {
|
||||
trace.report(PLATFORM_DECLARATION_WITH_BODY.on(accessor))
|
||||
}
|
||||
|
||||
val accessorModifierList = accessor.modifierList ?: return
|
||||
val tokens = modifiersChecker.getTokensCorrespondingToModifiers(accessorModifierList,
|
||||
Sets.newHashSet(KtTokens.PUBLIC_KEYWORD, KtTokens.PROTECTED_KEYWORD, KtTokens.PRIVATE_KEYWORD, KtTokens.INTERNAL_KEYWORD))
|
||||
val tokens = modifiersChecker.getTokensCorrespondingToModifiers(
|
||||
accessorModifierList,
|
||||
setOf(KtTokens.PUBLIC_KEYWORD, KtTokens.PROTECTED_KEYWORD, KtTokens.PRIVATE_KEYWORD, KtTokens.INTERNAL_KEYWORD)
|
||||
)
|
||||
if (accessor.isGetter) {
|
||||
if (accessorDescriptor.visibility != propertyDescriptor.visibility) {
|
||||
reportVisibilityModifierDiagnostics(tokens.values, Errors.GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY)
|
||||
|
||||
@@ -808,7 +808,10 @@ public class DescriptorResolver {
|
||||
CallableMemberDescriptor.Kind.DECLARATION,
|
||||
KotlinSourceElementKt.toSourceElement(property),
|
||||
modifierList != null && modifierList.hasModifier(KtTokens.LATEINIT_KEYWORD),
|
||||
modifierList != null && modifierList.hasModifier(KtTokens.CONST_KEYWORD)
|
||||
modifierList != null && modifierList.hasModifier(KtTokens.CONST_KEYWORD),
|
||||
modifierList != null && modifierList.hasModifier(KtTokens.PLATFORM_KEYWORD) ||
|
||||
containingDeclaration instanceof ClassDescriptor && ((ClassDescriptor) containingDeclaration).isPlatform(),
|
||||
modifierList != null && modifierList.hasModifier(KtTokens.IMPL_KEYWORD)
|
||||
);
|
||||
wrapper.setDescriptor(propertyDescriptor);
|
||||
|
||||
@@ -1123,7 +1126,9 @@ public class DescriptorResolver {
|
||||
CallableMemberDescriptor.Kind.DECLARATION,
|
||||
KotlinSourceElementKt.toSourceElement(parameter),
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false
|
||||
/* isConst = */ false,
|
||||
/* isPlatform = */ false,
|
||||
/* isImpl = */ false
|
||||
);
|
||||
propertyWrapper.setDescriptor(propertyDescriptor);
|
||||
propertyDescriptor.setType(type, Collections.<TypeParameterDescriptor>emptyList(),
|
||||
|
||||
@@ -85,14 +85,14 @@ class LocalVariableResolver(
|
||||
propertyDescriptor,
|
||||
delegateExpression,
|
||||
typingContext.scope,
|
||||
typingContext.trace);
|
||||
typingContext.trace)
|
||||
}
|
||||
}
|
||||
|
||||
val initializer = property.initializer
|
||||
var typeInfo: KotlinTypeInfo
|
||||
if (initializer != null) {
|
||||
val outType = propertyDescriptor.getType()
|
||||
val outType = propertyDescriptor.type
|
||||
typeInfo = facade.getTypeInfo(initializer, context.replaceExpectedType(outType))
|
||||
val dataFlowInfo = typeInfo.dataFlowInfo
|
||||
val type = typeInfo.type
|
||||
@@ -146,7 +146,9 @@ class LocalVariableResolver(
|
||||
CallableMemberDescriptor.Kind.DECLARATION,
|
||||
variable.toSourceElement(),
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false
|
||||
/* isConst = */ false,
|
||||
/* isPlatform = */ false,
|
||||
/* isImpl = */ false
|
||||
)
|
||||
// For a local variable the type must not be deferred
|
||||
type = variableTypeAndInitializerResolver.resolveType(propertyDescriptor, scope, variable, dataFlowInfo, trace, local = true)
|
||||
|
||||
@@ -90,8 +90,8 @@ object ModifierCheckerCore {
|
||||
CONST_KEYWORD to EnumSet.of(MEMBER_PROPERTY, TOP_LEVEL_PROPERTY),
|
||||
OPERATOR_KEYWORD to EnumSet.of(FUNCTION),
|
||||
INFIX_KEYWORD to EnumSet.of(FUNCTION),
|
||||
PLATFORM_KEYWORD to EnumSet.of(FUNCTION, CLASS_ONLY, OBJECT, INTERFACE, INNER_CLASS, ENUM_CLASS, ANNOTATION_CLASS), // TODO
|
||||
IMPL_KEYWORD to EnumSet.of(FUNCTION, CLASS_ONLY, OBJECT, INTERFACE, INNER_CLASS, ENUM_CLASS, ANNOTATION_CLASS) // TODO
|
||||
PLATFORM_KEYWORD to EnumSet.of(FUNCTION, TOP_LEVEL_PROPERTY_WITHOUT_FIELD_OR_DELEGATE, CLASS_ONLY, OBJECT, INTERFACE, INNER_CLASS, ENUM_CLASS, ANNOTATION_CLASS), // TODO
|
||||
IMPL_KEYWORD to EnumSet.of(FUNCTION, TOP_LEVEL_PROPERTY_WITHOUT_FIELD_OR_DELEGATE, CLASS_ONLY, OBJECT, INTERFACE, INNER_CLASS, ENUM_CLASS, ANNOTATION_CLASS) // TODO
|
||||
)
|
||||
|
||||
val featureDependencies = mapOf(
|
||||
|
||||
@@ -97,7 +97,9 @@ class DynamicCallableDescriptors(storageManager: StorageManager, builtIns: Kotli
|
||||
CallableMemberDescriptor.Kind.DECLARATION,
|
||||
SourceElement.NO_SOURCE,
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false
|
||||
/* isConst = */ false,
|
||||
/* isPlatform = */ false,
|
||||
/* isImpl = */ false
|
||||
)
|
||||
propertyDescriptor.setType(
|
||||
dynamicType,
|
||||
|
||||
+8
-8
@@ -20,10 +20,8 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.PropertyDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.org.objectweb.asm.commons.Method
|
||||
|
||||
interface JvmDescriptorWithExtraFlags {
|
||||
val extraFlags: Int
|
||||
@@ -41,10 +39,12 @@ class JvmPropertyDescriptorImpl(
|
||||
kind: CallableMemberDescriptor.Kind,
|
||||
source: SourceElement,
|
||||
isLateInit: Boolean,
|
||||
isConst: Boolean
|
||||
isConst: Boolean,
|
||||
isPlatform: Boolean,
|
||||
isImpl: Boolean
|
||||
) : JvmDescriptorWithExtraFlags, PropertyDescriptorImpl(
|
||||
containingDeclaration, original, annotations, modality, visibility, isVar,
|
||||
name, kind, source, isLateInit, isConst
|
||||
name, kind, source, isLateInit, isConst, isPlatform, isImpl
|
||||
) {
|
||||
override fun createSubstitutedCopy(
|
||||
newOwner: DeclarationDescriptor,
|
||||
@@ -55,7 +55,7 @@ class JvmPropertyDescriptorImpl(
|
||||
): PropertyDescriptorImpl =
|
||||
JvmPropertyDescriptorImpl(
|
||||
newOwner, original, annotations, newModality, newVisibility, extraFlags, isVar, name, kind,
|
||||
SourceElement.NO_SOURCE, isLateInit, isConst
|
||||
SourceElement.NO_SOURCE, isLateInit, isConst, isPlatform, isImpl
|
||||
)
|
||||
|
||||
companion object {
|
||||
@@ -71,7 +71,7 @@ class JvmPropertyDescriptorImpl(
|
||||
): PropertyDescriptorImpl =
|
||||
JvmPropertyDescriptorImpl(
|
||||
containingDeclaration, null, annotations, modality, visibility, extraFlags, false, name,
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED, source, false, false
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED, source, false, false, false, false
|
||||
).initialize(type)
|
||||
|
||||
fun createFinalField(
|
||||
@@ -85,7 +85,7 @@ class JvmPropertyDescriptorImpl(
|
||||
): PropertyDescriptorImpl =
|
||||
JvmPropertyDescriptorImpl(
|
||||
classDescriptor, null, annotations, Modality.FINAL, visibility, extraFlags, false, name,
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED, source, false, false
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED, source, false, false, false, false
|
||||
).initialize(type, dispatchReceiverParameter = classDescriptor.thisAsReceiverParameter)
|
||||
}
|
||||
}
|
||||
@@ -108,4 +108,4 @@ class JvmFunctionDescriptorImpl(
|
||||
SourceElement.NO_SOURCE, extraFlags
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -59,7 +59,7 @@ class JvmSharedVariablesManager(val builtIns: KotlinBuiltIns) : SharedVariablesM
|
||||
PropertyDescriptorImpl.create(
|
||||
refClass, Annotations.EMPTY, Modality.FINAL, Visibilities.PUBLIC, true,
|
||||
Name.identifier("element"), CallableMemberDescriptor.Kind.DECLARATION, SourceElement.NO_SOURCE,
|
||||
false, false
|
||||
false, false, false, false
|
||||
).initialize(type, dispatchReceiverParameter = refClass.thisAsReceiverParameter)
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ class JvmSharedVariablesManager(val builtIns: KotlinBuiltIns) : SharedVariablesM
|
||||
PropertyDescriptorImpl.create(
|
||||
genericRefClass, Annotations.EMPTY, Modality.FINAL, Visibilities.PUBLIC, true,
|
||||
Name.identifier("element"), CallableMemberDescriptor.Kind.DECLARATION, SourceElement.NO_SOURCE,
|
||||
false, false
|
||||
false, false, false, false
|
||||
).initialize(
|
||||
type = builtIns.anyType,
|
||||
dispatchReceiverParameter = genericRefClass.thisAsReceiverParameter
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ class SpecialDescriptorsFactory(
|
||||
objectDescriptor,
|
||||
Annotations.EMPTY, Modality.FINAL, Visibilities.PUBLIC, false,
|
||||
Name.identifier("INSTANCE"),
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED, SourceElement.NO_SOURCE, false, false
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED, SourceElement.NO_SOURCE, false, false, false, false
|
||||
).initialize(objectDescriptor.defaultType)
|
||||
|
||||
return instanceFieldDescriptor
|
||||
|
||||
@@ -50,16 +50,18 @@ abstract class IrDelegateDescriptorBase(
|
||||
delegateType: KotlinType
|
||||
) : PropertyDescriptorImpl(
|
||||
containingDeclaration,
|
||||
null, // original
|
||||
/* original = */ null,
|
||||
Annotations.EMPTY,
|
||||
Modality.FINAL,
|
||||
Visibilities.PRIVATE,
|
||||
false, // isVar
|
||||
/* isVar = */ false,
|
||||
name,
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
SourceElement.NO_SOURCE,
|
||||
false, // lateInit
|
||||
false // isConst
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false,
|
||||
/* isPlatform = */ false,
|
||||
/* isImpl = */ false
|
||||
) {
|
||||
init {
|
||||
setOutType(delegateType)
|
||||
|
||||
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
platform val justVal: String
|
||||
platform var justVar: String
|
||||
|
||||
platform val String.extensionVal: Unit
|
||||
platform var <T> T.genericExtensionVar: T
|
||||
|
||||
platform val valWithGet: String
|
||||
get
|
||||
platform var varWithGetSet: String
|
||||
get set
|
||||
|
||||
platform var varWithPlatformGetSet: String
|
||||
<!WRONG_MODIFIER_TARGET!>platform<!> get
|
||||
<!WRONG_MODIFIER_TARGET!>platform<!> set
|
||||
|
||||
platform val backingFieldVal: String = <!PLATFORM_PROPERTY_INITIALIZER!>"no"<!>
|
||||
platform var backingFieldVar: String = <!PLATFORM_PROPERTY_INITIALIZER!>"no"<!>
|
||||
|
||||
platform val customAccessorVal: String
|
||||
<!PLATFORM_DECLARATION_WITH_BODY!>get()<!> = "no"
|
||||
platform var customAccessorVar: String
|
||||
<!PLATFORM_DECLARATION_WITH_BODY!>get()<!> = "no"
|
||||
<!PLATFORM_DECLARATION_WITH_BODY!>set(value)<!> {}
|
||||
|
||||
platform <!CONST_VAL_WITHOUT_INITIALIZER!>const<!> val constVal: Int
|
||||
|
||||
platform <!WRONG_MODIFIER_TARGET!>lateinit<!> var lateinitVar: String
|
||||
|
||||
<!WRONG_MODIFIER_TARGET!>platform<!> val delegated: String by Delegate
|
||||
object Delegate { operator fun getValue(x: Any?, y: Any?): String = "" }
|
||||
|
||||
fun test(): String {
|
||||
<!WRONG_MODIFIER_TARGET!>platform<!> val localVariable: String
|
||||
localVariable = "no"
|
||||
return localVariable
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
package
|
||||
|
||||
public val backingFieldVal: kotlin.String = "no"
|
||||
public var backingFieldVar: kotlin.String
|
||||
public const val constVal: kotlin.Int
|
||||
public val customAccessorVal: kotlin.String
|
||||
public var customAccessorVar: kotlin.String
|
||||
public val delegated: kotlin.String
|
||||
public val justVal: kotlin.String
|
||||
public var justVar: kotlin.String
|
||||
public lateinit var lateinitVar: kotlin.String
|
||||
public val valWithGet: kotlin.String
|
||||
public var varWithGetSet: kotlin.String
|
||||
public var varWithPlatformGetSet: kotlin.String
|
||||
public val kotlin.String.extensionVal: kotlin.Unit
|
||||
public var </*0*/ T> T.genericExtensionVar: T
|
||||
public fun test(): kotlin.String
|
||||
|
||||
public object Delegate {
|
||||
private constructor Delegate()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final operator fun getValue(/*0*/ x: kotlin.Any?, /*1*/ y: kotlin.Any?): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
platform var foo: String
|
||||
|
||||
// MODULE: m2-jvm(m1-common)
|
||||
// FILE: jvm.kt
|
||||
impl var foo: String = "JVM"
|
||||
|
||||
// MODULE: m3-js(m1-common)
|
||||
// FILE: js.kt
|
||||
impl var foo: String = "JS"
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// -- Module: <m1-common> --
|
||||
package
|
||||
|
||||
public var foo: kotlin.String
|
||||
|
||||
|
||||
// -- Module: <m2-jvm> --
|
||||
package
|
||||
|
||||
public var foo: kotlin.String
|
||||
|
||||
|
||||
// -- Module: <m3-js> --
|
||||
package
|
||||
|
||||
public var foo: kotlin.String
|
||||
@@ -12630,6 +12630,27 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelProperty")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class TopLevelProperty extends AbstractDiagnosticsTest {
|
||||
public void testAllFilesPresentInTopLevelProperty() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/topLevelProperty"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("differentKindsOfProperties.kt")
|
||||
public void testDifferentKindsOfProperties() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelProperty/differentKindsOfProperties.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simplePlatformVar.kt")
|
||||
public void testSimplePlatformVar() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelProperty/simplePlatformVar.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/namedArguments")
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja
|
||||
boolean isStaticFinal
|
||||
) {
|
||||
super(containingDeclaration, original, annotations, modality, visibility, isVar, name, kind, source,
|
||||
/* lateInit = */ false, /* isConst = */ false);
|
||||
/* lateInit = */ false, /* isConst = */ false, /* isPlatform = */ false, /* isImpl = */ false);
|
||||
|
||||
this.isStaticFinal = isStaticFinal;
|
||||
}
|
||||
|
||||
+14
-8
@@ -44,6 +44,8 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
private final Kind kind;
|
||||
private final boolean lateInit;
|
||||
private final boolean isConst;
|
||||
private final boolean isPlatform;
|
||||
private final boolean isImpl;
|
||||
|
||||
private ReceiverParameterDescriptor dispatchReceiverParameter;
|
||||
private ReceiverParameterDescriptor extensionReceiverParameter;
|
||||
@@ -63,7 +65,9 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
@NotNull Kind kind,
|
||||
@NotNull SourceElement source,
|
||||
boolean lateInit,
|
||||
boolean isConst
|
||||
boolean isConst,
|
||||
boolean isPlatform,
|
||||
boolean isImpl
|
||||
) {
|
||||
super(containingDeclaration, annotations, name, null, isVar, source);
|
||||
this.modality = modality;
|
||||
@@ -72,6 +76,8 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
this.kind = kind;
|
||||
this.lateInit = lateInit;
|
||||
this.isConst = isConst;
|
||||
this.isPlatform = isPlatform;
|
||||
this.isImpl = isImpl;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -85,10 +91,12 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
@NotNull Kind kind,
|
||||
@NotNull SourceElement source,
|
||||
boolean lateInit,
|
||||
boolean isConst
|
||||
boolean isConst,
|
||||
boolean isPlatform,
|
||||
boolean isImpl
|
||||
) {
|
||||
return new PropertyDescriptorImpl(containingDeclaration, null, annotations,
|
||||
modality, visibility, isVar, name, kind, source, lateInit, isConst);
|
||||
modality, visibility, isVar, name, kind, source, lateInit, isConst, isPlatform, isImpl);
|
||||
}
|
||||
|
||||
public void setType(
|
||||
@@ -334,7 +342,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
) {
|
||||
return new PropertyDescriptorImpl(
|
||||
newOwner, original, getAnnotations(), newModality, newVisibility, isVar(), getName(), kind, SourceElement.NO_SOURCE,
|
||||
isLateInit(), isConst()
|
||||
isLateInit(), isConst(), isPlatform(), isImpl()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -357,14 +365,12 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
|
||||
@Override
|
||||
public boolean isPlatform() {
|
||||
// TODO
|
||||
return false;
|
||||
return isPlatform;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isImpl() {
|
||||
// TODO
|
||||
return false;
|
||||
return isImpl;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -365,7 +365,9 @@ public class ErrorUtils {
|
||||
CallableMemberDescriptor.Kind.DECLARATION,
|
||||
SourceElement.NO_SOURCE,
|
||||
/* lateInit = */ false,
|
||||
/* isConst = */ false
|
||||
/* isConst = */ false,
|
||||
/* isPlatform = */ false,
|
||||
/* isImpl = */ false
|
||||
);
|
||||
descriptor.setType(ERROR_PROPERTY_TYPE,
|
||||
Collections.<TypeParameterDescriptor>emptyList(),
|
||||
|
||||
+5
-2
@@ -24,7 +24,10 @@ import org.jetbrains.kotlin.protobuf.MessageLite
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.NameResolver
|
||||
import org.jetbrains.kotlin.serialization.deserialization.TypeTable
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.SimpleType
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.types.asSimpleType
|
||||
|
||||
interface DeserializedMemberDescriptor : MemberDescriptor {
|
||||
val proto: MessageLite
|
||||
@@ -87,7 +90,7 @@ class DeserializedPropertyDescriptor(
|
||||
override val containerSource: SourceElement?
|
||||
) : DeserializedCallableMemberDescriptor,
|
||||
PropertyDescriptorImpl(containingDeclaration, original, annotations,
|
||||
modality, visibility, isVar, name, kind, SourceElement.NO_SOURCE, isLateInit, isConst) {
|
||||
modality, visibility, isVar, name, kind, SourceElement.NO_SOURCE, isLateInit, isConst, false, false) {
|
||||
|
||||
override fun createSubstitutedCopy(
|
||||
newOwner: DeclarationDescriptor,
|
||||
|
||||
+2
-2
@@ -101,8 +101,8 @@ private fun genProperty(
|
||||
Name.identifier(id.name),
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
sourceElement,
|
||||
false,
|
||||
false) {
|
||||
false, false, false, false
|
||||
) {
|
||||
override val errorType = errorType
|
||||
override val cacheView = cacheView
|
||||
override val resourceId = id
|
||||
|
||||
Reference in New Issue
Block a user