[NI] Fix OnlyInputTypes for captured types
Uncapture projections recursively for cases when captured type is not top-level type or first level type argument
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
|
||||
annotation class Anno
|
||||
|
||||
fun test(a: List<Class<Anno>>) {
|
||||
strictSelect(a, emptyList<Anno>().map { it.annotationClass.java })
|
||||
}
|
||||
|
||||
fun <@kotlin.internal.OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = TODO()
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ @kotlin.internal.OnlyInputTypes S> strictSelect(/*0*/ arg1: S, /*1*/ arg2: S): S
|
||||
public fun test(/*0*/ a: kotlin.collections.List<java.lang.Class<Anno>>): kotlin.Unit
|
||||
|
||||
public final annotation class Anno : kotlin.Annotation {
|
||||
public constructor Anno()
|
||||
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
|
||||
}
|
||||
+5
@@ -2798,6 +2798,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt35210.kt")
|
||||
public void testKt35210() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noInferAndLowPriority.kt")
|
||||
public void testNoInferAndLowPriority() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.kt");
|
||||
|
||||
compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java
Generated
+5
@@ -2798,6 +2798,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt29307.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt35210.kt")
|
||||
public void testKt35210() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/kt35210.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noInferAndLowPriority.kt")
|
||||
public void testNoInferAndLowPriority() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/noInferAndLowPriority.kt");
|
||||
|
||||
@@ -265,15 +265,25 @@ fun UnwrappedType.unCapture(): UnwrappedType = when (this) {
|
||||
}
|
||||
|
||||
fun SimpleType.unCapture(): UnwrappedType {
|
||||
if (this is ErrorType) return this
|
||||
if (this is NewCapturedType)
|
||||
return unCaptureTopLevelType()
|
||||
|
||||
val newArguments = arguments.map { projection ->
|
||||
projection.type.constructor.safeAs<NewCapturedTypeConstructor>()?.let {
|
||||
it.projection
|
||||
} ?: projection
|
||||
}
|
||||
return replace(newArguments)
|
||||
val newArguments = arguments.map(::unCaptureProjection)
|
||||
return replace(newArguments).unwrap()
|
||||
}
|
||||
|
||||
fun unCaptureProjection(projection: TypeProjection): TypeProjection {
|
||||
val unCapturedProjection = projection.type.constructor.safeAs<NewCapturedTypeConstructor>()?.let {
|
||||
it.projection
|
||||
} ?: projection
|
||||
if (unCapturedProjection.type is ErrorType) return unCapturedProjection
|
||||
|
||||
val newArguments = unCapturedProjection.type.arguments.map(::unCaptureProjection)
|
||||
return TypeProjectionImpl(
|
||||
unCapturedProjection.projectionKind,
|
||||
unCapturedProjection.type.replace(newArguments)
|
||||
)
|
||||
}
|
||||
|
||||
fun AbbreviatedType.unCapture(): SimpleType {
|
||||
|
||||
Reference in New Issue
Block a user