[FIR] Fix type arguments and substitution for flexible types
This commit is contained in:
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
FILE: main.kt
|
FILE: main.kt
|
||||||
public final fun main(): R|kotlin/Unit| {
|
public final fun main(): R|kotlin/Unit| {
|
||||||
R|/MyFunction|<R|kotlin/Int|, R|kotlin/String|>(<L> = MyFunction@fun <anonymous>(x: R|kotlin/Int|): R|kotlin/String| {
|
R|/MyFunction|<R|kotlin/Int|, R|kotlin/String|>(<L> = MyFunction@fun <anonymous>(x: R|ft<kotlin/Int, kotlin/Int?>!|): R|kotlin/String| {
|
||||||
^ R|<local>/x|.R|kotlin/Int.toInt|().R|kotlin/Any.toString|()
|
^ R|<local>/x|.R|kotlin/Int.toInt|().R|kotlin/Any.toString|()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -8,7 +8,7 @@ FILE: main.kt
|
|||||||
^ R|<local>/x|.R|kotlin/Any.toString|()
|
^ R|<local>/x|.R|kotlin/Any.toString|()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
R|/MyFunction|<R|kotlin/Any?|, R|ft<kotlin/String, kotlin/String?>!|>(<L> = MyFunction@fun <anonymous>(x: R|kotlin/Any?|): R|kotlin/String| {
|
R|/MyFunction|<R|kotlin/Any?|, R|ft<kotlin/String, kotlin/String?>!|>(<L> = MyFunction@fun <anonymous>(x: R|ft<kotlin/Any?, kotlin/Any?>?|): R|kotlin/String| {
|
||||||
^ String()
|
^ String()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Vendored
+3
-3
@@ -6,11 +6,11 @@ FILE: main.kt
|
|||||||
public final fun <X, Y> foo3(f: R|MyFunction<X, Y>|, x: R|X|): R|kotlin/Unit| {
|
public final fun <X, Y> foo3(f: R|MyFunction<X, Y>|, x: R|X|): R|kotlin/Unit| {
|
||||||
}
|
}
|
||||||
public final fun main(): R|kotlin/Unit| {
|
public final fun main(): R|kotlin/Unit| {
|
||||||
R|/foo1|(R|/MyFunction|<R|kotlin/Int|, R|kotlin/String|>(<L> = MyFunction@fun <anonymous>(x: R|kotlin/Int|): R|kotlin/String| {
|
R|/foo1|(R|/MyFunction|<R|kotlin/Int|, R|kotlin/String|>(<L> = MyFunction@fun <anonymous>(x: R|ft<kotlin/Int, kotlin/Int?>!|): R|kotlin/String| {
|
||||||
^ R|<local>/x|.R|kotlin/Int.toInt|().R|kotlin/Any.toString|()
|
^ R|<local>/x|.R|kotlin/Int.toInt|().R|kotlin/Any.toString|()
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
R|/foo2|(R|/MyFunction|<R|kotlin/Number|, R|ft<kotlin/String, kotlin/String?>!|>(<L> = MyFunction@fun <anonymous>(x: R|kotlin/Number|): R|kotlin/String| {
|
R|/foo2|(R|/MyFunction|<R|kotlin/Number|, R|ft<kotlin/String, kotlin/String?>!|>(<L> = MyFunction@fun <anonymous>(x: R|ft<kotlin/Number, kotlin/Number?>!|): R|kotlin/String| {
|
||||||
^ R|<local>/x|.R|kotlin/Number.toInt|().R|kotlin/Any.toString|()
|
^ R|<local>/x|.R|kotlin/Number.toInt|().R|kotlin/Any.toString|()
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
@@ -18,7 +18,7 @@ FILE: main.kt
|
|||||||
^ R|<local>/x|.R|kotlin/Any.toString|()
|
^ R|<local>/x|.R|kotlin/Any.toString|()
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
R|/foo3|<R|kotlin/Int|, R|ft<kotlin/String, kotlin/String?>!|>(R|/MyFunction|<R|kotlin/Int|, R|ft<kotlin/String, kotlin/String?>!|>(<L> = MyFunction@fun <anonymous>(x: R|kotlin/Int|): R|kotlin/String| {
|
R|/foo3|<R|kotlin/Int|, R|ft<kotlin/String, kotlin/String?>!|>(R|/MyFunction|<R|kotlin/Int|, R|ft<kotlin/String, kotlin/String?>!|>(<L> = MyFunction@fun <anonymous>(x: R|ft<kotlin/Int, kotlin/Int?>!|): R|kotlin/String| {
|
||||||
^ R|<local>/x|.R|kotlin/Int.plus|(Int(1)).R|kotlin/Any.toString|()
|
^ R|<local>/x|.R|kotlin/Int.plus|(Int(1)).R|kotlin/Any.toString|()
|
||||||
}
|
}
|
||||||
), Int(1))
|
), Int(1))
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ FILE: main.kt
|
|||||||
^ R|<local>/x|.R|kotlin/Any.toString|()
|
^ R|<local>/x|.R|kotlin/Any.toString|()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
Q|JavaUsage|.R|/JavaUsage.foo3|<R|kotlin/Int|, R|ft<kotlin/String, kotlin/String?>!|>(foo3@fun <anonymous>(x: R|kotlin/Int|): R|kotlin/String| {
|
Q|JavaUsage|.R|/JavaUsage.foo3|<R|kotlin/Int|, R|ft<kotlin/String, kotlin/String?>!|>(foo3@fun <anonymous>(x: R|ft<kotlin/Int, kotlin/Int?>!|): R|kotlin/String| {
|
||||||
^ R|<local>/x|.R|kotlin/Int.plus|(Int(1)).R|kotlin/Any.toString|()
|
^ R|<local>/x|.R|kotlin/Int.plus|(Int(1)).R|kotlin/Any.toString|()
|
||||||
}
|
}
|
||||||
, Int(1))
|
, Int(1))
|
||||||
|
|||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
// ISSUE: KT-37623
|
||||||
|
// FULL_JDK
|
||||||
|
// FILE: JavaEnum.java
|
||||||
|
|
||||||
|
public enum JavaEnum {
|
||||||
|
A;
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
import java.util.EnumMap
|
||||||
|
|
||||||
|
val enumMap = EnumMap(
|
||||||
|
mapOf(
|
||||||
|
JavaEnum.A to "A"
|
||||||
|
)
|
||||||
|
)
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
FILE: main.kt
|
||||||
|
public final val enumMap: R|java/util/EnumMap<ft<JavaEnum, JavaEnum?>!, ft<kotlin/String, kotlin/String?>!>| = R|java/util/EnumMap.EnumMap|<R|ft<JavaEnum, JavaEnum?>!|, R|ft<kotlin/String, kotlin/String?>!|>(R|kotlin/collections/mapOf|<R|ft<JavaEnum, JavaEnum?>!|, R|kotlin/String|>(Q|JavaEnum|.R|/JavaEnum.A|.R|kotlin/to|<R|JavaEnum|, R|kotlin/String|>(String(A))))
|
||||||
|
public get(): R|java/util/EnumMap<ft<JavaEnum, JavaEnum?>!, ft<kotlin/String, kotlin/String?>!>|
|
||||||
+1
-1
@@ -17,7 +17,7 @@ FILE: main.kt
|
|||||||
}
|
}
|
||||||
|
|
||||||
Q|JavaClass|.R|/JavaClass.foo2|(R|<local>/y|)
|
Q|JavaClass|.R|/JavaClass.foo2|(R|<local>/y|)
|
||||||
Q|JavaClass|.R|/JavaClass.foo3|<R|kotlin/Int|>(foo3@fun <anonymous>(it: R|kotlin/Int|): R|ft<kotlin/String, kotlin/String?>!| {
|
Q|JavaClass|.R|/JavaClass.foo3|<R|kotlin/Int|>(foo3@fun <anonymous>(it: R|ft<kotlin/Int, kotlin/Int?>!|): R|ft<kotlin/String, kotlin/String?>!| {
|
||||||
^ R|<local>/it|.R|kotlin/Int.plus|(Int(4)).R|kotlin/Any.toString|()
|
^ R|<local>/it|.R|kotlin/Int.plus|(Int(4)).R|kotlin/Any.toString|()
|
||||||
}
|
}
|
||||||
, Int(5))
|
, Int(5))
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
FILE: javaLangComparator.kt
|
FILE: javaLangComparator.kt
|
||||||
public final fun test_2(list: R|kotlin/collections/List<kotlin/Int>|): R|kotlin/Unit| {
|
public final fun test_2(list: R|kotlin/collections/List<kotlin/Int>|): R|kotlin/Unit| {
|
||||||
lval comp: R|java/util/Comparator<kotlin/Int>| = Q|java/util|.R|java/util/Comparator|<R|kotlin/Int|>(<L> = Comparator@fun <anonymous>(x: R|kotlin/Int|, y: R|kotlin/Int|): R|kotlin/Int| {
|
lval comp: R|java/util/Comparator<kotlin/Int>| = Q|java/util|.R|java/util/Comparator|<R|kotlin/Int|>(<L> = Comparator@fun <anonymous>(x: R|ft<kotlin/Int, kotlin/Int?>!|, y: R|ft<kotlin/Int, kotlin/Int?>!|): R|kotlin/Int| {
|
||||||
^ Int(1)
|
^ Int(1)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
FILE: kotlinComparatorAlias.kt
|
FILE: kotlinComparatorAlias.kt
|
||||||
public final fun test_1(): R|kotlin/Unit| {
|
public final fun test_1(): R|kotlin/Unit| {
|
||||||
lval comp: R|java/util/Comparator<kotlin/Int>| = R|java/util/Comparator|<R|kotlin/Int|>(<L> = Comparator@fun <anonymous>(x: R|kotlin/Int|, y: R|kotlin/Int|): R|kotlin/Int| {
|
lval comp: R|java/util/Comparator<kotlin/Int>| = R|java/util/Comparator|<R|kotlin/Int|>(<L> = Comparator@fun <anonymous>(x: R|ft<kotlin/Int, kotlin/Int?>!|, y: R|ft<kotlin/Int, kotlin/Int?>!|): R|kotlin/Int| {
|
||||||
^ Int(1)
|
^ Int(1)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
+5
@@ -556,6 +556,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic
|
|||||||
public void testComplexConstraintSystem() throws Exception {
|
public void testComplexConstraintSystem() throws Exception {
|
||||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/complexConstraintSystem.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/complexConstraintSystem.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("flexibleTypeInSystem.kt")
|
||||||
|
public void testFlexibleTypeInSystem() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/flexibleTypeInSystem.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k")
|
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k")
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ open class ConeFlexibleType(val lowerBound: ConeKotlinType, val upperBound: Cone
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val typeArguments: Array<out ConeTypeProjection>
|
override val typeArguments: Array<out ConeTypeProjection>
|
||||||
get() = emptyArray()
|
get() = lowerBound.typeArguments
|
||||||
|
|
||||||
override val nullability: ConeNullability
|
override val nullability: ConeNullability
|
||||||
get() = lowerBound.nullability.takeIf { it == upperBound.nullability } ?: ConeNullability.UNKNOWN
|
get() = lowerBound.nullability.takeIf { it == upperBound.nullability } ?: ConeNullability.UNKNOWN
|
||||||
|
|||||||
@@ -288,6 +288,7 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo
|
|||||||
return object : AbstractConeSubstitutor(),
|
return object : AbstractConeSubstitutor(),
|
||||||
TypeSubstitutorMarker {
|
TypeSubstitutorMarker {
|
||||||
override fun substituteType(type: ConeKotlinType): ConeKotlinType? {
|
override fun substituteType(type: ConeKotlinType): ConeKotlinType? {
|
||||||
|
if (type !is ConeLookupTagBasedType) return null
|
||||||
val new = map[type.typeConstructor()] ?: return null
|
val new = map[type.typeConstructor()] ?: return null
|
||||||
return (new as ConeKotlinType).approximateIntegerLiteralType().updateNullabilityIfNeeded(type)
|
return (new as ConeKotlinType).approximateIntegerLiteralType().updateNullabilityIfNeeded(type)
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+1
-1
@@ -5,4 +5,4 @@ typealias ComparatorStrT = ComparatorT<String>
|
|||||||
|
|
||||||
val test1 = RunnableT { }
|
val test1 = RunnableT { }
|
||||||
val test2 = ComparatorT<String> { s1, s2 -> s1.compareTo(s2) }
|
val test2 = ComparatorT<String> { s1, s2 -> s1.compareTo(s2) }
|
||||||
val test3 = ComparatorStrT { s1, s2 -> s1.<!UNRESOLVED_REFERENCE!>compareTo<!>(s2) }
|
val test3 = ComparatorStrT { s1, s2 -> s1.<!INAPPLICABLE_CANDIDATE!>compareTo<!>(s2) }
|
||||||
|
|||||||
Vendored
+1
-1
@@ -23,5 +23,5 @@ typealias C2<T> = JHost.Consumer2<T, T>
|
|||||||
val test1 = R { }
|
val test1 = R { }
|
||||||
val test2 = C<String> { s -> println(s.length) }
|
val test2 = C<String> { s -> println(s.length) }
|
||||||
val test3 = CStr { s -> <!AMBIGUITY!>println<!>(s.<!UNRESOLVED_REFERENCE!>length<!>) }
|
val test3 = CStr { s -> <!AMBIGUITY!>println<!>(s.<!UNRESOLVED_REFERENCE!>length<!>) }
|
||||||
val test4 = CStrList { ss -> <!UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>for (s in ss) { <!AMBIGUITY!>println<!>(s.<!UNRESOLVED_REFERENCE!>length<!>) }<!> }
|
val test4 = CStrList { ss -> <!INAPPLICABLE_CANDIDATE, UNRESOLVED_REFERENCE, UNRESOLVED_REFERENCE!>for (s in ss) { <!AMBIGUITY!>println<!>(s.<!UNRESOLVED_REFERENCE!>length<!>) }<!> }
|
||||||
val test5 = <!INAPPLICABLE_CANDIDATE!>C2<!><Int> { a, b -> val x: Int = a <!AMBIGUITY!>+<!> b; println(x)}
|
val test5 = <!INAPPLICABLE_CANDIDATE!>C2<!><Int> { a, b -> val x: Int = a <!AMBIGUITY!>+<!> b; println(x)}
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ FILE fqName:<root> fileName:/samConstructors.kt
|
|||||||
RETURN type=kotlin.Nothing from='public final fun test4 (): java.util.Comparator<kotlin.Int> declared in <root>'
|
RETURN type=kotlin.Nothing from='public final fun test4 (): java.util.Comparator<kotlin.Int> declared in <root>'
|
||||||
CALL 'public final fun Comparator <T> (block: kotlin.Function2<T of java.util.Comparator?, T of java.util.Comparator?, kotlin.Int>): java.util.Comparator<T of java.util.Comparator> declared in java.util' type=java.util.Comparator<kotlin.Int> origin=null
|
CALL 'public final fun Comparator <T> (block: kotlin.Function2<T of java.util.Comparator?, T of java.util.Comparator?, kotlin.Int>): java.util.Comparator<T of java.util.Comparator> declared in java.util' type=java.util.Comparator<kotlin.Int> origin=null
|
||||||
<T>: kotlin.Int
|
<T>: kotlin.Int
|
||||||
block: FUN_EXPR type=kotlin.Function2<kotlin.Int, kotlin.Int, kotlin.Int> origin=LAMBDA
|
block: FUN_EXPR type=kotlin.Function2<kotlin.Int?, kotlin.Int?, kotlin.Int> origin=LAMBDA
|
||||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Int
|
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (a:kotlin.Int?, b:kotlin.Int?) returnType:kotlin.Int
|
||||||
VALUE_PARAMETER name:a index:0 type:kotlin.Int
|
VALUE_PARAMETER name:a index:0 type:kotlin.Int?
|
||||||
VALUE_PARAMETER name:b index:1 type:kotlin.Int
|
VALUE_PARAMETER name:b index:1 type:kotlin.Int?
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (a: kotlin.Int, b: kotlin.Int): kotlin.Int declared in <root>.test4'
|
RETURN type=kotlin.Nothing from='local final fun <anonymous> (a: kotlin.Int?, b: kotlin.Int?): kotlin.Int declared in <root>.test4'
|
||||||
CALL 'public final fun minus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MINUS
|
CALL 'public final fun minus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MINUS
|
||||||
$this: GET_VAR 'a: kotlin.Int declared in <root>.test4.<anonymous>' type=kotlin.Int origin=null
|
$this: GET_VAR 'a: kotlin.Int? declared in <root>.test4.<anonymous>' type=kotlin.Int? origin=null
|
||||||
other: GET_VAR 'b: kotlin.Int declared in <root>.test4.<anonymous>' type=kotlin.Int origin=null
|
other: GET_VAR 'b: kotlin.Int? declared in <root>.test4.<anonymous>' type=kotlin.Int? origin=null
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ FILE fqName:<root> fileName:/samConversionToGeneric.kt
|
|||||||
RETURN type=kotlin.Nothing from='public final fun test1 (): <root>.J<kotlin.String> declared in <root>'
|
RETURN type=kotlin.Nothing from='public final fun test1 (): <root>.J<kotlin.String> declared in <root>'
|
||||||
CALL 'public final fun J <T> (block: kotlin.Function1<T of <root>.J?, T of <root>.J?>): <root>.J<T of <root>.J> declared in <root>' type=<root>.J<kotlin.String> origin=null
|
CALL 'public final fun J <T> (block: kotlin.Function1<T of <root>.J?, T of <root>.J?>): <root>.J<T of <root>.J> declared in <root>' type=<root>.J<kotlin.String> origin=null
|
||||||
<T>: kotlin.String
|
<T>: kotlin.String
|
||||||
block: FUN_EXPR type=kotlin.Function1<kotlin.String, kotlin.String> origin=LAMBDA
|
block: FUN_EXPR type=kotlin.Function1<kotlin.String?, kotlin.String?> origin=LAMBDA
|
||||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (x:kotlin.String) returnType:kotlin.String
|
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (x:kotlin.String?) returnType:kotlin.String?
|
||||||
VALUE_PARAMETER name:x index:0 type:kotlin.String
|
VALUE_PARAMETER name:x index:0 type:kotlin.String?
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (x: kotlin.String): kotlin.String declared in <root>.test1'
|
RETURN type=kotlin.Nothing from='local final fun <anonymous> (x: kotlin.String?): kotlin.String? declared in <root>.test1'
|
||||||
GET_VAR 'x: kotlin.String declared in <root>.test1.<anonymous>' type=kotlin.String origin=null
|
GET_VAR 'x: kotlin.String? declared in <root>.test1.<anonymous>' type=kotlin.String? origin=null
|
||||||
FUN name:test2 visibility:public modality:FINAL <> () returnType:<root>.J<kotlin.String?>
|
FUN name:test2 visibility:public modality:FINAL <> () returnType:<root>.J<kotlin.String?>
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
RETURN type=kotlin.Nothing from='public final fun test2 (): <root>.J<kotlin.String?> declared in <root>'
|
RETURN type=kotlin.Nothing from='public final fun test2 (): <root>.J<kotlin.String?> declared in <root>'
|
||||||
|
|||||||
Reference in New Issue
Block a user