diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirUpperBoundViolatedHelpers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirUpperBoundViolatedHelpers.kt index 344f4fd146b..c74fa818455 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirUpperBoundViolatedHelpers.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirUpperBoundViolatedHelpers.kt @@ -209,7 +209,7 @@ fun checkUpperBoundViolated( argumentSource, FirErrors.UPPER_BOUND_VIOLATED_IN_TYPEALIAS_EXPANSION, upperBound, argumentType.type, context ) } else { - val extraMessage = if(upperBound is ConeCapturedType) "Consider removing the explicit type arguments" else "" + val extraMessage = if (upperBound.lowerBoundIfFlexible().originalIfDefinitelyNotNullable() is ConeCapturedType) "Consider removing the explicit type arguments" else "" reporter.reportOn( argumentSource, FirErrors.UPPER_BOUND_VIOLATED, upperBound, argumentType.type, extraMessage, context diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedUpperBound.fir.diag.txt b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedUpperBound.fir.diag.txt index b2b3ba445ba..3a5230a5810 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedUpperBound.fir.diag.txt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedUpperBound.fir.diag.txt @@ -1,5 +1,9 @@ -/capturedUpperBound.fir.kt:(100,120): error: Type argument is not within its bounds: should be subtype of 'CapturedType(*)'. Consider removing the explicit type arguments. +/test.kt:(116,136): error: Type argument is not within its bounds: should be subtype of 'CapturedType(*)'. Consider removing the explicit type arguments. -/capturedUpperBound.fir.kt:(136,150): error: Type argument is not within its bounds: should be subtype of 'CapturedType(*)'. Consider removing the explicit type arguments. +/test.kt:(152,166): error: Type argument is not within its bounds: should be subtype of 'CapturedType(*)'. Consider removing the explicit type arguments. -/capturedUpperBound.fir.kt:(166,182): error: Type argument is not within its bounds: should be subtype of 'CapturedType(*)'. Consider removing the explicit type arguments. +/test.kt:(182,198): error: Type argument is not within its bounds: should be subtype of 'CapturedType(*)'. Consider removing the explicit type arguments. + +/test.kt:(227,237): error: Type argument is not within its bounds: should be subtype of 'CapturedType(*) & Any'. Consider removing the explicit type arguments. + +/test.kt:(266,280): error: Type argument is not within its bounds: should be subtype of 'CapturedType(*)!'. Consider removing the explicit type arguments. diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedUpperBound.fir.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedUpperBound.fir.kt index d76326fba84..a6243958a28 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedUpperBound.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedUpperBound.fir.kt @@ -1,12 +1,31 @@ // ISSUE: KT-65712 // RENDER_DIAGNOSTICS_FULL_TEXT -fun test(a: BodySpec, *>) { +// FILE: JavaClass.java +public interface JavaClass> { + public default T value() { + return null; + } +} + +// FILE: test.kt +fun test(a: BodySpec, *>, k: WithDnn<*>, j: JavaClass, *>) { a.value<BodySpec, *>>() a.value<BodySpec<*, *>>() a.value<BodySpec>() + a.value() + + k.bar<WithDnn<*>>() + k.bar() + + j.value<JavaClass<*,*>>() + j.value() } interface BodySpec> { fun value(): T } + +interface WithDnn?> { + fun bar() {} +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedUpperBound.kt b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedUpperBound.kt index 75375a82ff6..8b3ad70d0b1 100644 --- a/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedUpperBound.kt +++ b/compiler/testData/diagnostics/tests/inference/capturedTypes/capturedUpperBound.kt @@ -1,12 +1,31 @@ // ISSUE: KT-65712 // RENDER_DIAGNOSTICS_FULL_TEXT -fun test(a: BodySpec, *>) { +// FILE: JavaClass.java +public interface JavaClass> { + public default T value() { + return null; + } +} + +// FILE: test.kt +fun test(a: BodySpec, *>, k: WithDnn<*>, j: JavaClass, *>) { a.value, *>>() a.value>() a.value>() + a.value() + + k.bar>() + k.bar() + + j.value>() + j.value() } interface BodySpec> { fun value(): T } + +interface WithDnn?> { + fun bar() {} +} \ No newline at end of file