Create special descriptor for an object corresponding to type alias.
This commit is contained in:
@@ -246,7 +246,7 @@ class CandidateResolver(
|
|||||||
nestedClass = candidateDescriptor.containingDeclaration
|
nestedClass = candidateDescriptor.containingDeclaration
|
||||||
}
|
}
|
||||||
else if (candidateDescriptor is FakeCallableDescriptorForObject) {
|
else if (candidateDescriptor is FakeCallableDescriptorForObject) {
|
||||||
nestedClass = candidateDescriptor.getReferencedDescriptor()
|
nestedClass = candidateDescriptor.getReferencedObject()
|
||||||
}
|
}
|
||||||
if (nestedClass != null) {
|
if (nestedClass != null) {
|
||||||
tracing.nestedClassAccessViaInstanceReference(trace, nestedClass, candidateCall.explicitReceiverKind)
|
tracing.nestedClassAccessViaInstanceReference(trace, nestedClass, candidateCall.explicitReceiverKind)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.incremental.components.LookupLocation
|
|||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.getReceiverValueWithSmartCast
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.getReceiverValueWithSmartCast
|
||||||
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
|
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForTypeAliasObject
|
||||||
import org.jetbrains.kotlin.resolve.coroutine.CoroutineReceiverValue
|
import org.jetbrains.kotlin.resolve.coroutine.CoroutineReceiverValue
|
||||||
import org.jetbrains.kotlin.resolve.coroutine.createCoroutineSuspensionFunctionView
|
import org.jetbrains.kotlin.resolve.coroutine.createCoroutineSuspensionFunctionView
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.HIDES_MEMBERS_NAME_LIST
|
import org.jetbrains.kotlin.resolve.descriptorUtil.HIDES_MEMBERS_NAME_LIST
|
||||||
@@ -273,7 +274,12 @@ private fun ResolutionScope.getContributedObjectVariables(name: Name, location:
|
|||||||
fun getFakeDescriptorForObject(classifier: ClassifierDescriptor?): FakeCallableDescriptorForObject? =
|
fun getFakeDescriptorForObject(classifier: ClassifierDescriptor?): FakeCallableDescriptorForObject? =
|
||||||
when (classifier) {
|
when (classifier) {
|
||||||
is TypeAliasDescriptor ->
|
is TypeAliasDescriptor ->
|
||||||
getFakeDescriptorForObject(classifier.classDescriptor)
|
classifier.classDescriptor?.let { classDescriptor ->
|
||||||
|
if (classDescriptor.hasClassValueDescriptor)
|
||||||
|
FakeCallableDescriptorForTypeAliasObject(classifier)
|
||||||
|
else
|
||||||
|
null
|
||||||
|
}
|
||||||
is ClassDescriptor ->
|
is ClassDescriptor ->
|
||||||
if (classifier.hasClassValueDescriptor)
|
if (classifier.hasClassValueDescriptor)
|
||||||
FakeCallableDescriptorForObject(classifier)
|
FakeCallableDescriptorForObject(classifier)
|
||||||
|
|||||||
+4
-2
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.hasClassValueDescriptor
|
|||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class FakeCallableDescriptorForObject(
|
open class FakeCallableDescriptorForObject(
|
||||||
val classDescriptor: ClassDescriptor
|
val classDescriptor: ClassDescriptor
|
||||||
) : DeclarationDescriptorWithVisibility by classDescriptor.getClassObjectReferenceTarget(), VariableDescriptor {
|
) : DeclarationDescriptorWithVisibility by classDescriptor.getClassObjectReferenceTarget(), VariableDescriptor {
|
||||||
|
|
||||||
@@ -34,7 +34,9 @@ class FakeCallableDescriptorForObject(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getReferencedDescriptor(): ClassDescriptor = classDescriptor.getClassObjectReferenceTarget()
|
open fun getReferencedDescriptor(): ClassifierDescriptorWithTypeParameters = classDescriptor.getClassObjectReferenceTarget()
|
||||||
|
|
||||||
|
fun getReferencedObject(): ClassDescriptor = classDescriptor.getClassObjectReferenceTarget()
|
||||||
|
|
||||||
override fun getExtensionReceiverParameter(): ReceiverParameterDescriptor? = null
|
override fun getExtensionReceiverParameter(): ReceiverParameterDescriptor? = null
|
||||||
|
|
||||||
|
|||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.resolve.calls.util
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
|
||||||
|
|
||||||
|
class FakeCallableDescriptorForTypeAliasObject(val typeAliasDescriptor: TypeAliasDescriptor) :
|
||||||
|
FakeCallableDescriptorForObject(typeAliasDescriptor.classDescriptor!!) {
|
||||||
|
override fun getReferencedDescriptor() =
|
||||||
|
typeAliasDescriptor
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean =
|
||||||
|
other is FakeCallableDescriptorForTypeAliasObject &&
|
||||||
|
typeAliasDescriptor == other.typeAliasDescriptor
|
||||||
|
|
||||||
|
override fun hashCode(): Int =
|
||||||
|
typeAliasDescriptor.hashCode()
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
class C {
|
||||||
|
private companion object
|
||||||
|
}
|
||||||
|
|
||||||
|
typealias CAlias = C
|
||||||
|
|
||||||
|
val <!EXPOSED_PROPERTY_TYPE!>test1<!> = <!INVISIBLE_MEMBER!>CAlias<!>
|
||||||
|
val <!EXPOSED_PROPERTY_TYPE!>test1a<!> = <!INVISIBLE_MEMBER!>C<!>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public val test1: C.Companion
|
||||||
|
public val test1a: C.Companion
|
||||||
|
|
||||||
|
public final class C {
|
||||||
|
public 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
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
private companion object Companion {
|
||||||
|
private constructor Companion()
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public typealias CAlias = C
|
||||||
@@ -20397,6 +20397,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("typeAliasInvisibleObject.kt")
|
||||||
|
public void testTypeAliasInvisibleObject() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasInvisibleObject.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("typeAliasNotNull.kt")
|
@TestMetadata("typeAliasNotNull.kt")
|
||||||
public void testTypeAliasNotNull() throws Exception {
|
public void testTypeAliasNotNull() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasNotNull.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasNotNull.kt");
|
||||||
|
|||||||
@@ -433,7 +433,7 @@ public final class StaticContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FakeCallableDescriptorForObject fakeCallableDescriptor = (FakeCallableDescriptorForObject) descriptor;
|
FakeCallableDescriptorForObject fakeCallableDescriptor = (FakeCallableDescriptorForObject) descriptor;
|
||||||
return getNameForDescriptor(fakeCallableDescriptor.getReferencedDescriptor());
|
return getNameForDescriptor(fakeCallableDescriptor.getReferencedObject());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user