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
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.resolve.TypeResolver;
import org.jetbrains.kotlin.resolve.lazy.JvmResolveUtil;
import org.jetbrains.kotlin.resolve.scopes.*;
import org.jetbrains.kotlin.resolve.scopes.utils.ScopeUtilsKt;
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import org.jetbrains.kotlin.test.ConfigurationKind;
import org.jetbrains.kotlin.test.DummyTraces;
import org.jetbrains.kotlin.test.KotlinTestWithEnvironment;
@@ -77,7 +78,8 @@ public class TypeUnifierTest extends KotlinTestWithEnvironment {
private TypeParameterDescriptor createTypeVariable(String name) {
return TypeParameterDescriptorImpl.createWithDefaultBound(
module, Annotations.Companion.getEMPTY(), false, Variance.INVARIANT, Name.identifier(name), 0
module, Annotations.Companion.getEMPTY(), false, Variance.INVARIANT,
Name.identifier(name), 0, LockBasedStorageManager.NO_LOCKS
);
}