== turned into a safe-call

This commit is contained in:
Andrey Breslav
2015-02-03 18:25:19 +03:00
parent 560b2346a6
commit 0e972acf8c
50 changed files with 149 additions and 142 deletions
@@ -1,8 +1,9 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
val a: Int by Delegate()
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
}
@@ -1,8 +1,9 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
val a by Delegate()
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
}
@@ -1,10 +1,11 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
abstract class A {
abstract val a: Int <!ABSTRACT_DELEGATED_PROPERTY!>by Delegate()<!>
}
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
}
@@ -1,3 +1,5 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class B {
val a: Int by Delegate()
@@ -6,7 +8,6 @@ class B {
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
}
@@ -1,3 +1,5 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
trait A {
val prop: Int
}
@@ -12,7 +14,6 @@ fun foo() {
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
}
@@ -1,3 +1,5 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
trait A {
val prop: Int
}
@@ -12,7 +14,6 @@ fun foo() {
class Delegate {
fun get(t: Any?, p: PropertyMetadata): String {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return ""
}
}
@@ -1,8 +1,9 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
val a: Int by A(1)
class A<T: Any>(<!UNUSED_PARAMETER!>i<!>: T) {
class A<T: Any>(i: T) {
fun get(t: Any?, p: PropertyMetadata): T {
t.equals(p) // to avoid UNUSED_PARAMETER warning
throw Exception()
}
}
@@ -1,3 +1,5 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class Base
class Derived: Base()
@@ -5,7 +7,6 @@ val a: Base by A()
class A {
fun get(t: Any?, p: PropertyMetadata): Derived {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return Derived()
}
}
@@ -1,10 +1,11 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
trait T {
val a: Int <!DELEGATED_PROPERTY_IN_TRAIT!>by Delegate()<!>
}
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
}
@@ -1,3 +1,5 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A
class D {
@@ -8,7 +10,6 @@ val cTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING!>IncorrectThis<A>()<!>
class IncorrectThis<T> {
fun get<R>(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
}
@@ -1,12 +1,13 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
class Local {
fun foo() {
val <!UNUSED_VARIABLE!>a<!>: Int <!LOCAL_VARIABLE_WITH_DELEGATE!>by Delegate()<!>
val a: Int <!LOCAL_VARIABLE_WITH_DELEGATE!>by Delegate()<!>
}
}
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
}
@@ -1,8 +1,9 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
var a: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING!>A()<!>
class A {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
}
@@ -1,10 +1,9 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class B {
val c by Delegate(<!UNRESOLVED_REFERENCE!>ag<!>)
}
class Delegate<T: Any>(val init: T) {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
throw Exception()
}
fun get(t: Any?, p: PropertyMetadata): Int = null!!
}
@@ -1,16 +1,13 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
val a: Int by <!DELEGATE_SPECIAL_FUNCTION_AMBIGUITY!>Delegate()<!>
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
fun propertyDelegated(p: PropertyMetadata) {
p.equals(p)
}
fun propertyDelegated(p: PropertyMetadata) {}
fun propertyDelegated(p: PropertyMetadata, s: String = "") {
p.equals(s)
}
fun propertyDelegated(p: PropertyMetadata, s: String = "") {}
}
@@ -1,12 +1,11 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
val a: Int by <!DELEGATE_PD_METHOD_NONE_APPLICABLE!>Delegate()<!>
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
fun propertyDelegated<T>(p: PropertyMetadata) {
p.equals(p)
}
fun propertyDelegated<T>(p: PropertyMetadata) {}
}
@@ -1,8 +1,9 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
val a: Int by Delegate()
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
}
@@ -1,12 +1,11 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
val a: Int by <!DELEGATE_PD_METHOD_NONE_APPLICABLE!>Delegate()<!>
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
private fun propertyDelegated(p: PropertyMetadata) {
p.equals(p)
}
private fun propertyDelegated(p: PropertyMetadata) {}
}
@@ -1,22 +1,17 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
val a: Int by <!DELEGATE_PD_METHOD_NONE_APPLICABLE!>Delegate()<!>
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
fun propertyDelegated() {}
fun propertyDelegated(a: Int) {
a.equals(a)
}
fun propertyDelegated(a: Int) {}
fun propertyDelegated(a: String) {
a.equals(a)
}
fun propertyDelegated(a: String) {}
fun propertyDelegated(p: PropertyMetadata, a: Int) {
p.equals(a)
}
fun propertyDelegated(p: PropertyMetadata, a: Int) {}
}
@@ -1,8 +1,9 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
<!PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE!>public val a<!> by Delegate()
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
}
@@ -1,3 +1,5 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
val a by <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>a<!>
val b by Delegate(<!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>b<!>)
@@ -5,9 +7,8 @@ val b by Delegate(<!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>b<!>)
val c by <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>d<!>
val d by <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>c<!>
class Delegate(<!UNUSED_PARAMETER!>i<!>: Int) {
class Delegate(i: Int) {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
}
@@ -1,9 +1,10 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
val a: Int by Delegate()
<!ACCESSOR_FOR_DELEGATED_PROPERTY!>get() = 1<!>
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
}
@@ -1,14 +1,13 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
var a: Int by Delegate()
<!ACCESSOR_FOR_DELEGATED_PROPERTY!>get() = 1<!>
<!ACCESSOR_FOR_DELEGATED_PROPERTY!>set(i) {}<!>
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
fun set(t: Any?, p: PropertyMetadata, i: Int) {
t.equals(p) || i.equals(null) // to avoid UNUSED_PARAMETER warning
}
fun set(t: Any?, p: PropertyMetadata, i: Int) {}
}
@@ -1,3 +1,5 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class D {
var c: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
}
@@ -8,11 +10,7 @@ class A
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
fun set(t: A, p: PropertyMetadata, i: Int) {
t.equals(p) // to avoid UNUSED_PARAMETER warning
i.equals(null)
}
fun set(t: A, p: PropertyMetadata, i: Int) {}
}
@@ -1,3 +1,5 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class Base
class Derived: Base()
@@ -5,13 +7,9 @@ var a: Derived by A()
class A {
fun get(t: Any?, p: PropertyMetadata): Derived {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return Derived()
}
fun set(t: Any?, p: PropertyMetadata, i: Base) {
t.equals(p) // to avoid UNUSED_PARAMETER warning
i.equals(null) // to avoid UNUSED_PARAMETER warning
}
fun set(t: Any?, p: PropertyMetadata, i: Base) {}
}
@@ -1,12 +1,13 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
val Int.a by Delegate(<!NO_THIS!>this<!>)
class A {
val Int.a by Delegate(<!TYPE_MISMATCH!>this<!>)
}
class Delegate(<!UNUSED_PARAMETER!>i<!>: Int) {
class Delegate(i: Int) {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
}
@@ -1,3 +1,5 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A {
var a: Int by Delegate()
}
@@ -6,11 +8,7 @@ var aTopLevel: Int by Delegate()
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
fun set(t: Any?, p: PropertyMetadata, a: Int) {
t.equals(p) // to avoid UNUSED_PARAMETER warning
a.equals(null)
}
fun set(t: Any?, p: PropertyMetadata, a: Int) {}
}
@@ -1,8 +1,9 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
val c: Int by <!DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH!>Delegate()<!>
class Delegate {
fun get(t: Any?, p: PropertyMetadata): String {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return ""
}
}
@@ -1,3 +1,5 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A {
var a: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
}
@@ -6,11 +8,7 @@ var aTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
fun set(t: Any?, p: PropertyMetadata, i: String) {
t.equals(p) // to avoid UNUSED_PARAMETER warning
i.equals(null)
}
fun set(t: Any?, p: PropertyMetadata, i: String) {}
}
@@ -1,3 +1,5 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A {
val a: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
}
@@ -6,7 +8,6 @@ val aTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
class Delegate {
fun get(t: Any?, p: PropertyMetadata, a: Int): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return a
}
}
@@ -1,3 +1,5 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class A {
var a: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
}
@@ -6,12 +8,8 @@ var aTopLevel: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>Delegate()<!>
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
fun set(t: Any?, p: PropertyMetadata, a: Int, c: Int) {
t.equals(p) // to avoid UNUSED_PARAMETER warning
c.equals(a)
}
fun set(t: Any?, p: PropertyMetadata, a: Int, c: Int) {}
}
@@ -1,13 +1,13 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
var b: Int by Delegate()
class Delegate {
fun get(t: Any?, p: PropertyMetadata): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return 1
}
fun set(t: Any?, p: PropertyMetadata, i: Int): Int {
t.equals(p) // to avoid UNUSED_PARAMETER warning
return i
}
}
@@ -63,7 +63,7 @@ import outer.*
command.foo
command.equals(null)
command<!UNSAFE_CALL!>.<!>equals(null)
command?.equals(null)
command.equals1(null)
command?.equals1(null)
@@ -12,7 +12,6 @@ internal final class C : kotlin.MutableIterator<kotlin.Int> {
package kotlin {
public fun </*0*/ reified T> arrayOfNulls(/*0*/ size: kotlin.Int): kotlin.Array<T?>
public fun kotlin.Any?.equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public fun kotlin.Any?.identityEquals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public fun kotlin.String?.plus(/*0*/ other: kotlin.Any?): kotlin.String
public fun kotlin.Any?.toString(): kotlin.String
@@ -2,7 +2,6 @@
class Foo() {}
fun Any.equals(<!UNUSED_PARAMETER!>other<!> : Any?) : Boolean = true
fun Any?.equals1(<!UNUSED_PARAMETER!>other<!> : Any?) : Boolean = true
fun main(args: Array<String>) {
@@ -14,5 +13,6 @@ fun main(args: Array<String>) {
// .equals(null) => 1; // must be resolved
// ?.equals(null) => 1 // same here
// }
command.equals(null)
command.equals1(null)
command?.equals(null)
}
@@ -1,7 +1,6 @@
package
internal fun main(/*0*/ args: kotlin.Array<kotlin.String>): kotlin.Unit
internal fun kotlin.Any.equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
internal fun kotlin.Any?.equals1(/*0*/ other: kotlin.Any?): kotlin.Boolean
internal final class Foo {
@@ -2,7 +2,6 @@ package
package kotlin {
public fun </*0*/ reified T> arrayOfNulls(/*0*/ size: kotlin.Int): kotlin.Array<T?>
public fun kotlin.Any?.equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public fun kotlin.Any?.identityEquals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public fun kotlin.String?.plus(/*0*/ other: kotlin.Any?): kotlin.String
public fun kotlin.Any?.toString(): kotlin.String