Render stub types properly

This commit is contained in:
Victor Petukhov
2021-04-27 13:57:46 +03:00
parent af12b2fdf0
commit 26b8e86fe1
8 changed files with 104 additions and 10 deletions
@@ -12638,6 +12638,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/builderInference"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test
@TestMetadata("renderingStubTypes.kt")
public void testRenderingStubTypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/builderInference/renderingStubTypes.kt");
}
@Test
@TestMetadata("simpleLambdaInCallWithAnotherLambdaWithBuilderInference.kt")
public void testSimpleLambdaInCallWithAnotherLambdaWithBuilderInference() throws Exception {
@@ -12638,6 +12638,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/builderInference"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test
@TestMetadata("renderingStubTypes.kt")
public void testRenderingStubTypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/builderInference/renderingStubTypes.kt");
}
@Test
@TestMetadata("simpleLambdaInCallWithAnotherLambdaWithBuilderInference.kt")
public void testSimpleLambdaInCallWithAnotherLambdaWithBuilderInference() throws Exception {
@@ -0,0 +1,25 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// WITH_RUNTIME
import kotlin.experimental.ExperimentalTypeInference
@UseExperimental(ExperimentalTypeInference::class)
fun <R> build(
@BuilderInference block: TestInterface<R>.() -> Unit
): R = TODO()
class Inv<K>
interface TestInterface<R> {
fun emit(r: R)
fun get(): R
fun getInv(): Inv<R>
}
fun test() {
val ret = build {
emit(1)
get()
getInv()
}
}
@@ -0,0 +1,28 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -EXPERIMENTAL_IS_NOT_ENABLED -UNUSED_VARIABLE
// WITH_RUNTIME
import kotlin.experimental.ExperimentalTypeInference
@UseExperimental(ExperimentalTypeInference::class)
fun <R> build(
@BuilderInference block: TestInterface<R>.() -> Unit
): R = TODO()
class Inv<K>
interface TestInterface<R> {
fun emit(r: R)
fun get(): R
fun getInv(): Inv<R>
}
fun <U> id(x: U) = x
fun test() {
val ret = build {
emit("1")
<!DEBUG_INFO_EXPRESSION_TYPE("TypeVariable(R)")!>get()<!>
<!DEBUG_INFO_EXPRESSION_TYPE("Inv<TypeVariable(R)>")!>getInv()<!>
""
}
}
@@ -0,0 +1,21 @@
package
@kotlin.UseExperimental(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun </*0*/ R> build(/*0*/ @kotlin.BuilderInference block: TestInterface<R>.() -> kotlin.Unit): R
public fun </*0*/ U> id(/*0*/ x: U): U
public fun test(): kotlin.Unit
public final class Inv</*0*/ K> {
public constructor Inv</*0*/ K>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface TestInterface</*0*/ R> {
public abstract fun emit(/*0*/ r: R): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun get(): R
public abstract fun getInv(): Inv<R>
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -12644,6 +12644,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/builderInference"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test
@TestMetadata("renderingStubTypes.kt")
public void testRenderingStubTypes() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/builderInference/renderingStubTypes.kt");
}
@Test
@TestMetadata("simpleLambdaInCallWithAnotherLambdaWithBuilderInference.kt")
public void testSimpleLambdaInCallWithAnotherLambdaWithBuilderInference() throws Exception {
@@ -236,19 +236,21 @@ internal class DescriptorRendererImpl(
private fun StringBuilder.renderDefaultType(type: KotlinType) {
this.renderAnnotations(type)
if (type.isError) {
if (type is UnresolvedType && presentableUnresolvedTypes) {
append(type.presentableName)
} else {
if (type is ErrorType && !informativeErrorType) {
when {
type.isError -> {
if (type is UnresolvedType && presentableUnresolvedTypes) {
append(type.presentableName)
} else {
append(type.constructor.toString()) // Debug name of an error type is more informative
if (type is ErrorType && !informativeErrorType) {
append(type.presentableName)
} else {
append(type.constructor.toString()) // Debug name of an error type is more informative
}
}
append(renderTypeArguments(type.arguments))
}
append(renderTypeArguments(type.arguments))
} else {
renderTypeConstructorAndArguments(type)
type is StubType -> append(type.originalTypeVariable.toString())
else -> renderTypeConstructorAndArguments(type)
}
if (type.isMarkedNullable) {
@@ -36,7 +36,7 @@ class StubTypeForProvideDelegateReceiver(
}
abstract class AbstractStubType(
protected val originalTypeVariable: TypeConstructor,
val originalTypeVariable: TypeConstructor,
override val isMarkedNullable: Boolean,
override val constructor: TypeConstructor,
override val memberScope: MemberScope