[NI] Look for type variables in captured flexible types
#KT-32434 Fixed
This commit is contained in:
+5
@@ -9711,6 +9711,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
|
||||
runTest("compiler/testData/diagnostics/tests/inference/kt3184.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt32434.kt")
|
||||
public void testKt32434() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/kt32434.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt6175.kt")
|
||||
public void testKt6175() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/kt6175.kt");
|
||||
|
||||
+9
-5
@@ -90,7 +90,7 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck
|
||||
val projection = typeMarker.typeConstructorProjection()
|
||||
if (projection.isStarProjection()) return null
|
||||
if (projection.getVariance() == TypeVariance.IN) {
|
||||
val type = projection.getType().asSimpleType() ?: return null
|
||||
val type = projection.getType().let { it.asSimpleType() ?: it.asFlexibleType()?.lowerBound() } ?: return null
|
||||
if (isMyTypeVariable(type)) {
|
||||
simplifyLowerConstraint(type, superType)
|
||||
if (isMyTypeVariable(superType.asSimpleType() ?: return null)) {
|
||||
@@ -100,10 +100,14 @@ abstract class AbstractTypeCheckerContextForConstraintSystem : AbstractTypeCheck
|
||||
return null
|
||||
}
|
||||
|
||||
return if (projection.getVariance() == TypeVariance.OUT)
|
||||
projection.getType().takeIf { it is SimpleTypeMarker && isMyTypeVariable(it) }?.asSimpleType()
|
||||
else
|
||||
null
|
||||
return if (projection.getVariance() == TypeVariance.OUT) {
|
||||
val type = projection.getType()
|
||||
when {
|
||||
type is SimpleTypeMarker && isMyTypeVariable(type) -> type.asSimpleType()
|
||||
type is FlexibleTypeMarker && isMyTypeVariable(type.lowerBound()) -> type.asFlexibleType()?.lowerBound()
|
||||
else -> null
|
||||
}
|
||||
} else null
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// FULL_JDK
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// Issue: KT-32434
|
||||
|
||||
// FILE: CacheMonoJava.java
|
||||
|
||||
public class CacheMonoJava {
|
||||
public static <K, V> Mono<V> lookup(java.util.Map<K, ? super Signal<? extends V>> map, K key) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
interface Cache<K, V> {
|
||||
fun asMap(): MutableMap<K, V>
|
||||
}
|
||||
|
||||
interface Mono<E>
|
||||
interface Signal<E> : Mono<E>
|
||||
|
||||
interface AttributeDefinition
|
||||
|
||||
val cache: Cache<String, Signal<out AttributeDefinition>> = TODO()
|
||||
|
||||
object CacheMonoKotlin {
|
||||
fun <K, V> lookup(map: MutableMap<K, in Signal<out V>>, key: K): Mono<V> = TODO()
|
||||
}
|
||||
|
||||
fun findByName_java(name: String): Mono<AttributeDefinition> = CacheMonoJava.lookup(cache.asMap(), name)
|
||||
fun findByName_kotlin(name: String): Mono<AttributeDefinition> = CacheMonoKotlin.lookup(cache.asMap(), name)
|
||||
@@ -0,0 +1,48 @@
|
||||
package
|
||||
|
||||
public val cache: Cache<kotlin.String, Signal<out AttributeDefinition>>
|
||||
public fun findByName_java(/*0*/ name: kotlin.String): Mono<AttributeDefinition>
|
||||
public fun findByName_kotlin(/*0*/ name: kotlin.String): Mono<AttributeDefinition>
|
||||
|
||||
public interface AttributeDefinition {
|
||||
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 Cache</*0*/ K, /*1*/ V> {
|
||||
public abstract fun asMap(): kotlin.collections.MutableMap<K, V>
|
||||
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 open class CacheMonoJava {
|
||||
public constructor CacheMonoJava()
|
||||
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
|
||||
|
||||
// Static members
|
||||
public open fun </*0*/ K : kotlin.Any!, /*1*/ V : kotlin.Any!> lookup(/*0*/ map: kotlin.collections.MutableMap<K!, in Signal<out V!>!>!, /*1*/ key: K!): Mono<V!>!
|
||||
}
|
||||
|
||||
public object CacheMonoKotlin {
|
||||
private constructor CacheMonoKotlin()
|
||||
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 final fun </*0*/ K, /*1*/ V> lookup(/*0*/ map: kotlin.collections.MutableMap<K, in Signal<out V>>, /*1*/ key: K): Mono<V>
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Mono</*0*/ E> {
|
||||
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 Signal</*0*/ E> : Mono<E> {
|
||||
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
|
||||
}
|
||||
@@ -9718,6 +9718,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/kt3184.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt32434.kt")
|
||||
public void testKt32434() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/kt32434.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt6175.kt")
|
||||
public void testKt6175() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/kt6175.kt");
|
||||
|
||||
Generated
+5
@@ -9713,6 +9713,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/inference/kt3184.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt32434.kt")
|
||||
public void testKt32434() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/kt32434.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt6175.kt")
|
||||
public void testKt6175() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/kt6175.kt");
|
||||
|
||||
Reference in New Issue
Block a user