- call multifile class members (compiling against binaries)
- inline multifile class members HACK? scope-based part/facade resolution
This commit is contained in:
@@ -55,9 +55,11 @@ import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.kotlin.resolve.scopes.AbstractScopeAdapter;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializedType;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPackageMemberScope;
|
||||
import org.jetbrains.kotlin.types.*;
|
||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
@@ -174,6 +176,9 @@ public class JetTypeMapper {
|
||||
if (containingDeclaration instanceof PackageFragmentDescriptor) {
|
||||
PackageFragmentDescriptor packageFragmentDescriptor = (PackageFragmentDescriptor) containingDeclaration;
|
||||
JetScope scope = packageFragmentDescriptor.getMemberScope();
|
||||
if (scope instanceof AbstractScopeAdapter) {
|
||||
scope = ((AbstractScopeAdapter) scope).getActualScope();
|
||||
}
|
||||
if (scope instanceof LazyJavaPackageScope) {
|
||||
String facadeShortName = ((LazyJavaPackageScope) scope).getFacadeSimpleNameForPartSimpleName(implClassName.asString());
|
||||
if (facadeShortName != null) {
|
||||
@@ -181,6 +186,13 @@ public class JetTypeMapper {
|
||||
return internalNameByFqNameWithoutInnerClasses(facadeFqName);
|
||||
}
|
||||
}
|
||||
else if (scope instanceof DeserializedPackageMemberScope) {
|
||||
FqName implClassFqName = packageFragmentDescriptor.getFqName().child(implClassName);
|
||||
return internalNameByFqNameWithoutInnerClasses(implClassFqName);
|
||||
}
|
||||
else {
|
||||
throw new AssertionError("Unexpected member scope for deserialized callable: " + scope);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-5
@@ -61,12 +61,19 @@ public class LazyJavaPackageScope(
|
||||
|
||||
private val partToFacade = c.storageManager.createLazyValue {
|
||||
val result = hashMapOf<String, String>()
|
||||
for (kotlinClass in kotlinBinaryClasses()) {
|
||||
kotlinClasses@for (kotlinClass in kotlinBinaryClasses()) {
|
||||
val header = kotlinClass.classHeader
|
||||
if (header.kind == KotlinClassHeader.Kind.MULTIFILE_CLASS_PART) {
|
||||
val partName = kotlinClass.classId.shortClassName.asString()
|
||||
val facadeName = header.multifileClassName ?: ""
|
||||
result[partName] = facadeName
|
||||
when (header.kind ) {
|
||||
KotlinClassHeader.Kind.MULTIFILE_CLASS_PART -> {
|
||||
val partName = kotlinClass.classId.shortClassName.asString()
|
||||
val facadeName = header.multifileClassName ?: continue@kotlinClasses
|
||||
result[partName] = facadeName
|
||||
}
|
||||
KotlinClassHeader.Kind.FILE_FACADE -> {
|
||||
val fileFacadeName = kotlinClass.classId.shortClassName.asString()
|
||||
result[fileFacadeName] = fileFacadeName
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
result
|
||||
|
||||
@@ -28,6 +28,12 @@ import org.jetbrains.kotlin.utils.Printer
|
||||
public abstract class AbstractScopeAdapter : JetScope {
|
||||
protected abstract val workerScope: JetScope
|
||||
|
||||
public fun getActualScope(): JetScope =
|
||||
if (workerScope is AbstractScopeAdapter)
|
||||
(workerScope as AbstractScopeAdapter).getActualScope()
|
||||
else
|
||||
workerScope
|
||||
|
||||
override fun getImplicitReceiversHierarchy(): List<ReceiverParameterDescriptor> {
|
||||
return workerScope.getImplicitReceiversHierarchy()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user