Merge remote branch 'origin/master'
This commit is contained in:
+17
-56
@@ -10,11 +10,7 @@ import org.jetbrains.jet.lang.resolve.AbstractScopeAdapter;
|
|||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||||
import org.jetbrains.jet.lang.resolve.TraceBasedRedeclarationHandler;
|
import org.jetbrains.jet.lang.resolve.TraceBasedRedeclarationHandler;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
import org.jetbrains.jet.lang.resolve.scopes.*;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
|
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.SubstitutingScope;
|
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
|
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ClassReceiver;
|
import org.jetbrains.jet.lang.resolve.scopes.receivers.ClassReceiver;
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||||
import org.jetbrains.jet.lang.types.*;
|
import org.jetbrains.jet.lang.types.*;
|
||||||
@@ -37,15 +33,11 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme
|
|||||||
private Modality modality;
|
private Modality modality;
|
||||||
private Visibility visibility;
|
private Visibility visibility;
|
||||||
private TypeConstructor typeConstructor;
|
private TypeConstructor typeConstructor;
|
||||||
private final RedeclarationHandler redeclarationHandler;
|
|
||||||
private final WritableScope scopeForMemberResolution;
|
private final WritableScope scopeForMemberResolution;
|
||||||
private final WritableScope scopeForMemberLookup;
|
private final WritableScope scopeForMemberLookup;
|
||||||
// This scope contains type parameters but does not contain inner classes
|
// This scope contains type parameters but does not contain inner classes
|
||||||
private final WritableScope scopeForSupertypeResolution;
|
private final WritableScope scopeForSupertypeResolution;
|
||||||
private final WritableScope scopeForAnyConstructor;
|
private final WritableScope scopeForInitializers; //contains members + primary constructor value parameters + map for backing fields
|
||||||
private final Map<ConstructorDescriptor, WritableScope> scopesForConstructors;
|
|
||||||
// for primary constructor and property initializers
|
|
||||||
private final WritableScope scopeForPrimaryConstructor;
|
|
||||||
|
|
||||||
private MutableClassDescriptor classObjectDescriptor;
|
private MutableClassDescriptor classObjectDescriptor;
|
||||||
private JetType classObjectType;
|
private JetType classObjectType;
|
||||||
@@ -57,18 +49,10 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme
|
|||||||
public MutableClassDescriptor(@NotNull BindingTrace trace, @NotNull DeclarationDescriptor containingDeclaration, @NotNull JetScope outerScope, ClassKind kind) {
|
public MutableClassDescriptor(@NotNull BindingTrace trace, @NotNull DeclarationDescriptor containingDeclaration, @NotNull JetScope outerScope, ClassKind kind) {
|
||||||
super(containingDeclaration);
|
super(containingDeclaration);
|
||||||
TraceBasedRedeclarationHandler redeclarationHandler = new TraceBasedRedeclarationHandler(trace);
|
TraceBasedRedeclarationHandler redeclarationHandler = new TraceBasedRedeclarationHandler(trace);
|
||||||
this.redeclarationHandler = redeclarationHandler;
|
this.scopeForMemberLookup = new WritableScopeImpl(JetScope.EMPTY, this, redeclarationHandler).setDebugName("MemberLookup").changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||||
this.scopeForMemberLookup = new WritableScopeImpl(JetScope.EMPTY, this, redeclarationHandler).setDebugName("MemberLookup");
|
this.scopeForSupertypeResolution = new WritableScopeImpl(outerScope, this, redeclarationHandler).setDebugName("SupertypeResolution").changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||||
this.scopeForMemberLookup.changeLockLevel(WritableScope.LockLevel.BOTH);
|
this.scopeForMemberResolution = new WritableScopeImpl(scopeForSupertypeResolution, this, redeclarationHandler).setDebugName("MemberResolution").changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||||
this.scopeForSupertypeResolution = new WritableScopeImpl(outerScope, this, redeclarationHandler).setDebugName("SupertypeResolution");
|
this.scopeForInitializers = new WritableScopeImpl(scopeForMemberResolution, this, redeclarationHandler).setDebugName("PropertyInitializers").changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||||
this.scopeForSupertypeResolution.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
this.scopeForMemberResolution = new WritableScopeImpl(scopeForSupertypeResolution, this, redeclarationHandler).setDebugName("MemberResolution");
|
|
||||||
this.scopeForMemberResolution.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
this.scopeForAnyConstructor = new WritableScopeImpl(scopeForMemberResolution, this, redeclarationHandler).setDebugName("AnyConstrutor");
|
|
||||||
this.scopeForAnyConstructor.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
this.scopeForPrimaryConstructor = new WritableScopeImpl(scopeForAnyConstructor, this, redeclarationHandler).setDebugName("PrimaryConstructor");
|
|
||||||
this.scopeForPrimaryConstructor.changeLockLevel(WritableScope.LockLevel.BOTH);
|
|
||||||
this.scopesForConstructors = new HashMap<ConstructorDescriptor, WritableScope>();
|
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,32 +116,19 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme
|
|||||||
|
|
||||||
public void addConstructor(@NotNull ConstructorDescriptor constructorDescriptor, BindingTrace trace) {
|
public void addConstructor(@NotNull ConstructorDescriptor constructorDescriptor, BindingTrace trace) {
|
||||||
assert constructorDescriptor.getContainingDeclaration() == this;
|
assert constructorDescriptor.getContainingDeclaration() == this;
|
||||||
// assert constructorDescriptor.getTypeParameters().size() == getTypeConstructor().getValueParameters().size();
|
|
||||||
constructors.add(constructorDescriptor);
|
constructors.add(constructorDescriptor);
|
||||||
if (defaultType != null) {
|
if (defaultType != null) {
|
||||||
// constructorDescriptor.getTypeParameters().addAll(typeParameters);
|
|
||||||
((ConstructorDescriptorImpl) constructorDescriptor).setReturnType(getDefaultType());
|
((ConstructorDescriptorImpl) constructorDescriptor).setReturnType(getDefaultType());
|
||||||
}
|
}
|
||||||
|
if (constructorDescriptor.isPrimary()) {
|
||||||
WritableScope scope = constructorDescriptor.isPrimary() ?
|
for (ValueParameterDescriptor valueParameterDescriptor : constructorDescriptor.getValueParameters()) {
|
||||||
scopeForPrimaryConstructor :
|
JetParameter parameter = (JetParameter) trace.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, valueParameterDescriptor);
|
||||||
new WritableScopeImpl(scopeForAnyConstructor, this, redeclarationHandler).setDebugName("SecondaryConstructor");
|
assert parameter != null;
|
||||||
|
if (parameter.getValOrVarNode() == null || !constructorDescriptor.isPrimary()) {
|
||||||
WritableScope old = scopesForConstructors.put(constructorDescriptor, scope);
|
scopeForInitializers.addVariableDescriptor(valueParameterDescriptor);
|
||||||
if (old != null) {
|
}
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ValueParameterDescriptor valueParameterDescriptor : constructorDescriptor.getValueParameters()) {
|
|
||||||
JetParameter parameter = (JetParameter) trace.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, valueParameterDescriptor);
|
|
||||||
if (parameter.getValOrVarNode() == null || !constructorDescriptor.isPrimary()) {
|
|
||||||
scope.addVariableDescriptor(valueParameterDescriptor);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.addLabeledDeclaration(constructorDescriptor); // TODO : Labels for constructors?!
|
|
||||||
|
|
||||||
scope.changeLockLevel(WritableScope.LockLevel.READING);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -166,7 +137,7 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme
|
|||||||
callableMembers.add(propertyDescriptor);
|
callableMembers.add(propertyDescriptor);
|
||||||
scopeForMemberLookup.addVariableDescriptor(propertyDescriptor);
|
scopeForMemberLookup.addVariableDescriptor(propertyDescriptor);
|
||||||
scopeForMemberResolution.addVariableDescriptor(propertyDescriptor);
|
scopeForMemberResolution.addVariableDescriptor(propertyDescriptor);
|
||||||
scopeForAnyConstructor.addPropertyDescriptorByFieldName("$" + propertyDescriptor.getName(), propertyDescriptor);
|
scopeForInitializers.addPropertyDescriptorByFieldName("$" + propertyDescriptor.getName(), propertyDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -299,13 +270,8 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JetScope getScopeForConstructor(@NotNull ConstructorDescriptor constructorDescriptor) {
|
public JetScope getScopeForInitializers() {
|
||||||
return scopesForConstructors.get(constructorDescriptor);
|
return scopeForInitializers;
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public JetScope getScopeForPropertyIntiailizer() {
|
|
||||||
return scopeForPrimaryConstructor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -399,12 +365,7 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme
|
|||||||
scopeForSupertypeResolution.changeLockLevel(WritableScope.LockLevel.READING);
|
scopeForSupertypeResolution.changeLockLevel(WritableScope.LockLevel.READING);
|
||||||
scopeForMemberLookup.changeLockLevel(WritableScope.LockLevel.READING);
|
scopeForMemberLookup.changeLockLevel(WritableScope.LockLevel.READING);
|
||||||
scopeForMemberResolution.changeLockLevel(WritableScope.LockLevel.READING);
|
scopeForMemberResolution.changeLockLevel(WritableScope.LockLevel.READING);
|
||||||
scopeForAnyConstructor.changeLockLevel(WritableScope.LockLevel.READING);
|
scopeForInitializers.changeLockLevel(WritableScope.LockLevel.READING);
|
||||||
scopeForPrimaryConstructor.changeLockLevel(WritableScope.LockLevel.READING);
|
|
||||||
for (WritableScope scope : scopesForConstructors.values()) {
|
|
||||||
scope.changeLockLevel(WritableScope.LockLevel.READING);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (classObjectDescriptor != null) {
|
if (classObjectDescriptor != null) {
|
||||||
classObjectDescriptor.lockScopes();
|
classObjectDescriptor.lockScopes();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab
|
|||||||
private final boolean isVar;
|
private final boolean isVar;
|
||||||
private final ReceiverDescriptor expectedThisObject;
|
private final ReceiverDescriptor expectedThisObject;
|
||||||
private final Set<PropertyDescriptor> overriddenProperties = Sets.newLinkedHashSet();
|
private final Set<PropertyDescriptor> overriddenProperties = Sets.newLinkedHashSet();
|
||||||
private final Set<PropertyDescriptor> overridingProperties = Sets.newLinkedHashSet();
|
|
||||||
private final PropertyDescriptor original;
|
private final PropertyDescriptor original;
|
||||||
|
|
||||||
private ReceiverDescriptor receiver;
|
private ReceiverDescriptor receiver;
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public class BodyResolver {
|
|||||||
final ConstructorDescriptor primaryConstructor = descriptor.getUnsubstitutedPrimaryConstructor();
|
final ConstructorDescriptor primaryConstructor = descriptor.getUnsubstitutedPrimaryConstructor();
|
||||||
final JetScope scopeForConstructor = primaryConstructor == null
|
final JetScope scopeForConstructor = primaryConstructor == null
|
||||||
? null
|
? null
|
||||||
: getInnerScopeForConstructor(primaryConstructor);
|
: FunctionDescriptorUtil.getFunctionInnerScope(descriptor.getScopeForSupertypeResolution(), primaryConstructor, traceForConstructors);
|
||||||
final ExpressionTypingServices typeInferrer = context.getSemanticServices().getTypeInferrerServices(traceForConstructors); // TODO : flow
|
final ExpressionTypingServices typeInferrer = context.getSemanticServices().getTypeInferrerServices(traceForConstructors); // TODO : flow
|
||||||
|
|
||||||
final Map<JetTypeReference, JetType> supertypes = Maps.newLinkedHashMap();
|
final Map<JetTypeReference, JetType> supertypes = Maps.newLinkedHashMap();
|
||||||
@@ -267,10 +267,10 @@ public class BodyResolver {
|
|||||||
if (jetClassOrObject.hasPrimaryConstructor()) {
|
if (jetClassOrObject.hasPrimaryConstructor()) {
|
||||||
ConstructorDescriptor primaryConstructor = classDescriptor.getUnsubstitutedPrimaryConstructor();
|
ConstructorDescriptor primaryConstructor = classDescriptor.getUnsubstitutedPrimaryConstructor();
|
||||||
assert primaryConstructor != null;
|
assert primaryConstructor != null;
|
||||||
final JetScope scopeForConstructor = getInnerScopeForConstructor(primaryConstructor);
|
final JetScope scopeForInitializers = classDescriptor.getScopeForInitializers();
|
||||||
ExpressionTypingServices typeInferrer = context.getSemanticServices().getTypeInferrerServices(traceForConstructors);
|
ExpressionTypingServices typeInferrer = context.getSemanticServices().getTypeInferrerServices(traceForConstructors);
|
||||||
for (JetClassInitializer anonymousInitializer : anonymousInitializers) {
|
for (JetClassInitializer anonymousInitializer : anonymousInitializers) {
|
||||||
typeInferrer.getType(scopeForConstructor, anonymousInitializer.getBody(), NO_EXPECTED_TYPE);
|
typeInferrer.getType(scopeForInitializers, anonymousInitializer.getBody(), NO_EXPECTED_TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -285,15 +285,19 @@ public class BodyResolver {
|
|||||||
JetSecondaryConstructor constructor = entry.getKey();
|
JetSecondaryConstructor constructor = entry.getKey();
|
||||||
ConstructorDescriptor descriptor = entry.getValue();
|
ConstructorDescriptor descriptor = entry.getValue();
|
||||||
|
|
||||||
resolveSecondaryConstructorBody(constructor, descriptor, ((MutableClassDescriptor) descriptor.getContainingDeclaration()).getScopeForMemberResolution());
|
resolveSecondaryConstructorBody(constructor, descriptor);
|
||||||
|
|
||||||
assert descriptor.getReturnType() != null;
|
assert descriptor.getReturnType() != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resolveSecondaryConstructorBody(JetSecondaryConstructor declaration, final ConstructorDescriptor descriptor, final JetScope declaringScope) {
|
private void resolveSecondaryConstructorBody(JetSecondaryConstructor declaration, final ConstructorDescriptor descriptor) {
|
||||||
if (!context.completeAnalysisNeeded(declaration)) return;
|
if (!context.completeAnalysisNeeded(declaration)) return;
|
||||||
final JetScope functionInnerScope = getInnerScopeForConstructor(descriptor);
|
MutableClassDescriptor classDescriptor = (MutableClassDescriptor) descriptor.getContainingDeclaration();
|
||||||
|
final JetScope scopeForSupertypeInitializers = FunctionDescriptorUtil.getFunctionInnerScope(classDescriptor.getScopeForSupertypeResolution(), descriptor, traceForConstructors);
|
||||||
|
//contains only constructor parameters
|
||||||
|
final JetScope scopeForConstructorBody = FunctionDescriptorUtil.getFunctionInnerScope(classDescriptor.getScopeForInitializers(), descriptor, traceForConstructors);
|
||||||
|
//contains members & backing fields
|
||||||
|
|
||||||
final CallResolver callResolver = new CallResolver(context.getSemanticServices(), DataFlowInfo.EMPTY); // TODO: dataFlowInfo
|
final CallResolver callResolver = new CallResolver(context.getSemanticServices(), DataFlowInfo.EMPTY); // TODO: dataFlowInfo
|
||||||
|
|
||||||
@@ -313,8 +317,7 @@ public class BodyResolver {
|
|||||||
public void visitDelegationToSuperCallSpecifier(JetDelegatorToSuperCall call) {
|
public void visitDelegationToSuperCallSpecifier(JetDelegatorToSuperCall call) {
|
||||||
JetTypeReference typeReference = call.getTypeReference();
|
JetTypeReference typeReference = call.getTypeReference();
|
||||||
if (typeReference != null) {
|
if (typeReference != null) {
|
||||||
callResolver.resolveCall(context.getTrace(), functionInnerScope,
|
callResolver.resolveCall(context.getTrace(), scopeForSupertypeInitializers, CallMaker.makeCall(ReceiverDescriptor.NO_RECEIVER, null, call), NO_EXPECTED_TYPE);
|
||||||
CallMaker.makeCall(ReceiverDescriptor.NO_RECEIVER, null, call), NO_EXPECTED_TYPE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,7 +328,7 @@ public class BodyResolver {
|
|||||||
ClassDescriptor classDescriptor = descriptor.getContainingDeclaration();
|
ClassDescriptor classDescriptor = descriptor.getContainingDeclaration();
|
||||||
|
|
||||||
callResolver.resolveCall(context.getTrace(),
|
callResolver.resolveCall(context.getTrace(),
|
||||||
functionInnerScope,
|
scopeForSupertypeInitializers,
|
||||||
CallMaker.makeCall(ReceiverDescriptor.NO_RECEIVER, null, call), NO_EXPECTED_TYPE);
|
CallMaker.makeCall(ReceiverDescriptor.NO_RECEIVER, null, call), NO_EXPECTED_TYPE);
|
||||||
// call.getThisReference(),
|
// call.getThisReference(),
|
||||||
// classDescriptor,
|
// classDescriptor,
|
||||||
@@ -357,20 +360,12 @@ public class BodyResolver {
|
|||||||
}
|
}
|
||||||
JetExpression bodyExpression = declaration.getBodyExpression();
|
JetExpression bodyExpression = declaration.getBodyExpression();
|
||||||
if (bodyExpression != null) {
|
if (bodyExpression != null) {
|
||||||
//context.getDescriptorResolver().computeFlowData(declaration, bodyExpression);
|
|
||||||
//JetFlowInformationProvider flowInformationProvider = context.getDescriptorResolver().computeFlowData(declaration, bodyExpression);
|
|
||||||
ExpressionTypingServices typeInferrer = context.getSemanticServices().getTypeInferrerServices(traceForConstructors);
|
ExpressionTypingServices typeInferrer = context.getSemanticServices().getTypeInferrerServices(traceForConstructors);
|
||||||
|
|
||||||
typeInferrer.checkFunctionReturnType(functionInnerScope, declaration, JetStandardClasses.getUnitType());
|
typeInferrer.checkFunctionReturnType(scopeForConstructorBody, declaration, JetStandardClasses.getUnitType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private JetScope getInnerScopeForConstructor(@NotNull ConstructorDescriptor descriptor) {
|
|
||||||
MutableClassDescriptor mutableClassDescriptor = (MutableClassDescriptor) descriptor.getContainingDeclaration();
|
|
||||||
return mutableClassDescriptor.getScopeForConstructor(descriptor);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void resolvePropertyDeclarationBodies() {
|
private void resolvePropertyDeclarationBodies() {
|
||||||
|
|
||||||
// Member properties
|
// Member properties
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ public class DeclarationResolver {
|
|||||||
MutableClassDescriptor classDescriptor = entry.getValue();
|
MutableClassDescriptor classDescriptor = entry.getValue();
|
||||||
|
|
||||||
resolveFunctionAndPropertyHeaders(jetClass.getDeclarations(), classDescriptor.getScopeForMemberResolution(),
|
resolveFunctionAndPropertyHeaders(jetClass.getDeclarations(), classDescriptor.getScopeForMemberResolution(),
|
||||||
classDescriptor.getScopeForPropertyIntiailizer(), classDescriptor.getScopeForMemberResolution(),
|
classDescriptor.getScopeForInitializers(), classDescriptor.getScopeForMemberResolution(),
|
||||||
classDescriptor);
|
classDescriptor);
|
||||||
// processPrimaryConstructor(classDescriptor, jetClass);
|
// processPrimaryConstructor(classDescriptor, jetClass);
|
||||||
// for (JetSecondaryConstructor jetConstructor : jetClass.getSecondaryConstructors()) {
|
// for (JetSecondaryConstructor jetConstructor : jetClass.getSecondaryConstructors()) {
|
||||||
@@ -86,7 +86,7 @@ public class DeclarationResolver {
|
|||||||
MutableClassDescriptor classDescriptor = entry.getValue();
|
MutableClassDescriptor classDescriptor = entry.getValue();
|
||||||
|
|
||||||
resolveFunctionAndPropertyHeaders(object.getDeclarations(), classDescriptor.getScopeForMemberResolution(),
|
resolveFunctionAndPropertyHeaders(object.getDeclarations(), classDescriptor.getScopeForMemberResolution(),
|
||||||
classDescriptor.getScopeForPropertyIntiailizer(), classDescriptor.getScopeForMemberResolution(),
|
classDescriptor.getScopeForInitializers(), classDescriptor.getScopeForMemberResolution(),
|
||||||
classDescriptor);
|
classDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -161,6 +161,9 @@ public class CallResolver {
|
|||||||
else if (calleeExpression instanceof JetThisReferenceExpression) {
|
else if (calleeExpression instanceof JetThisReferenceExpression) {
|
||||||
functionReference = (JetThisReferenceExpression) calleeExpression;
|
functionReference = (JetThisReferenceExpression) calleeExpression;
|
||||||
DeclarationDescriptor containingDeclaration = scope.getContainingDeclaration();
|
DeclarationDescriptor containingDeclaration = scope.getContainingDeclaration();
|
||||||
|
if (containingDeclaration instanceof ConstructorDescriptor) {
|
||||||
|
containingDeclaration = containingDeclaration.getContainingDeclaration();
|
||||||
|
}
|
||||||
assert containingDeclaration instanceof ClassDescriptor;
|
assert containingDeclaration instanceof ClassDescriptor;
|
||||||
ClassDescriptor classDescriptor = (ClassDescriptor) containingDeclaration;
|
ClassDescriptor classDescriptor = (ClassDescriptor) containingDeclaration;
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public interface WritableScope extends JetScope {
|
|||||||
READING,
|
READING,
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeLockLevel(LockLevel lockLevel);
|
WritableScope changeLockLevel(LockLevel lockLevel);
|
||||||
|
|
||||||
void addLabeledDeclaration(@NotNull DeclarationDescriptor descriptor);
|
void addLabeledDeclaration(@NotNull DeclarationDescriptor descriptor);
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -36,11 +36,12 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement
|
|||||||
private LockLevel lockLevel = LockLevel.WRITING;
|
private LockLevel lockLevel = LockLevel.WRITING;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changeLockLevel(LockLevel lockLevel) {
|
public WritableScope changeLockLevel(LockLevel lockLevel) {
|
||||||
if (lockLevel.ordinal() < this.lockLevel.ordinal()) {
|
if (lockLevel.ordinal() < this.lockLevel.ordinal()) {
|
||||||
throw new IllegalStateException("cannot lower lock level from " + this.lockLevel + " to " + lockLevel);
|
throw new IllegalStateException("cannot lower lock level from " + this.lockLevel + " to " + lockLevel);
|
||||||
}
|
}
|
||||||
this.lockLevel = lockLevel;
|
this.lockLevel = lockLevel;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkMayRead() {
|
protected void checkMayRead() {
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
// +JDK
|
||||||
|
|
||||||
|
namespace kt_250_617_10
|
||||||
|
|
||||||
|
import java.util.ArrayList
|
||||||
|
import java.util.HashMap
|
||||||
|
|
||||||
|
//KT-250 Incorrect variable resolve in constructor arguments of superclass
|
||||||
|
open class A(val x: Int)
|
||||||
|
class B(y: Int) : A(<!UNRESOLVED_REFERENCE!>x<!>) //x is resolved as a property in a, so no error is generated
|
||||||
|
|
||||||
|
//KT-617 Prohibit dollars in call to superclass constructors
|
||||||
|
open class M(p: Int)
|
||||||
|
class N(val p: Int) : A(<!UNRESOLVED_REFERENCE!>$p<!>)
|
||||||
|
|
||||||
|
//KT-10 Don't allow to use properties in supertype initializers
|
||||||
|
open class Element()
|
||||||
|
class TextElement(name: String) : Element()
|
||||||
|
|
||||||
|
abstract class Tag(val name : String) {
|
||||||
|
val children = ArrayList<Element>()
|
||||||
|
val attributes = HashMap<String, String>()
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class TagWithText(name : String) : Tag(name) {
|
||||||
|
fun String.plus() {
|
||||||
|
children.add(TextElement(this))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class BodyTag(name : String) : TagWithText(name) {
|
||||||
|
}
|
||||||
|
|
||||||
|
class Body() : BodyTag(<!UNRESOLVED_REFERENCE!>name<!>) { // Must be an error!
|
||||||
|
}
|
||||||
|
class Body1() : BodyTag(<!NO_THIS!>this<!>.name) { // Must be an error!
|
||||||
|
}
|
||||||
|
|
||||||
|
//more tests
|
||||||
|
|
||||||
|
open class X(p: Int, r: Int) {
|
||||||
|
val s = "s"
|
||||||
|
}
|
||||||
|
|
||||||
|
class Y(i: Int) : X(i, <!UNRESOLVED_REFERENCE!>rrr<!>) {
|
||||||
|
val rrr = 3
|
||||||
|
this(s: Int, r: Int) : this(s, <!UNRESOLVED_REFERENCE!>rrr<!>)
|
||||||
|
}
|
||||||
|
|
||||||
|
class Z(val i: Int) : X(<!UNRESOLVED_REFERENCE!>s<!>, <!UNRESOLVED_REFERENCE!>x<!>) {
|
||||||
|
val x = 2
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user