// ISSUE: KT-66453 // WITH_STDLIB import kotlin.reflect.KProperty class X(x: String) { companion object { operator fun get(x: String) {} operator fun get(x: X) = X operator fun set(x: String, v: String) {} operator fun unaryPlus() = this operator fun not() = this operator fun plus(x: String) {} operator fun rangeTo(x: String) {} operator fun contains(x: String) = true operator fun invoke() {} operator fun plusAssign(x: String) {} operator fun compareTo(x: String) = 0 operator fun iterator() = iterator { } operator fun getValue(thisRef: Any?, property: KProperty<*>) = "" infix fun foo(x: String) {} } } var Y = "" fun test() { class X(y: Int) class Y X("") X(1) // All the following usages of X must resolve to the local class because it's used // as receiver. X.get("") X[""] X.set("", "") X[""] = "" X[""] += "" X.unaryPlus() +X X.not() !X X.plus("") X + "" X.rangeTo("") X.."" X.contains("") "" in X X.invoke() X() X.plusAssign("") X += "" X[X] += "" // Must resolve to property Y = "" Y += "" X.compareTo("") X > "" X.foo("") X foo "" X.interator() for (x in X) {} // It seems it's okay to resolve to outer X because we assign `X` to delegate field where it's not used as receiver val delegated by X }