Fix race in IDE: inject proper storage manager for type parameters

With NO_LOCKS strategy we can easily end up in a situation when
 constraint system for a generic call is built incorrectly,
 producing flaky errors (or don't produce errors at all)

 Now proper storage manager is injected for all cases except:
 - IR
 - Codegen
 - Serialization plugin
 - Fake local objects

 Most likely, NO_LOCKS strategy for these cases is fine as at that point
 the compiler works in one thread

 #KT-34786 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2019-11-25 17:12:28 +03:00
parent 399667a434
commit eb73650209
21 changed files with 103 additions and 40 deletions
@@ -21,8 +21,6 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorUtils
import java.util.*
open class AbstractAccessorForFunctionDescriptor(
containingDeclaration: DeclarationDescriptor,
@@ -34,7 +32,9 @@ open class AbstractAccessorForFunctionDescriptor(
val copy = TypeParameterDescriptorImpl.createForFurtherModification(
this, it.annotations, it.isReified,
it.variance, it.name,
it.index, SourceElement.NO_SOURCE)
it.index, SourceElement.NO_SOURCE,
it.storageManager
)
for (upperBound in it.upperBounds) {
copy.addUpperBound(upperBound)
}
@@ -76,7 +76,8 @@ fun CallableMemberDescriptor.createTypeParameterWithNewName(
descriptor.variance,
Name.identifier(newName),
descriptor.index,
descriptor.source
descriptor.source,
descriptor.storageManager
)
descriptor.upperBounds.forEach {
newDescriptor.addUpperBound(it)