Introduced trait for deserialized callable and implementations.
This commit is contained in:
@@ -390,10 +390,10 @@ public class PackageCodegen extends GenerationStateAware {
|
||||
DeclarationDescriptor parent = deserializedFunction.getContainingDeclaration();
|
||||
assert parent instanceof PackageFragmentDescriptor : "parent should be package, but was: " + parent;
|
||||
|
||||
assert deserializedFunction.getFunctionProto().hasExtension(JavaProtoBuf.implClassName)
|
||||
assert deserializedFunction.getProto().hasExtension(JavaProtoBuf.implClassName)
|
||||
: "implClassName extension is absent for " + deserializedFunction;
|
||||
Name shortName = deserializedFunction.getNameResolver()
|
||||
.getName(deserializedFunction.getFunctionProto().getExtension(JavaProtoBuf.implClassName));
|
||||
.getName(deserializedFunction.getProto().getExtension(JavaProtoBuf.implClassName));
|
||||
FqName packagePartFqName = ((PackageFragmentDescriptor) parent).getFqName().child(shortName);
|
||||
return JvmClassName.byFqNameWithoutInnerClasses(packagePartFqName).getInternalName();
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class InlineCodegenUtil {
|
||||
VirtualFile file;
|
||||
DeclarationDescriptor parentDeclaration = deserializedDescriptor.getContainingDeclaration();
|
||||
if (parentDeclaration instanceof PackageFragmentDescriptor) {
|
||||
ProtoBuf.Callable proto = deserializedDescriptor.getFunctionProto();
|
||||
ProtoBuf.Callable proto = deserializedDescriptor.getProto();
|
||||
if (!proto.hasExtension(JavaProtoBuf.implClassName)) {
|
||||
throw new IllegalStateException("Function in namespace should have implClassName property in proto: " + deserializedDescriptor);
|
||||
}
|
||||
|
||||
+5
-2
@@ -136,14 +136,17 @@ public class DescriptorDeserializer {
|
||||
private PropertyDescriptor loadProperty(@NotNull final Callable proto) {
|
||||
final int flags = proto.getFlags();
|
||||
|
||||
PropertyDescriptorImpl property = new PropertyDescriptorImpl(
|
||||
DeserializedPropertyDescriptor property = new DeserializedPropertyDescriptor(
|
||||
null,
|
||||
containingDeclaration,
|
||||
getAnnotations(proto, flags, AnnotatedCallableKind.PROPERTY),
|
||||
modality(Flags.MODALITY.get(flags)),
|
||||
visibility(Flags.VISIBILITY.get(flags)),
|
||||
Flags.CALLABLE_KIND.get(flags) == Callable.CallableKind.VAR,
|
||||
nameResolver.getName(proto.getName()),
|
||||
memberKind(Flags.MEMBER_KIND.get(flags))
|
||||
memberKind(Flags.MEMBER_KIND.get(flags)),
|
||||
proto,
|
||||
nameResolver
|
||||
);
|
||||
|
||||
List<TypeParameterDescriptor> typeParameters = new ArrayList<TypeParameterDescriptor>(proto.getTypeParameterCount());
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.descriptors.serialization.descriptors
|
||||
|
||||
import org.jetbrains.jet.descriptors.serialization.ProtoBuf
|
||||
import org.jetbrains.jet.descriptors.serialization.NameResolver
|
||||
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor
|
||||
|
||||
public trait DeserializedCallableMemberDescriptor: CallableMemberDescriptor {
|
||||
public val proto: ProtoBuf.Callable
|
||||
public val nameResolver: NameResolver
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.descriptors.serialization.descriptors
|
||||
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.Modality
|
||||
import org.jetbrains.jet.lang.resolve.name.Name
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.Annotations
|
||||
import org.jetbrains.jet.lang.descriptors.Visibility
|
||||
import org.jetbrains.jet.descriptors.serialization.NameResolver
|
||||
import org.jetbrains.jet.lang.descriptors.impl.PropertyDescriptorImpl
|
||||
import org.jetbrains.jet.descriptors.serialization.ProtoBuf
|
||||
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor.Kind
|
||||
|
||||
public class DeserializedPropertyDescriptor(
|
||||
original: PropertyDescriptor?,
|
||||
containingDeclaration: DeclarationDescriptor,
|
||||
annotations: Annotations,
|
||||
modality: Modality,
|
||||
visibility: Visibility,
|
||||
isVar: Boolean,
|
||||
name: Name,
|
||||
kind: Kind,
|
||||
override public val proto: ProtoBuf.Callable,
|
||||
override public val nameResolver: NameResolver
|
||||
) : DeserializedCallableMemberDescriptor,
|
||||
PropertyDescriptorImpl(original, containingDeclaration, annotations, modality, visibility, isVar, name, kind) {
|
||||
|
||||
override fun createSubstitutedCopy(
|
||||
newOwner: DeclarationDescriptor,
|
||||
newModality: Modality,
|
||||
newVisibility: Visibility,
|
||||
original: PropertyDescriptor?,
|
||||
kind: Kind
|
||||
): PropertyDescriptorImpl {
|
||||
return DeserializedPropertyDescriptor(
|
||||
original, newOwner, getAnnotations(), newModality, newVisibility, isVar(), getName(), kind, proto, nameResolver)
|
||||
}
|
||||
}
|
||||
+16
-12
@@ -29,9 +29,9 @@ import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
public class DeserializedSimpleFunctionDescriptor extends SimpleFunctionDescriptorImpl {
|
||||
public class DeserializedSimpleFunctionDescriptor extends SimpleFunctionDescriptorImpl implements DeserializedCallableMemberDescriptor {
|
||||
|
||||
private final ProtoBuf.Callable functionProto;
|
||||
private final ProtoBuf.Callable proto;
|
||||
private final NameResolver nameResolver;
|
||||
|
||||
private DeserializedSimpleFunctionDescriptor(
|
||||
@@ -40,10 +40,10 @@ public class DeserializedSimpleFunctionDescriptor extends SimpleFunctionDescript
|
||||
@NotNull Annotations annotations,
|
||||
@NotNull Name name,
|
||||
@NotNull Kind kind,
|
||||
@NotNull ProtoBuf.Callable functionProto,
|
||||
@NotNull ProtoBuf.Callable proto,
|
||||
@NotNull NameResolver nameResolver) {
|
||||
super(containingDeclaration, original, annotations, name, kind);
|
||||
this.functionProto = functionProto;
|
||||
this.proto = proto;
|
||||
this.nameResolver = nameResolver;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class DeserializedSimpleFunctionDescriptor extends SimpleFunctionDescript
|
||||
getAnnotations(),
|
||||
getName(),
|
||||
kind,
|
||||
functionProto,
|
||||
proto,
|
||||
nameResolver
|
||||
);
|
||||
}
|
||||
@@ -66,21 +66,25 @@ public class DeserializedSimpleFunctionDescriptor extends SimpleFunctionDescript
|
||||
return (DeserializedSimpleFunctionDescriptor) super.getOriginal();
|
||||
}
|
||||
|
||||
public ProtoBuf.Callable getFunctionProto() {
|
||||
return functionProto;
|
||||
@NotNull
|
||||
@Override
|
||||
public ProtoBuf.Callable getProto() {
|
||||
return proto;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NameResolver getNameResolver() {
|
||||
return nameResolver;
|
||||
}
|
||||
|
||||
public static DeserializedSimpleFunctionDescriptor create(
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull ProtoBuf.Callable functionProto,
|
||||
@NotNull ProtoBuf.Callable proto,
|
||||
@NotNull Deserializers deserializers,
|
||||
@NotNull NameResolver nameResolver
|
||||
) {
|
||||
Annotations annotations = DescriptorDeserializer.getAnnotations(containingDeclaration, functionProto, functionProto.getFlags(),
|
||||
Annotations annotations = DescriptorDeserializer.getAnnotations(containingDeclaration, proto, proto.getFlags(),
|
||||
Deserializers.AnnotatedCallableKind.FUNCTION,
|
||||
deserializers.getAnnotationDeserializer(),
|
||||
nameResolver);
|
||||
@@ -88,9 +92,9 @@ public class DeserializedSimpleFunctionDescriptor extends SimpleFunctionDescript
|
||||
containingDeclaration,
|
||||
null,
|
||||
annotations,
|
||||
nameResolver.getName(functionProto.getName()),
|
||||
DescriptorDeserializer.memberKind(Flags.MEMBER_KIND.get(functionProto.getFlags())),
|
||||
functionProto,
|
||||
nameResolver.getName(proto.getName()),
|
||||
DescriptorDeserializer.memberKind(Flags.MEMBER_KIND.get(proto.getFlags())),
|
||||
proto,
|
||||
nameResolver);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,46 +50,46 @@ Trait.traitFunc:SimpleFunctionDescriptor
|
||||
Trait.traitProp:PropertyDescriptor
|
||||
Trait:ClassDescriptorWithResolutionScopes
|
||||
a:ValueParameterDescriptor
|
||||
fake <class-object-for-Class>.equals:SimpleFunctionDescriptor
|
||||
fake <class-object-for-Class>.hashCode:SimpleFunctionDescriptor
|
||||
fake <class-object-for-Class>.toString:SimpleFunctionDescriptor
|
||||
fake <class-object-for-NestedClass>.equals:SimpleFunctionDescriptor
|
||||
fake <class-object-for-NestedClass>.hashCode:SimpleFunctionDescriptor
|
||||
fake <class-object-for-NestedClass>.toString:SimpleFunctionDescriptor
|
||||
fake <class-object-for-NestedObject>.equals:SimpleFunctionDescriptor
|
||||
fake <class-object-for-NestedObject>.hashCode:SimpleFunctionDescriptor
|
||||
fake <class-object-for-Class>.equals:DeserializedCallableMemberDescriptor
|
||||
fake <class-object-for-Class>.hashCode:DeserializedCallableMemberDescriptor
|
||||
fake <class-object-for-Class>.toString:DeserializedCallableMemberDescriptor
|
||||
fake <class-object-for-NestedClass>.equals:DeserializedCallableMemberDescriptor
|
||||
fake <class-object-for-NestedClass>.hashCode:DeserializedCallableMemberDescriptor
|
||||
fake <class-object-for-NestedClass>.toString:DeserializedCallableMemberDescriptor
|
||||
fake <class-object-for-NestedObject>.equals:DeserializedCallableMemberDescriptor
|
||||
fake <class-object-for-NestedObject>.hashCode:DeserializedCallableMemberDescriptor
|
||||
fake <class-object-for-NestedObject>.nestedFunc:SimpleFunctionDescriptor
|
||||
fake <class-object-for-NestedObject>.toString:SimpleFunctionDescriptor
|
||||
fake <class-object-for-NestedObject>.toString:DeserializedCallableMemberDescriptor
|
||||
fake <class-object-for-Object>.<get-objProp>:PropertyGetterDescriptor
|
||||
fake <class-object-for-Object>.equals:SimpleFunctionDescriptor
|
||||
fake <class-object-for-Object>.hashCode:SimpleFunctionDescriptor
|
||||
fake <class-object-for-Object>.equals:DeserializedCallableMemberDescriptor
|
||||
fake <class-object-for-Object>.hashCode:DeserializedCallableMemberDescriptor
|
||||
fake <class-object-for-Object>.objFunc:SimpleFunctionDescriptor
|
||||
fake <class-object-for-Object>.objProp:PropertyDescriptor
|
||||
fake <class-object-for-Object>.toString:SimpleFunctionDescriptor
|
||||
fake <class-object-for-Object>.toString:DeserializedCallableMemberDescriptor
|
||||
fake Class.<get-traitProp>:PropertyGetterDescriptor
|
||||
fake Class.equals:SimpleFunctionDescriptor
|
||||
fake Class.hashCode:SimpleFunctionDescriptor
|
||||
fake Class.toString:SimpleFunctionDescriptor
|
||||
fake Class.equals:DeserializedCallableMemberDescriptor
|
||||
fake Class.hashCode:DeserializedCallableMemberDescriptor
|
||||
fake Class.toString:DeserializedCallableMemberDescriptor
|
||||
fake Class.traitFunc:SimpleFunctionDescriptor
|
||||
fake Class.traitProp:PropertyDescriptor
|
||||
fake NestedClass.equals:SimpleFunctionDescriptor
|
||||
fake NestedClass.hashCode:SimpleFunctionDescriptor
|
||||
fake NestedClass.toString:SimpleFunctionDescriptor
|
||||
fake NestedObject.equals:SimpleFunctionDescriptor
|
||||
fake NestedObject.hashCode:SimpleFunctionDescriptor
|
||||
fake NestedObject.toString:SimpleFunctionDescriptor
|
||||
fake NestedTrait.equals:SimpleFunctionDescriptor
|
||||
fake NestedTrait.hashCode:SimpleFunctionDescriptor
|
||||
fake NestedTrait.toString:SimpleFunctionDescriptor
|
||||
fake Object.equals:SimpleFunctionDescriptor
|
||||
fake Object.hashCode:SimpleFunctionDescriptor
|
||||
fake Object.toString:SimpleFunctionDescriptor
|
||||
fake Outer.equals:SimpleFunctionDescriptor
|
||||
fake Outer.hashCode:SimpleFunctionDescriptor
|
||||
fake Outer.toString:SimpleFunctionDescriptor
|
||||
fake Trait.equals:SimpleFunctionDescriptor
|
||||
fake Trait.hashCode:SimpleFunctionDescriptor
|
||||
fake Trait.toString:SimpleFunctionDescriptor
|
||||
fake NestedClass.equals:DeserializedCallableMemberDescriptor
|
||||
fake NestedClass.hashCode:DeserializedCallableMemberDescriptor
|
||||
fake NestedClass.toString:DeserializedCallableMemberDescriptor
|
||||
fake NestedObject.equals:DeserializedCallableMemberDescriptor
|
||||
fake NestedObject.hashCode:DeserializedCallableMemberDescriptor
|
||||
fake NestedObject.toString:DeserializedCallableMemberDescriptor
|
||||
fake NestedTrait.equals:DeserializedCallableMemberDescriptor
|
||||
fake NestedTrait.hashCode:DeserializedCallableMemberDescriptor
|
||||
fake NestedTrait.toString:DeserializedCallableMemberDescriptor
|
||||
fake Object.equals:DeserializedCallableMemberDescriptor
|
||||
fake Object.hashCode:DeserializedCallableMemberDescriptor
|
||||
fake Object.toString:DeserializedCallableMemberDescriptor
|
||||
fake Outer.equals:DeserializedCallableMemberDescriptor
|
||||
fake Outer.hashCode:DeserializedCallableMemberDescriptor
|
||||
fake Outer.toString:DeserializedCallableMemberDescriptor
|
||||
fake Trait.equals:DeserializedCallableMemberDescriptor
|
||||
fake Trait.hashCode:DeserializedCallableMemberDescriptor
|
||||
fake Trait.toString:DeserializedCallableMemberDescriptor
|
||||
func.this:ReceiverParameterDescriptor
|
||||
innerTest.<get-prop>:PropertyGetterDescriptor
|
||||
innerTest.<get-propVar>:PropertyGetterDescriptor
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.jet.lang.descriptors;
|
||||
|
||||
import jet.runtime.typeinfo.KotlinSignature;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -52,6 +53,8 @@ public interface CallableDescriptor extends DeclarationDescriptorWithVisibility,
|
||||
|
||||
boolean hasStableParameterNames();
|
||||
|
||||
// Workaround for KT-4609 Wildcard types (super/extends) shouldn't be loaded as nullable
|
||||
@KotlinSignature("fun getOverriddenDescriptors(): Set<out CallableDescriptor>")
|
||||
@NotNull
|
||||
Set<? extends CallableDescriptor> getOverriddenDescriptors();
|
||||
}
|
||||
|
||||
+14
-3
@@ -52,7 +52,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr
|
||||
private PropertySetterDescriptor setter;
|
||||
private boolean setterProjectedOut;
|
||||
|
||||
private PropertyDescriptorImpl(
|
||||
protected PropertyDescriptorImpl(
|
||||
@Nullable PropertyDescriptor original,
|
||||
@NotNull DeclarationDescriptor containingDeclaration,
|
||||
@NotNull Annotations annotations,
|
||||
@@ -216,8 +216,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr
|
||||
|
||||
private PropertyDescriptor doSubstitute(TypeSubstitutor originalSubstitutor,
|
||||
DeclarationDescriptor newOwner, Modality newModality, Visibility newVisibility, boolean preserveOriginal, boolean copyOverrides, Kind kind) {
|
||||
PropertyDescriptorImpl substitutedDescriptor = new PropertyDescriptorImpl(preserveOriginal ? getOriginal() : null, newOwner,
|
||||
getAnnotations(), newModality, newVisibility, isVar(), getName(), kind);
|
||||
PropertyDescriptorImpl substitutedDescriptor = createSubstitutedCopy(newOwner, newModality, newVisibility, preserveOriginal ? getOriginal() : null, kind);
|
||||
|
||||
List<TypeParameterDescriptor> substitutedTypeParameters = Lists.newArrayList();
|
||||
TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(getTypeParameters(), originalSubstitutor, substitutedDescriptor, substitutedTypeParameters);
|
||||
@@ -291,6 +290,18 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr
|
||||
return substitutedDescriptor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected PropertyDescriptorImpl createSubstitutedCopy(
|
||||
@NotNull DeclarationDescriptor newOwner,
|
||||
@NotNull Modality newModality,
|
||||
@NotNull Visibility newVisibility,
|
||||
@Nullable PropertyDescriptor original,
|
||||
@NotNull Kind kind
|
||||
) {
|
||||
return new PropertyDescriptorImpl(original, newOwner,
|
||||
getAnnotations(), newModality, newVisibility, isVar(), getName(), kind);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Visibility convertVisibility(Visibility orig, Visibility candidate) {
|
||||
if (candidate == Visibilities.INHERITED) {
|
||||
|
||||
Reference in New Issue
Block a user