Fixed scope creations for properties scopes.

This commit is contained in:
Stanislav Erokhin
2015-11-05 20:35:22 +03:00
parent 67abdd755f
commit a502405779
12 changed files with 109 additions and 176 deletions
@@ -576,9 +576,8 @@ public class BodyResolver {
});
}
private void resolveProperty(
public void resolveProperty(
@NotNull BodiesResolveContext c,
@Nullable LexicalScope parentScope,
@NotNull KtProperty property,
@NotNull PropertyDescriptor propertyDescriptor
) {
@@ -586,18 +585,16 @@ public class BodyResolver {
PreliminaryDeclarationVisitor.Companion.createForDeclaration(property, trace);
KtExpression initializer = property.getInitializer();
LexicalScope propertyScope = getScopeForProperty(c, property);
if (parentScope == null) {
parentScope = propertyScope;
}
LexicalScope propertyHeaderScope = JetScopeUtils.makeScopeForPropertyHeader(getScopeForProperty(c, property), propertyDescriptor);
if (initializer != null) {
resolvePropertyInitializer(c.getOuterDataFlowInfo(), property, propertyDescriptor, initializer, propertyScope);
resolvePropertyInitializer(c.getOuterDataFlowInfo(), property, propertyDescriptor, initializer, propertyHeaderScope);
}
KtExpression delegateExpression = property.getDelegateExpression();
if (delegateExpression != null) {
assert initializer == null : "Initializer should be null for delegated property : " + property.getText();
resolvePropertyDelegate(c.getOuterDataFlowInfo(), property, propertyDescriptor, delegateExpression, parentScope, propertyScope);
resolvePropertyDelegate(c.getOuterDataFlowInfo(), property, propertyDescriptor, delegateExpression, propertyHeaderScope);
}
resolvePropertyAccessors(c, property, propertyDescriptor);
@@ -616,7 +613,7 @@ public class BodyResolver {
PropertyDescriptor propertyDescriptor = c.getProperties().get(property);
assert propertyDescriptor != null;
resolveProperty(c, classDescriptor.getScopeForMemberDeclarationResolution(), property, propertyDescriptor);
resolveProperty(c, property, propertyDescriptor);
processed.add(property);
}
}
@@ -628,19 +625,21 @@ public class BodyResolver {
PropertyDescriptor propertyDescriptor = entry.getValue();
resolveProperty(c, null, property, propertyDescriptor);
resolveProperty(c, property, propertyDescriptor);
}
}
private LexicalScope makeScopeForPropertyAccessor(
private static LexicalScope makeScopeForPropertyAccessor(
@NotNull BodiesResolveContext c, @NotNull KtPropertyAccessor accessor, @NotNull PropertyDescriptor descriptor
) {
LexicalScope accessorDeclaringScope = c.getDeclaringScope(accessor);
assert accessorDeclaringScope != null : "Scope for accessor " + accessor.getText() + " should exists";
return JetScopeUtils.makeScopeForPropertyAccessor(descriptor, accessorDeclaringScope, trace);
LexicalScope headerScope = JetScopeUtils.makeScopeForPropertyHeader(accessorDeclaringScope, descriptor);
return new LexicalScopeImpl(headerScope, descriptor, true, descriptor.getExtensionReceiverParameter(),
LexicalScopeKind.PROPERTY_ACCESSOR);
}
public void resolvePropertyAccessors(
private void resolvePropertyAccessors(
@NotNull BodiesResolveContext c,
@NotNull KtProperty property,
@NotNull PropertyDescriptor propertyDescriptor
@@ -683,54 +682,51 @@ public class BodyResolver {
});
}
public void resolvePropertyDelegate(
private void resolvePropertyDelegate(
@NotNull DataFlowInfo outerDataFlowInfo,
@NotNull KtProperty jetProperty,
@NotNull KtProperty property,
@NotNull PropertyDescriptor propertyDescriptor,
@NotNull KtExpression delegateExpression,
@NotNull LexicalScope parentScopeForAccessor,
@NotNull LexicalScope propertyScope
@NotNull LexicalScope propertyHeaderScope
) {
KtPropertyAccessor getter = jetProperty.getGetter();
KtPropertyAccessor getter = property.getGetter();
if (getter != null && getter.hasBody()) {
trace.report(ACCESSOR_FOR_DELEGATED_PROPERTY.on(getter));
}
KtPropertyAccessor setter = jetProperty.getSetter();
KtPropertyAccessor setter = property.getSetter();
if (setter != null && setter.hasBody()) {
trace.report(ACCESSOR_FOR_DELEGATED_PROPERTY.on(setter));
}
LexicalScope propertyDeclarationInnerScope = JetScopeUtils.getPropertyDeclarationInnerScopeForInitializer(
propertyDescriptor, propertyScope, propertyDescriptor.getTypeParameters(), null, trace);
LexicalScope accessorScope = JetScopeUtils.makeScopeForPropertyAccessor(
propertyDescriptor, parentScopeForAccessor, trace);
LexicalScope delegateFunctionsScope = JetScopeUtils.makeScopeForDelegateConventionFunctions(propertyHeaderScope, propertyDescriptor);
LexicalScope initializerScope = JetScopeUtils.makeScopeForPropertyInitializer(propertyHeaderScope, propertyDescriptor);
KotlinType delegateType = delegatedPropertyResolver.resolveDelegateExpression(
delegateExpression, jetProperty, propertyDescriptor, propertyDeclarationInnerScope, accessorScope, trace,
delegateExpression, property, propertyDescriptor, initializerScope, trace,
outerDataFlowInfo);
delegatedPropertyResolver.resolveDelegatedPropertyGetMethod(propertyDescriptor, delegateExpression, delegateType,
trace, accessorScope);
trace, delegateFunctionsScope);
if (jetProperty.isVar()) {
if (property.isVar()) {
delegatedPropertyResolver.resolveDelegatedPropertySetMethod(propertyDescriptor, delegateExpression, delegateType,
trace, accessorScope);
trace, delegateFunctionsScope);
}
delegatedPropertyResolver.resolveDelegatedPropertyPDMethod(propertyDescriptor, delegateExpression, delegateType,
trace, accessorScope);
trace, delegateFunctionsScope);
}
public void resolvePropertyInitializer(
private void resolvePropertyInitializer(
@NotNull DataFlowInfo outerDataFlowInfo,
@NotNull KtProperty property,
@NotNull PropertyDescriptor propertyDescriptor,
@NotNull KtExpression initializer,
@NotNull LexicalScope scope
@NotNull LexicalScope propertyHeader
) {
LexicalScope propertyDeclarationInnerScope = JetScopeUtils.getPropertyDeclarationInnerScopeForInitializer(
propertyDescriptor, scope, propertyDescriptor.getTypeParameters(), null, trace);
LexicalScope propertyDeclarationInnerScope = JetScopeUtils.makeScopeForPropertyInitializer(propertyHeader, propertyDescriptor);
KotlinType expectedTypeForInitializer = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
if (propertyDescriptor.getCompileTimeInitializer() == null) {
expressionTypingServices.getType(propertyDeclarationInnerScope, initializer, expectedTypeForInitializer,
@@ -33,7 +33,10 @@ import org.jetbrains.kotlin.resolve.calls.inference.TypeVariableKt;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults;
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
import org.jetbrains.kotlin.resolve.scopes.JetScopeUtils;
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeImpl;
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind;
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
import org.jetbrains.kotlin.resolve.validation.OperatorValidator;
import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator;
@@ -87,9 +90,9 @@ public class DelegatedPropertyResolver {
@NotNull KtExpression delegateExpression,
@NotNull KotlinType delegateType,
@NotNull BindingTrace trace,
@NotNull LexicalScope scope
@NotNull LexicalScope delegateFunctionsScope
) {
resolveDelegatedPropertyConventionMethod(propertyDescriptor, delegateExpression, delegateType, trace, scope, true);
resolveDelegatedPropertyConventionMethod(propertyDescriptor, delegateExpression, delegateType, trace, delegateFunctionsScope, true);
ResolvedCall<FunctionDescriptor> resolvedCall =
trace.getBindingContext().get(DELEGATED_PROPERTY_RESOLVED_CALL, propertyDescriptor.getGetter());
return resolvedCall != null ? resolvedCall.getResultingDescriptor().getReturnType() : null;
@@ -311,24 +314,23 @@ public class DelegatedPropertyResolver {
return builder.toString();
}
@Nullable
@NotNull
public KotlinType resolveDelegateExpression(
@NotNull KtExpression delegateExpression,
@NotNull KtProperty jetProperty,
@NotNull PropertyDescriptor propertyDescriptor,
@NotNull LexicalScope propertyDeclarationInnerScope,
@NotNull LexicalScope accessorScope,
@NotNull LexicalScope scopeForDelegate,
@NotNull BindingTrace trace,
@NotNull DataFlowInfo dataFlowInfo
) {
TemporaryBindingTrace traceToResolveDelegatedProperty = TemporaryBindingTrace.create(trace, "Trace to resolve delegated property");
KtExpression calleeExpression = CallUtilKt.getCalleeExpressionIfAny(delegateExpression);
ConstraintSystemCompleter completer = createConstraintSystemCompleter(
jetProperty, propertyDescriptor, delegateExpression, accessorScope, trace);
jetProperty, propertyDescriptor, delegateExpression, scopeForDelegate, trace);
if (calleeExpression != null) {
traceToResolveDelegatedProperty.record(CONSTRAINT_SYSTEM_COMPLETER, calleeExpression, completer);
}
KotlinType delegateType = expressionTypingServices.safeGetType(propertyDeclarationInnerScope, delegateExpression, NO_EXPECTED_TYPE,
KotlinType delegateType = expressionTypingServices.safeGetType(scopeForDelegate, delegateExpression, NO_EXPECTED_TYPE,
dataFlowInfo, traceToResolveDelegatedProperty);
traceToResolveDelegatedProperty.commit(new TraceEntryFilter() {
@Override
@@ -344,9 +346,10 @@ public class DelegatedPropertyResolver {
@NotNull KtProperty property,
@NotNull final PropertyDescriptor propertyDescriptor,
@NotNull final KtExpression delegateExpression,
@NotNull final LexicalScope accessorScope,
@NotNull LexicalScope scopeForDelegate,
@NotNull final BindingTrace trace
) {
final LexicalScope delegateFunctionsScope = JetScopeUtils.makeScopeForDelegateConventionFunctions(scopeForDelegate, propertyDescriptor);
final KotlinType expectedType = property.getTypeReference() != null ? propertyDescriptor.getType() : NO_EXPECTED_TYPE;
return new ConstraintSystemCompleter() {
@Override
@@ -364,7 +367,7 @@ public class DelegatedPropertyResolver {
TemporaryBindingTrace.create(trace, "Trace to resolve delegated property convention methods");
OverloadResolutionResults<FunctionDescriptor>
getMethodResults = getDelegatedPropertyConventionMethod(
propertyDescriptor, delegateExpression, returnType, traceToResolveConventionMethods, accessorScope,
propertyDescriptor, delegateExpression, returnType, traceToResolveConventionMethods, delegateFunctionsScope,
true, false
);
@@ -388,7 +391,7 @@ public class DelegatedPropertyResolver {
OverloadResolutionResults<FunctionDescriptor>
setMethodResults = getDelegatedPropertyConventionMethod(
propertyDescriptor, delegateExpression, returnType, traceToResolveConventionMethods, accessorScope,
propertyDescriptor, delegateExpression, returnType, traceToResolveConventionMethods, delegateFunctionsScope,
false, false
);
@@ -46,10 +46,7 @@ import org.jetbrains.kotlin.resolve.constants.ConstantValue;
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator;
import org.jetbrains.kotlin.resolve.dataClassUtils.DataClassUtilsKt;
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil;
import org.jetbrains.kotlin.resolve.scopes.JetScopeUtils;
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
import org.jetbrains.kotlin.resolve.scopes.LexicalScopeKind;
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope;
import org.jetbrains.kotlin.resolve.scopes.*;
import org.jetbrains.kotlin.resolve.scopes.utils.ScopeUtilsKt;
import org.jetbrains.kotlin.resolve.source.KotlinSourceElementKt;
import org.jetbrains.kotlin.storage.StorageManager;
@@ -796,12 +793,9 @@ public class DescriptorResolver {
ReceiverParameterDescriptor receiverDescriptor =
DescriptorFactory.createExtensionReceiverParameterForCallable(propertyDescriptor, receiverType);
ReceiverParameterDescriptor implicitInitializerReceiver = property.hasDelegate() ? null : receiverDescriptor;
LexicalScope propertyScope = JetScopeUtils.getPropertyDeclarationInnerScope(propertyDescriptor, scope, typeParameterDescriptors,
implicitInitializerReceiver, trace);
KotlinType type = getVariableType(propertyDescriptor, propertyScope, property, dataFlowInfo, true, trace);
KotlinType type = getVariableType(propertyDescriptor,
JetScopeUtils.makeScopeForPropertyInitializer(scopeWithTypeParameters, propertyDescriptor),
property, dataFlowInfo, true, trace);
propertyDescriptor.setType(type, typeParameterDescriptors, getDispatchReceiverParameterIfNeeded(containingDeclaration),
receiverDescriptor);
@@ -836,7 +830,7 @@ public class DescriptorResolver {
@NotNull
private KotlinType getVariableType(
@NotNull final VariableDescriptorWithInitializerImpl variableDescriptor,
@NotNull final LexicalScope scope,
@NotNull final LexicalScope scopeForInitializer,
@NotNull final KtVariableDeclaration variable,
@NotNull final DataFlowInfo dataFlowInfo,
boolean notLocal,
@@ -856,7 +850,7 @@ public class DescriptorResolver {
new Function0<KotlinType>() {
@Override
public KotlinType invoke() {
return resolveDelegatedPropertyType(property, (PropertyDescriptor) variableDescriptor, scope,
return resolveDelegatedPropertyType(property, (PropertyDescriptor) variableDescriptor, scopeForInitializer,
property.getDelegateExpression(), dataFlowInfo, trace);
}
});
@@ -877,23 +871,23 @@ public class DescriptorResolver {
public KotlinType invoke() {
PreliminaryDeclarationVisitor.Companion.createForDeclaration(variable, trace);
KotlinType
initializerType = resolveInitializerType(scope, variable.getInitializer(), dataFlowInfo, trace);
setConstantForVariableIfNeeded(variableDescriptor, scope, variable, dataFlowInfo, initializerType, trace);
initializerType = resolveInitializerType(scopeForInitializer, variable.getInitializer(), dataFlowInfo, trace);
setConstantForVariableIfNeeded(variableDescriptor, scopeForInitializer, variable, dataFlowInfo, initializerType, trace);
return transformAnonymousTypeIfNeeded(variableDescriptor, variable, initializerType, trace);
}
}
);
}
else {
KotlinType initializerType = resolveInitializerType(scope, variable.getInitializer(), dataFlowInfo, trace);
setConstantForVariableIfNeeded(variableDescriptor, scope, variable, dataFlowInfo, initializerType, trace);
KotlinType initializerType = resolveInitializerType(scopeForInitializer, variable.getInitializer(), dataFlowInfo, trace);
setConstantForVariableIfNeeded(variableDescriptor, scopeForInitializer, variable, dataFlowInfo, initializerType, trace);
return initializerType;
}
}
}
else {
KotlinType type = typeResolver.resolveType(scope, propertyTypeRef, trace, true);
setConstantForVariableIfNeeded(variableDescriptor, scope, variable, dataFlowInfo, type, trace);
KotlinType type = typeResolver.resolveType(scopeForInitializer, propertyTypeRef, trace, true);
setConstantForVariableIfNeeded(variableDescriptor, scopeForInitializer, variable, dataFlowInfo, type, trace);
return type;
}
}
@@ -935,19 +929,19 @@ public class DescriptorResolver {
private KotlinType resolveDelegatedPropertyType(
@NotNull KtProperty property,
@NotNull PropertyDescriptor propertyDescriptor,
@NotNull LexicalScope scope,
@NotNull LexicalScope scopeForInitializer,
@NotNull KtExpression delegateExpression,
@NotNull DataFlowInfo dataFlowInfo,
@NotNull BindingTrace trace
) {
LexicalScope accessorScope = JetScopeUtils.makeScopeForPropertyAccessor(propertyDescriptor, scope, trace);
KotlinType type = delegatedPropertyResolver.resolveDelegateExpression(
delegateExpression, property, propertyDescriptor, scope, accessorScope, trace, dataFlowInfo);
delegateExpression, property, propertyDescriptor, scopeForInitializer, trace, dataFlowInfo);
if (type != null) {
LexicalScope delegateFunctionsScope = JetScopeUtils.makeScopeForDelegateConventionFunctions(scopeForInitializer, propertyDescriptor);
KotlinType getterReturnType = delegatedPropertyResolver
.getDelegatedPropertyGetMethodReturnType(propertyDescriptor, delegateExpression, type, trace, accessorScope);
.getDelegatedPropertyGetMethodReturnType(propertyDescriptor, delegateExpression, type, trace, delegateFunctionsScope);
if (getterReturnType != null) {
return getterReturnType;
}
@@ -1014,7 +1008,7 @@ public class DescriptorResolver {
.toSourceElement(setter));
KtTypeReference returnTypeReference = setter.getReturnTypeReference();
if (returnTypeReference != null) {
KotlinType returnType = typeResolver.resolveType(scope, returnTypeReference, trace, true);
KotlinType returnType = typeResolver.resolveType(scopeWithTypeParameters, returnTypeReference, trace, true);
if (!KotlinBuiltIns.isUnit(returnType)) {
trace.report(WRONG_SETTER_RETURN_TYPE.on(returnTypeReference));
}
@@ -22,12 +22,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.resolve.BindingTrace;
import org.jetbrains.kotlin.resolve.TraceBasedRedeclarationHandler;
import org.jetbrains.kotlin.utils.Printer;
import java.util.List;
public final class JetScopeUtils {
private JetScopeUtils() {}
@@ -42,85 +38,41 @@ public final class JetScopeUtils {
});
}
public static LexicalScope makeScopeForPropertyAccessor(
@NotNull PropertyDescriptor propertyDescriptor,
@NotNull LexicalScope parentScope,
@NotNull BindingTrace trace
public static LexicalScope makeScopeForPropertyHeader(
@NotNull LexicalScope parent,
@NotNull final PropertyDescriptor propertyDescriptor
) {
LexicalScope propertyDeclarationInnerScope =
getPropertyDeclarationInnerScope(propertyDescriptor, parentScope,
propertyDescriptor.getTypeParameters(),
propertyDescriptor.getExtensionReceiverParameter(), trace);
return new LexicalScopeImpl(propertyDeclarationInnerScope, parentScope.getOwnerDescriptor(), false, null, LexicalScopeKind.UNSORTED);
}
public static LexicalScope getPropertyDeclarationInnerScope(
@NotNull PropertyDescriptor propertyDescriptor,
@NotNull LexicalScope outerScope,
@NotNull RedeclarationHandler redeclarationHandler
) {
return getPropertyDeclarationInnerScope(propertyDescriptor,
outerScope,
propertyDescriptor.getTypeParameters(),
propertyDescriptor.getExtensionReceiverParameter(),
redeclarationHandler,
true);
}
public static LexicalScope getPropertyDeclarationInnerScope(
@NotNull PropertyDescriptor propertyDescriptor,
@NotNull LexicalScope outerScope,
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
@Nullable ReceiverParameterDescriptor receiver,
BindingTrace trace
) {
return getPropertyDeclarationInnerScope(propertyDescriptor, outerScope, typeParameters, receiver, trace, true);
}
public static LexicalScope getPropertyDeclarationInnerScopeForInitializer(
@NotNull PropertyDescriptor propertyDescriptor,
@NotNull LexicalScope outerScope,
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
@Nullable ReceiverParameterDescriptor receiver,
BindingTrace trace
) {
return getPropertyDeclarationInnerScope(propertyDescriptor, outerScope, typeParameters, receiver, trace, false);
}
private static LexicalScope getPropertyDeclarationInnerScope(
@NotNull PropertyDescriptor propertyDescriptor,
@NotNull LexicalScope outerScope,
@NotNull List<? extends TypeParameterDescriptor> typeParameters,
@Nullable ReceiverParameterDescriptor receiver,
BindingTrace trace,
boolean addLabelForProperty
) {
TraceBasedRedeclarationHandler redeclarationHandler = new TraceBasedRedeclarationHandler(trace);
return getPropertyDeclarationInnerScope(propertyDescriptor, outerScope, typeParameters, receiver, redeclarationHandler,
addLabelForProperty);
return new LexicalScopeImpl(parent, propertyDescriptor, false, null, LexicalScopeKind.PROPERTY_HEADER,
// redeclaration on type parameters should be reported early. see: DescriptorResolver.resolvePropertyDescriptor()
RedeclarationHandler.DO_NOTHING,
new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
@Override
public Unit invoke(LexicalScopeImpl.InitializeHandler handler) {
for (TypeParameterDescriptor typeParameterDescriptor : propertyDescriptor.getTypeParameters()) {
handler.addClassifierDescriptor(typeParameterDescriptor);
}
return Unit.INSTANCE$;
}
});
}
@NotNull
private static LexicalScope getPropertyDeclarationInnerScope(
@NotNull PropertyDescriptor propertyDescriptor,
@NotNull LexicalScope outerScope,
@NotNull final List<? extends TypeParameterDescriptor> typeParameters,
@Nullable ReceiverParameterDescriptor receiver,
@NotNull RedeclarationHandler redeclarationHandler,
boolean addLabelForProperty
public static LexicalScope makeScopeForPropertyInitializer(
@NotNull LexicalScope propertyHeader,
@NotNull PropertyDescriptor propertyDescriptor
) {
return new LexicalScopeImpl(
outerScope, propertyDescriptor, addLabelForProperty, receiver,
LexicalScopeKind.UNSORTED,
redeclarationHandler, new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
@Override
public Unit invoke(LexicalScopeImpl.InitializeHandler handler) {
for (TypeParameterDescriptor typeParameterDescriptor : typeParameters) {
handler.addClassifierDescriptor(typeParameterDescriptor);
}
return Unit.INSTANCE$;
}
});
return new LexicalScopeImpl(propertyHeader, propertyDescriptor, false, null, LexicalScopeKind.PROPERTY_INITIALIZER_OR_DELEGATE);
}
@NotNull
public static LexicalScope makeScopeForDelegateConventionFunctions(
@NotNull LexicalScope parent,
@NotNull PropertyDescriptor propertyDescriptor
) {
// todo: very strange scope!
return new LexicalScopeImpl(parent, propertyDescriptor, true, propertyDescriptor.getExtensionReceiverParameter(),
LexicalScopeKind.PROPERTY_DELEGATE_METHOD
);
}
@TestOnly
@@ -54,8 +54,6 @@ interface LexicalScope: HierarchicalScope {
}
enum class LexicalScopeKind {
@Deprecated("Temporary")
UNSORTED,
EMPTY,
CLASS_HEADER,
@@ -67,9 +65,9 @@ enum class LexicalScopeKind {
CLASS_INITIALIZER,
PROPERTY_HEADER,
PROPERTY_INITIALIZER,
PROPERTY_DELEGATE,
PROPERTY_INITIALIZER_OR_DELEGATE,
PROPERTY_ACCESSOR,
PROPERTY_DELEGATE_METHOD,
FUNCTION_HEADER,
FUNCTION_INNER_SCOPE,
@@ -2,5 +2,5 @@ fun <<!REDECLARATION, REDECLARATION!>T<!>, <!REDECLARATION, REDECLARATION!>T<!>>
class P<<!REDECLARATION!>T<!>, <!REDECLARATION!>T<!>> {}
val <<!REDECLARATION, REDECLARATION, REDECLARATION, TYPE_PARAMETER_OF_PROPERTY_NOT_USED_IN_RECEIVER!>T<!>, <!REDECLARATION, REDECLARATION, REDECLARATION!>T<!>> T.foo : Int
val <<!REDECLARATION, TYPE_PARAMETER_OF_PROPERTY_NOT_USED_IN_RECEIVER!>T<!>, <!REDECLARATION!>T<!>> T.foo : Int
get() = 1
@@ -1,10 +1,10 @@
package i
val <T> List<T>.length = <!EXTENSION_PROPERTY_WITH_BACKING_FIELD!>size<!>
val <T> List<T>.length = <!UNRESOLVED_REFERENCE, EXTENSION_PROPERTY_WITH_BACKING_FIELD!>size<!>
val <T> List<T>.length1 : Int get() = size
val String.bd = <!EXTENSION_PROPERTY_WITH_BACKING_FIELD!>this + "!"<!>
val String.bd = <!EXTENSION_PROPERTY_WITH_BACKING_FIELD!><!NO_THIS!>this<!> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>+<!> "!"<!>
val String.bd1 : String get() = this + "!"
@@ -13,7 +13,7 @@ class A {
val ii : Int = 1
}
val A.foo = <!EXTENSION_PROPERTY_WITH_BACKING_FIELD!>ii<!>
val A.foo = <!UNRESOLVED_REFERENCE, EXTENSION_PROPERTY_WITH_BACKING_FIELD!>ii<!>
val A.foo1 : Int get() = ii
@@ -2,13 +2,13 @@ package
package i {
public val i.C.bar: i.C.D
public val kotlin.String.bd: kotlin.String
public val kotlin.String.bd: [ERROR : <ERROR FUNCTION RETURN TYPE>]
public val kotlin.String.bd1: kotlin.String
public val i.A.foo: kotlin.Int = 1
public val i.A.foo: [ERROR : Type for ii]
public val i.C.foo: i.C.D
public val i.A.foo1: kotlin.Int
public val i.C.foo1: i.C.D
public val </*0*/ T> kotlin.List<T>.length: kotlin.Int
public val </*0*/ T> kotlin.List<T>.length: [ERROR : Type for size]
public val </*0*/ T> kotlin.List<T>.length1: kotlin.Int
public final class A {
@@ -65,8 +65,8 @@ public final fun get(/*0*/ p0: dynamic): dynamic
public final fun divAssign(/*0*/ p0: dynamic): dynamic
public final fun get(/*0*/ p0: dynamic): dynamic
public final fun modAssign(/*0*/ p0: dynamic): dynamic
public fun getValue(/*0*/ p0: dynamic, /*1*/ p1: dynamic): dynamic
public fun propertyDelegated(/*0*/ p0: dynamic): dynamic
public fun getValue(/*0*/ p0: dynamic, /*1*/ p1: dynamic): dynamic
public fun setValue(/*0*/ p0: dynamic, /*1*/ p1: dynamic, /*2*/ p2: dynamic): dynamic
public fun propertyDelegated(/*0*/ p0: dynamic): dynamic
public final fun getValue(/*0*/ p0: dynamic, /*1*/ p1: dynamic): dynamic
public final fun propertyDelegated(/*0*/ p0: dynamic): dynamic
public final fun getValue(/*0*/ p0: dynamic, /*1*/ p1: dynamic): dynamic
public final fun setValue(/*0*/ p0: dynamic, /*1*/ p1: dynamic, /*2*/ p2: dynamic): dynamic
public final fun propertyDelegated(/*0*/ p0: dynamic): dynamic
@@ -167,9 +167,7 @@ public fun getResolutionScope(resolutionFacade: ResolutionFacade, descriptor: De
descriptor, RedeclarationHandler.DO_NOTHING)
is PropertyDescriptor ->
JetScopeUtils.getPropertyDeclarationInnerScope(descriptor,
getOuterScope(descriptor, resolutionFacade),
RedeclarationHandler.DO_NOTHING)
JetScopeUtils.makeScopeForPropertyHeader(getOuterScope(descriptor, resolutionFacade), descriptor)
is DeclarationDescriptorNonRoot ->
getOuterScope(descriptor, resolutionFacade)
@@ -413,28 +413,19 @@ public class ResolveElementCache(
private fun propertyAdditionalResolve(resolveSession: ResolveSession, property: KtProperty, file: KtFile, statementFilter: StatementFilter): BindingTrace {
val trace = createDelegatingTrace(property)
val propertyResolutionScope = resolveSession.declarationScopeProvider.getResolutionScopeForDeclaration(property)
val bodyResolver = createBodyResolver(resolveSession, trace, file, statementFilter)
val descriptor = resolveSession.resolveToDescriptor(property) as PropertyDescriptor
ForceResolveUtil.forceResolveAllContents(descriptor)
val propertyInitializer = property.getInitializer()
if (propertyInitializer != null) {
bodyResolver.resolvePropertyInitializer(DataFlowInfo.EMPTY, property, descriptor, propertyInitializer, propertyResolutionScope)
}
val propertyDelegate = property.getDelegateExpression()
if (propertyDelegate != null) {
bodyResolver.resolvePropertyDelegate(DataFlowInfo.EMPTY, property, descriptor, propertyDelegate, propertyResolutionScope, propertyResolutionScope)
}
val bodyResolveContext = BodyResolveContextForLazy(TopDownAnalysisMode.LocalDeclarations, { declaration ->
assert(declaration.getParent() == property) { "Must be called only for property accessors, but called for $declaration" }
assert(declaration.getParent() == property || declaration == property) {
"Must be called only for property accessors or for property, but called for $declaration"
}
resolveSession.declarationScopeProvider.getResolutionScopeForDeclaration(declaration)
})
bodyResolver.resolvePropertyAccessors(bodyResolveContext, property, descriptor)
bodyResolver.resolveProperty(bodyResolveContext, property, descriptor)
forceResolveAnnotationsInside(property)
@@ -259,7 +259,8 @@ object ReplaceWithAnnotationAnalyzer {
is PropertyDescriptor -> {
val outerScope = getResolutionScope(descriptor.containingDeclaration, ownerDescriptor, additionalScopes) ?: return null
JetScopeUtils.getPropertyDeclarationInnerScope(descriptor, outerScope, RedeclarationHandler.DO_NOTHING)
val propertyHeader = JetScopeUtils.makeScopeForPropertyHeader(outerScope, descriptor)
LexicalScopeImpl(propertyHeader, descriptor, false, descriptor.extensionReceiverParameter, LexicalScopeKind.PROPERTY_ACCESSOR)
}
else -> return null // something local, should not work with ReplaceWith