Write to trace in case class qualifier is a short reference to default object
This allows to fix some cases when there is a difference between explicit and short reference to default object Fix shorten reference, optimize imports and import insert helper for default objects ShortenReferences always transforms default object references to shorter form for now Fix DescriptorUtils#getFqName() for default objects (affects test data mostly) Fix DescriptorUtils#getImportableDescriptor()
This commit is contained in:
@@ -96,6 +96,9 @@ public interface BindingContext {
|
||||
|
||||
WritableSlice<JetReferenceExpression, DeclarationDescriptor> REFERENCE_TARGET =
|
||||
new BasicWritableSlice<JetReferenceExpression, DeclarationDescriptor>(DO_NOTHING);
|
||||
// if 'A' really means 'A.Default' then this slice stores class descriptor for A, REFERENCE_TARGET stores descriptor Default in this case
|
||||
WritableSlice<JetReferenceExpression, ClassDescriptor> SHORT_REFERENCE_TO_DEFAULT_OBJECT =
|
||||
new BasicWritableSlice<JetReferenceExpression, ClassDescriptor>(DO_NOTHING);
|
||||
|
||||
@KotlinSignature("val RESOLVED_CALL: WritableSlice<Call, ResolvedCall<out CallableDescriptor>>")
|
||||
WritableSlice<Call, ResolvedCall<?>> RESOLVED_CALL = new BasicWritableSlice<Call, ResolvedCall<?>>(DO_NOTHING);
|
||||
|
||||
+5
-1
@@ -58,7 +58,11 @@ public class TracingStrategyImpl extends AbstractTracingStrategy {
|
||||
descriptor = ((VariableAsFunctionResolvedCall) resolvedCall).getVariableCall().getCandidateDescriptor();
|
||||
}
|
||||
if (descriptor instanceof FakeCallableDescriptorForObject) {
|
||||
descriptor = ((FakeCallableDescriptorForObject) descriptor).getReferencedDescriptor();
|
||||
FakeCallableDescriptorForObject fakeCallableDescriptorForObject = (FakeCallableDescriptorForObject) descriptor;
|
||||
descriptor = fakeCallableDescriptorForObject.getReferencedDescriptor();
|
||||
if (fakeCallableDescriptorForObject.getClassDescriptor().getDefaultObjectDescriptor() != null) {
|
||||
trace.record(SHORT_REFERENCE_TO_DEFAULT_OBJECT, reference, fakeCallableDescriptorForObject.getClassDescriptor());
|
||||
}
|
||||
}
|
||||
DeclarationDescriptor storedReference = trace.get(REFERENCE_TARGET, reference);
|
||||
if (storedReference == null || !ErrorUtils.isError(descriptor)) {
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getClassObjectReferenceTarget
|
||||
|
||||
public class FakeCallableDescriptorForObject(
|
||||
private val classDescriptor: ClassDescriptor
|
||||
public val classDescriptor: ClassDescriptor
|
||||
) : DeclarationDescriptorWithVisibility by classDescriptor.getClassObjectReferenceTarget(), VariableDescriptor {
|
||||
|
||||
{
|
||||
|
||||
@@ -148,11 +148,14 @@ private fun QualifierReceiver.resolveAsReceiverInQualifiedExpression(context: Ex
|
||||
}
|
||||
|
||||
private fun QualifierReceiver.resolveAndRecordReferenceTarget(context: ExpressionTypingContext, selector: DeclarationDescriptor?) {
|
||||
resultingDescriptor = resolveReferenceTarget(selector)
|
||||
resultingDescriptor = resolveReferenceTarget(context, selector)
|
||||
context.trace.record(REFERENCE_TARGET, referenceExpression, resultingDescriptor)
|
||||
}
|
||||
|
||||
private fun QualifierReceiver.resolveReferenceTarget(selector: DeclarationDescriptor?): DeclarationDescriptor {
|
||||
private fun QualifierReceiver.resolveReferenceTarget(
|
||||
context: ExpressionTypingContext,
|
||||
selector: DeclarationDescriptor?
|
||||
): DeclarationDescriptor {
|
||||
if (classifier is TypeParameterDescriptor) {
|
||||
return classifier
|
||||
}
|
||||
@@ -168,6 +171,9 @@ private fun QualifierReceiver.resolveReferenceTarget(selector: DeclarationDescri
|
||||
}
|
||||
|
||||
if (classifier is ClassDescriptor && classifier.classObjectDescriptor == selectorContainer) {
|
||||
if (classifier.getDefaultObjectDescriptor() != null) {
|
||||
context.trace.record(SHORT_REFERENCE_TO_DEFAULT_OBJECT, referenceExpression, classifier)
|
||||
}
|
||||
return classifier.getClassObjectReferenceTarget()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package
|
||||
|
||||
package f {
|
||||
internal fun test(): f.A.B
|
||||
internal fun test(): f.A.Default.B
|
||||
|
||||
internal final class A {
|
||||
public constructor A()
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package
|
||||
|
||||
internal fun f1(): A.B.C.Default
|
||||
internal fun f1(): A.Default.B.C.Default
|
||||
internal fun f2(): kotlin.Unit
|
||||
|
||||
internal final class A {
|
||||
|
||||
@@ -12,10 +12,10 @@ internal final class A {
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
internal final enum class E : kotlin.Enum<A.E> {
|
||||
public enum entry ENTRY : A.E {
|
||||
internal final enum class E : kotlin.Enum<A.Default.E> {
|
||||
public enum entry ENTRY : A.Default.E {
|
||||
private constructor ENTRY()
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: A.E): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: A.Default.E): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
|
||||
@@ -24,7 +24,7 @@ internal final class A {
|
||||
}
|
||||
|
||||
private constructor E()
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: A.E): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: A.Default.E): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
|
||||
@@ -32,8 +32,8 @@ internal final class A {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): A.E
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<A.E>
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): A.Default.E
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<A.Default.E>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ internal final class A {
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
internal final enum class E : kotlin.Enum<A.E> {
|
||||
public enum entry ENTRY2 : A.E {
|
||||
internal final enum class E : kotlin.Enum<A.Default.E> {
|
||||
public enum entry ENTRY2 : A.Default.E {
|
||||
private constructor ENTRY2()
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: A.E): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: A.Default.E): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
|
||||
@@ -24,7 +24,7 @@ internal final class A {
|
||||
}
|
||||
|
||||
private constructor E()
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: A.E): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: A.Default.E): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
|
||||
@@ -32,8 +32,8 @@ internal final class A {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): A.E
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<A.E>
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): A.Default.E
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<A.Default.E>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -43,10 +43,10 @@ internal final class A {
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
internal final enum class E : kotlin.Enum<A.E> {
|
||||
public enum entry ENTRY : A.E {
|
||||
internal final enum class E : kotlin.Enum<A.Default.E> {
|
||||
public enum entry ENTRY : A.Default.E {
|
||||
private constructor ENTRY()
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: A.E): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: A.Default.E): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
|
||||
@@ -55,7 +55,7 @@ internal final class A {
|
||||
}
|
||||
|
||||
private constructor E()
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: A.E): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: A.Default.E): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun name(): kotlin.String
|
||||
@@ -63,8 +63,8 @@ internal final class A {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): A.E
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<A.E>
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): A.Default.E
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<A.Default.E>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,8 +81,8 @@ package c {
|
||||
}
|
||||
|
||||
package d {
|
||||
internal val b: d.A.B
|
||||
internal val c: d.A.B
|
||||
internal val b: d.A.Default.B
|
||||
internal val c: d.A.Default.B
|
||||
|
||||
internal final class A {
|
||||
public constructor A()
|
||||
@@ -103,7 +103,7 @@ package d {
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal object C : d.A.B {
|
||||
internal object C : d.A.Default.B {
|
||||
private constructor C()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
|
||||
@@ -6,7 +6,7 @@ internal final class Test {
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
Test.ClassObjectAnnotation() Test.NestedAnnotation() internal class object Default {
|
||||
Test.Default.ClassObjectAnnotation() Test.NestedAnnotation() internal class object Default {
|
||||
private constructor Default()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
|
||||
+1
-1
@@ -64,5 +64,5 @@ fun test(m1: M1) {
|
||||
d(m1.d)
|
||||
e(m1.e)
|
||||
f(m1.f)
|
||||
g(m1.g)
|
||||
g(<!TYPE_MISMATCH!>m1.g<!>)
|
||||
}
|
||||
+7
-7
@@ -64,10 +64,10 @@ package p {
|
||||
public final val a: p.A
|
||||
public final val b: p.A.B
|
||||
public final val c: p.A.C
|
||||
public final val d: p.A.D
|
||||
public final val e: p.A.D.E
|
||||
public final val d: p.A.Default.D
|
||||
public final val e: p.A.Default.D.E
|
||||
public final val f: p.A.F
|
||||
public final val g: p.A.G
|
||||
public final val g: p.A.Default.G
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
@@ -82,8 +82,8 @@ package p {
|
||||
public fun a(/*0*/ p: p.A): kotlin.Unit
|
||||
public fun b(/*0*/ p: p.A.B): kotlin.Unit
|
||||
public fun c(/*0*/ p: p.A.C): kotlin.Unit
|
||||
public fun d(/*0*/ p: p.A.D): kotlin.Unit
|
||||
public fun e(/*0*/ p: p.A.D.E): kotlin.Unit
|
||||
public fun d(/*0*/ p: p.A.Default.D): kotlin.Unit
|
||||
public fun e(/*0*/ p: p.A.Default.D.E): kotlin.Unit
|
||||
public fun f(/*0*/ p: p.A.F): kotlin.Unit
|
||||
public fun g(/*0*/ p: p.A.G): kotlin.Unit
|
||||
|
||||
@@ -154,8 +154,8 @@ package p {
|
||||
public fun a(/*0*/ p: p.A): kotlin.Unit
|
||||
public fun b(/*0*/ p: p.A.B): kotlin.Unit
|
||||
public fun c(/*0*/ p: p.A.C): kotlin.Unit
|
||||
public fun d(/*0*/ p: p.A.D): kotlin.Unit
|
||||
public fun e(/*0*/ p: p.A.D.E): kotlin.Unit
|
||||
public fun d(/*0*/ p: p.A.Default.D): kotlin.Unit
|
||||
public fun e(/*0*/ p: p.A.Default.D.E): kotlin.Unit
|
||||
public fun f(/*0*/ p: p.A.F): kotlin.Unit
|
||||
public fun g(/*0*/ p: p.A.G): kotlin.Unit
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package
|
||||
|
||||
internal final class X {
|
||||
public constructor X()
|
||||
internal final val y: X.Y
|
||||
internal final val y: X.Default.Y
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
@@ -20,7 +20,7 @@ internal final class Main {
|
||||
|
||||
internal class object Default {
|
||||
private constructor Default()
|
||||
public final val N: Main.States
|
||||
public final val N: Main.Default.States
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
+1
-1
@@ -20,6 +20,6 @@ internal final class A {
|
||||
}
|
||||
}
|
||||
|
||||
test.A.Anno1() test.A.B.Anno2() internal final class C {
|
||||
test.A.Default.Anno1() test.A.Default.B.Anno2() internal final class C {
|
||||
/*primary*/ public constructor C()
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package test
|
||||
internal final class Some {
|
||||
/*primary*/ public constructor Some()
|
||||
|
||||
test.Some.TestAnnotation() internal class object Default {
|
||||
test.Some.Default.TestAnnotation() internal class object Default {
|
||||
/*primary*/ private constructor Default()
|
||||
|
||||
internal final annotation class TestAnnotation : kotlin.Annotation {
|
||||
|
||||
Reference in New Issue
Block a user