drop BASE_WITH_NULLABLE_UPPER_BOUND
This commit is contained in:
@@ -93,7 +93,6 @@ public interface Errors {
|
||||
DiagnosticFactory0<JetTypeProjection> PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT = DiagnosticFactory0.create(ERROR, VARIANCE_IN_PROJECTION);
|
||||
DiagnosticFactory2<JetTypeReference, JetType, JetType> UPPER_BOUND_VIOLATED = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory0<JetNullableType> REDUNDANT_NULLABLE = DiagnosticFactory0.create(WARNING, NULLABLE_TYPE);
|
||||
DiagnosticFactory1<JetNullableType, JetType> BASE_WITH_NULLABLE_UPPER_BOUND = DiagnosticFactory1.create(WARNING, NULLABLE_TYPE);
|
||||
DiagnosticFactory1<JetElement, Integer> WRONG_NUMBER_OF_TYPE_ARGUMENTS = DiagnosticFactory1.create(ERROR);
|
||||
DiagnosticFactory2<JetTypeReference, Integer, String> NO_TYPE_ARGUMENTS_ON_RHS = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory1<JetTypeProjection, ClassifierDescriptor> CONFLICTING_PROJECTION = DiagnosticFactory1.create(ERROR, VARIANCE_IN_PROJECTION);
|
||||
|
||||
-3
@@ -473,9 +473,6 @@ public class DefaultErrorMessages {
|
||||
MAP.put(NULLABLE_SUPERTYPE, "A supertype cannot be nullable");
|
||||
MAP.put(DYNAMIC_SUPERTYPE, "A supertype cannot be dynamic");
|
||||
MAP.put(REDUNDANT_NULLABLE, "Redundant '?'");
|
||||
MAP.put(BASE_WITH_NULLABLE_UPPER_BOUND, "''{0}'' has a nullable upper bound. " +
|
||||
"This means that a value of this type may be null. " +
|
||||
"Using ''{0}?'' is likely to mislead the reader", RENDER_TYPE);
|
||||
MAP.put(UNSAFE_CALL, "Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type {0}", RENDER_TYPE);
|
||||
MAP.put(AMBIGUOUS_LABEL, "Ambiguous label");
|
||||
MAP.put(UNSUPPORTED, "Unsupported [{0}]", STRING);
|
||||
|
||||
@@ -231,9 +231,6 @@ public class TypeResolver(
|
||||
if (baseType.isNullable() || innerType is JetNullableType || innerType is JetDynamicType) {
|
||||
c.trace.report(REDUNDANT_NULLABLE.on(nullableType))
|
||||
}
|
||||
else if (c.checkBounds && !baseType.isBare() && TypeUtils.hasNullableSuperType(baseType.getActualType())) {
|
||||
c.trace.report(BASE_WITH_NULLABLE_UPPER_BOUND.on(nullableType, baseType.getActualType()))
|
||||
}
|
||||
result = baseType.makeNullable()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE,-BASE_WITH_NULLABLE_UPPER_BOUND
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
|
||||
|
||||
fun <E> bar(x: E) {}
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER, -BASE_WITH_NULLABLE_UPPER_BOUND, -UNUSED_VARIABLE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
|
||||
|
||||
class A<F> {
|
||||
fun <E : F> foo1(x: E) = x
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER, -BASE_WITH_NULLABLE_UPPER_BOUND, -UNUSED_VARIABLE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
|
||||
|
||||
class A<F> {
|
||||
class Inv<Q>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VALUE,-UNUSED_VARIABLE,-ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE,-BASE_WITH_NULLABLE_UPPER_BOUND,-VARIABLE_WITH_REDUNDANT_INITIALIZER
|
||||
// !DIAGNOSTICS: -UNUSED_VALUE,-UNUSED_VARIABLE,-ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE,-VARIABLE_WITH_REDUNDANT_INITIALIZER
|
||||
|
||||
class A<T : CharSequence?, E1 : T, E2: T?> {
|
||||
fun T.bar() {}
|
||||
|
||||
Vendored
-1
@@ -1,4 +1,3 @@
|
||||
// !DIAGNOSTICS: -BASE_WITH_NULLABLE_UPPER_BOUND
|
||||
// !CHECK_TYPE
|
||||
interface A<T>
|
||||
|
||||
|
||||
Vendored
-1
@@ -1,4 +1,3 @@
|
||||
// !DIAGNOSTICS: -BASE_WITH_NULLABLE_UPPER_BOUND
|
||||
// !CHECK_TYPE
|
||||
interface A<T>
|
||||
|
||||
|
||||
Vendored
-1
@@ -1,4 +1,3 @@
|
||||
// !DIAGNOSTICS: -BASE_WITH_NULLABLE_UPPER_BOUND
|
||||
// !CHECK_TYPE
|
||||
interface A<T>
|
||||
|
||||
|
||||
+1
-1
@@ -21,6 +21,6 @@ fun tests() {
|
||||
}
|
||||
|
||||
// from standard library
|
||||
operator fun <K, V> MutableMap<K, V>.set(key : K, value : V) : V<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!> = this.put(key, value)
|
||||
operator fun <K, V> MutableMap<K, V>.set(key : K, value : V) : V? = this.put(key, value)
|
||||
|
||||
fun println(message : Any?) = System.out.println(message)
|
||||
+1
-1
@@ -5,4 +5,4 @@ fun test(map: MutableMap<Int, Int>, t: Int) {
|
||||
}
|
||||
|
||||
//from library
|
||||
operator fun <K, V> MutableMap<K, V>.set(key : K, value : V) : V<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!> = this.put(key, value)
|
||||
operator fun <K, V> MutableMap<K, V>.set(key : K, value : V) : V? = this.put(key, value)
|
||||
@@ -4,6 +4,6 @@ fun foo(): String? {
|
||||
return accept(JV<String?, Unit?>())
|
||||
}
|
||||
|
||||
fun <R, D> accept(<!UNUSED_PARAMETER!>v<!>: JV<R, D>): R<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!> = null
|
||||
fun <R, D> accept(<!UNUSED_PARAMETER!>v<!>: JV<R, D>): R? = null
|
||||
|
||||
open class JV<R, D>()
|
||||
@@ -1,6 +1,6 @@
|
||||
// KT-3559 Strange inference failure error message
|
||||
|
||||
public inline fun <T:Any, R> let(subj: T?, body: (T) -> R): R<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!> {
|
||||
public inline fun <T:Any, R> let(subj: T?, body: (T) -> R): R? {
|
||||
return if (subj != null) body(<!DEBUG_INFO_SMARTCAST!>subj<!>) else null
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ fun <T> getJavaClass() : java.lang.Class<T> { <!NO_RETURN_IN_FUNCTION_WITH_BLOCK
|
||||
|
||||
public class Throwables() {
|
||||
companion object {
|
||||
public fun <X : Throwable?> propagateIfInstanceOf(throwable : Throwable?, declaredType : Class<X<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!>>?) : Unit {
|
||||
public fun <X : Throwable?> propagateIfInstanceOf(throwable : Throwable?, declaredType : Class<X?>?) : Unit {
|
||||
if (((throwable != null) && declaredType?.isInstance(throwable)!!))
|
||||
{
|
||||
throw declaredType?.cast(throwable)!!
|
||||
@@ -17,5 +17,4 @@ public class Throwables() {
|
||||
propagateIfInstanceOf(throwable, getJavaClass<RuntimeException?>()) // Type inference failed: Mismatch while expanding constraints
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
val <T> T.foo : T<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!>
|
||||
val <T> T.foo : T?
|
||||
get() = null
|
||||
|
||||
fun test(): Int? {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// !DIAGNOSTICS: -BASE_WITH_NULLABLE_UPPER_BOUND -UNNECESSARY_SAFE_CALL
|
||||
// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL
|
||||
|
||||
// MODULE: m1
|
||||
// FILE: a.kt
|
||||
|
||||
-2
@@ -1,5 +1,3 @@
|
||||
// !DIAGNOSTICS: -BASE_WITH_NULLABLE_UPPER_BOUND
|
||||
|
||||
// MODULE: m1
|
||||
// FILE: a.kt
|
||||
package p
|
||||
|
||||
+7
-7
@@ -9,16 +9,16 @@ fun <NN: Any, TWO_BOUNDS> twoBounds(
|
||||
) where TWO_BOUNDS: Any, TWO_BOUNDS : NN {}
|
||||
|
||||
fun <T, N: T, INDIRECT: N> misleadingNullableSimple(
|
||||
<!UNUSED_PARAMETER!>t<!>: T<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!>,
|
||||
<!UNUSED_PARAMETER!>t2<!>: T<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!>,
|
||||
<!UNUSED_PARAMETER!>n<!>: N<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!>,
|
||||
<!UNUSED_PARAMETER!>ind<!>: INDIRECT<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!>
|
||||
<!UNUSED_PARAMETER!>t<!>: T?,
|
||||
<!UNUSED_PARAMETER!>t2<!>: T?,
|
||||
<!UNUSED_PARAMETER!>n<!>: N?,
|
||||
<!UNUSED_PARAMETER!>ind<!>: INDIRECT?
|
||||
) {}
|
||||
|
||||
fun <FIRST_BOUND, SECOND_BOUND> misleadingNullableMultiBound(
|
||||
<!UNUSED_PARAMETER!>fb<!>: FIRST_BOUND<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!>,
|
||||
<!UNUSED_PARAMETER!>sb<!>: SECOND_BOUND<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!>
|
||||
<!UNUSED_PARAMETER!>fb<!>: FIRST_BOUND?,
|
||||
<!UNUSED_PARAMETER!>sb<!>: SECOND_BOUND?
|
||||
) where FIRST_BOUND: Any?, FIRST_BOUND: Any, SECOND_BOUND: Any, SECOND_BOUND: Any? {
|
||||
}
|
||||
|
||||
fun <T> interactionWithRedundant(<!UNUSED_PARAMETER!>t<!>: T<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!><!REDUNDANT_NULLABLE!>?<!>) {}
|
||||
fun <T> interactionWithRedundant(<!UNUSED_PARAMETER!>t<!>: T?<!REDUNDANT_NULLABLE!>?<!>) {}
|
||||
-1
@@ -1,5 +1,4 @@
|
||||
// !EXPLICIT_FLEXIBLE_TYPES
|
||||
// !DIAGNOSTICS: -BASE_WITH_NULLABLE_UPPER_BOUND
|
||||
|
||||
interface A<T>
|
||||
interface B<T>: A<ft<T, T?>>
|
||||
|
||||
@@ -3,11 +3,10 @@ public inline fun <reified T> Array(n: Int, block: (Int) -> T): Array<T> = null!
|
||||
|
||||
// KT-312 Nullability problem when a nullable version of a generic type is returned
|
||||
|
||||
fun <T> Array<out T>.safeGet(index : Int) : T<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!> {
|
||||
fun <T> Array<out T>.safeGet(index : Int) : T? {
|
||||
return if (index < size()) this[index] else null
|
||||
}
|
||||
|
||||
val args : Array<String> = Array<String>(1, {""})
|
||||
val name : String = <!TYPE_MISMATCH!>args.safeGet<String>(0)<!> // No error, must be type mismatch
|
||||
val name1 : String? = args.safeGet(0)
|
||||
|
||||
val name1 : String? = args.safeGet(0)
|
||||
@@ -3,7 +3,7 @@ fun <T> getJavaClass() : java.lang.Class<T> { return "" <!CAST_NEVER_SUCCEEDS!>a
|
||||
|
||||
public class Throwables() {
|
||||
companion object {
|
||||
public fun <X : Throwable?> propagateIfInstanceOf(throwable : Throwable?, declaredType : Class<X<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!>>?) {
|
||||
public fun <X : Throwable?> propagateIfInstanceOf(throwable : Throwable?, declaredType : Class<X?>?) {
|
||||
if (((throwable != null) && declaredType?.isInstance(throwable)!!))
|
||||
{
|
||||
throw declaredType?.cast(throwable)!!
|
||||
@@ -14,4 +14,4 @@ public class Throwables() {
|
||||
propagateIfInstanceOf(throwable, getJavaClass<RuntimeException?>()) // Type inference failed: Mismatch while expanding constraints
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,9 +15,6 @@ public fun typeof(a: Any?): String = noImpl
|
||||
@native
|
||||
public val undefined: Nothing? = noImpl
|
||||
|
||||
// Drop this after KT-2093 will be fixed and restore MutableMap.set in Maps.kt from MapsJVM.kt
|
||||
/** Provides [] access to maps */
|
||||
@Suppress("BASE_WITH_NULLABLE_UPPER_BOUND")
|
||||
@native public fun <K, V> MutableMap<K, V>.set(key: K, value: V): V? = noImpl
|
||||
|
||||
@library
|
||||
|
||||
@@ -70,9 +70,7 @@ public open class LinkedList<E>() : AbstractList<E>() {
|
||||
override fun set(index: Int, element: E): E = noImpl
|
||||
override fun add(index: Int, element: E): Unit = noImpl
|
||||
|
||||
@Suppress("BASE_WITH_NULLABLE_UPPER_BOUND")
|
||||
public fun poll(): E? = noImpl
|
||||
@Suppress("BASE_WITH_NULLABLE_UPPER_BOUND")
|
||||
public fun peek(): E? = noImpl
|
||||
public fun offer(e: E): Boolean = noImpl
|
||||
}
|
||||
@@ -104,13 +102,10 @@ public open class LinkedHashSet<E>(
|
||||
public open class HashMap<K, V>(initialCapacity: Int = DEFAULT_INITIAL_CAPACITY, loadFactor: Float = DEFAULT_LOAD_FACTOR) : MutableMap<K, V> {
|
||||
override val size: Int get() = noImpl
|
||||
override fun isEmpty(): Boolean = noImpl
|
||||
@Suppress("BASE_WITH_NULLABLE_UPPER_BOUND")
|
||||
override fun get(key: K): V? = noImpl
|
||||
override fun containsKey(key: K): Boolean = noImpl
|
||||
@Suppress("BASE_WITH_NULLABLE_UPPER_BOUND")
|
||||
override fun put(key: K, value: V): V? = noImpl
|
||||
override fun putAll(m: Map<out K, V>): Unit = noImpl
|
||||
@Suppress("BASE_WITH_NULLABLE_UPPER_BOUND")
|
||||
override fun remove(key: K): V? = noImpl
|
||||
override fun clear(): Unit = noImpl
|
||||
override fun containsValue(value: V): Boolean = noImpl
|
||||
|
||||
Reference in New Issue
Block a user