Create actual: use analyzeWithContent to resolve annotations correctly
So #KT-26626 Fixed
This commit is contained in:
@@ -34,7 +34,7 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic
|
|||||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
|
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
|
||||||
import org.jetbrains.kotlin.diagnostics.Errors
|
import org.jetbrains.kotlin.diagnostics.Errors
|
||||||
import org.jetbrains.kotlin.idea.caches.project.ModuleSourceInfo
|
import org.jetbrains.kotlin.idea.caches.project.ModuleSourceInfo
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
import org.jetbrains.kotlin.idea.caches.resolve.analyzeWithContent
|
||||||
import org.jetbrains.kotlin.idea.core.*
|
import org.jetbrains.kotlin.idea.core.*
|
||||||
import org.jetbrains.kotlin.idea.quickfix.KotlinQuickFixAction
|
import org.jetbrains.kotlin.idea.quickfix.KotlinQuickFixAction
|
||||||
import org.jetbrains.kotlin.idea.quickfix.KotlinSingleIntentionActionFactory
|
import org.jetbrains.kotlin.idea.quickfix.KotlinSingleIntentionActionFactory
|
||||||
@@ -277,7 +277,7 @@ internal fun KtPsiFactory.generateClassOrObjectByExpectedClass(
|
|||||||
primaryConstructor.delete()
|
primaryConstructor.delete()
|
||||||
}
|
}
|
||||||
|
|
||||||
val context = expectedClass.analyze()
|
val context = expectedClass.analyzeWithContent()
|
||||||
actualClass.superTypeListEntries.zip(expectedClass.superTypeListEntries).forEach { (actualEntry, expectedEntry) ->
|
actualClass.superTypeListEntries.zip(expectedClass.superTypeListEntries).forEach { (actualEntry, expectedEntry) ->
|
||||||
if (actualEntry !is KtSuperTypeEntry) return@forEach
|
if (actualEntry !is KtSuperTypeEntry) return@forEach
|
||||||
val superType = context[BindingContext.TYPE, expectedEntry.typeReference]
|
val superType = context[BindingContext.TYPE, expectedEntry.typeReference]
|
||||||
|
|||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
// "Create actual annotation class for module testModule_JVM (JVM)" "true"
|
||||||
|
// TOOL: org.jetbrains.kotlin.idea.inspections.OptionalExpectationInspection
|
||||||
|
|
||||||
|
package kotlin
|
||||||
|
|
||||||
|
annotation class ExperimentalMultiplatform
|
||||||
|
annotation class OptionalExpectation
|
||||||
|
|
||||||
|
@ExperimentalMultiplatform
|
||||||
|
@OptionalExpectation
|
||||||
|
expect annotation class <caret>Ann
|
||||||
Vendored
+11
@@ -0,0 +1,11 @@
|
|||||||
|
// "Create actual annotation class for module testModule_JVM (JVM)" "true"
|
||||||
|
// TOOL: org.jetbrains.kotlin.idea.inspections.OptionalExpectationInspection
|
||||||
|
|
||||||
|
package kotlin
|
||||||
|
|
||||||
|
annotation class ExperimentalMultiplatform
|
||||||
|
annotation class OptionalExpectation
|
||||||
|
|
||||||
|
@ExperimentalMultiplatform
|
||||||
|
@OptionalExpectation
|
||||||
|
expect annotation class <caret>Ann
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package kotlin
|
||||||
|
|
||||||
|
actual annotation class Ann
|
||||||
+5
@@ -79,6 +79,11 @@ public class QuickFixMultiModuleTestGenerated extends AbstractQuickFixMultiModul
|
|||||||
runTest("idea/testData/multiModuleQuickFix/annotationOptionalExpectation/");
|
runTest("idea/testData/multiModuleQuickFix/annotationOptionalExpectation/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("annotationOptionalExpectationNoDir")
|
||||||
|
public void testAnnotationOptionalExpectationNoDir() throws Exception {
|
||||||
|
runTest("idea/testData/multiModuleQuickFix/annotationOptionalExpectationNoDir/");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("class")
|
@TestMetadata("class")
|
||||||
public void testClass() throws Exception {
|
public void testClass() throws Exception {
|
||||||
runTest("idea/testData/multiModuleQuickFix/class/");
|
runTest("idea/testData/multiModuleQuickFix/class/");
|
||||||
|
|||||||
Reference in New Issue
Block a user