Remove VariableDescriptor#isObjectDeclaration and usages.
Replace with BindingContext trace slice OBJECT_DECLARATION_CLASS. Remove corresponding field from constructor. Introduce hack in JavaDescriptorResolver which creates dummy class descriptors for enum entry objects.
This commit is contained in:
@@ -29,7 +29,7 @@ import java.util.Collections;
|
|||||||
public class AccessorForPropertyDescriptor extends PropertyDescriptor {
|
public class AccessorForPropertyDescriptor extends PropertyDescriptor {
|
||||||
public AccessorForPropertyDescriptor(PropertyDescriptor pd, DeclarationDescriptor containingDeclaration, int index) {
|
public AccessorForPropertyDescriptor(PropertyDescriptor pd, DeclarationDescriptor containingDeclaration, int index) {
|
||||||
super(containingDeclaration, Collections.<AnnotationDescriptor>emptyList(), Modality.FINAL, Visibilities.PUBLIC,
|
super(containingDeclaration, Collections.<AnnotationDescriptor>emptyList(), Modality.FINAL, Visibilities.PUBLIC,
|
||||||
pd.isVar(), pd.isObjectDeclaration(), Name.identifier(pd.getName() + "$b$" + index),
|
pd.isVar(), Name.identifier(pd.getName() + "$b$" + index),
|
||||||
Kind.DECLARATION);
|
Kind.DECLARATION);
|
||||||
|
|
||||||
JetType receiverType = pd.getReceiverParameter().exists() ? pd.getReceiverParameter().getType() : null;
|
JetType receiverType = pd.getReceiverParameter().exists() ? pd.getReceiverParameter().getType() : null;
|
||||||
|
|||||||
@@ -1107,7 +1107,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
if (descriptor instanceof PropertyDescriptor) {
|
if (descriptor instanceof PropertyDescriptor) {
|
||||||
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
|
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
|
||||||
|
|
||||||
if (propertyDescriptor.isObjectDeclaration()) {
|
ClassDescriptor objectClassDescriptor = getBindingContext().get(BindingContext.OBJECT_DECLARATION_CLASS, propertyDescriptor);
|
||||||
|
if (objectClassDescriptor != null) {
|
||||||
boolean isEnumEntry = DescriptorUtils.isEnumClassObject(propertyDescriptor.getContainingDeclaration());
|
boolean isEnumEntry = DescriptorUtils.isEnumClassObject(propertyDescriptor.getContainingDeclaration());
|
||||||
if (isEnumEntry) {
|
if (isEnumEntry) {
|
||||||
ClassDescriptor containing = (ClassDescriptor) propertyDescriptor.getContainingDeclaration().getContainingDeclaration();
|
ClassDescriptor containing = (ClassDescriptor) propertyDescriptor.getContainingDeclaration().getContainingDeclaration();
|
||||||
@@ -1117,9 +1118,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
return StackValue.onStack(type);
|
return StackValue.onStack(type);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ClassifierDescriptor classDescriptor = propertyDescriptor.getReturnType().getConstructor().getDeclarationDescriptor();
|
Type type = typeMapper.mapType(objectClassDescriptor.getDefaultType(), MapTypeMode.VALUE);
|
||||||
assert classDescriptor != null;
|
|
||||||
Type type = typeMapper.mapType(classDescriptor.getDefaultType(), MapTypeMode.VALUE);
|
|
||||||
return StackValue.field(type, JvmClassName.byType(type), "$instance", true);
|
return StackValue.field(type, JvmClassName.byType(type), "$instance", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-2
@@ -39,7 +39,10 @@ import org.jetbrains.jet.lang.resolve.name.FqName;
|
|||||||
import org.jetbrains.jet.lang.resolve.name.FqNameBase;
|
import org.jetbrains.jet.lang.resolve.name.FqNameBase;
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.*;
|
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||||
|
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
|
||||||
|
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||||
|
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
||||||
import org.jetbrains.jet.lang.types.*;
|
import org.jetbrains.jet.lang.types.*;
|
||||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||||
@@ -1185,10 +1188,23 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
|
|||||||
resolveModality(anyMember.getMember(), isFinal),
|
resolveModality(anyMember.getMember(), isFinal),
|
||||||
visibility,
|
visibility,
|
||||||
isVar,
|
isVar,
|
||||||
DescriptorUtils.isEnumClassObject(realOwner),
|
|
||||||
propertyName,
|
propertyName,
|
||||||
CallableMemberDescriptor.Kind.DECLARATION);
|
CallableMemberDescriptor.Kind.DECLARATION);
|
||||||
|
|
||||||
|
//TODO: this is a hack to indicate that this enum entry is an object
|
||||||
|
// class descriptor for enum entries is not used by backends so for now this should be safe to use
|
||||||
|
// remove this when JavaDescriptorResolver gets rewritten
|
||||||
|
if (DescriptorUtils.isEnumClassObject(realOwner)) {
|
||||||
|
ClassDescriptorImpl dummyClassDescriptorForEnumEntryObject =
|
||||||
|
new ClassDescriptorImpl(realOwner, Collections.<AnnotationDescriptor>emptyList(), Modality.FINAL, propertyName);
|
||||||
|
dummyClassDescriptorForEnumEntryObject.initialize(
|
||||||
|
true,
|
||||||
|
Collections.<TypeParameterDescriptor>emptyList(),
|
||||||
|
Collections.<JetType>emptyList(), JetScope.EMPTY,
|
||||||
|
Collections.<ConstructorDescriptor>emptySet(), null);
|
||||||
|
trace.record(BindingContext.OBJECT_DECLARATION_CLASS, propertyDescriptor, dummyClassDescriptorForEnumEntryObject);
|
||||||
|
}
|
||||||
|
|
||||||
PropertyGetterDescriptor getterDescriptor = null;
|
PropertyGetterDescriptor getterDescriptor = null;
|
||||||
PropertySetterDescriptor setterDescriptor = null;
|
PropertySetterDescriptor setterDescriptor = null;
|
||||||
if (members.getter != null) {
|
if (members.getter != null) {
|
||||||
|
|||||||
@@ -56,11 +56,6 @@ public class LocalVariableDescriptor extends VariableDescriptorImpl {
|
|||||||
return isVar;
|
return isVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isObjectDeclaration() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Visibility getVisibility() {
|
public Visibility getVisibility() {
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
|||||||
private final Modality modality;
|
private final Modality modality;
|
||||||
private Visibility visibility;
|
private Visibility visibility;
|
||||||
private final boolean isVar;
|
private final boolean isVar;
|
||||||
private final boolean isObject;
|
|
||||||
private final Set<PropertyDescriptor> overriddenProperties = Sets.newLinkedHashSet(); // LinkedHashSet is essential here
|
private final Set<PropertyDescriptor> overriddenProperties = Sets.newLinkedHashSet(); // LinkedHashSet is essential here
|
||||||
private final PropertyDescriptor original;
|
private final PropertyDescriptor original;
|
||||||
private final Kind kind;
|
private final Kind kind;
|
||||||
@@ -64,12 +63,11 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
|||||||
@NotNull Modality modality,
|
@NotNull Modality modality,
|
||||||
@NotNull Visibility visibility,
|
@NotNull Visibility visibility,
|
||||||
boolean isVar,
|
boolean isVar,
|
||||||
boolean isObject,
|
|
||||||
@NotNull Name name,
|
@NotNull Name name,
|
||||||
@NotNull Kind kind) {
|
@NotNull Kind kind
|
||||||
|
) {
|
||||||
super(containingDeclaration, annotations, name);
|
super(containingDeclaration, annotations, name);
|
||||||
this.isVar = isVar;
|
this.isVar = isVar;
|
||||||
this.isObject = isObject;
|
|
||||||
this.modality = modality;
|
this.modality = modality;
|
||||||
this.visibility = visibility;
|
this.visibility = visibility;
|
||||||
this.original = original == null ? this : original.getOriginal();
|
this.original = original == null ? this : original.getOriginal();
|
||||||
@@ -82,10 +80,10 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
|||||||
@NotNull Modality modality,
|
@NotNull Modality modality,
|
||||||
@NotNull Visibility visibility,
|
@NotNull Visibility visibility,
|
||||||
boolean isVar,
|
boolean isVar,
|
||||||
boolean isObject,
|
|
||||||
@NotNull Name name,
|
@NotNull Name name,
|
||||||
@NotNull Kind kind) {
|
@NotNull Kind kind
|
||||||
this(null, containingDeclaration, annotations, modality, visibility, isVar, isObject, name, kind);
|
) {
|
||||||
|
this(null, containingDeclaration, annotations, modality, visibility, isVar, name, kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyDescriptor(
|
public PropertyDescriptor(
|
||||||
@@ -94,14 +92,13 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
|||||||
@NotNull Modality modality,
|
@NotNull Modality modality,
|
||||||
@NotNull Visibility visibility,
|
@NotNull Visibility visibility,
|
||||||
boolean isVar,
|
boolean isVar,
|
||||||
boolean isObject,
|
|
||||||
@Nullable JetType receiverType,
|
@Nullable JetType receiverType,
|
||||||
@NotNull ReceiverDescriptor expectedThisObject,
|
@NotNull ReceiverDescriptor expectedThisObject,
|
||||||
@NotNull Name name,
|
@NotNull Name name,
|
||||||
@NotNull JetType outType,
|
@NotNull JetType outType,
|
||||||
@NotNull Kind kind
|
@NotNull Kind kind
|
||||||
) {
|
) {
|
||||||
this(containingDeclaration, annotations, modality, visibility, isVar, isObject, name, kind);
|
this(containingDeclaration, annotations, modality, visibility, isVar, name, kind);
|
||||||
setType(outType, Collections.<TypeParameterDescriptor>emptyList(), expectedThisObject, receiverType);
|
setType(outType, Collections.<TypeParameterDescriptor>emptyList(), expectedThisObject, receiverType);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,11 +156,6 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
|||||||
return isVar;
|
return isVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isObjectDeclaration() {
|
|
||||||
return isObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Modality getModality() {
|
public Modality getModality() {
|
||||||
@@ -209,7 +201,7 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
|||||||
private PropertyDescriptor doSubstitute(TypeSubstitutor originalSubstitutor,
|
private PropertyDescriptor doSubstitute(TypeSubstitutor originalSubstitutor,
|
||||||
DeclarationDescriptor newOwner, Modality newModality, Visibility newVisibility, boolean preserveOriginal, boolean copyOverrides, Kind kind) {
|
DeclarationDescriptor newOwner, Modality newModality, Visibility newVisibility, boolean preserveOriginal, boolean copyOverrides, Kind kind) {
|
||||||
PropertyDescriptor substitutedDescriptor = new PropertyDescriptor(preserveOriginal ? getOriginal() : this, newOwner,
|
PropertyDescriptor substitutedDescriptor = new PropertyDescriptor(preserveOriginal ? getOriginal() : this, newOwner,
|
||||||
getAnnotations(), newModality, newVisibility, isVar(), isObjectDeclaration(), getName(), kind);
|
getAnnotations(), newModality, newVisibility, isVar(), getName(), kind);
|
||||||
|
|
||||||
List<TypeParameterDescriptor> substitutedTypeParameters = Lists.newArrayList();
|
List<TypeParameterDescriptor> substitutedTypeParameters = Lists.newArrayList();
|
||||||
TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(getTypeParameters(), originalSubstitutor, substitutedDescriptor, substitutedTypeParameters);
|
TypeSubstitutor substitutor = DescriptorSubstitutor.substituteTypeParameters(getTypeParameters(), originalSubstitutor, substitutedDescriptor, substitutedTypeParameters);
|
||||||
|
|||||||
@@ -92,7 +92,6 @@ public class ScriptDescriptor extends DeclarationDescriptorNonRootImpl {
|
|||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
Visibilities.PUBLIC,
|
Visibilities.PUBLIC,
|
||||||
false,
|
false,
|
||||||
false,
|
|
||||||
Name.identifier(ScriptNameUtil.LAST_EXPRESSION_VALUE_FIELD_NAME),
|
Name.identifier(ScriptNameUtil.LAST_EXPRESSION_VALUE_FIELD_NAME),
|
||||||
CallableMemberDescriptor.Kind.DECLARATION);
|
CallableMemberDescriptor.Kind.DECLARATION);
|
||||||
propertyDescriptor.setType(returnType, Collections.<TypeParameterDescriptor>emptyList(), new ClassReceiver(classDescriptor), ReceiverDescriptor.NO_RECEIVER);
|
propertyDescriptor.setType(returnType, Collections.<TypeParameterDescriptor>emptyList(), new ClassReceiver(classDescriptor), ReceiverDescriptor.NO_RECEIVER);
|
||||||
@@ -181,7 +180,6 @@ public class ScriptDescriptor extends DeclarationDescriptorNonRootImpl {
|
|||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
Visibilities.PUBLIC,
|
Visibilities.PUBLIC,
|
||||||
false,
|
false,
|
||||||
false,
|
|
||||||
parameter.getName(),
|
parameter.getName(),
|
||||||
CallableMemberDescriptor.Kind.DECLARATION);
|
CallableMemberDescriptor.Kind.DECLARATION);
|
||||||
propertyDescriptor.setType(parameter.getType(), Collections.<TypeParameterDescriptor>emptyList(), classReceiver, ReceiverDescriptor.NO_RECEIVER);
|
propertyDescriptor.setType(parameter.getType(), Collections.<TypeParameterDescriptor>emptyList(), classReceiver, ReceiverDescriptor.NO_RECEIVER);
|
||||||
|
|||||||
-5
@@ -143,11 +143,6 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme
|
|||||||
return isVar;
|
return isVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isObjectDeclaration() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public ValueParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner) {
|
public ValueParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner) {
|
||||||
|
|||||||
@@ -36,6 +36,4 @@ public interface VariableDescriptor extends CallableDescriptor {
|
|||||||
VariableDescriptor substitute(TypeSubstitutor substitutor);
|
VariableDescriptor substitute(TypeSubstitutor substitutor);
|
||||||
|
|
||||||
boolean isVar();
|
boolean isVar();
|
||||||
|
|
||||||
boolean isObjectDeclaration();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,6 +113,8 @@ public interface BindingContext {
|
|||||||
|
|
||||||
WritableSlice<Box<DeferredType>, Boolean> DEFERRED_TYPE = Slices.createCollectiveSetSlice();
|
WritableSlice<Box<DeferredType>, Boolean> DEFERRED_TYPE = Slices.createCollectiveSetSlice();
|
||||||
|
|
||||||
|
WritableSlice<PropertyDescriptor, ClassDescriptor> OBJECT_DECLARATION_CLASS = Slices.createSimpleSlice();
|
||||||
|
|
||||||
WritableSlice<PropertyDescriptor, Boolean> BACKING_FIELD_REQUIRED = new Slices.SetSlice<PropertyDescriptor>(DO_NOTHING) {
|
WritableSlice<PropertyDescriptor, Boolean> BACKING_FIELD_REQUIRED = new Slices.SetSlice<PropertyDescriptor>(DO_NOTHING) {
|
||||||
@Override
|
@Override
|
||||||
public Boolean computeValue(SlicedMap map, PropertyDescriptor propertyDescriptor, Boolean backingFieldRequired, boolean valueNotFound) {
|
public Boolean computeValue(SlicedMap map, PropertyDescriptor propertyDescriptor, Boolean backingFieldRequired, boolean valueNotFound) {
|
||||||
|
|||||||
@@ -609,7 +609,6 @@ public class DescriptorResolver {
|
|||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
Visibilities.INTERNAL,
|
Visibilities.INTERNAL,
|
||||||
variable.isVar(),
|
variable.isVar(),
|
||||||
false,
|
|
||||||
JetPsiUtil.safeName(variable.getName()),
|
JetPsiUtil.safeName(variable.getName()),
|
||||||
CallableMemberDescriptor.Kind.DECLARATION
|
CallableMemberDescriptor.Kind.DECLARATION
|
||||||
);
|
);
|
||||||
@@ -678,13 +677,13 @@ public class DescriptorResolver {
|
|||||||
Modality.FINAL,
|
Modality.FINAL,
|
||||||
resolveVisibilityFromModifiers(modifierList),
|
resolveVisibilityFromModifiers(modifierList),
|
||||||
false,
|
false,
|
||||||
true,
|
|
||||||
JetPsiUtil.safeName(objectDeclaration.getName()),
|
JetPsiUtil.safeName(objectDeclaration.getName()),
|
||||||
CallableMemberDescriptor.Kind.DECLARATION
|
CallableMemberDescriptor.Kind.DECLARATION
|
||||||
);
|
);
|
||||||
propertyDescriptor.setType(classDescriptor.getDefaultType(), Collections.<TypeParameterDescriptor>emptyList(),
|
propertyDescriptor.setType(classDescriptor.getDefaultType(), Collections.<TypeParameterDescriptor>emptyList(),
|
||||||
DescriptorUtils.getExpectedThisObjectIfNeeded(containingDeclaration), ReceiverDescriptor.NO_RECEIVER);
|
DescriptorUtils.getExpectedThisObjectIfNeeded(containingDeclaration), ReceiverDescriptor.NO_RECEIVER);
|
||||||
propertyDescriptor.initialize(createDefaultGetter(propertyDescriptor), null);
|
propertyDescriptor.initialize(createDefaultGetter(propertyDescriptor), null);
|
||||||
|
trace.record(BindingContext.OBJECT_DECLARATION_CLASS, propertyDescriptor, classDescriptor);
|
||||||
JetObjectDeclarationName nameAsDeclaration = objectDeclaration.getNameAsDeclaration();
|
JetObjectDeclarationName nameAsDeclaration = objectDeclaration.getNameAsDeclaration();
|
||||||
if (nameAsDeclaration != null) {
|
if (nameAsDeclaration != null) {
|
||||||
trace.record(BindingContext.OBJECT_DECLARATION, nameAsDeclaration, propertyDescriptor);
|
trace.record(BindingContext.OBJECT_DECLARATION, nameAsDeclaration, propertyDescriptor);
|
||||||
@@ -747,7 +746,6 @@ public class DescriptorResolver {
|
|||||||
resolveModalityFromModifiers(property.getModifierList(), defaultModality),
|
resolveModalityFromModifiers(property.getModifierList(), defaultModality),
|
||||||
resolveVisibilityFromModifiers(property.getModifierList()),
|
resolveVisibilityFromModifiers(property.getModifierList()),
|
||||||
isVar,
|
isVar,
|
||||||
false,
|
|
||||||
JetPsiUtil.safeName(property.getName()),
|
JetPsiUtil.safeName(property.getName()),
|
||||||
CallableMemberDescriptor.Kind.DECLARATION
|
CallableMemberDescriptor.Kind.DECLARATION
|
||||||
);
|
);
|
||||||
@@ -1087,7 +1085,6 @@ public class DescriptorResolver {
|
|||||||
resolveModalityFromModifiers(parameter.getModifierList(), Modality.FINAL),
|
resolveModalityFromModifiers(parameter.getModifierList(), Modality.FINAL),
|
||||||
resolveVisibilityFromModifiers(parameter.getModifierList()),
|
resolveVisibilityFromModifiers(parameter.getModifierList()),
|
||||||
isMutable,
|
isMutable,
|
||||||
false,
|
|
||||||
name,
|
name,
|
||||||
CallableMemberDescriptor.Kind.DECLARATION
|
CallableMemberDescriptor.Kind.DECLARATION
|
||||||
);
|
);
|
||||||
|
|||||||
+3
-2
@@ -258,7 +258,7 @@ public class QualifiedExpressionResolver {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private Collection<? extends DeclarationDescriptor> filterAndStoreResolutionResult(@NotNull Collection<SuccessfulLookupResult> lookupResults,
|
private Collection<? extends DeclarationDescriptor> filterAndStoreResolutionResult(@NotNull Collection<SuccessfulLookupResult> lookupResults,
|
||||||
@NotNull JetSimpleNameExpression referenceExpression, @NotNull BindingTrace trace, @NotNull JetScope scopeToCheckVisibility,
|
@NotNull JetSimpleNameExpression referenceExpression, @NotNull final BindingTrace trace, @NotNull JetScope scopeToCheckVisibility,
|
||||||
boolean onlyClasses, boolean storeResult) {
|
boolean onlyClasses, boolean storeResult) {
|
||||||
|
|
||||||
if (lookupResults.isEmpty()) {
|
if (lookupResults.isEmpty()) {
|
||||||
@@ -304,7 +304,8 @@ public class QualifiedExpressionResolver {
|
|||||||
public boolean apply(@Nullable DeclarationDescriptor descriptor) {
|
public boolean apply(@Nullable DeclarationDescriptor descriptor) {
|
||||||
return (descriptor instanceof NamespaceDescriptor) ||
|
return (descriptor instanceof NamespaceDescriptor) ||
|
||||||
(descriptor instanceof ClassifierDescriptor) ||
|
(descriptor instanceof ClassifierDescriptor) ||
|
||||||
(descriptor instanceof VariableDescriptor && ((VariableDescriptor)descriptor).isObjectDeclaration());
|
((descriptor instanceof PropertyDescriptor) &&
|
||||||
|
(trace.get(BindingContext.OBJECT_DECLARATION_CLASS, ((PropertyDescriptor) descriptor)) != null));
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,7 +162,6 @@ public class ErrorUtils {
|
|||||||
Modality.OPEN,
|
Modality.OPEN,
|
||||||
Visibilities.INTERNAL,
|
Visibilities.INTERNAL,
|
||||||
true,
|
true,
|
||||||
false,
|
|
||||||
null,
|
null,
|
||||||
ReceiverDescriptor.NO_RECEIVER,
|
ReceiverDescriptor.NO_RECEIVER,
|
||||||
Name.special("<ERROR PROPERTY>"),
|
Name.special("<ERROR PROPERTY>"),
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ public class JetStandardClasses {
|
|||||||
false, Variance.OUT_VARIANCE, Name.identifier("T" + (j + 1)), j);
|
false, Variance.OUT_VARIANCE, Name.identifier("T" + (j + 1)), j);
|
||||||
typeParameters.add(typeParameterDescriptor);
|
typeParameters.add(typeParameterDescriptor);
|
||||||
|
|
||||||
PropertyDescriptor propertyDescriptor = new PropertyDescriptor(classDescriptor, Collections.<AnnotationDescriptor>emptyList(), Modality.FINAL, Visibilities.PUBLIC, false, false, Name.identifier("_" + (j + 1)), CallableMemberDescriptor.Kind.DECLARATION);
|
PropertyDescriptor propertyDescriptor = new PropertyDescriptor(classDescriptor, Collections.<AnnotationDescriptor>emptyList(), Modality.FINAL, Visibilities.PUBLIC, false, Name.identifier("_" + (j + 1)), CallableMemberDescriptor.Kind.DECLARATION);
|
||||||
propertyDescriptor.setType(typeParameterDescriptor.getDefaultType(), Collections.<TypeParameterDescriptorImpl>emptyList(), classDescriptor.getImplicitReceiver(), ReceiverDescriptor.NO_RECEIVER);
|
propertyDescriptor.setType(typeParameterDescriptor.getDefaultType(), Collections.<TypeParameterDescriptorImpl>emptyList(), classDescriptor.getImplicitReceiver(), ReceiverDescriptor.NO_RECEIVER);
|
||||||
PropertyGetterDescriptor getterDescriptor = new PropertyGetterDescriptor(propertyDescriptor, Collections.<AnnotationDescriptor>emptyList(), Modality.FINAL, Visibilities.PUBLIC, false, true, CallableMemberDescriptor.Kind.DECLARATION);
|
PropertyGetterDescriptor getterDescriptor = new PropertyGetterDescriptor(propertyDescriptor, Collections.<AnnotationDescriptor>emptyList(), Modality.FINAL, Visibilities.PUBLIC, false, true, CallableMemberDescriptor.Kind.DECLARATION);
|
||||||
getterDescriptor.initialize(typeParameterDescriptor.getDefaultType());
|
getterDescriptor.initialize(typeParameterDescriptor.getDefaultType());
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import org.jetbrains.k2js.translate.utils.PredefinedAnnotation;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.jetbrains.k2js.translate.utils.AnnotationsUtils.*;
|
import static org.jetbrains.k2js.translate.utils.AnnotationsUtils.*;
|
||||||
|
import static org.jetbrains.k2js.translate.utils.BindingUtils.isObjectDeclaration;
|
||||||
import static org.jetbrains.k2js.translate.utils.JsDescriptorUtils.*;
|
import static org.jetbrains.k2js.translate.utils.JsDescriptorUtils.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -226,7 +227,7 @@ public final class StaticContext {
|
|||||||
|
|
||||||
PropertyAccessorDescriptor accessorDescriptor = (PropertyAccessorDescriptor) descriptor;
|
PropertyAccessorDescriptor accessorDescriptor = (PropertyAccessorDescriptor) descriptor;
|
||||||
String propertyName = accessorDescriptor.getCorrespondingProperty().getName().getName();
|
String propertyName = accessorDescriptor.getCorrespondingProperty().getName().getName();
|
||||||
if (accessorDescriptor.getCorrespondingProperty().isObjectDeclaration()) {
|
if (isObjectDeclaration(bindingContext, accessorDescriptor.getCorrespondingProperty())) {
|
||||||
return declareName(descriptor, propertyName);
|
return declareName(descriptor, propertyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.jetbrains.k2js.translate.reference.CallParametersResolver.resolveCallParameters;
|
import static org.jetbrains.k2js.translate.reference.CallParametersResolver.resolveCallParameters;
|
||||||
|
import static org.jetbrains.k2js.translate.utils.BindingUtils.isObjectDeclaration;
|
||||||
import static org.jetbrains.k2js.translate.utils.JsAstUtils.assignment;
|
import static org.jetbrains.k2js.translate.utils.JsAstUtils.assignment;
|
||||||
import static org.jetbrains.k2js.translate.utils.JsAstUtils.setQualifier;
|
import static org.jetbrains.k2js.translate.utils.JsAstUtils.setQualifier;
|
||||||
import static org.jetbrains.k2js.translate.utils.JsDescriptorUtils.isConstructorDescriptor;
|
import static org.jetbrains.k2js.translate.utils.JsDescriptorUtils.isConstructorDescriptor;
|
||||||
@@ -267,7 +268,12 @@ public final class CallTranslator extends AbstractTranslator {
|
|||||||
|
|
||||||
private boolean isDirectPropertyAccess() {
|
private boolean isDirectPropertyAccess() {
|
||||||
return descriptor instanceof PropertyAccessorDescriptor &&
|
return descriptor instanceof PropertyAccessorDescriptor &&
|
||||||
(context().isEcma5() || ((PropertyAccessorDescriptor) descriptor).getCorrespondingProperty().isObjectDeclaration());
|
(context().isEcma5() || isObjectAccessor((PropertyAccessorDescriptor) descriptor));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isObjectAccessor(@NotNull PropertyAccessorDescriptor propertyAccessorDescriptor) {
|
||||||
|
PropertyDescriptor correspondingProperty = propertyAccessorDescriptor.getCorrespondingProperty();
|
||||||
|
return isObjectDeclaration(bindingContext(), correspondingProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -298,4 +298,11 @@ public final class BindingUtils {
|
|||||||
@NotNull JetNamedFunction function) {
|
@NotNull JetNamedFunction function) {
|
||||||
return bindingContext.get(BindingContext.FUNCTION, function);
|
return bindingContext.get(BindingContext.FUNCTION, function);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isObjectDeclaration(
|
||||||
|
@NotNull BindingContext bindingContext,
|
||||||
|
@NotNull PropertyDescriptor propertyDescriptor
|
||||||
|
) {
|
||||||
|
return bindingContext.get(BindingContext.OBJECT_DECLARATION_CLASS, propertyDescriptor) != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user