Move type enhacement parts to separate package in runtime

It's needed to enhace types when loading descriptors via reflection.
Also get rid of `enhanceSignatures` method in ExternalSignatureResolver as enhancement does not use external signature at all
This commit is contained in:
Denis Zharkov
2015-06-19 15:47:07 +03:00
parent c6b91b0f81
commit c769748cb0
7 changed files with 21 additions and 41 deletions
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.load.java.components;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.ReadOnly;
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor;
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
@@ -37,7 +36,6 @@ import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.SignaturesPropagationDat
import org.jetbrains.kotlin.types.JetType;
import javax.inject.Inject;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -136,9 +134,4 @@ public class TraceBasedExternalSignatureResolver implements ExternalSignatureRes
public void reportSignatureErrors(@NotNull CallableMemberDescriptor descriptor, @NotNull List<String> signatureErrors) {
trace.record(JavaBindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, descriptor, signatureErrors);
}
@Override
public <D extends CallableMemberDescriptor> Collection<D> enhanceSignatures(@NotNull @ReadOnly Collection<D> platformSignatures) {
return ComponentsPackage.enhanceSignatures(platformSignatures);
}
}
@@ -18,14 +18,12 @@ package org.jetbrains.kotlin.load.java.components;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.ReadOnly;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.load.java.structure.JavaField;
import org.jetbrains.kotlin.load.java.structure.JavaMember;
import org.jetbrains.kotlin.load.java.structure.JavaMethod;
import org.jetbrains.kotlin.types.JetType;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -75,11 +73,6 @@ public interface ExternalSignatureResolver {
public void reportSignatureErrors(@NotNull CallableMemberDescriptor descriptor, @NotNull List<String> signatureErrors) {
throw new UnsupportedOperationException("Should not be called");
}
@Override
public <D extends CallableMemberDescriptor> Collection<D> enhanceSignatures(@NotNull @ReadOnly Collection<D> platformSignatures) {
return platformSignatures;
}
};
abstract class MemberSignature {
@@ -208,10 +201,4 @@ public interface ExternalSignatureResolver {
);
void reportSignatureErrors(@NotNull CallableMemberDescriptor descriptor, @NotNull List<String> signatureErrors);
/**
* Replaces some items in the {@code platformSignatures} collection with enhanced signatures.
* Is called after binding overrides, so the implementation is allowed to inspect contents of getOverriddenDescriptors()
*/
<D extends CallableMemberDescriptor> Collection<D> enhanceSignatures(@NotNull @ReadOnly Collection<D> platformSignatures);
}
@@ -35,16 +35,15 @@ import org.jetbrains.kotlin.load.java.structure.JavaArrayType
import org.jetbrains.kotlin.load.java.structure.JavaClass
import org.jetbrains.kotlin.load.java.structure.JavaConstructor
import org.jetbrains.kotlin.load.java.structure.JavaMethod
import org.jetbrains.kotlin.load.java.structure.*
import org.jetbrains.kotlin.load.java.typeEnhacement.enhanceSignatures
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorFactory
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.types.JetType
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.utils.addIfNotNull
import org.jetbrains.kotlin.utils.emptyOrSingletonList
import org.jetbrains.kotlin.utils.ifEmpty
import org.jetbrains.kotlin.utils.valuesToMap
import org.jetbrains.kotlin.utils.*
import java.util.ArrayList
import java.util.Collections
import java.util.LinkedHashSet
@@ -72,7 +71,7 @@ public class LazyJavaClassMemberScope(
result.addIfNotNull(c.samConversionResolver.resolveSamAdapter(descriptor))
}
c.externalSignatureResolver.enhanceSignatures(
enhanceSignatures(
result ifEmpty { emptyOrSingletonList(createDefaultConstructor()) }
).toReadOnlyList()
}
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.load.java.structure.JavaArrayType
import org.jetbrains.kotlin.load.java.structure.JavaField
import org.jetbrains.kotlin.load.java.structure.JavaMethod
import org.jetbrains.kotlin.load.java.structure.JavaValueParameter
import org.jetbrains.kotlin.load.java.typeEnhacement.enhanceSignatures
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.jvm.PLATFORM_TYPES
@@ -86,7 +87,7 @@ public abstract class LazyJavaMemberScope(
computeNonDeclaredFunctions(result, name)
val enhancedResult = c.externalSignatureResolver.enhanceSignatures(result)
val enhancedResult = enhanceSignatures(result)
// Make sure that lazy things are computed before we release the lock
for (f in enhancedResult) {
@@ -239,7 +240,7 @@ public abstract class LazyJavaMemberScope(
if (DescriptorUtils.isAnnotationClass(containingDeclaration))
properties.toReadOnlyList()
else
c.externalSignatureResolver.enhanceSignatures(properties).toReadOnlyList()
enhanceSignatures(properties).toReadOnlyList()
}
private fun resolveProperty(field: JavaField): PropertyDescriptor {
@@ -14,16 +14,16 @@
* limitations under the License.
*/
package org.jetbrains.kotlin.load.java.components
package org.jetbrains.kotlin.load.java.typeEnhacement
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
import org.jetbrains.kotlin.load.java.typeEnhacement.computeIndexedQualifiersForOverride
import org.jetbrains.kotlin.load.java.typeEnhacement.enhance
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor
import org.jetbrains.kotlin.load.java.descriptors.JavaConstructorDescriptor
import org.jetbrains.kotlin.load.java.descriptors.JavaPropertyDescriptor
import org.jetbrains.kotlin.types.JetType
fun <D : CallableMemberDescriptor> enhanceSignatures(platformSignatures: Collection<D>): Collection<D> {
@@ -14,15 +14,15 @@
* limitations under the License.
*/
package org.jetbrains.kotlin.load.java.components
package org.jetbrains.kotlin.load.java.typeEnhacement
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.load.java.components.MutabilityQualifier.MUTABLE
import org.jetbrains.kotlin.load.java.components.MutabilityQualifier.READ_ONLY
import org.jetbrains.kotlin.load.java.components.NullabilityQualifier.NOT_NULL
import org.jetbrains.kotlin.load.java.components.NullabilityQualifier.NULLABLE
import org.jetbrains.kotlin.load.java.typeEnhacement.JavaTypeQualifiers
import org.jetbrains.kotlin.load.java.typeEnhacement.MutabilityQualifier.MUTABLE
import org.jetbrains.kotlin.load.java.typeEnhacement.MutabilityQualifier.READ_ONLY
import org.jetbrains.kotlin.load.java.typeEnhacement.NullabilityQualifier.NOT_NULL
import org.jetbrains.kotlin.load.java.typeEnhacement.NullabilityQualifier.NULLABLE
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap
import org.jetbrains.kotlin.types.*
@@ -14,14 +14,14 @@
* limitations under the License.
*/
package org.jetbrains.kotlin.load.java.components
package org.jetbrains.kotlin.load.java.typeEnhacement
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
import org.jetbrains.kotlin.load.java.components.MutabilityQualifier.MUTABLE
import org.jetbrains.kotlin.load.java.components.MutabilityQualifier.READ_ONLY
import org.jetbrains.kotlin.load.java.components.NullabilityQualifier.NOT_NULL
import org.jetbrains.kotlin.load.java.components.NullabilityQualifier.NULLABLE
import org.jetbrains.kotlin.load.java.typeEnhacement.MutabilityQualifier.MUTABLE
import org.jetbrains.kotlin.load.java.typeEnhacement.MutabilityQualifier.READ_ONLY
import org.jetbrains.kotlin.load.java.typeEnhacement.NullabilityQualifier.NOT_NULL
import org.jetbrains.kotlin.load.java.typeEnhacement.NullabilityQualifier.NULLABLE
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.platform.JavaToKotlinClassMap
import org.jetbrains.kotlin.types.JetType