mamoe / mirai-console

mirai 的高效率 QQ 机器人控制台
GNU Affero General Public License v3.0
1.19k stars 412 forks source link

IntelliJ plugin incompatible with new version of Kotlin plugin #363

Closed hguandl closed 3 years ago

hguandl commented 3 years ago

If Kotlin plugin is upgraded to lastest (211-1.5.10-release-891-IJ7142.45), Mirai Console (2.6.3) would report such exception:

java.util.NoSuchElementException: Collection is empty.
    at kotlin.collections.CollectionsKt___CollectionsKt.first(_Collections.kt:200)
    at net.mamoe.mirai.console.compiler.common.UtilCommonKt.firstValue(utilCommon.kt:19)
    at net.mamoe.mirai.console.compiler.common.resolve.ResolveTypesKt.getResolveContextKinds(resolveTypes.kt:72)
    at net.mamoe.mirai.console.intellij.diagnostics.ContextualParametersChecker.checkArgument(ContextualParametersChecker.kt:65)
    at net.mamoe.mirai.console.intellij.diagnostics.ContextualParametersChecker.check(ContextualParametersChecker.kt:54)
    at net.mamoe.mirai.console.intellij.IDEContainerContributor$DeclarationCheckerIgnoringExceptions.check(IDEContainerContributor.kt:56)
    at org.jetbrains.kotlin.resolve.ModifiersChecker$ModifiersCheckingProcedure.runDeclarationCheckers(ModifiersChecker.java:285)
    at org.jetbrains.kotlin.resolve.ModifiersChecker$ModifiersCheckingProcedure.checkModifierListCommon(ModifiersChecker.java:224)
    at org.jetbrains.kotlin.resolve.ModifiersChecker$ModifiersCheckingProcedure.checkModifiersForDeclaration(ModifiersChecker.java:183)
    at org.jetbrains.kotlin.resolve.DeclarationsChecker.process(DeclarationsChecker.kt:94)
    at org.jetbrains.kotlin.resolve.BodyResolver.resolveBodies(BodyResolver.java:256)
    at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer.analyzeDeclarations(LazyTopDownAnalyzer.kt:227)
    at org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer.analyzeDeclarations$default(LazyTopDownAnalyzer.kt:58)
    at org.jetbrains.kotlin.idea.caches.resolve.KotlinResolveDataProvider.analyze(PerFileAnalysisCache.kt:492)
    at org.jetbrains.kotlin.idea.caches.resolve.PerFileAnalysisCache.analyze(PerFileAnalysisCache.kt:265)
    at org.jetbrains.kotlin.idea.caches.resolve.PerFileAnalysisCache.access$analyze(PerFileAnalysisCache.kt:53)
    at org.jetbrains.kotlin.idea.caches.resolve.PerFileAnalysisCache.getAnalysisResults$kotlin_core(PerFileAnalysisCache.kt:127)
    at org.jetbrains.kotlin.idea.caches.resolve.ProjectResolutionFacade.getAnalysisResultsForElements$kotlin_core(ProjectResolutionFacade.kt:168)
    at org.jetbrains.kotlin.idea.caches.resolve.ModuleResolutionFacadeImpl$analyzeWithAllCompilerChecks$1.invoke(ModuleResolutionFacadeImpl.kt:79)
    at org.jetbrains.kotlin.idea.caches.resolve.ModuleResolutionFacadeImpl$analyzeWithAllCompilerChecks$1.invoke(ModuleResolutionFacadeImpl.kt:42)
    at com.intellij.openapi.progress.impl.CancellationCheck.withCancellationCheck(CancellationCheck.kt:59)
    at com.intellij.openapi.progress.impl.CancellationCheck$Companion.runWithCancellationCheck(CancellationCheck.kt:105)
    at org.jetbrains.kotlin.idea.util.application.ApplicationUtilsKt.runWithCancellationCheck(ApplicationUtils.kt:48)
    at org.jetbrains.kotlin.idea.caches.resolve.ModuleResolutionFacadeImpl.analyzeWithAllCompilerChecks(ModuleResolutionFacadeImpl.kt:78)
    at org.jetbrains.kotlin.idea.caches.resolve.ResolutionFacadeWithDebugInfo.analyzeWithAllCompilerChecks(ResolutionFacadeWithDebugInfo.kt:61)
    at org.jetbrains.kotlin.idea.caches.resolve.ResolutionUtils.analyzeWithAllCompilerChecks(resolutionApi.kt:175)
    at org.jetbrains.kotlin.idea.caches.resolve.ResolutionUtils.analyzeWithAllCompilerChecks(resolutionApi.kt:171)
    at org.jetbrains.kotlin.idea.highlighter.AbstractKotlinHighlightVisitor.analyze(AbstractKotlinHighlightVisitor.kt:89)
    at org.jetbrains.kotlin.idea.highlighter.AbstractKotlinHighlightVisitor.analyze(AbstractKotlinHighlightVisitor.kt:56)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:297)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.lambda$analyzeByVisitors$6(GeneralHighlightingPass.java:297)
    at com.intellij.codeInsight.daemon.impl.DefaultHighlightVisitor.analyze(DefaultHighlightVisitor.java:96)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.analyzeByVisitors(GeneralHighlightingPass.java:297)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectHighlights(GeneralHighlightingPass.java:265)
    at com.intellij.codeInsight.daemon.impl.GeneralHighlightingPass.collectInformationWithProgress(GeneralHighlightingPass.java:211)
    at com.intellij.codeInsight.daemon.impl.ProgressableTextEditorHighlightingPass.doCollectInformation(ProgressableTextEditorHighlightingPass.java:84)
    at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:56)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$1(PassExecutorService.java:400)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1096)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:393)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:688)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:634)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:64)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:392)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:368)
    at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:167)
    at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:178)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:366)
    at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:188)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)

After I restore the default version of Kotlin plugin (211-1.4.32-release-IJ7442.2), Mirai Console works fine.

Karlatemp commented 3 years ago

Steps to reproduce? What file you are editing?

hguandl commented 3 years ago
  1. Upgrade Kotlin plugin from 211-1.4.32-release-IJ7442.2 to 211-1.5.10-release-891-IJ7142.45.
  2. Create a new project from template provided by Mirai Console.
  3. Open src/main/kotlin/Plugin.kt, and then it reports "IDE error occurred".

Platform information: IntelliJ IDEA 2021.1.2 (Ultimate Edition) Build #IU-211.7442.40, built on June 1, 2021 Runtime version: 11.0.11+9-b1341.57 x86_64 VM: Dynamic Code Evolution 64-Bit Server VM by JetBrains s.r.o. macOS 11.4 GC: G1 Young Generation, G1 Old Generation Memory: 2048M Cores: 12 Registry: ide.balloon.shadow.size=0 Non-Bundled Plugins: com.mallowigi (36.0), mobi.hsz.idea.gitignore (4.1.0), org.jetbrains.kotlin (211-1.5.10-release-891-IJ7142.45), net.mamoe.mirai-console (2.6.3), com.chrisrm.idea.MaterialThemeUI (6.6.0), izhangzhihao.rainbow.brackets (6.17), me.xdrop.night-owl (1.5.8) Kotlin: 211-1.5.10-release-891-IJ7142.45