Containing declaration for TypeAliasConstructorDescriptor
is a corresponding TypeAliasDescriptor.
This commit is contained in:
committed by
Dmitry Petrov
parent
1cc7f19d10
commit
b31ab729de
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.cfg.WhenMissingCase
|
||||
import org.jetbrains.kotlin.cfg.hasUnknown
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.TabledDescriptorRenderer.newTable
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.TabledDescriptorRenderer.newText
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
@@ -85,7 +86,9 @@ object Renderers {
|
||||
val declarationKindWithSpace = when (it) {
|
||||
is PackageFragmentDescriptor -> "package "
|
||||
is ClassDescriptor -> "${it.renderKind()} "
|
||||
is TypeAliasDescriptor -> "typealias "
|
||||
is ConstructorDescriptor -> "constructor "
|
||||
is TypeAliasConstructorDescriptor -> "typealias constructor "
|
||||
is PropertyGetterDescriptor -> "property getter "
|
||||
is PropertySetterDescriptor -> "property setter "
|
||||
is FunctionDescriptor -> "function "
|
||||
|
||||
@@ -90,8 +90,7 @@ class OverloadChecker(val specificityComparator: TypeSpecificityComparator) {
|
||||
DeclarationCategory.EXTENSION_PROPERTY
|
||||
else
|
||||
DeclarationCategory.TYPE_OR_VALUE
|
||||
is ConstructorDescriptor,
|
||||
is SimpleFunctionDescriptor ->
|
||||
is FunctionDescriptor ->
|
||||
DeclarationCategory.FUNCTION
|
||||
is ClassifierDescriptor ->
|
||||
DeclarationCategory.TYPE_OR_VALUE
|
||||
|
||||
@@ -41,8 +41,8 @@ class OverloadResolver(
|
||||
checkOverloadsInPackages(c)
|
||||
}
|
||||
|
||||
private fun findConstructorsInNestedClassesAndTypeAliases(c: BodiesResolveContext): MultiMap<ClassDescriptor, ConstructorDescriptor> {
|
||||
val constructorsByOuterClass = MultiMap.create<ClassDescriptor, ConstructorDescriptor>()
|
||||
private fun findConstructorsInNestedClassesAndTypeAliases(c: BodiesResolveContext): MultiMap<ClassDescriptor, FunctionDescriptor> {
|
||||
val constructorsByOuterClass = MultiMap.create<ClassDescriptor, FunctionDescriptor>()
|
||||
|
||||
for (klass in c.declaredClasses.values) {
|
||||
if (klass.kind.isSingleton || klass.name.isSpecial) {
|
||||
@@ -83,7 +83,7 @@ class OverloadResolver(
|
||||
|
||||
private fun checkOverloadsInClass(
|
||||
classDescriptor: ClassDescriptorWithResolutionScopes,
|
||||
nestedClassConstructors: Collection<ConstructorDescriptor>
|
||||
nestedClassConstructors: Collection<FunctionDescriptor>
|
||||
) {
|
||||
val functionsByName = MultiMap.create<Name, CallableMemberDescriptor>()
|
||||
|
||||
@@ -92,12 +92,7 @@ class OverloadResolver(
|
||||
}
|
||||
|
||||
for (nestedConstructor in nestedClassConstructors) {
|
||||
val name =
|
||||
if (nestedConstructor is TypeAliasConstructorDescriptor)
|
||||
nestedConstructor.typeAliasDescriptor.name
|
||||
else
|
||||
nestedConstructor.containingDeclaration.name
|
||||
|
||||
val name = nestedConstructor.containingDeclaration.name
|
||||
functionsByName.putValue(name, nestedConstructor)
|
||||
}
|
||||
|
||||
|
||||
@@ -630,7 +630,7 @@ class CandidateResolver(
|
||||
val substitutedType = typeAliasParametersSubstitutor.substitute(typeAliasConstructorDescriptor.returnType, Variance.INVARIANT)!!
|
||||
val boundsSubstitutor = TypeSubstitutor.create(substitutedType)
|
||||
|
||||
val typeAliasDescriptor = typeAliasConstructorDescriptor.typeAliasDescriptor
|
||||
val typeAliasDescriptor = typeAliasConstructorDescriptor.containingDeclaration
|
||||
|
||||
val unsubstitutedType = typeAliasDescriptor.expandedType
|
||||
if (unsubstitutedType.isError) return
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.tower
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptorImpl
|
||||
import org.jetbrains.kotlin.incremental.components.LookupLocation
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -297,7 +298,7 @@ private fun getClassWithConstructors(classifier: ClassifierDescriptor?): ClassDe
|
||||
private val ClassDescriptor.canHaveCallableConstructors: Boolean
|
||||
get() = !ErrorUtils.isError(this) && !kind.isSingleton
|
||||
|
||||
fun ClassifierDescriptor.getTypeAliasConstructors(): Collection<ConstructorDescriptor> {
|
||||
fun ClassifierDescriptor.getTypeAliasConstructors(): Collection<TypeAliasConstructorDescriptor> {
|
||||
if (this !is TypeAliasDescriptor) return emptyList()
|
||||
|
||||
val classDescriptor = this.classDescriptor ?: return emptyList()
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
typealias Exn = java.lang.Exception
|
||||
|
||||
fun test() {
|
||||
throw <!NO_COMPANION_OBJECT!>Exn<!>
|
||||
throw <!FUNCTION_CALL_EXPECTED!>Exn<!>
|
||||
}
|
||||
Reference in New Issue
Block a user