Our test infrastructure (in particular, muting mechanics) rely on
thrown exception during doTestFor function call. But if the
exception happened on background thread, then here we'll get only
TimeOutException but the actual exception won't be reported during
doTestFor call. It would be reported later by the common IDEA test
framework and bypass our mute mechanics
Before the System.lineSeparator() was used for splitting KtFile.text into lines.
In IJ all lines has UNIX file endings, so it failed on Windows TC agent
When listing members in a class, we need to resolve super types. But if
a super type is defined in another file, this file may not have been
resolved. In this case, listing the members would require resolving the
unresolved file, which can only be done in a write lock.
Before this change, KtFirScopeProvider only acquire the read lock, which
then causes read/write deadlock when the logic tries to further resolve
super types defined in other files. This change makes KtFirScopeProvider
acquire a write lock in the beginning so resolving can happen correctly
later.
Previously, the FirFieldImpl generated from class delegation has a real
source. This causes troubles in the IDE. This change adds a new fake
source kind for class delegation fields.
Currently FIR IDE throws exceptions when enumerating members in this
scope if the class has delegate super types.
java.lang.IllegalStateException: Expected FirResolvedTypeRef with ConeKotlinType but was FirUserTypeRefImpl Tjava.lang.IllegalStateException: java.lang.IllegalStateException: Expected FirResolvedTypeRef with ConeKotlinType but was FirUserTypeRefImpl T
at org.jetbrains.kotlin.test.KotlinTestUtils.lambda$runTestWithThrowable$3(KotlinTestUtils.java:498)
at org.jetbrains.kotlin.test.MuteWithDatabaseKt.runTest(muteWithDatabase.kt:96)
at org.jetbrains.kotlin.test.KotlinTestUtils.runTestWithThrowable(KotlinTestUtils.java:493)
at org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCaseBase.runTest(KotlinLightCodeInsightFixtureTestCaseBase.java:93)
at com.intellij.testFramework.UsefulTestCase.defaultRunBare(UsefulTestCase.java:394)
at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:18)
at com.intellij.testFramework.EdtTestUtil$Companion$runInEdtAndWait$1.invoke(EdtTestUtil.kt:13)
at com.intellij.testFramework.EdtTestUtilKt$runInEdtAndWait$1.run(EdtTestUtil.kt:50)
at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:201)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:802)
at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeAndWait$8(ApplicationImpl.java:475)
at com.intellij.openapi.application.impl.LaterInvocator$1.run(LaterInvocator.java:126)
at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:84)
at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:132)
at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:188)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:971)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:841)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:452)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:744)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:451)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:802)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:499)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.IllegalStateException: Expected FirResolvedTypeRef with ConeKotlinType but was FirUserTypeRefImpl T
at org.jetbrains.kotlin.fir.types.FirTypeUtilsKt.getConeType(FirTypeUtils.kt:33)
at org.jetbrains.kotlin.fir.scopes.KotlinScopeProviderKt.scopeForSupertype(KotlinScopeProvider.kt:111)
at org.jetbrains.kotlin.fir.scopes.KotlinScopeProvider.getUseSiteMemberScope(KotlinScopeProvider.kt:42)
at org.jetbrains.kotlin.fir.scopes.KotlinScopeProviderKt.unsubstitutedScope(KotlinScopeProvider.kt:83)
at org.jetbrains.kotlin.idea.frontend.api.fir.components.KtFirScopeProvider$getMemberScope$lambda-3$lambda-2$$inlined$withFirForScope$1.invoke(FirRefWithValidityCheck.kt:83)
at org.jetbrains.kotlin.idea.frontend.api.fir.components.KtFirScopeProvider$getMemberScope$lambda-3$lambda-2$$inlined$withFirForScope$1.invoke(FirRefWithValidityCheck.kt:41)
at org.jetbrains.kotlin.idea.fir.low.level.api.api.LowLevelFirApiFacadeKt.withFirDeclaration(LowLevelFirApiFacade.kt:209)
at org.jetbrains.kotlin.idea.frontend.api.fir.components.KtFirScopeProvider.getMemberScope(KtFirScopeProvider.kt:323)
at org.jetbrains.kotlin.idea.frontend.api.components.KtScopeProviderMixIn$DefaultImpls.getMemberScope(KtScopeProvider.kt:34)
at org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession.getMemberScope(KtAnalysisSession.kt:26)
at org.jetbrains.kotlin.idea.core.overrideImplement.KtOverrideMembersHandler.getOverridableMembers(KtOverrideMembersHandler.kt:54)
at org.jetbrains.kotlin.idea.core.overrideImplement.KtOverrideMembersHandler.collectMembers(KtOverrideMembersHandler.kt:35)
at org.jetbrains.kotlin.idea.core.overrideImplement.KtOverrideMembersHandler.collectMembersToGenerate(KtOverrideMembersHandler.kt:28)
at org.jetbrains.kotlin.idea.codeInsight.AbstractOverrideImplementTest.doMultiOverrideImplement(AbstractOverrideImplementTest.kt:141)
at org.jetbrains.kotlin.idea.codeInsight.AbstractOverrideImplementTest.doMultiFileTest(AbstractOverrideImplementTest.kt:98)
at org.jetbrains.kotlin.idea.codeInsight.AbstractOverrideImplementTest.doMultiOverrideFileTest(AbstractOverrideImplementTest.kt:54)
at org.jetbrains.kotlin.idea.codeInsight.OverrideImplementTest.testDelegatedMembers(OverrideImplementTest.kt:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at junit.framework.TestCase.runTest(TestCase.java:176)
at com.intellij.testFramework.UsefulTestCase.lambda$runTest$9(UsefulTestCase.java:331)
at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:462)
at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:480)
at com.intellij.testFramework.UsefulTestCase.invokeTestRunnable(UsefulTestCase.java:378)
at com.intellij.testFramework.UsefulTestCase.runTest(UsefulTestCase.java:350)
at org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCaseBase.lambda$runTest$0(KotlinLightCodeInsightFixtureTestCaseBase.java:93)
at org.jetbrains.kotlin.test.KotlinTestUtils.lambda$runTestWithThrowable$3(KotlinTestUtils.java:495)
... 36 more
.. 112 more