Get rid of recordToTrace
recordToTrace is a bad practice as instance could be initialized out of our control (e.g. in other plugins) #KTIJ-22182
This commit is contained in:
committed by
Space Team
parent
79b8954814
commit
d3fcd965ba
@@ -96,7 +96,6 @@ public class AnnotationResolverImpl extends AnnotationResolver {
|
||||
if (descriptor == null) {
|
||||
LazyAnnotationDescriptor lazyAnnotationDescriptor =
|
||||
new LazyAnnotationDescriptor(new LazyAnnotationsContextImpl(this, storageManager, trace, scope), entryElement);
|
||||
lazyAnnotationDescriptor.recordToTrace();
|
||||
descriptor = lazyAnnotationDescriptor;
|
||||
}
|
||||
if (shouldResolveArguments) {
|
||||
|
||||
+5
-5
@@ -60,7 +60,7 @@ class LazyAnnotations(
|
||||
override fun isEmpty() = annotationEntries.isEmpty()
|
||||
|
||||
private val annotation = c.storageManager.createMemoizedFunction { entry: KtAnnotationEntry ->
|
||||
c.trace.get(BindingContext.ANNOTATION, entry) ?: LazyAnnotationDescriptor(c, entry).also { it.recordToTrace() }
|
||||
c.trace.get(BindingContext.ANNOTATION, entry) ?: LazyAnnotationDescriptor(c, entry)
|
||||
}
|
||||
|
||||
override fun iterator(): Iterator<AnnotationDescriptor> = annotationEntries.asSequence().map(annotation).iterator()
|
||||
@@ -121,6 +121,10 @@ class LazyAnnotationDescriptor(
|
||||
valueArgumentsWithSourceInfo.mapValues { it.value.first }
|
||||
}
|
||||
|
||||
init {
|
||||
c.trace.record(BindingContext.ANNOTATION, annotationEntry, this)
|
||||
}
|
||||
|
||||
fun getSourceForArgument(name: Name): SourceElement =
|
||||
valueArgumentsWithSourceInfo[name]?.second ?: SourceElement.NO_SOURCE
|
||||
|
||||
@@ -129,10 +133,6 @@ class LazyAnnotationDescriptor(
|
||||
allValueArguments
|
||||
}
|
||||
|
||||
fun recordToTrace() {
|
||||
c.trace.record(BindingContext.ANNOTATION, annotationEntry, this)
|
||||
}
|
||||
|
||||
private class FileDescriptorForVisibilityChecks(
|
||||
private val source: SourceElement,
|
||||
private val containingDeclaration: PackageFragmentDescriptor
|
||||
|
||||
Reference in New Issue
Block a user