Don't unwrap captured types in IDE descriptors renderers

#KT-42263 Fixed
This commit is contained in:
Dmitriy Novozhilov
2020-10-20 12:54:51 +03:00
parent 3068d79d2b
commit 0484ab8cca
6 changed files with 46 additions and 0 deletions
@@ -23,7 +23,9 @@ import org.jetbrains.kotlin.renderer.DescriptorRenderer
import org.jetbrains.kotlin.renderer.DescriptorRenderer.Companion.FQ_NAMES_IN_TYPES
import org.jetbrains.kotlin.renderer.DescriptorRendererModifier
import org.jetbrains.kotlin.renderer.OverrideRenderingPolicy
import org.jetbrains.kotlin.resolve.calls.inference.isCaptured
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.checker.NewCapturedTypeConstructor
import org.jetbrains.kotlin.types.isDynamic
import org.jetbrains.kotlin.types.typeUtil.builtIns
@@ -36,6 +38,7 @@ object IdeDescriptorRenderers {
private fun unwrapAnonymousType(type: KotlinType): KotlinType {
if (type.isDynamic()) return type
if (type.constructor is NewCapturedTypeConstructor) return type
val classifier = type.constructor.declarationDescriptor
if (classifier != null && !classifier.name.isSpecial) return type
@@ -113,6 +113,11 @@ public class FirHighlightingPerformanceTestGenerated extends AbstractFirHighligh
runTest("idea/testData/highlighter/PropertiesWithPropertyDeclarations.kt");
}
@TestMetadata("RecursiveTypes.kt")
public void testRecursiveTypes() throws Exception {
runTest("idea/testData/highlighter/RecursiveTypes.kt");
}
@TestMetadata("SmartCast.kt")
public void testSmartCast() throws Exception {
runTest("idea/testData/highlighter/SmartCast.kt");
@@ -115,6 +115,11 @@ public class FirHighlightingTestGenerated extends AbstractFirHighlightingTest {
runTest("idea/testData/highlighter/PropertiesWithPropertyDeclarations.kt");
}
@TestMetadata("RecursiveTypes.kt")
public void testRecursiveTypes() throws Exception {
runTest("idea/testData/highlighter/RecursiveTypes.kt");
}
@TestMetadata("SmartCast.kt")
public void testSmartCast() throws Exception {
runTest("idea/testData/highlighter/SmartCast.kt");
@@ -113,6 +113,11 @@ public class PerformanceHighlightingTestGenerated extends AbstractPerformanceHig
runTest("idea/testData/highlighter/PropertiesWithPropertyDeclarations.kt");
}
@TestMetadata("RecursiveTypes.kt")
public void testRecursiveTypes() throws Exception {
runTest("idea/testData/highlighter/RecursiveTypes.kt");
}
@TestMetadata("SmartCast.kt")
public void testSmartCast() throws Exception {
runTest("idea/testData/highlighter/SmartCast.kt");
+23
View File
@@ -0,0 +1,23 @@
// IGNORE_FIR
// EXPECTED_DUPLICATED_HIGHLIGHTING
// ISSUE: KT-42263
interface <info descr="null">TestModule</info>
<info descr="null">sealed</info> class <info descr="null">ResultingArtifact</info> {
<info descr="null">abstract</info> class <info descr="null">Source</info><<info descr="null">R</info> : <info descr="null">Source</info><<info descr="null">R</info>>> : <info descr="null">ResultingArtifact</info>() {
<info descr="null">abstract</info> val <info descr="null">frontendKind</info>: <info descr="null">FrontendKind</info><<info descr="null">R</info>>
}
}
class <info descr="null">ClassicFrontendSourceArtifacts</info> : <info descr="null">ResultingArtifact</info>.<info descr="null">Source</info><<info descr="null">ClassicFrontendSourceArtifacts</info>>() {
<info descr="null">override</info> val <info descr="null"><info descr="null">frontendKind</info></info>: <info descr="null">FrontendKind</info><<info descr="null">ClassicFrontendSourceArtifacts</info>>
<info descr="null">get</info>() = <info descr="null">FrontendKind</info>.<info descr="null">ClassicFrontend</info>
}
<info descr="null">sealed</info> class <info descr="null">FrontendKind</info><<info descr="null">R</info> : <info descr="null">ResultingArtifact</info>.<info descr="null">Source</info><<info descr="null">R</info>>> {
object <info descr="null">ClassicFrontend</info> : <info descr="null">FrontendKind</info><<info descr="null">ClassicFrontendSourceArtifacts</info>>()
}
<info descr="null">abstract</info> class <info descr="null">DependencyProvider</info> {
<info descr="null">abstract</info> fun <<info descr="null">R</info> : <info descr="null">ResultingArtifact</info>.<info descr="null">Source</info><<info descr="null">R</info>>> <info descr="null">registerSourceArtifact</info>(<info descr="null">artifact</info>: <info descr="null">R</info>)
}
fun <info descr="null">test</info>(<info descr="null">dependencyProvider</info>: <info descr="null">DependencyProvider</info>, <info descr="null">artifact</info>: <info descr="null">ResultingArtifact</info>.<info descr="null">Source</info><*>) {
<info descr="null">dependencyProvider</info>.<info descr="null">registerSourceArtifact</info>(<error descr="[TYPE_MISMATCH] Type mismatch: inferred type is ResultingArtifact.Source<*> but CapturedType(*) was expected">artifact</error>) // <- uncomment this and see exception
}
@@ -113,6 +113,11 @@ public class HighlightingTestGenerated extends AbstractHighlightingTest {
runTest("idea/testData/highlighter/PropertiesWithPropertyDeclarations.kt");
}
@TestMetadata("RecursiveTypes.kt")
public void testRecursiveTypes() throws Exception {
runTest("idea/testData/highlighter/RecursiveTypes.kt");
}
@TestMetadata("SmartCast.kt")
public void testSmartCast() throws Exception {
runTest("idea/testData/highlighter/SmartCast.kt");