Place !WITH_NEW_INFERENCE directive to diagnostics test data

This commit is contained in:
Mikhail Zarechenskiy
2017-11-20 09:26:11 +03:00
parent 81b3fefa58
commit a71238bf94
468 changed files with 468 additions and 0 deletions
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
fun foo(): String {
var s: String?
s = null
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
// FILE: My.java
public class My {
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
// !LANGUAGE: +SafeCastCheckBoundSmartCasts
interface SomeClass {
val data: Any?
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
fun foo(x : String?, y : String?) {
if (y != null && x == y) {
// Both not null
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
fun foo(x: String?, y: String?, z: String?, w: String?) {
if (x != null && y != null && (x == z || y == z))
<!DEBUG_INFO_SMARTCAST!>z<!>.length
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
// !LANGUAGE: +BooleanElvisBoundSmartCasts
// See KT-20752
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
fun foo(s: Any?): String {
val t = when {
// To resolve: String U Nothing? = String?
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
class ExplicitAccessorForAnnotation {
val tt: String? = "good"
get
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
// !CHECK_TYPE
package a
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
// !CHECK_TYPE
// FILE: A.java
public interface A {
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
// !CHECK_TYPE
interface A {
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
// KT-10444 Do not ignore smart (unchecked) casts to the same classifier
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
operator fun <K, V> MutableMap<K, V>.set(<!UNUSED_PARAMETER!>k<!>: K, <!UNUSED_PARAMETER!>v<!>: V) {}
fun foo(a: MutableMap<String, String>, x: String?) {
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
interface Foo
interface Bar : Foo
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
fun trans(n: Int, f: () -> Boolean) = if (f()) n else null
fun foo() {
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
abstract class Runnable {
abstract fun run()
}
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
abstract class Runnable {
abstract fun run()
}
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
// See also: KT-11998
data class My(val x: Boolean?)
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
class Immutable(val x: String?) {
fun foo(): String {
if (x != null) return <!DEBUG_INFO_SMARTCAST!>x<!>
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
import kotlin.reflect.KProperty
class Delegate {
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
// !LANGUAGE: -SafeCastCheckBoundSmartCasts -BooleanElvisBoundSmartCasts
// A set of examples for
// "If the result of a safe call is not null, understand that its receiver is not null"
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
fun foo(): Int {
val x: Any? = null
val y = 2
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
// See KT-13468, KT-13765
fun basic(): String {
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun foo(x: Int, f: () -> Unit, y: Int) {}
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
class MyClass(var p: String?)
fun bar(s: String): Int {
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
fun foo() {
var v: String? = null
v<!UNSAFE_CALL!>.<!>length
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
// KT-15792 and related
fun foo() {
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
data class SomeObject(val n: SomeObject?) {
fun doSomething() {}
fun next(): SomeObject? = n
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
data class SomeObject(val n: SomeObject?) {
fun doSomething() {}
fun next(): SomeObject? = n
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
data class SomeObject(val n: SomeObject?) {
fun doSomething() {}
fun next(): SomeObject? = n
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
// JAVAC_EXPECTED_FILE
// See also KT-10735
fun test() {
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
fun foo() {
var v: String? = "xyz"
// It is possible in principle to provide smart cast here
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
fun foo(arg: Int?): Int {
var i = arg
if (i != null && <!DEBUG_INFO_SMARTCAST!>i<!>++ == 5) {
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
class MyClass
operator fun MyClass.inc(): MyClass { <!UNREACHABLE_CODE!>return<!> null!! }
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
class MyClass
operator fun MyClass.inc(): MyClass { <!UNREACHABLE_CODE!>return<!> null!! }
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
fun create(): Map<String, String> = null!!
operator fun <K, V> Map<K, V>.iterator(): Iterator<Map.Entry<K, V>> = null!!
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
// See also KT-7186
fun IntArray.forEachIndexed( op: (i: Int, value: Int) -> Unit) {
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
fun foo(): Int {
var i: Int? = <!VARIABLE_WITH_REDUNDANT_INITIALIZER!>42<!>
i = null
@@ -1,3 +1,4 @@
// !WITH_NEW_INFERENCE
fun foo(): Int {
var s: String? = <!VARIABLE_WITH_REDUNDANT_INITIALIZER!>"abc"<!>
s = null