Changed containing declaration for PropertyDeclarationInnerScope

This commit is contained in:
Stanislav Erokhin
2015-02-03 21:09:49 +03:00
parent 49b77a1523
commit 3b92cab9e0
13 changed files with 48 additions and 49 deletions
@@ -646,7 +646,7 @@ public class BodyResolver {
}
JetScope propertyDeclarationInnerScope = JetScopeUtils.getPropertyDeclarationInnerScopeForInitializer(
propertyScope, propertyDescriptor.getTypeParameters(), NO_RECEIVER_PARAMETER, trace);
propertyDescriptor, propertyScope, propertyDescriptor.getTypeParameters(), NO_RECEIVER_PARAMETER, trace);
JetScope accessorScope = JetScopeUtils.makeScopeForPropertyAccessor(
propertyDescriptor, parentScopeForAccessor, trace);
@@ -674,7 +674,7 @@ public class BodyResolver {
@NotNull JetScope scope
) {
JetScope propertyDeclarationInnerScope = JetScopeUtils.getPropertyDeclarationInnerScopeForInitializer(
scope, propertyDescriptor.getTypeParameters(), NO_RECEIVER_PARAMETER, trace);
propertyDescriptor, scope, propertyDescriptor.getTypeParameters(), NO_RECEIVER_PARAMETER, trace);
JetType expectedTypeForInitializer = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
CompileTimeConstant<?> compileTimeInitializer = propertyDescriptor.getCompileTimeInitializer();
if (compileTimeInitializer == null) {
@@ -424,7 +424,7 @@ public class DescriptorResolver {
? Visibilities.INHERITED
: Visibilities.INTERNAL;
}
else if (containingDescriptor instanceof FunctionDescriptor) {
else if (containingDescriptor instanceof FunctionDescriptor || containingDescriptor instanceof PropertyDescriptor) {
defaultVisibility = Visibilities.LOCAL;
}
else {
@@ -64,8 +64,8 @@ public class OverloadResolver {
@NotNull MultiMap<FqNameUnsafe, ConstructorDescriptor> inPackages
) {
for (ClassDescriptorWithResolutionScopes klass : c.getDeclaredClasses().values()) {
if (klass.getKind().isSingleton()) {
// Constructors of singletons aren't callable from the code, so they shouldn't participate in overload name checking
if (klass.getKind().isSingleton() || klass.getName().isSpecial()) {
// Constructors of singletons or anonymous object aren't callable from the code, so they shouldn't participate in overload name checking
continue;
}
DeclarationDescriptor containingDeclaration = klass.getContainingDeclaration();
@@ -91,17 +91,17 @@ public final class JetScopeUtils {
}
public static JetScope getPropertyDeclarationInnerScopeForInitializer(
@NotNull PropertyDescriptor propertyDescriptor,
@NotNull JetScope outerScope,
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
@Nullable ReceiverParameterDescriptor receiver,
BindingTrace trace
) {
return getPropertyDeclarationInnerScope(null, outerScope, typeParameters, receiver, trace, false);
return getPropertyDeclarationInnerScope(propertyDescriptor, outerScope, typeParameters, receiver, trace, false);
}
private static JetScope getPropertyDeclarationInnerScope(
@Nullable PropertyDescriptor propertyDescriptor,
// PropertyDescriptor can be null for property scope which hasn't label to property (in this case addLabelForProperty parameter must be false
@NotNull PropertyDescriptor propertyDescriptor,
@NotNull JetScope outerScope,
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
@Nullable ReceiverParameterDescriptor receiver,
@@ -115,7 +115,7 @@ public final class JetScopeUtils {
@NotNull
private static JetScope getPropertyDeclarationInnerScope(
@Nullable PropertyDescriptor propertyDescriptor,
@NotNull PropertyDescriptor propertyDescriptor,
@NotNull JetScope outerScope,
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
@Nullable ReceiverParameterDescriptor receiver,
@@ -123,10 +123,9 @@ public final class JetScopeUtils {
boolean addLabelForProperty
) {
WritableScopeImpl result = new WritableScopeImpl(
outerScope, outerScope.getContainingDeclaration(), redeclarationHandler,
outerScope, propertyDescriptor, redeclarationHandler,
"Property declaration inner scope");
if (addLabelForProperty) {
assert propertyDescriptor != null : "PropertyDescriptor can be null for property scope which hasn't label to property";
result.addLabeledDeclaration(propertyDescriptor);
}
for (TypeParameterDescriptor typeParameterDescriptor : typeParameters) {