From 21dada4d2d4a6ad712777b5ab22598be7450b34a Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Wed, 12 May 2021 19:22:56 +0300 Subject: [PATCH] [Jspecify] Use enhancement of type with enhancement if possible during substitution --- .../calls/inference/components/NewTypeSubstitutor.kt | 2 +- .../jspecify/warnMode/TypeParameterBounds.fir.kt | 8 ++++---- .../java8Tests/jspecify/warnMode/TypeParameterBounds.kt | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/NewTypeSubstitutor.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/NewTypeSubstitutor.kt index 12d91812b4c..1bf30bcb8db 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/NewTypeSubstitutor.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/NewTypeSubstitutor.kt @@ -65,7 +65,7 @@ interface NewTypeSubstitutor : TypeSubstitutorMarker { KotlinTypeFactory.flexibleType( lowerBound?.lowerIfFlexible() ?: type.lowerBound, upperBound?.upperIfFlexible() ?: type.upperBound - ).wrapEnhancement(enhancement) + ).wrapEnhancement(if (enhancement is TypeWithEnhancement) enhancement.enhancement else enhancement) } } } diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeParameterBounds.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeParameterBounds.fir.kt index 9393bafdfdc..34427d84af8 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeParameterBounds.fir.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeParameterBounds.fir.kt @@ -31,14 +31,14 @@ fun main(a1: A<Any? a2.bar<T?>(null) a2.bar(x) - // jspecify_nullness_mismatch{mute} - b1.foo(null) + // jspecify_nullness_mismatch + b1.foo(null) // jspecify_nullness_mismatch b1.bar<T?>(null) b1.bar(x) - // jspecify_nullness_mismatch{mute} - b2.foo(null) + // jspecify_nullness_mismatch + b2.foo(null) // jspecify_nullness_mismatch b2.bar<T?>(null) b2.bar(x) diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeParameterBounds.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeParameterBounds.kt index 000e1a5aa54..87bbfd0993a 100644 --- a/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeParameterBounds.kt +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/java8Tests/jspecify/warnMode/TypeParameterBounds.kt @@ -31,14 +31,14 @@ fun main(a1: A<Any? a2.bar<T?>(null) a2.bar(x) - // jspecify_nullness_mismatch{mute} - b1.foo(null) + // jspecify_nullness_mismatch + b1.foo(null) // jspecify_nullness_mismatch b1.bar<T?>(null) b1.bar(x) - // jspecify_nullness_mismatch{mute} - b2.foo(null) + // jspecify_nullness_mismatch + b2.foo(null) // jspecify_nullness_mismatch b2.bar<T?>(null) b2.bar(x)