Replace Injected properties with constructor parameters when it doesn't cause cycles
This commit is contained in:
+1
-8
@@ -22,23 +22,16 @@ import org.jetbrains.kotlin.load.java.structure.impl.*
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSessionUtils
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import javax.inject.Inject
|
||||
import kotlin.properties.Delegates
|
||||
import org.jetbrains.kotlin.name.tail
|
||||
import org.jetbrains.kotlin.resolve.BindingContext.*
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.BindingContextUtils
|
||||
|
||||
public class LazyResolveBasedCache : JavaResolverCache {
|
||||
private var resolveSession by Delegates.notNull<ResolveSession>()
|
||||
public class LazyResolveBasedCache(private val resolveSession: ResolveSession) : JavaResolverCache {
|
||||
|
||||
private val trace: BindingTrace get() = resolveSession.getTrace()
|
||||
|
||||
Inject
|
||||
public fun setSession(resolveSession: ResolveSession) {
|
||||
this.resolveSession = resolveSession
|
||||
}
|
||||
|
||||
override fun getClassResolvedFromSource(fqName: FqName): ClassDescriptor? {
|
||||
return trace.get(FQNAME_TO_CLASS_DESCRIPTOR, fqName.toUnsafe()) ?: findInPackageFragments(fqName)
|
||||
}
|
||||
|
||||
+4
-13
@@ -26,9 +26,7 @@ import org.jetbrains.kotlin.serialization.deserialization.ErrorReporter
|
||||
import org.jetbrains.kotlin.util.slicedMap.Slices
|
||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice
|
||||
|
||||
import javax.inject.Inject
|
||||
|
||||
public class TraceBasedErrorReporter : ErrorReporter {
|
||||
public class TraceBasedErrorReporter(private val trace: BindingTrace) : ErrorReporter {
|
||||
|
||||
companion object {
|
||||
private val LOG = Logger.getInstance(javaClass<TraceBasedErrorReporter>())
|
||||
@@ -43,24 +41,17 @@ public class TraceBasedErrorReporter : ErrorReporter {
|
||||
public val classId: ClassId
|
||||
)
|
||||
|
||||
private var trace: BindingTrace? = null
|
||||
|
||||
Inject
|
||||
public fun setTrace(trace: BindingTrace) {
|
||||
this.trace = trace
|
||||
}
|
||||
|
||||
override fun reportIncompatibleAbiVersion(classId: ClassId, filePath: String, actualVersion: Int) {
|
||||
trace!!.record(ABI_VERSION_ERRORS, filePath, AbiVersionErrorData(actualVersion, classId))
|
||||
trace.record(ABI_VERSION_ERRORS, filePath, AbiVersionErrorData(actualVersion, classId))
|
||||
}
|
||||
|
||||
override fun reportIncompleteHierarchy(descriptor: ClassDescriptor, unresolvedSuperClasses: List<String>) {
|
||||
// TODO: MutableList is a workaround for KT-5792 Covariant types in Kotlin translated to wildcard types in Java
|
||||
trace!!.record(INCOMPLETE_HIERARCHY, descriptor, unresolvedSuperClasses as MutableList)
|
||||
trace.record(INCOMPLETE_HIERARCHY, descriptor, unresolvedSuperClasses as MutableList)
|
||||
}
|
||||
|
||||
override fun reportCannotInferVisibility(descriptor: CallableMemberDescriptor) {
|
||||
OverrideResolver.createCannotInferVisibilityReporter(trace!!).invoke(descriptor)
|
||||
OverrideResolver.createCannotInferVisibilityReporter(trace).invoke(descriptor)
|
||||
}
|
||||
|
||||
override fun reportLoadingError(message: String, exception: Exception?) {
|
||||
|
||||
+9
-15
@@ -35,28 +35,22 @@ import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.AlternativeMethodSignatu
|
||||
import org.jetbrains.kotlin.resolve.jvm.kotlinSignature.SignaturesPropagationData;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class TraceBasedExternalSignatureResolver implements ExternalSignatureResolver {
|
||||
private BindingTrace trace;
|
||||
private ExternalAnnotationResolver externalAnnotationResolver;
|
||||
private Project project;
|
||||
@NotNull private final BindingTrace trace;
|
||||
@NotNull private final ExternalAnnotationResolver externalAnnotationResolver;
|
||||
@NotNull private final Project project;
|
||||
|
||||
@Inject
|
||||
public void setTrace(BindingTrace trace) {
|
||||
this.trace = trace;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setExternalAnnotationResolver(ExternalAnnotationResolver externalAnnotationResolver) {
|
||||
public TraceBasedExternalSignatureResolver(
|
||||
@NotNull ExternalAnnotationResolver externalAnnotationResolver,
|
||||
@NotNull Project project,
|
||||
@NotNull BindingTrace trace
|
||||
) {
|
||||
this.externalAnnotationResolver = externalAnnotationResolver;
|
||||
}
|
||||
|
||||
@Inject
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
this.trace = trace;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user