Added 'isInline' implementation to property accessor descriptors
This commit is contained in:
+2
-2
@@ -95,7 +95,7 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl implem
|
||||
public static class Getter extends PropertyGetterDescriptorImpl implements AccessorForCallableDescriptor<PropertyGetterDescriptor> {
|
||||
public Getter(AccessorForPropertyDescriptor property) {
|
||||
super(property, Annotations.Companion.getEMPTY(), Modality.FINAL, Visibilities.LOCAL,
|
||||
/* isDefault = */ false, /* isExternal = */ false, Kind.DECLARATION, null, SourceElement.NO_SOURCE);
|
||||
/* isDefault = */ false, /* isExternal = */ false, /* isInline = */false, Kind.DECLARATION, null, SourceElement.NO_SOURCE);
|
||||
initialize(property.getType());
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl implem
|
||||
public static class Setter extends PropertySetterDescriptorImpl implements AccessorForCallableDescriptor<PropertySetterDescriptor>{
|
||||
public Setter(AccessorForPropertyDescriptor property) {
|
||||
super(property, Annotations.Companion.getEMPTY(), Modality.FINAL, Visibilities.LOCAL,
|
||||
/* isDefault = */ false, /* isExternal = */ false, Kind.DECLARATION, null, SourceElement.NO_SOURCE);
|
||||
/* isDefault = */ false, /* isExternal = */ false, /* isInline = */ false, Kind.DECLARATION, null, SourceElement.NO_SOURCE);
|
||||
initializeDefault();
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -317,6 +317,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l
|
||||
visibility,
|
||||
false,
|
||||
getMethod.isExternal,
|
||||
false,
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
null,
|
||||
SourceElement.NO_SOURCE)
|
||||
@@ -329,6 +330,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l
|
||||
syntheticExtensionVisibility(setMethod),
|
||||
false,
|
||||
setMethod.isExternal,
|
||||
false,
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
null,
|
||||
SourceElement.NO_SOURCE)
|
||||
|
||||
@@ -925,6 +925,7 @@ public class DescriptorResolver {
|
||||
resolveModalityFromModifiers(setter, propertyDescriptor.getModality()),
|
||||
resolveVisibilityFromModifiers(setter, propertyDescriptor.getVisibility()),
|
||||
/* isDefault = */ false, setter.hasModifier(EXTERNAL_KEYWORD),
|
||||
property.hasModifier(KtTokens.INLINE_KEYWORD) || setter.hasModifier(KtTokens.INLINE_KEYWORD),
|
||||
CallableMemberDescriptor.Kind.DECLARATION, null, KotlinSourceElementKt.toSourceElement(setter)
|
||||
);
|
||||
KtTypeReference returnTypeReference = setter.getReturnTypeReference();
|
||||
@@ -973,7 +974,8 @@ public class DescriptorResolver {
|
||||
else if (property.isVar()) {
|
||||
Annotations setterAnnotations = annotationSplitter.getAnnotationsForTarget(PROPERTY_SETTER);
|
||||
setterDescriptor = DescriptorFactory.createSetter(propertyDescriptor, setterAnnotations, !property.hasDelegate(),
|
||||
/* isExternal = */ false, propertyDescriptor.getSource());
|
||||
/* isExternal = */ false, property.hasModifier(KtTokens.INLINE_KEYWORD),
|
||||
propertyDescriptor.getSource());
|
||||
}
|
||||
|
||||
if (!property.isVar()) {
|
||||
@@ -1005,6 +1007,7 @@ public class DescriptorResolver {
|
||||
resolveModalityFromModifiers(getter, propertyDescriptor.getModality()),
|
||||
resolveVisibilityFromModifiers(getter, propertyDescriptor.getVisibility()),
|
||||
/* isDefault = */ false, getter.hasModifier(EXTERNAL_KEYWORD),
|
||||
property.hasModifier(KtTokens.INLINE_KEYWORD) || getter.hasModifier(KtTokens.INLINE_KEYWORD),
|
||||
CallableMemberDescriptor.Kind.DECLARATION, null, KotlinSourceElementKt.toSourceElement(getter)
|
||||
);
|
||||
KotlinType returnType =
|
||||
@@ -1015,7 +1018,7 @@ public class DescriptorResolver {
|
||||
else {
|
||||
Annotations getterAnnotations = annotationSplitter.getAnnotationsForTarget(PROPERTY_GETTER);
|
||||
getterDescriptor = DescriptorFactory.createGetter(propertyDescriptor, getterAnnotations, !property.hasDelegate(),
|
||||
/* isExternal = */ false);
|
||||
/* isExternal = */ false, property.hasModifier(KtTokens.INLINE_KEYWORD));
|
||||
getterDescriptor.initialize(propertyDescriptor.getType());
|
||||
}
|
||||
return getterDescriptor;
|
||||
|
||||
+3
-2
@@ -141,7 +141,7 @@ class DescriptorSerializer private constructor(
|
||||
|
||||
val hasAnnotations = descriptor.annotations.getAllAnnotations().isNotEmpty()
|
||||
|
||||
val propertyFlags = Flags.getAccessorFlags(hasAnnotations, descriptor.visibility, descriptor.modality, false, false)
|
||||
val propertyFlags = Flags.getAccessorFlags(hasAnnotations, descriptor.visibility, descriptor.modality, false, false, false)
|
||||
|
||||
val getter = descriptor.getter
|
||||
if (getter != null) {
|
||||
@@ -593,7 +593,8 @@ class DescriptorSerializer private constructor(
|
||||
accessor.visibility,
|
||||
accessor.modality,
|
||||
!accessor.isDefault,
|
||||
accessor.isExternal
|
||||
accessor.isExternal,
|
||||
accessor.isInline
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -112,7 +112,7 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja
|
||||
if (getter != null) {
|
||||
newGetter = new PropertyGetterDescriptorImpl(
|
||||
enhanced, getter.getAnnotations(), getter.getModality(), getter.getVisibility(),
|
||||
getter.isDefault(), getter.isExternal(), getKind(), getter, getter.getSource()
|
||||
getter.isDefault(), getter.isExternal(), getter.isInline(), getKind(), getter, getter.getSource()
|
||||
);
|
||||
newGetter.setInitialSignatureDescriptor(getter.getInitialSignatureDescriptor());
|
||||
newGetter.initialize(enhancedReturnType);
|
||||
@@ -123,7 +123,7 @@ public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements Ja
|
||||
if (setter != null) {
|
||||
newSetter = new PropertySetterDescriptorImpl(
|
||||
enhanced, setter.getAnnotations(), setter.getModality(), setter.getVisibility(),
|
||||
setter.isDefault(), setter.isExternal(), getKind(), setter, setter.getSource()
|
||||
setter.isDefault(), setter.isExternal(), setter.isInline(), getKind(), setter, setter.getSource()
|
||||
);
|
||||
newSetter.setInitialSignatureDescriptor(newSetter.getInitialSignatureDescriptor());
|
||||
newSetter.initialize(setter.getValueParameters().get(0));
|
||||
|
||||
+2
-2
@@ -444,7 +444,7 @@ class LazyJavaClassMemberScope(
|
||||
|
||||
val getter = DescriptorFactory.createGetter(
|
||||
propertyDescriptor, getterMethod.annotations, /* isDefault = */false,
|
||||
/* isExternal = */ false, getterMethod.source
|
||||
/* isExternal = */ false, /* isInline = */ false, getterMethod.source
|
||||
).apply {
|
||||
initialSignatureDescriptor = getterMethod
|
||||
initialize(propertyDescriptor.type)
|
||||
@@ -452,7 +452,7 @@ class LazyJavaClassMemberScope(
|
||||
|
||||
val setter = setterMethod?.let { setterMethod ->
|
||||
DescriptorFactory.createSetter(propertyDescriptor, setterMethod.annotations, /* isDefault = */false,
|
||||
/* isExternal = */ false, setterMethod.visibility, setterMethod.source
|
||||
/* isExternal = */ false, /* isInline = */ false, setterMethod.visibility, setterMethod.source
|
||||
).apply {
|
||||
initialSignatureDescriptor = setterMethod
|
||||
}
|
||||
|
||||
+4
-1
@@ -33,6 +33,7 @@ public abstract class PropertyAccessorDescriptorImpl extends DeclarationDescript
|
||||
private final boolean isExternal;
|
||||
private final Modality modality;
|
||||
private final PropertyDescriptor correspondingProperty;
|
||||
private final boolean isInline;
|
||||
private final Kind kind;
|
||||
private Visibility visibility;
|
||||
@Nullable
|
||||
@@ -46,6 +47,7 @@ public abstract class PropertyAccessorDescriptorImpl extends DeclarationDescript
|
||||
@NotNull Name name,
|
||||
boolean isDefault,
|
||||
boolean isExternal,
|
||||
boolean isInline,
|
||||
Kind kind,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
@@ -55,6 +57,7 @@ public abstract class PropertyAccessorDescriptorImpl extends DeclarationDescript
|
||||
this.correspondingProperty = correspondingProperty;
|
||||
this.isDefault = isDefault;
|
||||
this.isExternal = isExternal;
|
||||
this.isInline = isInline;
|
||||
this.kind = kind;
|
||||
}
|
||||
|
||||
@@ -86,7 +89,7 @@ public abstract class PropertyAccessorDescriptorImpl extends DeclarationDescript
|
||||
|
||||
@Override
|
||||
public boolean isInline() {
|
||||
return false;
|
||||
return isInline;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -260,7 +260,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
|
||||
PropertyGetterDescriptorImpl newGetter = getter == null ? null : new PropertyGetterDescriptorImpl(
|
||||
substitutedDescriptor, getter.getAnnotations(), newModality, normalizeVisibility(getter.getVisibility(), kind),
|
||||
getter.isDefault(), getter.isExternal(), kind, original == null ? null : original.getGetter(),
|
||||
getter.isDefault(), getter.isExternal(), getter.isInline(), kind, original == null ? null : original.getGetter(),
|
||||
SourceElement.NO_SOURCE
|
||||
);
|
||||
if (newGetter != null) {
|
||||
@@ -270,7 +270,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorWithInitializerImp
|
||||
}
|
||||
PropertySetterDescriptorImpl newSetter = setter == null ? null : new PropertySetterDescriptorImpl(
|
||||
substitutedDescriptor, setter.getAnnotations(), newModality, normalizeVisibility(setter.getVisibility(), kind),
|
||||
setter.isDefault(), setter.isExternal(), kind, original == null ? null : original.getSetter(),
|
||||
setter.isDefault(), setter.isExternal(), setter.isInline(), kind, original == null ? null : original.getSetter(),
|
||||
SourceElement.NO_SOURCE
|
||||
);
|
||||
if (newSetter != null) {
|
||||
|
||||
+2
-1
@@ -40,12 +40,13 @@ public class PropertyGetterDescriptorImpl extends PropertyAccessorDescriptorImpl
|
||||
@NotNull Visibility visibility,
|
||||
boolean isDefault,
|
||||
boolean isExternal,
|
||||
boolean isInline,
|
||||
@NotNull Kind kind,
|
||||
@Nullable PropertyGetterDescriptor original,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(modality, visibility, correspondingProperty, annotations, Name.special("<get-" + correspondingProperty.getName() + ">"),
|
||||
isDefault, isExternal, kind, source);
|
||||
isDefault, isExternal, isInline, kind, source);
|
||||
this.original = original != null ? original : this;
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -42,12 +42,13 @@ public class PropertySetterDescriptorImpl extends PropertyAccessorDescriptorImpl
|
||||
@NotNull Visibility visibility,
|
||||
boolean isDefault,
|
||||
boolean isExternal,
|
||||
boolean isInline,
|
||||
@NotNull Kind kind,
|
||||
@Nullable PropertySetterDescriptor original,
|
||||
@NotNull SourceElement source
|
||||
) {
|
||||
super(modality, visibility, correspondingProperty, annotations, Name.special("<set-" + correspondingProperty.getName() + ">"),
|
||||
isDefault, isExternal, kind, source);
|
||||
isDefault, isExternal, isInline, kind, source);
|
||||
this.original = original != null ? original : this;
|
||||
}
|
||||
|
||||
@@ -107,4 +108,5 @@ public class PropertySetterDescriptorImpl extends PropertyAccessorDescriptorImpl
|
||||
public PropertySetterDescriptor getOriginal() {
|
||||
return this.original;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public class DescriptorFactory {
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull Annotations annotations
|
||||
) {
|
||||
return createSetter(propertyDescriptor, annotations, true, false, propertyDescriptor.getSource());
|
||||
return createSetter(propertyDescriptor, annotations, true, false, false, propertyDescriptor.getSource());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -57,9 +57,10 @@ public class DescriptorFactory {
|
||||
@NotNull Annotations annotations,
|
||||
boolean isDefault,
|
||||
boolean isExternal,
|
||||
boolean isInline,
|
||||
@NotNull SourceElement sourceElement
|
||||
) {
|
||||
return createSetter(propertyDescriptor, annotations, isDefault, isExternal, propertyDescriptor.getVisibility(), sourceElement);
|
||||
return createSetter(propertyDescriptor, annotations, isDefault, isExternal, isInline, propertyDescriptor.getVisibility(), sourceElement);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -68,12 +69,13 @@ public class DescriptorFactory {
|
||||
@NotNull Annotations annotations,
|
||||
boolean isDefault,
|
||||
boolean isExternal,
|
||||
boolean isInline,
|
||||
@NotNull Visibility visibility,
|
||||
@NotNull SourceElement sourceElement
|
||||
) {
|
||||
PropertySetterDescriptorImpl setterDescriptor = new PropertySetterDescriptorImpl(
|
||||
propertyDescriptor, annotations, propertyDescriptor.getModality(), visibility, isDefault, isExternal,
|
||||
CallableMemberDescriptor.Kind.DECLARATION, null, sourceElement
|
||||
isInline, CallableMemberDescriptor.Kind.DECLARATION, null, sourceElement
|
||||
);
|
||||
setterDescriptor.initializeDefault();
|
||||
return setterDescriptor;
|
||||
@@ -84,17 +86,7 @@ public class DescriptorFactory {
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull Annotations annotations
|
||||
) {
|
||||
return createGetter(propertyDescriptor, annotations, true, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PropertyGetterDescriptorImpl createGetter(
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull Annotations annotations,
|
||||
boolean isDefault,
|
||||
boolean isExternal
|
||||
) {
|
||||
return createGetter(propertyDescriptor, annotations, isDefault, isExternal, propertyDescriptor.getSource());
|
||||
return createGetter(propertyDescriptor, annotations, true, false, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -103,11 +95,23 @@ public class DescriptorFactory {
|
||||
@NotNull Annotations annotations,
|
||||
boolean isDefault,
|
||||
boolean isExternal,
|
||||
boolean isInline
|
||||
) {
|
||||
return createGetter(propertyDescriptor, annotations, isDefault, isExternal, isInline, propertyDescriptor.getSource());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static PropertyGetterDescriptorImpl createGetter(
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@NotNull Annotations annotations,
|
||||
boolean isDefault,
|
||||
boolean isExternal,
|
||||
boolean isInline,
|
||||
@NotNull SourceElement sourceElement
|
||||
) {
|
||||
return new PropertyGetterDescriptorImpl(
|
||||
propertyDescriptor, annotations, propertyDescriptor.getModality(), propertyDescriptor.getVisibility(),
|
||||
isDefault, isExternal, CallableMemberDescriptor.Kind.DECLARATION, null, sourceElement
|
||||
isDefault, isExternal, isInline, CallableMemberDescriptor.Kind.DECLARATION, null, sourceElement
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -300,6 +300,7 @@ message Property {
|
||||
Modality
|
||||
isNotDefault
|
||||
isExternal
|
||||
isInline
|
||||
*/
|
||||
optional int32 getter_flags = 7 /* absent => same as property */;
|
||||
optional int32 setter_flags = 8 /* absent => same as property */;
|
||||
|
||||
@@ -73,6 +73,7 @@ public class Flags {
|
||||
|
||||
public static final BooleanFlagField IS_NOT_DEFAULT = FlagField.booleanAfter(MODALITY);
|
||||
public static final BooleanFlagField IS_EXTERNAL_ACCESSOR = FlagField.booleanAfter(IS_NOT_DEFAULT);
|
||||
public static final BooleanFlagField IS_INLINE_ACCESSOR = FlagField.booleanAfter(IS_EXTERNAL_ACCESSOR);
|
||||
|
||||
// ---
|
||||
|
||||
@@ -180,13 +181,15 @@ public class Flags {
|
||||
@NotNull Visibility visibility,
|
||||
@NotNull Modality modality,
|
||||
boolean isNotDefault,
|
||||
boolean isExternal
|
||||
boolean isExternal,
|
||||
boolean isInlineAccessor
|
||||
) {
|
||||
return HAS_ANNOTATIONS.toFlags(hasAnnotations)
|
||||
| MODALITY.toFlags(modality(modality))
|
||||
| VISIBILITY.toFlags(visibility(visibility))
|
||||
| IS_NOT_DEFAULT.toFlags(isNotDefault)
|
||||
| IS_EXTERNAL_ACCESSOR.toFlags(isExternal)
|
||||
| IS_INLINE_ACCESSOR.toFlags(isInlineAccessor)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -69,6 +69,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
||||
val getterFlags = proto.getterFlags
|
||||
val isNotDefault = proto.hasGetterFlags() && Flags.IS_NOT_DEFAULT.get(getterFlags)
|
||||
val isExternal = proto.hasGetterFlags() && Flags.IS_EXTERNAL_ACCESSOR.get(getterFlags)
|
||||
val isInline = proto.hasGetterFlags() && Flags.IS_INLINE_ACCESSOR.get(getterFlags)
|
||||
val getter = if (isNotDefault) {
|
||||
PropertyGetterDescriptorImpl(
|
||||
property,
|
||||
@@ -77,6 +78,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
||||
Deserialization.visibility(Flags.VISIBILITY.get(getterFlags)),
|
||||
/* isDefault = */ !isNotDefault,
|
||||
/* isExternal = */ isExternal,
|
||||
isInline,
|
||||
property.kind, null, SourceElement.NO_SOURCE
|
||||
)
|
||||
}
|
||||
@@ -94,6 +96,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
||||
val setterFlags = proto.setterFlags
|
||||
val isNotDefault = proto.hasSetterFlags() && Flags.IS_NOT_DEFAULT.get(setterFlags)
|
||||
val isExternal = proto.hasSetterFlags() && Flags.IS_EXTERNAL_ACCESSOR.get(setterFlags)
|
||||
val isInline = proto.hasGetterFlags() && Flags.IS_INLINE_ACCESSOR.get(setterFlags)
|
||||
if (isNotDefault) {
|
||||
val setter = PropertySetterDescriptorImpl(
|
||||
property,
|
||||
@@ -102,6 +105,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
||||
Deserialization.visibility(Flags.VISIBILITY.get(setterFlags)),
|
||||
/* isDefault = */ !isNotDefault,
|
||||
/* isExternal = */ isExternal,
|
||||
isInline,
|
||||
property.kind, null, SourceElement.NO_SOURCE
|
||||
)
|
||||
val setterLocal = local.childContext(setter, listOf())
|
||||
|
||||
+1
@@ -123,6 +123,7 @@ private fun genProperty(
|
||||
Visibilities.PUBLIC,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
null,
|
||||
SourceElement.NO_SOURCE
|
||||
|
||||
Reference in New Issue
Block a user