From e38279899c6e3a26707cdecda7eeb29f759aa784 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Thu, 13 Oct 2011 19:22:17 +0400 Subject: [PATCH] New tests for nullability --- .../InfixCallNullability.jet | 41 +++++++++++++++++++ .../PreferExtensionsOnNullableReceiver.jet | 9 ++++ 2 files changed, 50 insertions(+) create mode 100644 idea/testData/checkerWithErrorTypes/quick/nullabilityAndAutoCasts/InfixCallNullability.jet create mode 100644 idea/testData/checkerWithErrorTypes/quick/nullabilityAndAutoCasts/PreferExtensionsOnNullableReceiver.jet diff --git a/idea/testData/checkerWithErrorTypes/quick/nullabilityAndAutoCasts/InfixCallNullability.jet b/idea/testData/checkerWithErrorTypes/quick/nullabilityAndAutoCasts/InfixCallNullability.jet new file mode 100644 index 00000000000..d27f6834a73 --- /dev/null +++ b/idea/testData/checkerWithErrorTypes/quick/nullabilityAndAutoCasts/InfixCallNullability.jet @@ -0,0 +1,41 @@ +class A() { + fun plus(i : Int) {} + fun minus() {} + fun contains(a : Any?) : Boolean = true +} + +fun A.div(i : Int) {} +fun A?.times(i : Int) {} + +fun test(x : Int?, a : A?) { + x.plus(1) + x?.plus(1) + x plus 1 + x + 1 + -x + x.minus() + x?.minus() + + a.plus(1) + a?.plus(1) + a plus 1 + a + 1 + -a + a.minus() + a?.minus() + + a.div(1) + a / 1 + a div 1 + a?.div(1) + + a.times(1) + a * 1 + a times 1 + a?.times(1) + + 1 in a + a contains 1 + a.contains(1) + a?.contains(1) +} diff --git a/idea/testData/checkerWithErrorTypes/quick/nullabilityAndAutoCasts/PreferExtensionsOnNullableReceiver.jet b/idea/testData/checkerWithErrorTypes/quick/nullabilityAndAutoCasts/PreferExtensionsOnNullableReceiver.jet new file mode 100644 index 00000000000..b841960b590 --- /dev/null +++ b/idea/testData/checkerWithErrorTypes/quick/nullabilityAndAutoCasts/PreferExtensionsOnNullableReceiver.jet @@ -0,0 +1,9 @@ +class Foo { + fun foo() {} +} + +fun Any?.foo() {} + +fun test(f : Foo?) { + f.foo() +}