[FE] Add isLocal name to ClassId constructor calls where it needed
This commit is contained in:
committed by
Space Team
parent
adaf8ae46a
commit
9e5ee3afa0
+1
-1
@@ -567,7 +567,7 @@ internal val ClassifierDescriptor.classId: ClassId?
|
||||
}
|
||||
|
||||
internal val ClassifierDescriptor.maybeLocalClassId: ClassId
|
||||
get() = classId ?: ClassId(containingPackage() ?: FqName.ROOT, FqName.topLevel(this.name), true)
|
||||
get() = classId ?: ClassId(containingPackage() ?: FqName.ROOT, FqName.topLevel(this.name), isLocal = true)
|
||||
|
||||
internal fun ClassDescriptor.getSupertypesWithAny(): Collection<KotlinType> {
|
||||
val supertypes = typeConstructor.supertypes
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ class KtFe10DescFunctionLikeSymbolPointer<T : KtFunctionLikeSymbol>(
|
||||
|
||||
val className = callableId.className
|
||||
val memberScope = if (className != null) {
|
||||
val outerClassId = ClassId(callableId.packageName, className, false)
|
||||
val outerClassId = ClassId(callableId.packageName, className, isLocal = false)
|
||||
analysisContext.resolveSession.moduleDescriptor.findClassAcrossModuleDependencies(outerClassId)
|
||||
?.unsubstitutedMemberScope
|
||||
?: MemberScope.Empty
|
||||
|
||||
+1
-1
@@ -296,7 +296,7 @@ private sealed class FqNameInterpretation {
|
||||
|
||||
return when {
|
||||
classParts.isEmpty() && callable == null -> FqNameInterpretationAsPackage(packageName)
|
||||
callable == null -> FqNameInterpretationAsClassId(ClassId(packageName, relativeClassName, false))
|
||||
callable == null -> FqNameInterpretationAsClassId(ClassId(packageName, relativeClassName, isLocal = false))
|
||||
else -> FqNameInterpretationAsCallableId(CallableId(packageName, relativeClassName.takeUnless { it.isRoot }, callable))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,5 +17,5 @@ public val PsiClass.classIdIfNonLocal: ClassId?
|
||||
val relatedClassName = qualifiedName.removePrefix("$packageName.")
|
||||
if (relatedClassName.isEmpty()) return null
|
||||
|
||||
return ClassId(FqName(packageName), FqName(relatedClassName), false)
|
||||
return ClassId(FqName(packageName), FqName(relatedClassName), isLocal = false)
|
||||
}
|
||||
|
||||
+2
-2
@@ -101,7 +101,7 @@ internal class StubBasedFirDeserializationContext(
|
||||
)
|
||||
|
||||
val memberDeserializer: StubBasedFirMemberDeserializer = StubBasedFirMemberDeserializer(this, initialOrigin)
|
||||
val dispatchReceiver = relativeClassName?.let { ClassId(packageFqName, it, /* local = */ false).defaultType(allTypeParameters) }
|
||||
val dispatchReceiver = relativeClassName?.let { ClassId(packageFqName, it, isLocal = false).defaultType(allTypeParameters) }
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -513,7 +513,7 @@ internal class StubBasedFirMemberDeserializer(
|
||||
dispatchReceiverType =
|
||||
if (!isInner) null
|
||||
else with(c) {
|
||||
ClassId(packageFqName, relativeClassName.parent(), false).defaultType(outerTypeParameters)
|
||||
ClassId(packageFqName, relativeClassName.parent(), isLocal = false).defaultType(outerTypeParameters)
|
||||
}
|
||||
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
||||
this.typeParameters +=
|
||||
|
||||
+1
-1
@@ -308,6 +308,6 @@ internal fun KtUserType.classId(): ClassId {
|
||||
return ClassId(
|
||||
FqName.fromSegments(packageFragments),
|
||||
FqName.fromSegments(classFragments),
|
||||
/* local = */ false
|
||||
isLocal = false
|
||||
)
|
||||
}
|
||||
+1
-1
@@ -76,7 +76,7 @@ class SymbolKotlinAsJavaSupport(project: Project) : KotlinAsJavaSupportBase<KtMo
|
||||
|
||||
return sequence {
|
||||
while (true) {
|
||||
yield(ClassId(currentParent, FqName(currentRelativeName), false))
|
||||
yield(ClassId(currentParent, FqName(currentRelativeName), isLocal = false))
|
||||
currentName = currentParent.shortNameOrSpecial()
|
||||
if (currentName.isSpecial) break
|
||||
currentParent = currentParent.parentOrNull() ?: break
|
||||
|
||||
@@ -111,9 +111,9 @@ object ClassIdExternalizer : DataExternalizer<ClassId> {
|
||||
|
||||
override fun read(input: DataInput): ClassId {
|
||||
return ClassId(
|
||||
/* packageFqName */ FqNameExternalizer.read(input),
|
||||
/* relativeClassName */ FqNameExternalizer.read(input),
|
||||
/* isLocal */ input.readBoolean()
|
||||
packageFqName = FqNameExternalizer.read(input),
|
||||
relativeClassName = FqNameExternalizer.read(input),
|
||||
isLocal = input.readBoolean()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,5 +53,5 @@ val Type.classId: ClassId
|
||||
val packageFQN = if (lastDotIndex >= 0) FqName(className.substring(0, lastDotIndex)) else FqName.ROOT
|
||||
val classRelativeNameWithDollars = if (lastDotIndex >= 0) className.substring(lastDotIndex + 1) else className
|
||||
val classFQN = FqName(classRelativeNameWithDollars.replace('$', '.'))
|
||||
return ClassId(packageFQN, classFQN, false)
|
||||
return ClassId(packageFQN, classFQN, isLocal = false)
|
||||
}
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ class JvmCodegenStringTable @JvmOverloads constructor(
|
||||
}
|
||||
else -> {
|
||||
val fqName = FqName(typeMapper.mapClass(descriptor).internalName.replace('/', '.'))
|
||||
ClassId(fqName.parent(), FqName.topLevel(fqName.shortName()), true)
|
||||
ClassId(fqName.parent(), FqName.topLevel(fqName.shortName()), isLocal = true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1366,7 +1366,7 @@ class KotlinTypeMapper @JvmOverloads constructor(
|
||||
return JvmClassName.byClassId(ownerClassId).internalName
|
||||
}
|
||||
|
||||
private val FAKE_CLASS_ID_FOR_BUILTINS = ClassId(FqName("kotlin.jvm.internal"), FqName("Intrinsics.Kotlin"), false)
|
||||
private val FAKE_CLASS_ID_FOR_BUILTINS = ClassId(FqName("kotlin.jvm.internal"), FqName("Intrinsics.Kotlin"), isLocal = false)
|
||||
|
||||
private fun getPackageMemberContainingClassesInfo(descriptor: DescriptorWithContainerSource): ContainingClassesInfo? {
|
||||
val containingDeclaration = descriptor.containingDeclaration
|
||||
|
||||
+1
-1
@@ -174,7 +174,7 @@ class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJ
|
||||
classId = ClassId(
|
||||
packageFqName.parent(),
|
||||
FqName(packageFqName.shortName().asString() + "." + classId.relativeClassName.asString()),
|
||||
false
|
||||
isLocal = false
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -181,7 +181,7 @@ abstract class AbstractFirTypeEnhancementTest : KtUsefulTestCase() {
|
||||
val packageStatement = psiFile.children.filterIsInstance<PsiPackageStatement>().firstOrNull()
|
||||
val packageName = packageStatement?.packageName
|
||||
val fqName = parentFqName.child(Name.identifier(this.name!!))
|
||||
return ClassId(packageName?.let { FqName(it) } ?: FqName.ROOT, fqName, false)
|
||||
return ClassId(packageName?.let { FqName(it) } ?: FqName.ROOT, fqName, isLocal = false)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -178,7 +178,7 @@ fun FirClassSymbol<*>.getContainingDeclarationSymbol(session: FirSession): FirCl
|
||||
} else {
|
||||
val parentId = classId.relativeClassName.parent()
|
||||
if (!parentId.isRoot) {
|
||||
val containingDeclarationId = ClassId(classId.packageFqName, parentId, false)
|
||||
val containingDeclarationId = ClassId(classId.packageFqName, parentId, isLocal = false)
|
||||
return session.symbolProvider.getClassLikeSymbolByClassId(containingDeclarationId)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -205,7 +205,7 @@ object FirImportsChecker : FirFileChecker() {
|
||||
val parentClass = resolvedParentClassId!!
|
||||
val relativeClassName = this.relativeParentClassName ?: return false
|
||||
val importedName = this.importedName ?: return false
|
||||
val innerClassId = ClassId(parentClass.packageFqName, relativeClassName.child(importedName), false)
|
||||
val innerClassId = ClassId(parentClass.packageFqName, relativeClassName.child(importedName), isLocal = false)
|
||||
return innerClassId.resolveToClass(context) != null
|
||||
} else {
|
||||
val importedFqName = importedFqName ?: return false
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ abstract class AbstractFirReflectionApiCallChecker : FirBasicExpressionChecker()
|
||||
|
||||
private val ALLOWED_CLASSES: Set<ClassId> =
|
||||
listOf("KType", "KTypeParameter", "KTypeProjection", "KTypeProjection.Companion", "KVariance").mapTo(HashSet()) {
|
||||
ClassId(StandardNames.KOTLIN_REFLECT_FQ_NAME, FqName(it), false)
|
||||
ClassId(StandardNames.KOTLIN_REFLECT_FQ_NAME, FqName(it), isLocal = false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -97,7 +97,7 @@ class FirDeserializationContext(
|
||||
)
|
||||
|
||||
val memberDeserializer: FirMemberDeserializer = FirMemberDeserializer(this)
|
||||
val dispatchReceiver = relativeClassName?.let { ClassId(packageFqName, it, false).defaultType(allTypeParameters) }
|
||||
val dispatchReceiver = relativeClassName?.let { ClassId(packageFqName, it, isLocal = false).defaultType(allTypeParameters) }
|
||||
|
||||
companion object {
|
||||
fun createForPackage(
|
||||
@@ -623,7 +623,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
dispatchReceiverType =
|
||||
if (!isInner) null
|
||||
else with(c) {
|
||||
ClassId(packageFqName, relativeClassName.parent(), false).defaultType(outerTypeParameters)
|
||||
ClassId(packageFqName, relativeClassName.parent(), isLocal = false).defaultType(outerTypeParameters)
|
||||
}
|
||||
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
||||
this.typeParameters +=
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ class FirJvmElementAwareStringTable(
|
||||
is IrClass -> parent.getLocalClassIdReplacement().createNestedClassId(name)
|
||||
else -> {
|
||||
val fqName = FqName(typeMapper.mapClass(this).internalName.replace('/', '.'))
|
||||
ClassId(fqName.parent(), FqName.topLevel(fqName.shortName()), true)
|
||||
ClassId(fqName.parent(), FqName.topLevel(fqName.shortName()), isLocal = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -153,7 +153,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
fun callableIdForName(name: Name) =
|
||||
when {
|
||||
context.className.shortNameOrSpecial() == SpecialNames.ANONYMOUS -> CallableId(
|
||||
ClassId(context.packageFqName, SpecialNames.ANONYMOUS_FQ_NAME, true), name
|
||||
ClassId(context.packageFqName, SpecialNames.ANONYMOUS_FQ_NAME, isLocal = true), name
|
||||
)
|
||||
context.className.isRoot && !context.inLocalContext -> CallableId(context.packageFqName, name)
|
||||
context.inLocalContext -> {
|
||||
@@ -162,7 +162,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
if (context.classNameBeforeLocalContext.isRoot) {
|
||||
context.packageFqName
|
||||
} else {
|
||||
ClassId(context.packageFqName, context.classNameBeforeLocalContext, false).asSingleFqName()
|
||||
ClassId(context.packageFqName, context.classNameBeforeLocalContext, isLocal = false).asSingleFqName()
|
||||
}
|
||||
) { result, firFunctionTarget ->
|
||||
if (firFunctionTarget.isLambda || firFunctionTarget.labelName == null)
|
||||
@@ -960,7 +960,7 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
private fun generateCopyFunction() {
|
||||
classBuilder.addDeclaration(
|
||||
classBuilder.createDataClassCopyFunction(
|
||||
ClassId(packageFqName, classFqName, false),
|
||||
ClassId(packageFqName, classFqName, isLocal = false),
|
||||
source,
|
||||
currentDispatchReceiverType(),
|
||||
zippedParameters,
|
||||
|
||||
@@ -26,8 +26,8 @@ class Context<T> {
|
||||
var inLocalContext: Boolean = false
|
||||
val currentClassId
|
||||
get() = when {
|
||||
inLocalContext -> ClassId(CallableId.PACKAGE_FQ_NAME_FOR_LOCAL, className, /*local =*/ true)
|
||||
else -> ClassId(packageFqName, className, /*local =*/ false)
|
||||
inLocalContext -> ClassId(CallableId.PACKAGE_FQ_NAME_FOR_LOCAL, className, isLocal = true)
|
||||
else -> ClassId(packageFqName, className, isLocal = false)
|
||||
}
|
||||
|
||||
var classNameBeforeLocalContext: FqName = FqName.ROOT
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ class FirQualifierResolverImpl(val session: FirSession) : FirQualifierResolver()
|
||||
val fqName = ClassId(
|
||||
prefix.packageFqName,
|
||||
parts.drop(1).fold(prefix.relativeClassName) { result, suffix -> result.child(suffix.name) },
|
||||
false
|
||||
isLocal = false
|
||||
)
|
||||
return symbolProvider.getClassLikeSymbolByClassId(fqName)
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class FirQualifierResolverImpl(val session: FirSession) : FirQualifierResolver()
|
||||
lastPart.add(0, firstPart.last())
|
||||
firstPart.removeAt(firstPart.lastIndex)
|
||||
|
||||
val fqName = ClassId(firstPart.toFqName(), lastPart.toFqName(), false)
|
||||
val fqName = ClassId(firstPart.toFqName(), lastPart.toFqName(), isLocal = false)
|
||||
val foundSymbol = firProvider.getClassLikeSymbolByClassId(fqName)
|
||||
if (foundSymbol != null) {
|
||||
return foundSymbol
|
||||
|
||||
@@ -24,7 +24,7 @@ fun FirClassLikeDeclaration.getContainingDeclaration(session: FirSession): FirCl
|
||||
val classId = symbol.classId
|
||||
val parentId = classId.relativeClassName.parent()
|
||||
if (!parentId.isRoot) {
|
||||
val containingDeclarationId = ClassId(classId.packageFqName, parentId, false)
|
||||
val containingDeclarationId = ClassId(classId.packageFqName, parentId, isLocal = false)
|
||||
return session.symbolProvider.getClassLikeSymbolByClassId(containingDeclarationId)?.fir
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ fun resolveToPackageOrClass(symbolProvider: FirSymbolProvider, fqName: FqName):
|
||||
if (currentPackage == fqName) return PackageResolutionResult.PackageOrClass(currentPackage, null, null)
|
||||
val relativeClassFqName = FqName.fromSegments((prefixSize until pathSegments.size).map { pathSegments[it].asString() })
|
||||
|
||||
val classId = ClassId(currentPackage, relativeClassFqName, false)
|
||||
val classId = ClassId(currentPackage, relativeClassFqName, isLocal = false)
|
||||
val symbol = symbolProvider.getClassLikeSymbolByClassId(classId) ?: return PackageResolutionResult.Error(
|
||||
ConeUnresolvedParentInImport(classId)
|
||||
)
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ internal class FirResolvedImportImpl(
|
||||
override val isAllUnder: Boolean get() = delegate.isAllUnder
|
||||
override val aliasName: Name? get() = delegate.aliasName
|
||||
override val aliasSource: KtSourceElement? get() = delegate.aliasSource
|
||||
override val resolvedParentClassId: ClassId? get() = relativeParentClassName?.let { ClassId(packageFqName, it, false) }
|
||||
override val resolvedParentClassId: ClassId? get() = relativeParentClassName?.let { ClassId(packageFqName, it, isLocal = false) }
|
||||
override val importedName: Name? get() = importedFqName?.shortName()
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ internal class FirErrorResolvedQualifierImpl(
|
||||
override val diagnostic: ConeDiagnostic,
|
||||
) : FirErrorResolvedQualifier() {
|
||||
override val classId: ClassId? get() = relativeClassFqName?.let {
|
||||
ClassId(packageFqName, it, false)
|
||||
ClassId(packageFqName, it, isLocal = false)
|
||||
}
|
||||
override val resolvedToCompanionObject: Boolean get() = false
|
||||
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ internal class FirResolvedQualifierImpl(
|
||||
override var typeArguments: MutableOrEmptyList<FirTypeProjection>,
|
||||
) : FirResolvedQualifier() {
|
||||
override val classId: ClassId? get() = relativeClassFqName?.let {
|
||||
ClassId(packageFqName, it, false)
|
||||
ClassId(packageFqName, it, isLocal = false)
|
||||
}
|
||||
override var resolvedToCompanionObject: Boolean = (symbol?.fir as? FirRegularClass)?.companionObjectSymbol != null
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ class FirRegularClassSymbol(classId: ClassId) : FirClassSymbol<FirRegularClass>(
|
||||
}
|
||||
|
||||
class FirAnonymousObjectSymbol(packageFqName: FqName) : FirClassSymbol<FirAnonymousObject>(
|
||||
ClassId(packageFqName, SpecialNames.ANONYMOUS_FQ_NAME, true)
|
||||
ClassId(packageFqName, SpecialNames.ANONYMOUS_FQ_NAME, isLocal = true)
|
||||
)
|
||||
|
||||
class FirTypeAliasSymbol(classId: ClassId) : FirClassLikeSymbol<FirTypeAlias>(classId), TypeAliasSymbolMarker {
|
||||
|
||||
+2
-2
@@ -64,7 +64,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
|
||||
default("resolvedParentClassId") {
|
||||
delegate = "relativeParentClassName"
|
||||
delegateCall = "let { ClassId(packageFqName, it, false) }"
|
||||
delegateCall = "let { ClassId(packageFqName, it, isLocal = false) }"
|
||||
withGetter = true
|
||||
}
|
||||
|
||||
@@ -703,7 +703,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
default("classId") {
|
||||
value = """
|
||||
|relativeClassFqName?.let {
|
||||
| ClassId(packageFqName, it, false)
|
||||
| ClassId(packageFqName, it, isLocal = false)
|
||||
|}
|
||||
""".trimMargin()
|
||||
withGetter = true
|
||||
|
||||
+3
-3
@@ -264,9 +264,9 @@ private object ClassIdExternalizerWithInterning : DataExternalizer<ClassId> by C
|
||||
return ClassId(
|
||||
// To reduce memory usage, apply object interning to package name as they are commonly shared.
|
||||
// (Don't apply object interning to relative class name as they are not commonly shared.)
|
||||
/* packageFqName */ FqNameExternalizerWithInterning.read(input),
|
||||
/* relativeClassName */ FqNameExternalizer.read(input),
|
||||
/* isLocal */ input.readBoolean()
|
||||
packageFqName = FqNameExternalizerWithInterning.read(input),
|
||||
relativeClassName = FqNameExternalizer.read(input),
|
||||
isLocal = input.readBoolean()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ class BasicClassInfoTest {
|
||||
}
|
||||
|
||||
private fun classId(@Suppress("SameParameterValue") packageFqName: String, relativeClassName: String, local: Boolean) =
|
||||
ClassId(FqName(packageFqName), FqName(relativeClassName), local)
|
||||
ClassId(FqName(packageFqName), FqName(relativeClassName), isLocal = local)
|
||||
}
|
||||
|
||||
private const val className = "com/example/TopLevelClass"
|
||||
|
||||
@@ -44,6 +44,6 @@ internal object ClassIdCalculator {
|
||||
}
|
||||
)
|
||||
|
||||
return ClassId(ktFile.packageFqName, relativeClassName, /*local=*/false)
|
||||
return ClassId(ktFile.packageFqName, relativeClassName, isLocal = false)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -92,7 +92,7 @@ class ClassifierResolutionContext private constructor(
|
||||
val packageFqName = outerFqName.parent()
|
||||
val relativeName = FqName(outerFqName.shortName().asString() + "." + substrings.subList(1, substrings.size).joinToString("."))
|
||||
|
||||
return ClassId(packageFqName, relativeName, false)
|
||||
return ClassId(packageFqName, relativeName, isLocal = false)
|
||||
}
|
||||
|
||||
internal fun resolveByInternalName(internalName: String): Result {
|
||||
|
||||
@@ -215,7 +215,7 @@ class KotlinCliJavaFileManagerTest : KotlinTestWithEnvironment() {
|
||||
private fun assertCanFind(manager: KotlinCliJavaFileManagerImpl, packageFQName: String, classFqName: String) {
|
||||
val allScope = GlobalSearchScope.allScope(project)
|
||||
|
||||
val classId = ClassId(FqName(packageFQName), FqName(classFqName), false)
|
||||
val classId = ClassId(FqName(packageFQName), FqName(classFqName), isLocal = false)
|
||||
val stringRequest = classId.asSingleFqName().asString()
|
||||
|
||||
val foundByClassId = (manager.findClass(classId, allScope) as JavaClassImpl).psi
|
||||
@@ -230,7 +230,7 @@ class KotlinCliJavaFileManagerTest : KotlinTestWithEnvironment() {
|
||||
}
|
||||
|
||||
private fun assertCannotFind(manager: KotlinCliJavaFileManagerImpl, packageFQName: String, classFqName: String) {
|
||||
val classId = ClassId(FqName(packageFQName), FqName(classFqName), false)
|
||||
val classId = ClassId(FqName(packageFQName), FqName(classFqName), isLocal = false)
|
||||
val foundClass = manager.findClass(classId, GlobalSearchScope.allScope(project))
|
||||
TestCase.assertNull("Found, but shouldn't have: $classId", foundClass)
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class KotlinJavacBasedClassFinderTest : KotlinTestWithEnvironmentManagement() {
|
||||
val classFinder = createClassFinder(project)
|
||||
|
||||
val className = "test.A.B.C"
|
||||
val classId = ClassId(FqName("test"), FqName("A.B.C"), false)
|
||||
val classId = ClassId(FqName("test"), FqName("A.B.C"), isLocal = false)
|
||||
val found = classFinder.findClass(classId)
|
||||
assertNotNull(found, "Class not found for $className")
|
||||
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ object JavaToKotlinClassMap {
|
||||
)
|
||||
|
||||
private inline fun <reified T> mutabilityMapping(kotlinReadOnly: ClassId, kotlinMutable: FqName): PlatformMutabilityMapping {
|
||||
val mutableClassId = ClassId(kotlinReadOnly.packageFqName, kotlinMutable.tail(kotlinReadOnly.packageFqName), false)
|
||||
val mutableClassId = ClassId(kotlinReadOnly.packageFqName, kotlinMutable.tail(kotlinReadOnly.packageFqName), isLocal = false)
|
||||
return PlatformMutabilityMapping(classId(T::class.java), kotlinReadOnly, mutableClassId)
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ data class CallableId(
|
||||
var classId: ClassId? = null
|
||||
get() {
|
||||
if (field == null && className != null) {
|
||||
field = ClassId(packageName, className, packageName == PACKAGE_FQ_NAME_FOR_LOCAL)
|
||||
field = ClassId(packageName, className, isLocal = packageName == PACKAGE_FQ_NAME_FOR_LOCAL)
|
||||
}
|
||||
return field
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||
* the second one being the class' short name.
|
||||
*/
|
||||
class ClassId(val packageFqName: FqName, val relativeClassName: FqName, val isLocal: Boolean) {
|
||||
constructor(packageFqName: FqName, topLevelName: Name) : this(packageFqName, FqName.topLevel(topLevelName), false)
|
||||
constructor(packageFqName: FqName, topLevelName: Name) : this(packageFqName, FqName.topLevel(topLevelName), isLocal = false)
|
||||
|
||||
init {
|
||||
assert(!relativeClassName.isRoot) { "Class name must not be root: " + packageFqName + if (isLocal) " (local)" else "" }
|
||||
@@ -53,7 +53,7 @@ class ClassId(val packageFqName: FqName, val relativeClassName: FqName, val isLo
|
||||
while (!name.parent().isRoot) {
|
||||
name = name.parent()
|
||||
}
|
||||
return ClassId(packageFqName, name, false)
|
||||
return ClassId(packageFqName, name, isLocal = false)
|
||||
}
|
||||
|
||||
val isNestedClass: Boolean
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ val Class<*>.classId: ClassId
|
||||
isArray -> throw IllegalArgumentException("Can't compute ClassId for array type: $this")
|
||||
enclosingMethod != null || enclosingConstructor != null || simpleName.isEmpty() -> {
|
||||
val fqName = FqName(name)
|
||||
ClassId(fqName.parent(), FqName.topLevel(fqName.shortName()), /* local = */ true)
|
||||
ClassId(fqName.parent(), FqName.topLevel(fqName.shortName()), isLocal = true)
|
||||
}
|
||||
else -> declaringClass?.classId?.createNestedClassId(Name.identifier(simpleName)) ?: ClassId.topLevel(FqName(name))
|
||||
}
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ open class ParcelableResolveExtension : SyntheticResolveExtension {
|
||||
}
|
||||
|
||||
fun resolveParcelableCreatorClassType(module: ModuleDescriptor): SimpleType? {
|
||||
val creatorClassId = ClassId(FqName("android.os"), FqName("Parcelable.Creator"), false)
|
||||
val creatorClassId = ClassId(FqName("android.os"), FqName("Parcelable.Creator"), isLocal = false)
|
||||
return module.findClassAcrossModuleDependencies(creatorClassId)?.defaultType
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user