[Jspecify] Use enhancement of type with enhancement if possible during substitution

This commit is contained in:
Victor Petukhov
2021-05-12 19:22:56 +03:00
parent 12f6146bdf
commit 21dada4d2d
3 changed files with 9 additions and 9 deletions
@@ -65,7 +65,7 @@ interface NewTypeSubstitutor : TypeSubstitutorMarker {
KotlinTypeFactory.flexibleType( KotlinTypeFactory.flexibleType(
lowerBound?.lowerIfFlexible() ?: type.lowerBound, lowerBound?.lowerIfFlexible() ?: type.lowerBound,
upperBound?.upperIfFlexible() ?: type.upperBound upperBound?.upperIfFlexible() ?: type.upperBound
).wrapEnhancement(enhancement) ).wrapEnhancement(if (enhancement is TypeWithEnhancement) enhancement.enhancement else enhancement)
} }
} }
} }
@@ -31,14 +31,14 @@ fun <T : Test> main(a1: A<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Any?
a2.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null) a2.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null)
a2.bar<T>(x) a2.bar<T>(x)
// jspecify_nullness_mismatch{mute} // jspecify_nullness_mismatch
b1.foo(null) b1.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
// jspecify_nullness_mismatch // jspecify_nullness_mismatch
b1.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null) b1.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null)
b1.bar<T>(x) b1.bar<T>(x)
// jspecify_nullness_mismatch{mute} // jspecify_nullness_mismatch
b2.foo(null) b2.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
// jspecify_nullness_mismatch // jspecify_nullness_mismatch
b2.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null) b2.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null)
b2.bar<T>(x) b2.bar<T>(x)
@@ -31,14 +31,14 @@ fun <T : Test> main(a1: A<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>Any?
a2.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null) a2.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null)
a2.bar<T>(x) a2.bar<T>(x)
// jspecify_nullness_mismatch{mute} // jspecify_nullness_mismatch
b1.foo(null) b1.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
// jspecify_nullness_mismatch // jspecify_nullness_mismatch
b1.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null) b1.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null)
b1.bar<T>(x) b1.bar<T>(x)
// jspecify_nullness_mismatch{mute} // jspecify_nullness_mismatch
b2.foo(null) b2.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!>)
// jspecify_nullness_mismatch // jspecify_nullness_mismatch
b2.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null) b2.bar<<!UPPER_BOUND_VIOLATED_BASED_ON_JAVA_ANNOTATIONS!>T?<!>>(null)
b2.bar<T>(x) b2.bar<T>(x)