Record reference to class object directly
not to containing class descriptor
This commit is contained in:
@@ -1698,10 +1698,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
}
|
||||
}
|
||||
|
||||
//if (descriptor instanceof VariableAsFunctionDescriptor) {
|
||||
// descriptor = ((VariableAsFunctionDescriptor) descriptor).getVariableDescriptor();
|
||||
//}
|
||||
|
||||
assert descriptor != null : "Couldn't find descriptor for '" + expression.getText() + "'";
|
||||
descriptor = descriptor.getOriginal();
|
||||
|
||||
@@ -1738,7 +1734,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) descriptor;
|
||||
if (classDescriptor.getKind() == ClassKind.OBJECT) {
|
||||
if (classDescriptor.getKind() == ClassKind.OBJECT || classDescriptor.getKind() == ClassKind.CLASS_OBJECT) {
|
||||
return StackValue.singleton(classDescriptor, typeMapper);
|
||||
}
|
||||
if (classDescriptor.getKind() == ClassKind.ENUM_ENTRY) {
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
||||
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
|
||||
|
||||
public fun JetReturnExpression.getTargetFunctionDescriptor(context: BindingContext): FunctionDescriptor? {
|
||||
val targetLabel = getTargetLabel()
|
||||
if (targetLabel != null) return context[LABEL_TARGET, targetLabel]?.let { context[FUNCTION, it] }
|
||||
|
||||
+1
@@ -30,6 +30,7 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.LibrarySourceHacks.filterOutMembersFromLibrarySource;
|
||||
import static org.jetbrains.jet.lang.resolve.descriptorUtil.DescriptorUtilPackage.getClassObjectReferenceTarget;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class CallableDescriptorCollectors<D extends CallableDescriptor> implements Iterable<CallableDescriptorCollector<D>> {
|
||||
|
||||
+8
@@ -37,6 +37,7 @@ import org.jetbrains.jet.lang.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.impl.PackageFragmentDescriptorImpl
|
||||
import org.jetbrains.jet.lang.types.expressions.ExpressionTypingContext
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.getTopmostParentQualifiedExpressionForSelector
|
||||
import org.jetbrains.jet.lang.resolve.descriptorUtil.getClassObjectReferenceTarget
|
||||
|
||||
public class QualifierReceiver(
|
||||
val expression: JetSimpleNameExpression,
|
||||
@@ -150,6 +151,13 @@ private fun QualifierReceiver.resolveReferenceTarget(selector: DeclarationDescri
|
||||
return packageView
|
||||
}
|
||||
|
||||
if (classifier != null && containingDeclaration is ClassDescriptor && classifier == containingDeclaration) {
|
||||
return classifier
|
||||
}
|
||||
if (classifier is ClassDescriptor && classifier.getClassObjectDescriptor() != null) {
|
||||
return classifier.getClassObjectReferenceTarget()
|
||||
}
|
||||
|
||||
return descriptor
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package foo
|
||||
fun test() {
|
||||
A.d
|
||||
A.<!INVISIBLE_MEMBER!>f<!>
|
||||
<!INVISIBLE_MEMBER!>CCC<!>
|
||||
<!INVISIBLE_MEMBER!>CCC<!>.<!INVISIBLE_MEMBER!>classObjectVar<!>
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package Jet86
|
||||
|
||||
~A~class A {
|
||||
class object {
|
||||
class A {
|
||||
class ~A~object {
|
||||
~A.x~val x = 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ fun test() = <caret>A(1)
|
||||
|
||||
Resolved call:
|
||||
|
||||
Resulting descriptor: class A
|
||||
Resulting descriptor: class object
|
||||
|
||||
Explicit receiver kind = NO_EXPLICIT_RECEIVER
|
||||
This object = NO_RECEIVER
|
||||
|
||||
Reference in New Issue
Block a user