Properly resolve descriptors from compiled kotlin
Added protected flag for annotation
This commit is contained in:
+3
@@ -84,6 +84,9 @@ public final class DescriptorResolverUtils {
|
||||
else if (annotation.hasInternalFlag()) {
|
||||
return Visibilities.INTERNAL;
|
||||
}
|
||||
else if (annotation.hasProtectedFlag()) {
|
||||
return Visibilities.PROTECTED;
|
||||
}
|
||||
}
|
||||
|
||||
if (modifierListOwner.hasModifierProperty(PsiModifier.PUBLIC)) {
|
||||
|
||||
@@ -27,7 +27,7 @@ public 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 = 3;
|
||||
public static final int VERSION = 4;
|
||||
|
||||
public static final String TRAIT_IMPL_CLASS_NAME = "$TImpl";
|
||||
public static final String TRAIT_IMPL_SUFFIX = "$" + TRAIT_IMPL_CLASS_NAME;
|
||||
|
||||
@@ -47,17 +47,18 @@ public class JvmStdlibNames {
|
||||
public static final int FLAG_FORCE_FINAL_BIT = 1 << 2;
|
||||
public static final int FLAG_PRIVATE_BIT = 1 << 3;
|
||||
public static final int FLAG_INTERNAL_BIT = 1 << 4;
|
||||
public static final int FLAG_PROTECTED_BIT = 1 << 5;
|
||||
|
||||
// for method, three bits (one reserved)
|
||||
public static final int FLAG_METHOD_KIND_MASK = 7 << 5;
|
||||
public static final int FLAG_METHOD_KIND_DECLARATION = 0 << 5;
|
||||
public static final int FLAG_METHOD_KIND_FAKE_OVERRIDE = 1 << 5;
|
||||
public static final int FLAG_METHOD_KIND_DELEGATION = 2 << 5;
|
||||
public static final int FLAG_METHOD_KIND_SYNTHESIZED = 3 << 5;
|
||||
public static final int FLAG_METHOD_KIND_MASK = 7 << 6;
|
||||
public static final int FLAG_METHOD_KIND_DECLARATION = 0 << 6;
|
||||
public static final int FLAG_METHOD_KIND_FAKE_OVERRIDE = 1 << 6;
|
||||
public static final int FLAG_METHOD_KIND_DELEGATION = 2 << 6;
|
||||
public static final int FLAG_METHOD_KIND_SYNTHESIZED = 3 << 6;
|
||||
|
||||
public static final int FLAG_CLASS_KIND_MASK = 7 << 5;
|
||||
public static final int FLAG_CLASS_KIND_DEFAULT = 0 << 5;
|
||||
public static final int FLAG_CLASS_KIND_OBJECT = 1 << 5;
|
||||
public static final int FLAG_CLASS_KIND_MASK = 7 << 6;
|
||||
public static final int FLAG_CLASS_KIND_DEFAULT = 0 << 6;
|
||||
public static final int FLAG_CLASS_KIND_OBJECT = 1 << 6;
|
||||
|
||||
public static final JvmClassName JET_CONSTRUCTOR = JvmClassName.byFqNameWithoutInnerClasses("jet.runtime.typeinfo.JetConstructor");
|
||||
|
||||
|
||||
+5
-1
@@ -51,8 +51,12 @@ public abstract class PsiAnnotationWithFlags extends PsiAnnotationWrapper {
|
||||
|
||||
public final boolean hasInternalFlag() {
|
||||
return (flags() & JvmStdlibNames.FLAG_INTERNAL_BIT) != 0;
|
||||
|
||||
}
|
||||
|
||||
public final boolean hasProtectedFlag() {
|
||||
return (flags() & JvmStdlibNames.FLAG_PROTECTED_BIT) != 0;
|
||||
}
|
||||
|
||||
public final boolean hasPrivateFlag() {
|
||||
return (flags() & JvmStdlibNames.FLAG_PRIVATE_BIT) != 0;
|
||||
}
|
||||
|
||||
+3
-1
@@ -138,7 +138,9 @@ public final class MembersCache {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (member.isPrivate()) {
|
||||
//process private accessors
|
||||
if (member.isPrivate()
|
||||
&& !(member instanceof PsiMethodWrapper && ((PsiMethodWrapper)member).getJetMethodAnnotation().hasPropertyFlag())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+16
-12
@@ -33,10 +33,7 @@ import org.jetbrains.jet.lang.resolve.java.kt.DescriptorKindUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.kt.JetMethodAnnotation;
|
||||
import org.jetbrains.jet.lang.resolve.java.provider.NamedMembers;
|
||||
import org.jetbrains.jet.lang.resolve.java.provider.PsiDeclarationProvider;
|
||||
import org.jetbrains.jet.lang.resolve.java.wrapper.PropertyPsiData;
|
||||
import org.jetbrains.jet.lang.resolve.java.wrapper.PropertyPsiDataElement;
|
||||
import org.jetbrains.jet.lang.resolve.java.wrapper.PsiFieldWrapper;
|
||||
import org.jetbrains.jet.lang.resolve.java.wrapper.PsiMethodWrapper;
|
||||
import org.jetbrains.jet.lang.resolve.java.wrapper.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
@@ -235,7 +232,7 @@ public final class JavaPropertyResolver {
|
||||
DescriptorUtils.getExpectedThisObjectIfNeeded(owner),
|
||||
receiverType
|
||||
);
|
||||
initializeSetterAndGetter(propertyDescriptor, getterDescriptor, setterDescriptor, propertyType);
|
||||
initializeSetterAndGetter(propertyDescriptor, getterDescriptor, setterDescriptor, propertyType, psiData);
|
||||
|
||||
if (kind == CallableMemberDescriptor.Kind.DECLARATION) {
|
||||
trace.record(BindingContext.VARIABLE, psiData.getCharacteristicPsi(), propertyDescriptor);
|
||||
@@ -274,20 +271,27 @@ public final class JavaPropertyResolver {
|
||||
}
|
||||
|
||||
private static void initializeSetterAndGetter(
|
||||
PropertyDescriptor propertyDescriptor,
|
||||
PropertyGetterDescriptorImpl getterDescriptor,
|
||||
PropertySetterDescriptorImpl setterDescriptor,
|
||||
JetType propertyType
|
||||
@NotNull PropertyDescriptor propertyDescriptor,
|
||||
@Nullable PropertyGetterDescriptorImpl getterDescriptor,
|
||||
@Nullable PropertySetterDescriptorImpl setterDescriptor,
|
||||
@NotNull JetType propertyType,
|
||||
@NotNull PropertyPsiData data
|
||||
) {
|
||||
if (getterDescriptor != null) {
|
||||
getterDescriptor.initialize(propertyType);
|
||||
}
|
||||
if (setterDescriptor != null) {
|
||||
PropertyPsiDataElement setter = data.getSetter();
|
||||
assert setter != null;
|
||||
List<PsiParameterWrapper> parameters = ((PsiMethodWrapper) setter.getMember()).getParameters();
|
||||
assert parameters.size() != 0;
|
||||
int valueIndex = parameters.size() - 1;
|
||||
PsiParameterWrapper valueParameter = parameters.get(valueIndex);
|
||||
setterDescriptor.initialize(new ValueParameterDescriptorImpl(
|
||||
setterDescriptor,
|
||||
0,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
Name.identifier("p0") /*TODO*/,
|
||||
Name.identifierNoValidate(valueParameter.getJetValueParameter().name()),
|
||||
propertyDescriptor.getType(),
|
||||
false,
|
||||
null));
|
||||
@@ -325,7 +329,7 @@ public final class JavaPropertyResolver {
|
||||
return new PropertyGetterDescriptorImpl(
|
||||
propertyDescriptor,
|
||||
annotationResolver.resolveAnnotations(getter.getMember().getPsiMember()),
|
||||
Modality.OPEN,
|
||||
propertyDescriptor.getModality(),
|
||||
visibility,
|
||||
true,
|
||||
false,
|
||||
@@ -352,7 +356,7 @@ public final class JavaPropertyResolver {
|
||||
return new PropertySetterDescriptorImpl(
|
||||
propertyDescriptor,
|
||||
annotationResolver.resolveAnnotations(setter.getMember().getPsiMember()),
|
||||
Modality.OPEN,
|
||||
propertyDescriptor.getModality(),
|
||||
setterVisibility,
|
||||
true,
|
||||
false,
|
||||
|
||||
Reference in New Issue
Block a user