Added error 'NESTED_CLASS_SHOULD_BE_QUALIFIED'
when nested class is resolved through implicit this
This commit is contained in:
@@ -602,6 +602,7 @@ public interface Errors {
|
||||
DiagnosticFactory1<JetSimpleNameExpression, TypeParameterDescriptor> TYPE_PARAMETER_IS_NOT_AN_EXPRESSION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetSimpleNameExpression, TypeParameterDescriptor> TYPE_PARAMETER_ON_LHS_OF_DOT = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetExpression, ClassDescriptor> NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory1<JetExpression, ClassDescriptor> NESTED_CLASS_SHOULD_BE_QUALIFIED = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<PsiElement, ClassDescriptor> INACCESSIBLE_OUTER_CLASS_EXPRESSION = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory0<JetClass> NESTED_CLASS_NOT_ALLOWED = DiagnosticFactory0.create(ERROR, DECLARATION_NAME);
|
||||
|
||||
+1
@@ -262,6 +262,7 @@ public class DefaultErrorMessages {
|
||||
MAP.put(TYPE_PARAMETER_ON_LHS_OF_DOT, "Type parameter ''{0}'' cannot have or inherit a class object, so it cannot be on the left hand side of dot", NAME);
|
||||
MAP.put(NO_GENERICS_IN_SUPERTYPE_SPECIFIER, "Generic arguments of the base type must be specified");
|
||||
MAP.put(NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE, "Nested {0} accessed via instance reference", RENDER_CLASS_OR_OBJECT_NAME);
|
||||
MAP.put(NESTED_CLASS_SHOULD_BE_QUALIFIED, "Nested {0} should be qualified", RENDER_CLASS_OR_OBJECT_NAME);
|
||||
|
||||
MAP.put(INACCESSIBLE_OUTER_CLASS_EXPRESSION, "Expression is inaccessible from a nested class ''{0}'', use ''inner'' keyword to make the class inner", NAME);
|
||||
MAP.put(NESTED_CLASS_NOT_ALLOWED, "Nested class is not allowed here, use ''inner'' keyword to make the class inner");
|
||||
|
||||
@@ -188,7 +188,7 @@ public class CandidateResolver {
|
||||
nestedClass = ((FakeCallableDescriptorForObject) candidateDescriptor).getReferencedDescriptor();
|
||||
}
|
||||
if (nestedClass != null) {
|
||||
context.tracing.nestedClassAccessViaInstanceReference(context.trace, nestedClass);
|
||||
context.tracing.nestedClassAccessViaInstanceReference(context.trace, nestedClass, candidateCall.getExplicitReceiverKind());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-2
@@ -128,8 +128,17 @@ public abstract class AbstractTracingStrategy implements TracingStrategy {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void nestedClassAccessViaInstanceReference(@NotNull BindingTrace trace, @NotNull ClassDescriptor classDescriptor) {
|
||||
trace.report(NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE.on(reference, classDescriptor));
|
||||
public void nestedClassAccessViaInstanceReference(
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull ClassDescriptor classDescriptor,
|
||||
@NotNull ExplicitReceiverKind explicitReceiverKind
|
||||
) {
|
||||
if (explicitReceiverKind == ExplicitReceiverKind.NO_EXPLICIT_RECEIVER) {
|
||||
trace.report(NESTED_CLASS_SHOULD_BE_QUALIFIED.on(reference, classDescriptor));
|
||||
}
|
||||
else {
|
||||
trace.report(NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE.on(reference, classDescriptor));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+10
-2
@@ -81,7 +81,11 @@ public interface TracingStrategy {
|
||||
public void instantiationOfAbstractClass(@NotNull BindingTrace trace) {}
|
||||
|
||||
@Override
|
||||
public void nestedClassAccessViaInstanceReference(@NotNull BindingTrace trace, @NotNull ClassDescriptor classDescriptor) {}
|
||||
public void nestedClassAccessViaInstanceReference(
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull ClassDescriptor classDescriptor,
|
||||
@NotNull ExplicitReceiverKind explicitReceiverKind
|
||||
) {}
|
||||
|
||||
@Override
|
||||
public void unsafeCall(@NotNull BindingTrace trace, @NotNull JetType type, boolean isCallForImplicitInvoke) {}
|
||||
@@ -132,7 +136,11 @@ public interface TracingStrategy {
|
||||
|
||||
void instantiationOfAbstractClass(@NotNull BindingTrace trace);
|
||||
|
||||
void nestedClassAccessViaInstanceReference(@NotNull BindingTrace trace, @NotNull ClassDescriptor classDescriptor);
|
||||
void nestedClassAccessViaInstanceReference(
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull ClassDescriptor classDescriptor,
|
||||
@NotNull ExplicitReceiverKind explicitReceiverKind
|
||||
);
|
||||
|
||||
void unsafeCall(@NotNull BindingTrace trace, @NotNull JetType type, boolean isCallForImplicitInvoke);
|
||||
|
||||
|
||||
+3
-1
@@ -35,6 +35,7 @@ import org.jetbrains.jet.lang.resolve.calls.inference.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.MutableDataFlowInfoForArguments;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.jet.lang.resolve.calls.results.OverloadResolutionResults;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.ExplicitReceiverKind;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.ResolutionCandidate;
|
||||
import org.jetbrains.jet.lang.resolve.calls.tasks.TracingStrategy;
|
||||
import org.jetbrains.jet.lang.resolve.calls.util.CallMaker;
|
||||
@@ -456,7 +457,8 @@ public class ControlStructureTypingUtils {
|
||||
|
||||
@Override
|
||||
public void nestedClassAccessViaInstanceReference(
|
||||
@NotNull BindingTrace trace, @NotNull ClassDescriptor classDescriptor
|
||||
@NotNull BindingTrace trace, @NotNull ClassDescriptor classDescriptor,
|
||||
@NotNull ExplicitReceiverKind explicitReceiverKind
|
||||
) {
|
||||
throwError();
|
||||
}
|
||||
|
||||
@@ -23,6 +23,6 @@ class Outer {
|
||||
|
||||
fun Outer.foo() {
|
||||
Outer()
|
||||
<!NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE!>Nested<!>()
|
||||
<!NESTED_CLASS_SHOULD_BE_QUALIFIED!>Nested<!>()
|
||||
Inner()
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ class A {
|
||||
}
|
||||
|
||||
fun A.main() {
|
||||
::<!NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE!>Nested<!>
|
||||
::<!NESTED_CLASS_SHOULD_BE_QUALIFIED!>Nested<!>
|
||||
val y = A::Nested
|
||||
|
||||
y : KFunction0<A.Nested>
|
||||
|
||||
Reference in New Issue
Block a user