Deserialize annotations on property setter parameters

This commit is contained in:
Alexander Udalov
2013-10-22 21:23:53 +04:00
parent 464b0dea4b
commit dd50438c78
17 changed files with 271 additions and 168 deletions
@@ -171,7 +171,6 @@ message Callable {
*/
optional int32 getter_flags = 9 /* absent => same as property */;
optional int32 setter_flags = 10 /* absent => same as property */;
optional int32 setter_parameter_name = 11;
repeated TypeParameter type_parameter = 4;
@@ -192,6 +191,7 @@ message Callable {
extensions 100 to 199;
}
// Value parameters for functions and constructors, or setter value parameter for properties
repeated ValueParameter value_parameter = 7;
required Type return_type = 8;
@@ -176,10 +176,11 @@ public class DescriptorDeserializer {
modality(Flags.MODALITY.get(setterFlags)), visibility(Flags.VISIBILITY.get(setterFlags)),
isNotDefault, !isNotDefault, property.getKind()
);
setter.initialize(new ValueParameterDescriptorImpl(
setter, 0, Collections.<AnnotationDescriptor>emptyList(),
nameResolver.getName(proto.getSetterParameterName()),
property.getReturnType(), false, null));
DescriptorDeserializer setterLocal = local.createChildDeserializer(setter, Collections.<TypeParameter>emptyList(),
Collections.<TypeParameterDescriptor>emptyList());
List<ValueParameterDescriptor> valueParameters = setterLocal.valueParameters(proto, AnnotatedCallableKind.PROPERTY_SETTER);
assert valueParameters.size() == 1 : "Property setter should have a single value parameter: " + setter;
setter.initialize(valueParameters.get(0));
}
else {
setter = DescriptorFactory.createDefaultSetter(property);
@@ -237,7 +238,7 @@ public class DescriptorDeserializer {
local.typeDeserializer.typeOrNull(proto.hasReceiverType() ? proto.getReceiverType() : null),
getExpectedThisObject(),
typeParameters,
local.valueParameters(proto),
local.valueParameters(proto, AnnotatedCallableKind.FUNCTION),
local.typeDeserializer.type(proto.getReturnType()),
modality(Flags.MODALITY.get(flags)),
visibility(Flags.VISIBILITY.get(flags)),
@@ -265,7 +266,7 @@ public class DescriptorDeserializer {
DescriptorDeserializer local = createChildDeserializer(descriptor, Collections.<TypeParameter>emptyList(), typeParameters);
descriptor.initialize(
classDescriptor.getTypeConstructor().getParameters(),
local.valueParameters(proto),
local.valueParameters(proto, AnnotatedCallableKind.FUNCTION),
visibility(Flags.VISIBILITY.get(proto.getFlags())),
DescriptorUtils.isConstructorOfStaticNestedClass(descriptor)
);
@@ -384,7 +385,7 @@ public class DescriptorDeserializer {
}
@NotNull
private List<ValueParameterDescriptor> valueParameters(@NotNull Callable callable) {
private List<ValueParameterDescriptor> valueParameters(@NotNull Callable callable, @NotNull AnnotatedCallableKind kind) {
DeclarationDescriptor containerOfCallable = containingDeclaration.getContainingDeclaration();
assert containerOfCallable instanceof ClassOrNamespaceDescriptor
: "Only members in classes or namespaces should be serialized: " + containerOfCallable;
@@ -397,7 +398,7 @@ public class DescriptorDeserializer {
result.add(new ValueParameterDescriptorImpl(
containingDeclaration,
i,
getAnnotations(classOrNamespace, callable, proto),
getAnnotations(classOrNamespace, callable, kind, proto),
nameResolver.getName(proto.getName()),
typeDeserializer.type(proto.getType()),
Flags.DECLARES_DEFAULT_VALUE.get(proto.getFlags()),
@@ -411,10 +412,11 @@ public class DescriptorDeserializer {
private List<AnnotationDescriptor> getAnnotations(
@NotNull ClassOrNamespaceDescriptor classOrNamespace,
@NotNull Callable callable,
@NotNull AnnotatedCallableKind kind,
@NotNull Callable.ValueParameter valueParameter
) {
return Flags.HAS_ANNOTATIONS.get(valueParameter.getFlags())
? annotationDeserializer.loadValueParameterAnnotations(classOrNamespace, callable, nameResolver, valueParameter)
? annotationDeserializer.loadValueParameterAnnotations(classOrNamespace, callable, nameResolver, kind, valueParameter)
: Collections.<AnnotationDescriptor>emptyList();
}
}
@@ -145,6 +145,8 @@ public class DescriptorSerializer {
public ProtoBuf.Callable.Builder callableProto(@NotNull CallableMemberDescriptor descriptor) {
ProtoBuf.Callable.Builder builder = ProtoBuf.Callable.newBuilder();
DescriptorSerializer local = createChildSerializer();
boolean hasGetter = false;
boolean hasSetter = false;
if (descriptor instanceof PropertyDescriptor) {
@@ -175,9 +177,9 @@ public class DescriptorSerializer {
}
if (!setter.isDefault()) {
List<ValueParameterDescriptor> parameters = setter.getValueParameters();
assert parameters.size() == 1 : "Unexpected number of setter parameters: " + setter;
builder.setSetterParameterName(nameTable.getSimpleNameIndex(parameters.get(0).getName()));
for (ValueParameterDescriptor valueParameterDescriptor : setter.getValueParameters()) {
builder.addValueParameter(local.valueParameter(valueParameterDescriptor));
}
}
}
}
@@ -195,8 +197,6 @@ public class DescriptorSerializer {
));
//TODO builder.setExtraVisibility()
DescriptorSerializer local = createChildSerializer();
for (TypeParameterDescriptor typeParameterDescriptor : descriptor.getTypeParameters()) {
builder.addTypeParameter(local.typeParameter(typeParameterDescriptor));
}
@@ -7125,16 +7125,6 @@ public final class ProtoBuf {
*/
int getSetterFlags();
// optional int32 setter_parameter_name = 11;
/**
* <code>optional int32 setter_parameter_name = 11;</code>
*/
boolean hasSetterParameterName();
/**
* <code>optional int32 setter_parameter_name = 11;</code>
*/
int getSetterParameterName();
// repeated .org.jetbrains.jet.descriptors.serialization.TypeParameter type_parameter = 4;
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.TypeParameter type_parameter = 4;</code>
@@ -7173,15 +7163,27 @@ public final class ProtoBuf {
// repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
java.util.List<org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter>
getValueParameterList();
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter getValueParameter(int index);
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
int getValueParameterCount();
@@ -7249,16 +7251,16 @@ public final class ProtoBuf {
break;
}
case 34: {
if (!((mutable_bitField0_ & 0x00000020) == 0x00000020)) {
if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) {
typeParameter_ = new java.util.ArrayList<org.jetbrains.jet.descriptors.serialization.ProtoBuf.TypeParameter>();
mutable_bitField0_ |= 0x00000020;
mutable_bitField0_ |= 0x00000010;
}
typeParameter_.add(input.readMessage(org.jetbrains.jet.descriptors.serialization.ProtoBuf.TypeParameter.PARSER, extensionRegistry));
break;
}
case 42: {
org.jetbrains.jet.descriptors.serialization.ProtoBuf.Type.Builder subBuilder = null;
if (((bitField0_ & 0x00000020) == 0x00000020)) {
if (((bitField0_ & 0x00000010) == 0x00000010)) {
subBuilder = receiverType_.toBuilder();
}
receiverType_ = input.readMessage(org.jetbrains.jet.descriptors.serialization.ProtoBuf.Type.PARSER, extensionRegistry);
@@ -7266,25 +7268,25 @@ public final class ProtoBuf {
subBuilder.mergeFrom(receiverType_);
receiverType_ = subBuilder.buildPartial();
}
bitField0_ |= 0x00000020;
bitField0_ |= 0x00000010;
break;
}
case 48: {
bitField0_ |= 0x00000040;
bitField0_ |= 0x00000020;
name_ = input.readInt32();
break;
}
case 58: {
if (!((mutable_bitField0_ & 0x00000100) == 0x00000100)) {
if (!((mutable_bitField0_ & 0x00000080) == 0x00000080)) {
valueParameter_ = new java.util.ArrayList<org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter>();
mutable_bitField0_ |= 0x00000100;
mutable_bitField0_ |= 0x00000080;
}
valueParameter_.add(input.readMessage(org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter.PARSER, extensionRegistry));
break;
}
case 66: {
org.jetbrains.jet.descriptors.serialization.ProtoBuf.Type.Builder subBuilder = null;
if (((bitField0_ & 0x00000080) == 0x00000080)) {
if (((bitField0_ & 0x00000040) == 0x00000040)) {
subBuilder = returnType_.toBuilder();
}
returnType_ = input.readMessage(org.jetbrains.jet.descriptors.serialization.ProtoBuf.Type.PARSER, extensionRegistry);
@@ -7292,7 +7294,7 @@ public final class ProtoBuf {
subBuilder.mergeFrom(returnType_);
returnType_ = subBuilder.buildPartial();
}
bitField0_ |= 0x00000080;
bitField0_ |= 0x00000040;
break;
}
case 72: {
@@ -7305,11 +7307,6 @@ public final class ProtoBuf {
setterFlags_ = input.readInt32();
break;
}
case 88: {
bitField0_ |= 0x00000010;
setterParameterName_ = input.readInt32();
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
@@ -7318,10 +7315,10 @@ public final class ProtoBuf {
throw new com.google.protobuf.InvalidProtocolBufferException(
e.getMessage()).setUnfinishedMessage(this);
} finally {
if (((mutable_bitField0_ & 0x00000020) == 0x00000020)) {
if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) {
typeParameter_ = java.util.Collections.unmodifiableList(typeParameter_);
}
if (((mutable_bitField0_ & 0x00000100) == 0x00000100)) {
if (((mutable_bitField0_ & 0x00000080) == 0x00000080)) {
valueParameter_ = java.util.Collections.unmodifiableList(valueParameter_);
}
makeExtensionsImmutable();
@@ -8405,22 +8402,6 @@ public final class ProtoBuf {
return setterFlags_;
}
// optional int32 setter_parameter_name = 11;
public static final int SETTER_PARAMETER_NAME_FIELD_NUMBER = 11;
private int setterParameterName_;
/**
* <code>optional int32 setter_parameter_name = 11;</code>
*/
public boolean hasSetterParameterName() {
return ((bitField0_ & 0x00000010) == 0x00000010);
}
/**
* <code>optional int32 setter_parameter_name = 11;</code>
*/
public int getSetterParameterName() {
return setterParameterName_;
}
// repeated .org.jetbrains.jet.descriptors.serialization.TypeParameter type_parameter = 4;
public static final int TYPE_PARAMETER_FIELD_NUMBER = 4;
private java.util.List<org.jetbrains.jet.descriptors.serialization.ProtoBuf.TypeParameter> typeParameter_;
@@ -8464,7 +8445,7 @@ public final class ProtoBuf {
* <code>optional .org.jetbrains.jet.descriptors.serialization.Type receiver_type = 5;</code>
*/
public boolean hasReceiverType() {
return ((bitField0_ & 0x00000020) == 0x00000020);
return ((bitField0_ & 0x00000010) == 0x00000010);
}
/**
* <code>optional .org.jetbrains.jet.descriptors.serialization.Type receiver_type = 5;</code>
@@ -8480,7 +8461,7 @@ public final class ProtoBuf {
* <code>required int32 name = 6;</code>
*/
public boolean hasName() {
return ((bitField0_ & 0x00000040) == 0x00000040);
return ((bitField0_ & 0x00000020) == 0x00000020);
}
/**
* <code>required int32 name = 6;</code>
@@ -8494,12 +8475,20 @@ public final class ProtoBuf {
private java.util.List<org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter> valueParameter_;
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
public java.util.List<org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter> getValueParameterList() {
return valueParameter_;
}
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
public java.util.List<? extends org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameterOrBuilder>
getValueParameterOrBuilderList() {
@@ -8507,18 +8496,30 @@ public final class ProtoBuf {
}
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
public int getValueParameterCount() {
return valueParameter_.size();
}
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
public org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter getValueParameter(int index) {
return valueParameter_.get(index);
}
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
public org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameterOrBuilder getValueParameterOrBuilder(
int index) {
@@ -8532,7 +8533,7 @@ public final class ProtoBuf {
* <code>required .org.jetbrains.jet.descriptors.serialization.Type return_type = 8;</code>
*/
public boolean hasReturnType() {
return ((bitField0_ & 0x00000080) == 0x00000080);
return ((bitField0_ & 0x00000040) == 0x00000040);
}
/**
* <code>required .org.jetbrains.jet.descriptors.serialization.Type return_type = 8;</code>
@@ -8546,7 +8547,6 @@ public final class ProtoBuf {
extraVisibility_ = "";
getterFlags_ = 0;
setterFlags_ = 0;
setterParameterName_ = 0;
typeParameter_ = java.util.Collections.emptyList();
receiverType_ = org.jetbrains.jet.descriptors.serialization.ProtoBuf.Type.getDefaultInstance();
name_ = 0;
@@ -8611,16 +8611,16 @@ public final class ProtoBuf {
for (int i = 0; i < typeParameter_.size(); i++) {
output.writeMessage(4, typeParameter_.get(i));
}
if (((bitField0_ & 0x00000020) == 0x00000020)) {
if (((bitField0_ & 0x00000010) == 0x00000010)) {
output.writeMessage(5, receiverType_);
}
if (((bitField0_ & 0x00000040) == 0x00000040)) {
if (((bitField0_ & 0x00000020) == 0x00000020)) {
output.writeInt32(6, name_);
}
for (int i = 0; i < valueParameter_.size(); i++) {
output.writeMessage(7, valueParameter_.get(i));
}
if (((bitField0_ & 0x00000080) == 0x00000080)) {
if (((bitField0_ & 0x00000040) == 0x00000040)) {
output.writeMessage(8, returnType_);
}
if (((bitField0_ & 0x00000004) == 0x00000004)) {
@@ -8629,9 +8629,6 @@ public final class ProtoBuf {
if (((bitField0_ & 0x00000008) == 0x00000008)) {
output.writeInt32(10, setterFlags_);
}
if (((bitField0_ & 0x00000010) == 0x00000010)) {
output.writeInt32(11, setterParameterName_);
}
extensionWriter.writeUntil(200, output);
}
@@ -8653,11 +8650,11 @@ public final class ProtoBuf {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(4, typeParameter_.get(i));
}
if (((bitField0_ & 0x00000020) == 0x00000020)) {
if (((bitField0_ & 0x00000010) == 0x00000010)) {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(5, receiverType_);
}
if (((bitField0_ & 0x00000040) == 0x00000040)) {
if (((bitField0_ & 0x00000020) == 0x00000020)) {
size += com.google.protobuf.CodedOutputStream
.computeInt32Size(6, name_);
}
@@ -8665,7 +8662,7 @@ public final class ProtoBuf {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(7, valueParameter_.get(i));
}
if (((bitField0_ & 0x00000080) == 0x00000080)) {
if (((bitField0_ & 0x00000040) == 0x00000040)) {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(8, returnType_);
}
@@ -8677,10 +8674,6 @@ public final class ProtoBuf {
size += com.google.protobuf.CodedOutputStream
.computeInt32Size(10, setterFlags_);
}
if (((bitField0_ & 0x00000010) == 0x00000010)) {
size += com.google.protobuf.CodedOutputStream
.computeInt32Size(11, setterParameterName_);
}
size += extensionsSerializedSize();
memoizedSerializedSize = size;
return size;
@@ -8780,18 +8773,16 @@ public final class ProtoBuf {
bitField0_ = (bitField0_ & ~0x00000004);
setterFlags_ = 0;
bitField0_ = (bitField0_ & ~0x00000008);
setterParameterName_ = 0;
bitField0_ = (bitField0_ & ~0x00000010);
typeParameter_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000020);
bitField0_ = (bitField0_ & ~0x00000010);
receiverType_ = org.jetbrains.jet.descriptors.serialization.ProtoBuf.Type.getDefaultInstance();
bitField0_ = (bitField0_ & ~0x00000040);
bitField0_ = (bitField0_ & ~0x00000020);
name_ = 0;
bitField0_ = (bitField0_ & ~0x00000080);
bitField0_ = (bitField0_ & ~0x00000040);
valueParameter_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000100);
bitField0_ = (bitField0_ & ~0x00000080);
returnType_ = org.jetbrains.jet.descriptors.serialization.ProtoBuf.Type.getDefaultInstance();
bitField0_ = (bitField0_ & ~0x00000200);
bitField0_ = (bitField0_ & ~0x00000100);
return this;
}
@@ -8831,30 +8822,26 @@ public final class ProtoBuf {
to_bitField0_ |= 0x00000008;
}
result.setterFlags_ = setterFlags_;
if (((from_bitField0_ & 0x00000010) == 0x00000010)) {
to_bitField0_ |= 0x00000010;
}
result.setterParameterName_ = setterParameterName_;
if (((bitField0_ & 0x00000020) == 0x00000020)) {
if (((bitField0_ & 0x00000010) == 0x00000010)) {
typeParameter_ = java.util.Collections.unmodifiableList(typeParameter_);
bitField0_ = (bitField0_ & ~0x00000020);
bitField0_ = (bitField0_ & ~0x00000010);
}
result.typeParameter_ = typeParameter_;
if (((from_bitField0_ & 0x00000020) == 0x00000020)) {
to_bitField0_ |= 0x00000010;
}
result.receiverType_ = receiverType_;
if (((from_bitField0_ & 0x00000040) == 0x00000040)) {
to_bitField0_ |= 0x00000020;
}
result.receiverType_ = receiverType_;
if (((from_bitField0_ & 0x00000080) == 0x00000080)) {
to_bitField0_ |= 0x00000040;
}
result.name_ = name_;
if (((bitField0_ & 0x00000100) == 0x00000100)) {
if (((bitField0_ & 0x00000080) == 0x00000080)) {
valueParameter_ = java.util.Collections.unmodifiableList(valueParameter_);
bitField0_ = (bitField0_ & ~0x00000100);
bitField0_ = (bitField0_ & ~0x00000080);
}
result.valueParameter_ = valueParameter_;
if (((from_bitField0_ & 0x00000200) == 0x00000200)) {
to_bitField0_ |= 0x00000080;
if (((from_bitField0_ & 0x00000100) == 0x00000100)) {
to_bitField0_ |= 0x00000040;
}
result.returnType_ = returnType_;
result.bitField0_ = to_bitField0_;
@@ -8877,13 +8864,10 @@ public final class ProtoBuf {
if (other.hasSetterFlags()) {
setSetterFlags(other.getSetterFlags());
}
if (other.hasSetterParameterName()) {
setSetterParameterName(other.getSetterParameterName());
}
if (!other.typeParameter_.isEmpty()) {
if (typeParameter_.isEmpty()) {
typeParameter_ = other.typeParameter_;
bitField0_ = (bitField0_ & ~0x00000020);
bitField0_ = (bitField0_ & ~0x00000010);
} else {
ensureTypeParameterIsMutable();
typeParameter_.addAll(other.typeParameter_);
@@ -8899,7 +8883,7 @@ public final class ProtoBuf {
if (!other.valueParameter_.isEmpty()) {
if (valueParameter_.isEmpty()) {
valueParameter_ = other.valueParameter_;
bitField0_ = (bitField0_ & ~0x00000100);
bitField0_ = (bitField0_ & ~0x00000080);
} else {
ensureValueParameterIsMutable();
valueParameter_.addAll(other.valueParameter_);
@@ -9247,46 +9231,13 @@ public final class ProtoBuf {
return this;
}
// optional int32 setter_parameter_name = 11;
private int setterParameterName_ ;
/**
* <code>optional int32 setter_parameter_name = 11;</code>
*/
public boolean hasSetterParameterName() {
return ((bitField0_ & 0x00000010) == 0x00000010);
}
/**
* <code>optional int32 setter_parameter_name = 11;</code>
*/
public int getSetterParameterName() {
return setterParameterName_;
}
/**
* <code>optional int32 setter_parameter_name = 11;</code>
*/
public Builder setSetterParameterName(int value) {
bitField0_ |= 0x00000010;
setterParameterName_ = value;
return this;
}
/**
* <code>optional int32 setter_parameter_name = 11;</code>
*/
public Builder clearSetterParameterName() {
bitField0_ = (bitField0_ & ~0x00000010);
setterParameterName_ = 0;
return this;
}
// repeated .org.jetbrains.jet.descriptors.serialization.TypeParameter type_parameter = 4;
private java.util.List<org.jetbrains.jet.descriptors.serialization.ProtoBuf.TypeParameter> typeParameter_ =
java.util.Collections.emptyList();
private void ensureTypeParameterIsMutable() {
if (!((bitField0_ & 0x00000020) == 0x00000020)) {
if (!((bitField0_ & 0x00000010) == 0x00000010)) {
typeParameter_ = new java.util.ArrayList<org.jetbrains.jet.descriptors.serialization.ProtoBuf.TypeParameter>(typeParameter_);
bitField0_ |= 0x00000020;
bitField0_ |= 0x00000010;
}
}
@@ -9391,7 +9342,7 @@ public final class ProtoBuf {
*/
public Builder clearTypeParameter() {
typeParameter_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000020);
bitField0_ = (bitField0_ & ~0x00000010);
return this;
}
@@ -9411,7 +9362,7 @@ public final class ProtoBuf {
* <code>optional .org.jetbrains.jet.descriptors.serialization.Type receiver_type = 5;</code>
*/
public boolean hasReceiverType() {
return ((bitField0_ & 0x00000040) == 0x00000040);
return ((bitField0_ & 0x00000020) == 0x00000020);
}
/**
* <code>optional .org.jetbrains.jet.descriptors.serialization.Type receiver_type = 5;</code>
@@ -9428,7 +9379,7 @@ public final class ProtoBuf {
}
receiverType_ = value;
bitField0_ |= 0x00000040;
bitField0_ |= 0x00000020;
return this;
}
/**
@@ -9438,14 +9389,14 @@ public final class ProtoBuf {
org.jetbrains.jet.descriptors.serialization.ProtoBuf.Type.Builder builderForValue) {
receiverType_ = builderForValue.build();
bitField0_ |= 0x00000040;
bitField0_ |= 0x00000020;
return this;
}
/**
* <code>optional .org.jetbrains.jet.descriptors.serialization.Type receiver_type = 5;</code>
*/
public Builder mergeReceiverType(org.jetbrains.jet.descriptors.serialization.ProtoBuf.Type value) {
if (((bitField0_ & 0x00000040) == 0x00000040) &&
if (((bitField0_ & 0x00000020) == 0x00000020) &&
receiverType_ != org.jetbrains.jet.descriptors.serialization.ProtoBuf.Type.getDefaultInstance()) {
receiverType_ =
org.jetbrains.jet.descriptors.serialization.ProtoBuf.Type.newBuilder(receiverType_).mergeFrom(value).buildPartial();
@@ -9453,7 +9404,7 @@ public final class ProtoBuf {
receiverType_ = value;
}
bitField0_ |= 0x00000040;
bitField0_ |= 0x00000020;
return this;
}
/**
@@ -9462,7 +9413,7 @@ public final class ProtoBuf {
public Builder clearReceiverType() {
receiverType_ = org.jetbrains.jet.descriptors.serialization.ProtoBuf.Type.getDefaultInstance();
bitField0_ = (bitField0_ & ~0x00000040);
bitField0_ = (bitField0_ & ~0x00000020);
return this;
}
@@ -9472,7 +9423,7 @@ public final class ProtoBuf {
* <code>required int32 name = 6;</code>
*/
public boolean hasName() {
return ((bitField0_ & 0x00000080) == 0x00000080);
return ((bitField0_ & 0x00000040) == 0x00000040);
}
/**
* <code>required int32 name = 6;</code>
@@ -9484,7 +9435,7 @@ public final class ProtoBuf {
* <code>required int32 name = 6;</code>
*/
public Builder setName(int value) {
bitField0_ |= 0x00000080;
bitField0_ |= 0x00000040;
name_ = value;
return this;
@@ -9493,7 +9444,7 @@ public final class ProtoBuf {
* <code>required int32 name = 6;</code>
*/
public Builder clearName() {
bitField0_ = (bitField0_ & ~0x00000080);
bitField0_ = (bitField0_ & ~0x00000040);
name_ = 0;
return this;
@@ -9503,32 +9454,48 @@ public final class ProtoBuf {
private java.util.List<org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter> valueParameter_ =
java.util.Collections.emptyList();
private void ensureValueParameterIsMutable() {
if (!((bitField0_ & 0x00000100) == 0x00000100)) {
if (!((bitField0_ & 0x00000080) == 0x00000080)) {
valueParameter_ = new java.util.ArrayList<org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter>(valueParameter_);
bitField0_ |= 0x00000100;
bitField0_ |= 0x00000080;
}
}
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
public java.util.List<org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter> getValueParameterList() {
return java.util.Collections.unmodifiableList(valueParameter_);
}
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
public int getValueParameterCount() {
return valueParameter_.size();
}
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
public org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter getValueParameter(int index) {
return valueParameter_.get(index);
}
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
public Builder setValueParameter(
int index, org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter value) {
@@ -9542,6 +9509,10 @@ public final class ProtoBuf {
}
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
public Builder setValueParameter(
int index, org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter.Builder builderForValue) {
@@ -9552,6 +9523,10 @@ public final class ProtoBuf {
}
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
public Builder addValueParameter(org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter value) {
if (value == null) {
@@ -9564,6 +9539,10 @@ public final class ProtoBuf {
}
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
public Builder addValueParameter(
int index, org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter value) {
@@ -9577,6 +9556,10 @@ public final class ProtoBuf {
}
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
public Builder addValueParameter(
org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter.Builder builderForValue) {
@@ -9587,6 +9570,10 @@ public final class ProtoBuf {
}
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
public Builder addValueParameter(
int index, org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter.Builder builderForValue) {
@@ -9597,6 +9584,10 @@ public final class ProtoBuf {
}
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
public Builder addAllValueParameter(
java.lang.Iterable<? extends org.jetbrains.jet.descriptors.serialization.ProtoBuf.Callable.ValueParameter> values) {
@@ -9607,15 +9598,23 @@ public final class ProtoBuf {
}
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
public Builder clearValueParameter() {
valueParameter_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000100);
bitField0_ = (bitField0_ & ~0x00000080);
return this;
}
/**
* <code>repeated .org.jetbrains.jet.descriptors.serialization.Callable.ValueParameter value_parameter = 7;</code>
*
* <pre>
* Value parameters for functions and constructors, or setter value parameter for properties
* </pre>
*/
public Builder removeValueParameter(int index) {
ensureValueParameterIsMutable();
@@ -9630,7 +9629,7 @@ public final class ProtoBuf {
* <code>required .org.jetbrains.jet.descriptors.serialization.Type return_type = 8;</code>
*/
public boolean hasReturnType() {
return ((bitField0_ & 0x00000200) == 0x00000200);
return ((bitField0_ & 0x00000100) == 0x00000100);
}
/**
* <code>required .org.jetbrains.jet.descriptors.serialization.Type return_type = 8;</code>
@@ -9647,7 +9646,7 @@ public final class ProtoBuf {
}
returnType_ = value;
bitField0_ |= 0x00000200;
bitField0_ |= 0x00000100;
return this;
}
/**
@@ -9657,14 +9656,14 @@ public final class ProtoBuf {
org.jetbrains.jet.descriptors.serialization.ProtoBuf.Type.Builder builderForValue) {
returnType_ = builderForValue.build();
bitField0_ |= 0x00000200;
bitField0_ |= 0x00000100;
return this;
}
/**
* <code>required .org.jetbrains.jet.descriptors.serialization.Type return_type = 8;</code>
*/
public Builder mergeReturnType(org.jetbrains.jet.descriptors.serialization.ProtoBuf.Type value) {
if (((bitField0_ & 0x00000200) == 0x00000200) &&
if (((bitField0_ & 0x00000100) == 0x00000100) &&
returnType_ != org.jetbrains.jet.descriptors.serialization.ProtoBuf.Type.getDefaultInstance()) {
returnType_ =
org.jetbrains.jet.descriptors.serialization.ProtoBuf.Type.newBuilder(returnType_).mergeFrom(value).buildPartial();
@@ -9672,7 +9671,7 @@ public final class ProtoBuf {
returnType_ = value;
}
bitField0_ |= 0x00000200;
bitField0_ |= 0x00000100;
return this;
}
/**
@@ -9681,7 +9680,7 @@ public final class ProtoBuf {
public Builder clearReturnType() {
returnType_ = org.jetbrains.jet.descriptors.serialization.ProtoBuf.Type.getDefaultInstance();
bitField0_ = (bitField0_ & ~0x00000200);
bitField0_ = (bitField0_ & ~0x00000100);
return this;
}
@@ -138,17 +138,25 @@ public class TypeDeserializer {
return classDescriptor.getTypeConstructor();
case TYPE_PARAMETER:
TypeParameterDescriptor descriptor = typeParameterDescriptors.get(proto.getId());
if (descriptor == null && parent != null) {
descriptor = parent.typeParameterDescriptors.get(proto.getId());
}
if (descriptor == null) return null;
return descriptor.getTypeConstructor();
return typeParameterTypeConstructor(proto);
}
throw new IllegalStateException("Unknown kind " + proto.getKind());
}
@Nullable
private TypeConstructor typeParameterTypeConstructor(@NotNull ProtoBuf.Type.Constructor proto) {
TypeParameterDescriptor descriptor = typeParameterDescriptors.get(proto.getId());
if (descriptor != null) {
return descriptor.getTypeConstructor();
}
if (parent != null) {
return parent.typeParameterTypeConstructor(proto);
}
return null;
}
@Nullable
private ClassDescriptor computeClassDescriptor(int fqNameIndex) {
ClassId classId = nameResolver.getClassId(fqNameIndex);
@@ -50,6 +50,7 @@ public interface AnnotationDeserializer {
@NotNull ClassOrNamespaceDescriptor container,
@NotNull ProtoBuf.Callable callable,
@NotNull NameResolver nameResolver,
@NotNull AnnotatedCallableKind kind,
@NotNull ProtoBuf.Callable.ValueParameter proto
) {
return notSupported();
@@ -84,6 +85,7 @@ public interface AnnotationDeserializer {
@NotNull ClassOrNamespaceDescriptor container,
@NotNull ProtoBuf.Callable callable,
@NotNull NameResolver nameResolver,
@NotNull AnnotatedCallableKind kind,
@NotNull ProtoBuf.Callable.ValueParameter proto
);
}
+2 -2
View File
@@ -1,5 +1,5 @@
WARNING: $TESTDATA_DIR$/wrongAbiVersion.kt: (3, 9) Parameter 'x' is never used
ERROR: $TESTDATA_DIR$/wrongAbiVersion.kt: (4, 3) Unresolved reference: bar
ERROR: $TESTDATA_DIR$/wrongAbiVersionLib/wrong/WrongPackage.class: (0, 0) Class 'wrong/WrongPackage' was compiled with an incompatible version of Kotlin. Its ABI version is -1, expected ABI version is 10
ERROR: $TESTDATA_DIR$/wrongAbiVersionLib/ClassWithWrongAbiVersion.class: (0, 0) Class 'ClassWithWrongAbiVersion' was compiled with an incompatible version of Kotlin. Its ABI version is -1, expected ABI version is 10
ERROR: $TESTDATA_DIR$/wrongAbiVersionLib/wrong/WrongPackage.class: (0, 0) Class 'wrong/WrongPackage' was compiled with an incompatible version of Kotlin. Its ABI version is -1, expected ABI version is 11
ERROR: $TESTDATA_DIR$/wrongAbiVersionLib/ClassWithWrongAbiVersion.class: (0, 0) Class 'ClassWithWrongAbiVersion' was compiled with an incompatible version of Kotlin. Its ABI version is -1, expected ABI version is 11
COMPILATION_ERROR
@@ -0,0 +1,9 @@
package test
annotation class A
class Class {
var Int.foo: Int
get() = this
set([A] value) {}
}
@@ -0,0 +1,12 @@
package test
internal final annotation class A : jet.Annotation {
/*primary*/ public constructor A()
}
internal final class Class {
/*primary*/ public constructor Class()
internal final var jet.Int.foo: jet.Int
internal final fun jet.Int.<get-foo>(): jet.Int
internal final fun jet.Int.<set-foo>(/*0*/ test.A() value: jet.Int): jet.Unit
}
@@ -0,0 +1,9 @@
package test
annotation class A
class Class {
var foo: Int
get() = 42
set([A] value) {}
}
@@ -0,0 +1,12 @@
package test
internal final annotation class A : jet.Annotation {
/*primary*/ public constructor A()
}
internal final class Class {
/*primary*/ public constructor Class()
internal final var foo: jet.Int
internal final fun <get-foo>(): jet.Int
internal final fun <set-foo>(/*0*/ test.A() value: jet.Int): jet.Unit
}
@@ -0,0 +1,8 @@
package test
annotation class A
annotation class B
var foo: Int
get() = 42
set([A B] value) {}
@@ -0,0 +1,13 @@
package test
internal var foo: jet.Int
internal fun <get-foo>(): jet.Int
internal fun <set-foo>(/*0*/ test.A() test.B() value: jet.Int): jet.Unit
internal final annotation class A : jet.Annotation {
/*primary*/ public constructor A()
}
internal final annotation class B : jet.Annotation {
/*primary*/ public constructor B()
}
@@ -209,6 +209,11 @@ public class LoadCompiledKotlinTestGenerated extends AbstractLoadCompiledKotlinT
doTestWithAccessors("compiler/testData/loadKotlin/annotations/parameters/ExtensionFunctionInClass.kt");
}
@TestMetadata("ExtensionPropertySetter.kt")
public void testExtensionPropertySetter() throws Exception {
doTestWithAccessors("compiler/testData/loadKotlin/annotations/parameters/ExtensionPropertySetter.kt");
}
@TestMetadata("FunctionInClass.kt")
public void testFunctionInClass() throws Exception {
doTestWithAccessors("compiler/testData/loadKotlin/annotations/parameters/FunctionInClass.kt");
@@ -224,11 +229,21 @@ public class LoadCompiledKotlinTestGenerated extends AbstractLoadCompiledKotlinT
doTestWithAccessors("compiler/testData/loadKotlin/annotations/parameters/ManyAnnotations.kt");
}
@TestMetadata("PropertySetterInClass.kt")
public void testPropertySetterInClass() throws Exception {
doTestWithAccessors("compiler/testData/loadKotlin/annotations/parameters/PropertySetterInClass.kt");
}
@TestMetadata("TopLevelFunction.kt")
public void testTopLevelFunction() throws Exception {
doTestWithAccessors("compiler/testData/loadKotlin/annotations/parameters/TopLevelFunction.kt");
}
@TestMetadata("TopLevelPropertySetter.kt")
public void testTopLevelPropertySetter() throws Exception {
doTestWithAccessors("compiler/testData/loadKotlin/annotations/parameters/TopLevelPropertySetter.kt");
}
}
@TestMetadata("compiler/testData/loadKotlin/annotations/propertiesWithoutBackingFields")
@@ -211,6 +211,11 @@ public class LazyResolveNamespaceComparingTestGenerated extends AbstractLazyReso
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadKotlin/annotations/parameters/ExtensionFunctionInClass.kt");
}
@TestMetadata("ExtensionPropertySetter.kt")
public void testExtensionPropertySetter() throws Exception {
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadKotlin/annotations/parameters/ExtensionPropertySetter.kt");
}
@TestMetadata("FunctionInClass.kt")
public void testFunctionInClass() throws Exception {
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadKotlin/annotations/parameters/FunctionInClass.kt");
@@ -226,11 +231,21 @@ public class LazyResolveNamespaceComparingTestGenerated extends AbstractLazyReso
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadKotlin/annotations/parameters/ManyAnnotations.kt");
}
@TestMetadata("PropertySetterInClass.kt")
public void testPropertySetterInClass() throws Exception {
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadKotlin/annotations/parameters/PropertySetterInClass.kt");
}
@TestMetadata("TopLevelFunction.kt")
public void testTopLevelFunction() throws Exception {
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadKotlin/annotations/parameters/TopLevelFunction.kt");
}
@TestMetadata("TopLevelPropertySetter.kt")
public void testTopLevelPropertySetter() throws Exception {
doTestCheckingPrimaryConstructorsAndAccessors("compiler/testData/loadKotlin/annotations/parameters/TopLevelPropertySetter.kt");
}
}
@TestMetadata("compiler/testData/loadKotlin/annotations/propertiesWithoutBackingFields")
@@ -28,7 +28,7 @@ public final class JvmAbi {
* This constant is used to identify binary format (class file) versions
* If you change class file metadata format and/or naming conventions, please increase this number
*/
public static final int VERSION = 10;
public static final int VERSION = 11;
public static final String TRAIT_IMPL_CLASS_NAME = "$TImpl";
public static final String TRAIT_IMPL_SUFFIX = "$" + TRAIT_IMPL_CLASS_NAME;
@@ -507,16 +507,15 @@ public class AnnotationDescriptorDeserializer implements AnnotationDeserializer
@NotNull ClassOrNamespaceDescriptor container,
@NotNull ProtoBuf.Callable callable,
@NotNull NameResolver nameResolver,
@NotNull AnnotatedCallableKind kind,
@NotNull ProtoBuf.Callable.ValueParameter proto
) {
// Kind = FUNCTION because properties and getters don't have any value parameters, and property setters are not supported yet
// TODO: support annotations on property setter value parameters
MemberSignature methodSignature = getCallableSignature(callable, nameResolver, AnnotatedCallableKind.FUNCTION);
MemberSignature methodSignature = getCallableSignature(callable, nameResolver, kind);
if (methodSignature != null) {
if (proto.hasExtension(JavaProtoBuf.index)) {
MemberSignature paramSignature =
MemberSignature.fromMethodSignatureAndParameterIndex(methodSignature, proto.getExtension(JavaProtoBuf.index));
return findClassAndLoadMemberAnnotations(container, callable, nameResolver, AnnotatedCallableKind.FUNCTION, paramSignature);
return findClassAndLoadMemberAnnotations(container, callable, nameResolver, kind, paramSignature);
}
}