K2: Don't use FirTypeParameterSymbol.resolvedBounds() from inference

This commit is contained in:
Mikhail Glukhikh
2022-11-18 18:37:09 +01:00
committed by Space Team
parent e57521ed23
commit df5aa59185
7 changed files with 464 additions and 6 deletions
@@ -0,0 +1,9 @@
open class Foo<T : CharSequence>
fun bar(): Foo<String>? {
return null
}
fun resolveMe() {
val x = bar()
}
@@ -0,0 +1,170 @@
RAW_FIR:
FILE: functionCallWithGenericResult.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] fun bar(): Foo<String>? { LAZY_BLOCK }
public? final? [RAW_FIR] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
IMPORTS:
FILE: functionCallWithGenericResult.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] fun bar(): Foo<String>? { LAZY_BLOCK }
public? final? [RAW_FIR] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
COMPILER_REQUIRED_ANNOTATIONS:
FILE: functionCallWithGenericResult.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] fun bar(): Foo<String>? { LAZY_BLOCK }
public? final? [COMPILER_REQUIRED_ANNOTATIONS] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
COMPANION_GENERATION:
FILE: functionCallWithGenericResult.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] fun bar(): Foo<String>? { LAZY_BLOCK }
public? final? [COMPANION_GENERATION] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
SUPER_TYPES:
FILE: functionCallWithGenericResult.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] fun bar(): Foo<String>? { LAZY_BLOCK }
public? final? [SUPER_TYPES] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
TYPES:
FILE: functionCallWithGenericResult.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] fun bar(): Foo<String>? { LAZY_BLOCK }
public? final? [TYPES] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
STATUS:
FILE: functionCallWithGenericResult.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] fun bar(): Foo<String>? { LAZY_BLOCK }
public final [STATUS] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
ARGUMENTS_OF_ANNOTATIONS:
FILE: functionCallWithGenericResult.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] fun bar(): Foo<String>? { LAZY_BLOCK }
public final [ARGUMENTS_OF_ANNOTATIONS] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
CONTRACTS:
FILE: functionCallWithGenericResult.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] fun bar(): Foo<String>? { LAZY_BLOCK }
public final [CONTRACTS] fun resolveMe(): R|kotlin/Unit| {
[RAW_FIR] lval x: <implicit> = bar#()
}
IMPLICIT_TYPES_BODY_RESOLVE:
FILE: functionCallWithGenericResult.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] fun bar(): Foo<String>? { LAZY_BLOCK }
public final [IMPLICIT_TYPES_BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| {
[RAW_FIR] lval x: <implicit> = bar#()
}
ANNOTATIONS_ARGUMENTS_MAPPING:
FILE: functionCallWithGenericResult.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] fun bar(): Foo<String>? { LAZY_BLOCK }
public final [ANNOTATIONS_ARGUMENTS_MAPPING] fun resolveMe(): R|kotlin/Unit| {
[RAW_FIR] lval x: <implicit> = bar#()
}
EXPECT_ACTUAL_MATCHING:
FILE: functionCallWithGenericResult.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] fun bar(): Foo<String>? { LAZY_BLOCK }
public final [EXPECT_ACTUAL_MATCHING] fun resolveMe(): R|kotlin/Unit| {
[RAW_FIR] lval x: <implicit> = bar#()
}
BODY_RESOLVE:
FILE: functionCallWithGenericResult.kt
public? open [COMPILER_REQUIRED_ANNOTATIONS] class Foo<[COMPILER_REQUIRED_ANNOTATIONS] T : CharSequence> : R|kotlin/Any| {
public? [COMPILER_REQUIRED_ANNOTATIONS] [ContainingClassKey=Foo] constructor<[COMPILER_REQUIRED_ANNOTATIONS] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public final [CONTRACTS] fun bar(): R|Foo<kotlin/String>?| {
^bar Null(null)
}
public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| {
[BODY_RESOLVE] lval x: R|Foo<kotlin/String>?| = R|/bar|()
}
FILE RAW TO BODY:
FILE: functionCallWithGenericResult.kt
public open [BODY_RESOLVE] class Foo<[BODY_RESOLVE] T : R|kotlin/CharSequence|> : R|kotlin/Any| {
public [BODY_RESOLVE] [ContainingClassKey=Foo] constructor<[BODY_RESOLVE] T : R|kotlin/CharSequence|>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public final [BODY_RESOLVE] fun bar(): R|Foo<kotlin/String>?| {
^bar Null(null)
}
public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| {
[BODY_RESOLVE] lval x: R|Foo<kotlin/String>?| = R|/bar|()
}
@@ -0,0 +1,9 @@
open class Foo<T : CharSequence>
class Bar : Foo<String>
fun bar() = Bar()
fun resolveMe() {
val x: Foo<String> = bar()
}
@@ -0,0 +1,253 @@
RAW_FIR:
FILE: functionWithGenericExpectedTypeInside.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] class Bar : Foo<String> {
public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| {
super<<implicit>>()
}
}
public? final? [RAW_FIR] fun bar(): <implicit> { LAZY_BLOCK }
public? final? [RAW_FIR] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
IMPORTS:
FILE: functionWithGenericExpectedTypeInside.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] class Bar : Foo<String> {
public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| {
super<<implicit>>()
}
}
public? final? [RAW_FIR] fun bar(): <implicit> { LAZY_BLOCK }
public? final? [RAW_FIR] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
COMPILER_REQUIRED_ANNOTATIONS:
FILE: functionWithGenericExpectedTypeInside.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] class Bar : Foo<String> {
public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| {
super<<implicit>>()
}
}
public? final? [RAW_FIR] fun bar(): <implicit> { LAZY_BLOCK }
public? final? [COMPILER_REQUIRED_ANNOTATIONS] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
COMPANION_GENERATION:
FILE: functionWithGenericExpectedTypeInside.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] class Bar : Foo<String> {
public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| {
super<<implicit>>()
}
}
public? final? [RAW_FIR] fun bar(): <implicit> { LAZY_BLOCK }
public? final? [COMPANION_GENERATION] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
SUPER_TYPES:
FILE: functionWithGenericExpectedTypeInside.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] class Bar : Foo<String> {
public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| {
super<<implicit>>()
}
}
public? final? [RAW_FIR] fun bar(): <implicit> { LAZY_BLOCK }
public? final? [SUPER_TYPES] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
TYPES:
FILE: functionWithGenericExpectedTypeInside.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] class Bar : Foo<String> {
public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| {
super<<implicit>>()
}
}
public? final? [RAW_FIR] fun bar(): <implicit> { LAZY_BLOCK }
public? final? [TYPES] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
STATUS:
FILE: functionWithGenericExpectedTypeInside.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] class Bar : Foo<String> {
public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| {
super<<implicit>>()
}
}
public? final? [RAW_FIR] fun bar(): <implicit> { LAZY_BLOCK }
public final [STATUS] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
ARGUMENTS_OF_ANNOTATIONS:
FILE: functionWithGenericExpectedTypeInside.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] class Bar : Foo<String> {
public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| {
super<<implicit>>()
}
}
public? final? [RAW_FIR] fun bar(): <implicit> { LAZY_BLOCK }
public final [ARGUMENTS_OF_ANNOTATIONS] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK }
CONTRACTS:
FILE: functionWithGenericExpectedTypeInside.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] class Bar : Foo<String> {
public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| {
super<<implicit>>()
}
}
public? final? [RAW_FIR] fun bar(): <implicit> { LAZY_BLOCK }
public final [CONTRACTS] fun resolveMe(): R|kotlin/Unit| {
[RAW_FIR] lval x: Foo<String> = bar#()
}
IMPLICIT_TYPES_BODY_RESOLVE:
FILE: functionWithGenericExpectedTypeInside.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] class Bar : Foo<String> {
public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| {
super<<implicit>>()
}
}
public? final? [RAW_FIR] fun bar(): <implicit> { LAZY_BLOCK }
public final [IMPLICIT_TYPES_BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| {
[RAW_FIR] lval x: Foo<String> = bar#()
}
ANNOTATIONS_ARGUMENTS_MAPPING:
FILE: functionWithGenericExpectedTypeInside.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] class Bar : Foo<String> {
public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| {
super<<implicit>>()
}
}
public? final? [RAW_FIR] fun bar(): <implicit> { LAZY_BLOCK }
public final [ANNOTATIONS_ARGUMENTS_MAPPING] fun resolveMe(): R|kotlin/Unit| {
[RAW_FIR] lval x: Foo<String> = bar#()
}
EXPECT_ACTUAL_MATCHING:
FILE: functionWithGenericExpectedTypeInside.kt
public? open [RAW_FIR] class Foo<[RAW_FIR] T : CharSequence> : R|kotlin/Any| {
public? [RAW_FIR] [ContainingClassKey=Foo] constructor<[RAW_FIR] T : CharSequence>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public? final? [RAW_FIR] class Bar : Foo<String> {
public? [RAW_FIR] [ContainingClassKey=Bar] constructor(): R|Bar| {
super<<implicit>>()
}
}
public? final? [RAW_FIR] fun bar(): <implicit> { LAZY_BLOCK }
public final [EXPECT_ACTUAL_MATCHING] fun resolveMe(): R|kotlin/Unit| {
[RAW_FIR] lval x: Foo<String> = bar#()
}
BODY_RESOLVE:
FILE: functionWithGenericExpectedTypeInside.kt
public open [TYPES] class Foo<[TYPES] T : R|kotlin/CharSequence|> : R|kotlin/Any| {
public [TYPES] [ContainingClassKey=Foo] constructor<[TYPES] T : R|kotlin/CharSequence|>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public final [TYPES] class Bar : R|Foo<kotlin/String>| {
public [STATUS] [ContainingClassKey=Bar] constructor(): R|Bar| {
super<<implicit>>()
}
}
public final [IMPLICIT_TYPES_BODY_RESOLVE] fun bar(): R|Bar| {
^bar R|/Bar.Bar|()
}
public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| {
[BODY_RESOLVE] lval x: R|Foo<kotlin/String>| = R|/bar|()
}
FILE RAW TO BODY:
FILE: functionWithGenericExpectedTypeInside.kt
public open [BODY_RESOLVE] class Foo<[BODY_RESOLVE] T : R|kotlin/CharSequence|> : R|kotlin/Any| {
public [BODY_RESOLVE] [ContainingClassKey=Foo] constructor<[BODY_RESOLVE] T : R|kotlin/CharSequence|>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
}
public final [BODY_RESOLVE] class Bar : R|Foo<kotlin/String>| {
public [BODY_RESOLVE] [ContainingClassKey=Bar] constructor(): R|Bar| {
super<R|Foo<kotlin/String>|>()
}
}
public final [BODY_RESOLVE] fun bar(): R|Bar| {
^bar R|/Bar.Bar|()
}
public final [BODY_RESOLVE] fun resolveMe(): R|kotlin/Unit| {
[BODY_RESOLVE] lval x: R|Foo<kotlin/String>| = R|/bar|()
}