- 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.JvmMethodParameterKind;
|
||||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature;
|
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature;
|
||||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
|
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.serialization.deserialization.DeserializedType;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor;
|
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.*;
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
||||||
import org.jetbrains.org.objectweb.asm.Type;
|
import org.jetbrains.org.objectweb.asm.Type;
|
||||||
@@ -174,6 +176,9 @@ public class JetTypeMapper {
|
|||||||
if (containingDeclaration instanceof PackageFragmentDescriptor) {
|
if (containingDeclaration instanceof PackageFragmentDescriptor) {
|
||||||
PackageFragmentDescriptor packageFragmentDescriptor = (PackageFragmentDescriptor) containingDeclaration;
|
PackageFragmentDescriptor packageFragmentDescriptor = (PackageFragmentDescriptor) containingDeclaration;
|
||||||
JetScope scope = packageFragmentDescriptor.getMemberScope();
|
JetScope scope = packageFragmentDescriptor.getMemberScope();
|
||||||
|
if (scope instanceof AbstractScopeAdapter) {
|
||||||
|
scope = ((AbstractScopeAdapter) scope).getActualScope();
|
||||||
|
}
|
||||||
if (scope instanceof LazyJavaPackageScope) {
|
if (scope instanceof LazyJavaPackageScope) {
|
||||||
String facadeShortName = ((LazyJavaPackageScope) scope).getFacadeSimpleNameForPartSimpleName(implClassName.asString());
|
String facadeShortName = ((LazyJavaPackageScope) scope).getFacadeSimpleNameForPartSimpleName(implClassName.asString());
|
||||||
if (facadeShortName != null) {
|
if (facadeShortName != null) {
|
||||||
@@ -181,6 +186,13 @@ public class JetTypeMapper {
|
|||||||
return internalNameByFqNameWithoutInnerClasses(facadeFqName);
|
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 {
|
private val partToFacade = c.storageManager.createLazyValue {
|
||||||
val result = hashMapOf<String, String>()
|
val result = hashMapOf<String, String>()
|
||||||
for (kotlinClass in kotlinBinaryClasses()) {
|
kotlinClasses@for (kotlinClass in kotlinBinaryClasses()) {
|
||||||
val header = kotlinClass.classHeader
|
val header = kotlinClass.classHeader
|
||||||
if (header.kind == KotlinClassHeader.Kind.MULTIFILE_CLASS_PART) {
|
when (header.kind ) {
|
||||||
val partName = kotlinClass.classId.shortClassName.asString()
|
KotlinClassHeader.Kind.MULTIFILE_CLASS_PART -> {
|
||||||
val facadeName = header.multifileClassName ?: ""
|
val partName = kotlinClass.classId.shortClassName.asString()
|
||||||
result[partName] = facadeName
|
val facadeName = header.multifileClassName ?: continue@kotlinClasses
|
||||||
|
result[partName] = facadeName
|
||||||
|
}
|
||||||
|
KotlinClassHeader.Kind.FILE_FACADE -> {
|
||||||
|
val fileFacadeName = kotlinClass.classId.shortClassName.asString()
|
||||||
|
result[fileFacadeName] = fileFacadeName
|
||||||
|
}
|
||||||
|
else -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
|
|||||||
@@ -28,6 +28,12 @@ import org.jetbrains.kotlin.utils.Printer
|
|||||||
public abstract class AbstractScopeAdapter : JetScope {
|
public abstract class AbstractScopeAdapter : JetScope {
|
||||||
protected abstract val workerScope: 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> {
|
override fun getImplicitReceiversHierarchy(): List<ReceiverParameterDescriptor> {
|
||||||
return workerScope.getImplicitReceiversHierarchy()
|
return workerScope.getImplicitReceiversHierarchy()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user