diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index d63e745a3ef..fb4978f0d05 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -93,7 +93,6 @@ public interface Errors { DiagnosticFactory0 PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT = DiagnosticFactory0.create(ERROR, VARIANCE_IN_PROJECTION); DiagnosticFactory2 UPPER_BOUND_VIOLATED = DiagnosticFactory2.create(ERROR); DiagnosticFactory0 REDUNDANT_NULLABLE = DiagnosticFactory0.create(WARNING, NULLABLE_TYPE); - DiagnosticFactory1 BASE_WITH_NULLABLE_UPPER_BOUND = DiagnosticFactory1.create(WARNING, NULLABLE_TYPE); DiagnosticFactory1 WRONG_NUMBER_OF_TYPE_ARGUMENTS = DiagnosticFactory1.create(ERROR); DiagnosticFactory2 NO_TYPE_ARGUMENTS_ON_RHS = DiagnosticFactory2.create(ERROR); DiagnosticFactory1 CONFLICTING_PROJECTION = DiagnosticFactory1.create(ERROR, VARIANCE_IN_PROJECTION); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index e51115b54e7..b6964336556 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -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); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt index 41abc8f32d8..6509a4f782c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt @@ -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() } diff --git a/compiler/testData/diagnostics/tests/generics/nullability/nullToGeneric.kt b/compiler/testData/diagnostics/tests/generics/nullability/nullToGeneric.kt index 5db508c62d6..c831d9dc3f4 100644 --- a/compiler/testData/diagnostics/tests/generics/nullability/nullToGeneric.kt +++ b/compiler/testData/diagnostics/tests/generics/nullability/nullToGeneric.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE,-BASE_WITH_NULLABLE_UPPER_BOUND +// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE fun bar(x: E) {} diff --git a/compiler/testData/diagnostics/tests/generics/nullability/tpBoundsViolation.kt b/compiler/testData/diagnostics/tests/generics/nullability/tpBoundsViolation.kt index 66570e97cd7..9ca0087d34c 100644 --- a/compiler/testData/diagnostics/tests/generics/nullability/tpBoundsViolation.kt +++ b/compiler/testData/diagnostics/tests/generics/nullability/tpBoundsViolation.kt @@ -1,5 +1,5 @@ // !CHECK_TYPE -// !DIAGNOSTICS: -UNUSED_PARAMETER, -BASE_WITH_NULLABLE_UPPER_BOUND, -UNUSED_VARIABLE +// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE class A { fun foo1(x: E) = x diff --git a/compiler/testData/diagnostics/tests/generics/nullability/tpBoundsViolationVariance.kt b/compiler/testData/diagnostics/tests/generics/nullability/tpBoundsViolationVariance.kt index 6e50f104289..e7f9482058d 100644 --- a/compiler/testData/diagnostics/tests/generics/nullability/tpBoundsViolationVariance.kt +++ b/compiler/testData/diagnostics/tests/generics/nullability/tpBoundsViolationVariance.kt @@ -1,5 +1,5 @@ // !CHECK_TYPE -// !DIAGNOSTICS: -UNUSED_PARAMETER, -BASE_WITH_NULLABLE_UPPER_BOUND, -UNUSED_VARIABLE +// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE class A { class Inv diff --git a/compiler/testData/diagnostics/tests/generics/nullability/tpInBounds.kt b/compiler/testData/diagnostics/tests/generics/nullability/tpInBounds.kt index c5c0103a568..e393b7b4322 100644 --- a/compiler/testData/diagnostics/tests/generics/nullability/tpInBounds.kt +++ b/compiler/testData/diagnostics/tests/generics/nullability/tpInBounds.kt @@ -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 { fun T.bar() {} diff --git a/compiler/testData/diagnostics/tests/inference/constraints/equalityConstraintOnNullableType.kt b/compiler/testData/diagnostics/tests/inference/constraints/equalityConstraintOnNullableType.kt index aae592088d5..152242d6392 100644 --- a/compiler/testData/diagnostics/tests/inference/constraints/equalityConstraintOnNullableType.kt +++ b/compiler/testData/diagnostics/tests/inference/constraints/equalityConstraintOnNullableType.kt @@ -1,4 +1,3 @@ -// !DIAGNOSTICS: -BASE_WITH_NULLABLE_UPPER_BOUND // !CHECK_TYPE interface A diff --git a/compiler/testData/diagnostics/tests/inference/constraints/subtypeConstraintOnNullableType.kt b/compiler/testData/diagnostics/tests/inference/constraints/subtypeConstraintOnNullableType.kt index c9466330f55..59d59410736 100644 --- a/compiler/testData/diagnostics/tests/inference/constraints/subtypeConstraintOnNullableType.kt +++ b/compiler/testData/diagnostics/tests/inference/constraints/subtypeConstraintOnNullableType.kt @@ -1,4 +1,3 @@ -// !DIAGNOSTICS: -BASE_WITH_NULLABLE_UPPER_BOUND // !CHECK_TYPE interface A diff --git a/compiler/testData/diagnostics/tests/inference/constraints/supertypeConstraintOnNullableType.kt b/compiler/testData/diagnostics/tests/inference/constraints/supertypeConstraintOnNullableType.kt index 7eb272e4d00..c6689046e89 100644 --- a/compiler/testData/diagnostics/tests/inference/constraints/supertypeConstraintOnNullableType.kt +++ b/compiler/testData/diagnostics/tests/inference/constraints/supertypeConstraintOnNullableType.kt @@ -1,4 +1,3 @@ -// !DIAGNOSTICS: -BASE_WITH_NULLABLE_UPPER_BOUND // !CHECK_TYPE interface A diff --git a/compiler/testData/diagnostics/tests/inference/kt3184.kt b/compiler/testData/diagnostics/tests/inference/kt3184.kt index 069676a9a52..f92985197d6 100644 --- a/compiler/testData/diagnostics/tests/inference/kt3184.kt +++ b/compiler/testData/diagnostics/tests/inference/kt3184.kt @@ -21,6 +21,6 @@ fun tests() { } // from standard library -operator fun MutableMap.set(key : K, value : V) : V? = this.put(key, value) +operator fun MutableMap.set(key : K, value : V) : V? = this.put(key, value) fun println(message : Any?) = System.out.println(message) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/nestedCalls/completeNestedCallsForArraySetExpression.kt b/compiler/testData/diagnostics/tests/inference/nestedCalls/completeNestedCallsForArraySetExpression.kt index 5f7c70b2979..583ec9f7104 100644 --- a/compiler/testData/diagnostics/tests/inference/nestedCalls/completeNestedCallsForArraySetExpression.kt +++ b/compiler/testData/diagnostics/tests/inference/nestedCalls/completeNestedCallsForArraySetExpression.kt @@ -5,4 +5,4 @@ fun test(map: MutableMap, t: Int) { } //from library -operator fun MutableMap.set(key : K, value : V) : V? = this.put(key, value) \ No newline at end of file +operator fun MutableMap.set(key : K, value : V) : V? = this.put(key, value) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/nullableUpperBound.kt b/compiler/testData/diagnostics/tests/inference/nullableUpperBound.kt index 358df6853b4..62b9383a669 100644 --- a/compiler/testData/diagnostics/tests/inference/nullableUpperBound.kt +++ b/compiler/testData/diagnostics/tests/inference/nullableUpperBound.kt @@ -4,6 +4,6 @@ fun foo(): String? { return accept(JV()) } -fun accept(v: JV): R? = null +fun accept(v: JV): R? = null open class JV() \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt3559.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt3559.kt index 4cd430d0752..4f7b83901c7 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt3559.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt3559.kt @@ -1,6 +1,6 @@ // KT-3559 Strange inference failure error message -public inline fun let(subj: T?, body: (T) -> R): R? { +public inline fun let(subj: T?, body: (T) -> R): R? { return if (subj != null) body(subj) else null } diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt702.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt702.kt index c5ce05c1686..656f9bba3ad 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt702.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt702.kt @@ -6,7 +6,7 @@ fun getJavaClass() : java.lang.Class { propagateIfInstanceOf(throwable : Throwable?, declaredType : Class?>?) : Unit { + public fun propagateIfInstanceOf(throwable : Throwable?, declaredType : Class?) : Unit { if (((throwable != null) && declaredType?.isInstance(throwable)!!)) { throw declaredType?.cast(throwable)!! @@ -17,5 +17,4 @@ public class Throwables() { propagateIfInstanceOf(throwable, getJavaClass()) // Type inference failed: Mismatch while expanding constraints } } -} - +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/kt53.kt b/compiler/testData/diagnostics/tests/kt53.kt index 6b31ad04a19..be726999125 100644 --- a/compiler/testData/diagnostics/tests/kt53.kt +++ b/compiler/testData/diagnostics/tests/kt53.kt @@ -1,4 +1,4 @@ -val T.foo : T? +val T.foo : T? get() = null fun test(): Int? { diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParamsBoundMismatch.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParamsBoundMismatch.kt index c5517ab355e..579a71baea5 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParamsBoundMismatch.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParamsBoundMismatch.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -BASE_WITH_NULLABLE_UPPER_BOUND -UNNECESSARY_SAFE_CALL +// !DIAGNOSTICS: -UNNECESSARY_SAFE_CALL // MODULE: m1 // FILE: a.kt diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParamsIndexMismatch.kt b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParamsIndexMismatch.kt index e07841631d6..af66c73c557 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParamsIndexMismatch.kt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateMethod/classGenericsInParamsIndexMismatch.kt @@ -1,5 +1,3 @@ -// !DIAGNOSTICS: -BASE_WITH_NULLABLE_UPPER_BOUND - // MODULE: m1 // FILE: a.kt package p diff --git a/compiler/testData/diagnostics/tests/nullableTypes/baseWithNullableUpperBound.kt b/compiler/testData/diagnostics/tests/nullableTypes/baseWithNullableUpperBound.kt index 4fb7a6bcd0d..c44a90d9212 100644 --- a/compiler/testData/diagnostics/tests/nullableTypes/baseWithNullableUpperBound.kt +++ b/compiler/testData/diagnostics/tests/nullableTypes/baseWithNullableUpperBound.kt @@ -9,16 +9,16 @@ fun twoBounds( ) where TWO_BOUNDS: Any, TWO_BOUNDS : NN {} fun misleadingNullableSimple( - t: T?, - t2: T?, - n: N?, - ind: INDIRECT? + t: T?, + t2: T?, + n: N?, + ind: INDIRECT? ) {} fun misleadingNullableMultiBound( - fb: FIRST_BOUND?, - sb: SECOND_BOUND? + fb: FIRST_BOUND?, + sb: SECOND_BOUND? ) where FIRST_BOUND: Any?, FIRST_BOUND: Any, SECOND_BOUND: Any, SECOND_BOUND: Any? { } -fun interactionWithRedundant(t: T??) {} \ No newline at end of file +fun interactionWithRedundant(t: T??) {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/supertypeArgumentsExplicit.kt b/compiler/testData/diagnostics/tests/platformTypes/supertypeArgumentsExplicit.kt index 51d087d07ff..4b897e4a36a 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/supertypeArgumentsExplicit.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/supertypeArgumentsExplicit.kt @@ -1,5 +1,4 @@ // !EXPLICIT_FLEXIBLE_TYPES -// !DIAGNOSTICS: -BASE_WITH_NULLABLE_UPPER_BOUND interface A interface B: A> diff --git a/compiler/testData/diagnostics/tests/regressions/kt312.kt b/compiler/testData/diagnostics/tests/regressions/kt312.kt index c87bf39327a..347b91a678f 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt312.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt312.kt @@ -3,11 +3,10 @@ public inline fun Array(n: Int, block: (Int) -> T): Array = null! // KT-312 Nullability problem when a nullable version of a generic type is returned -fun Array.safeGet(index : Int) : T? { +fun Array.safeGet(index : Int) : T? { return if (index < size()) this[index] else null } val args : Array = Array(1, {""}) val name : String = args.safeGet(0) // No error, must be type mismatch -val name1 : String? = args.safeGet(0) - +val name1 : String? = args.safeGet(0) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt701.kt b/compiler/testData/diagnostics/tests/regressions/kt701.kt index 2f262b11241..019099348bb 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt701.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt701.kt @@ -3,7 +3,7 @@ fun getJavaClass() : java.lang.Class { return "" a public class Throwables() { companion object { - public fun propagateIfInstanceOf(throwable : Throwable?, declaredType : Class?>?) { + public fun propagateIfInstanceOf(throwable : Throwable?, declaredType : Class?) { if (((throwable != null) && declaredType?.isInstance(throwable)!!)) { throw declaredType?.cast(throwable)!! @@ -14,4 +14,4 @@ public class Throwables() { propagateIfInstanceOf(throwable, getJavaClass()) // Type inference failed: Mismatch while expanding constraints } } -} +} \ No newline at end of file diff --git a/js/js.libraries/src/core/core.kt b/js/js.libraries/src/core/core.kt index df8d2999cb2..ed97c02a1ca 100644 --- a/js/js.libraries/src/core/core.kt +++ b/js/js.libraries/src/core/core.kt @@ -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 MutableMap.set(key: K, value: V): V? = noImpl @library diff --git a/js/js.libraries/src/core/javautil.kt b/js/js.libraries/src/core/javautil.kt index 3e50436490f..3bd4ae1838b 100644 --- a/js/js.libraries/src/core/javautil.kt +++ b/js/js.libraries/src/core/javautil.kt @@ -70,9 +70,7 @@ public open class LinkedList() : AbstractList() { 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( public open class HashMap(initialCapacity: Int = DEFAULT_INITIAL_CAPACITY, loadFactor: Float = DEFAULT_LOAD_FACTOR) : MutableMap { 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): 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