Change Signature: Support conversion between extension and non-extension functions

This commit is contained in:
Alexey Sedunov
2014-12-19 20:40:17 +03:00
parent b31da56e09
commit 96866a108f
82 changed files with 1425 additions and 64 deletions
@@ -0,0 +1,5 @@
class J {
void test() {
_DefaultPackage.foo(X(0), "1", 2);
}
}
@@ -0,0 +1,9 @@
fun X.foo(s: String, k: Int): Boolean {
return s.length() - k > 0
}
class X(val k: Int)
fun test() {
X(0).foo("1", 2)
}
@@ -0,0 +1,5 @@
class J {
void test() {
_DefaultPackage.foo("1", 2);
}
}
@@ -0,0 +1,9 @@
fun <caret>foo(s: String, k: Int): Boolean {
return s.length() - k > 0
}
class X(val k: Int)
fun test() {
foo("1", 2)
}
@@ -0,0 +1,13 @@
fun length(): Int = 1
fun <caret>foo(k: Int): Boolean {
return length() - k > 0
}
class X(val k: Int) {
fun length() = 2
}
fun test() {
foo(2)
}
@@ -0,0 +1 @@
Function length will no longer be accessible after signature change
@@ -0,0 +1,5 @@
class J {
void test() {
new A(3).foo(X(0), "1", 2);
}
}
@@ -0,0 +1,19 @@
class A(val k: Int) {
fun X.foo(s: String, n: Int): Boolean {
return s.length() * this@A.k - n.inc() + this@A.k > 0
}
fun test() {
X(0).foo("1", 2)
}
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
with(A(3)) {
X(0).foo("1", 2)
}
}
@@ -0,0 +1,5 @@
class J {
void test() {
new A(3).foo("1", 2);
}
}
@@ -0,0 +1,19 @@
class A(val k: Int) {
fun <caret>foo(s: String, n: Int): Boolean {
return s.length() * this.k - n.inc() + k > 0
}
fun test() {
foo("1", 2)
}
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
with(A(3)) {
foo("1", 2)
}
}
@@ -0,0 +1,20 @@
class A(val k: Int) {
fun <caret>foo(s: String, n: Int): Boolean {
return s.length()*this.k - n.inc() + k > 0
}
fun test() {
foo("1", 2)
}
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
A(3).foo("1", 2)
with(A(3)) {
foo("1", 2)
}
}
@@ -0,0 +1 @@
Explicit receiver is already present in call element: A(3).foo(&quot;1&quot;, 2)
@@ -0,0 +1,18 @@
interface J<A> extends T<A> {
@Override
<B> int foofoofoo(U<A> a, B b);
}
abstract class J1<X> implements J<U<X>> {
@Override
public <C> int foofoofoo(U<U<X>> xu, C c) {
throw new UnsupportedOperationException();
}
}
abstract class J2 extends J1<String> {
@Override
public <C> int foofoofoo(U<U<String>> xu, C c) {
throw new UnsupportedOperationException();
}
}
@@ -0,0 +1,17 @@
class U<A>
trait T<A> {
fun U<A>.foofoofoo<B>(b: B): Int
}
abstract class T1<X> : T<U<X>> {
override fun <B> U<U<X>>.foofoofoo(b: B): Int {
throw UnsupportedOperationException()
}
}
abstract class T2 : T1<String>() {
override fun <C> U<U<String>>.foofoofoo(b: C): Int {
throw UnsupportedOperationException()
}
}
@@ -0,0 +1,18 @@
interface J<A> extends T<A> {
@Override
<B> int foofoofoo(A a, B b);
}
abstract class J1<X> implements J<U<X>> {
@Override
public <C> int foofoofoo(U<X> xu, C c) {
throw new UnsupportedOperationException();
}
}
abstract class J2 extends J1<String> {
@Override
public <C> int foofoofoo(U<String> xu, C c) {
throw new UnsupportedOperationException();
}
}
@@ -0,0 +1,17 @@
class U<A>
trait T<A> {
fun <caret>foofoofoo<B>(a: A, b: B): Int
}
abstract class T1<X> : T<U<X>> {
override fun <B> foofoofoo(a: U<X>, b: B): Int {
throw UnsupportedOperationException()
}
}
abstract class T2 : T1<String>() {
override fun <C> foofoofoo(a: U<String>, b: C): Int {
throw UnsupportedOperationException()
}
}
@@ -0,0 +1,5 @@
class J {
void test() {
_DefaultPackage.foo("1", new X(0), 2);
}
}
@@ -0,0 +1,9 @@
fun String.foo(x: X, k: Int): Boolean {
return x.k + length() - k > 0
}
class X(val k: Int)
fun test() {
"1".foo(X(0), 2)
}
@@ -0,0 +1,5 @@
class J {
void test() {
_DefaultPackage.foo(new X(0), "1", 2);
}
}
@@ -0,0 +1,9 @@
fun X.<caret>foo(s: String, k: Int): Boolean {
return this.k + s.length() - k > 0
}
class X(val k: Int)
fun test() {
X(0).foo("1", 2)
}
@@ -0,0 +1,5 @@
class J {
void test() {
new A(3).foo("1", new X(0), 2);
}
}
@@ -0,0 +1,19 @@
class A(val k: Int) {
fun String.foo(x: X, k: Int): Boolean {
return x.k + length() - k + this@A.k/2 > 0
}
fun test() {
"1".foo(X(0), 2)
}
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
with(A(3)) {
"1".foo(X(0), 2)
}
}
@@ -0,0 +1,5 @@
class J {
void test() {
new A(3).foo(new X(0), "1", 2);
}
}
@@ -0,0 +1,19 @@
class A(val k: Int) {
fun X.<caret>foo(s: String, k: Int): Boolean {
return this.k + s.length() - k + this@A.k/2 > 0
}
fun test() {
X(0).foo("1", 2)
}
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
with(A(3)) {
X(0).foo("1", 2)
}
}
@@ -0,0 +1,5 @@
class J {
void test() {
_DefaultPackage.foo(new X(0), "1", 2);
}
}
@@ -0,0 +1,9 @@
fun X.foo(s: String, k: Int): Boolean {
return this.k + s.length() - k > 0
}
class X(val k: Int)
fun test() {
X(0).foo("1", 2)
}
@@ -0,0 +1,5 @@
class J {
void test() {
_DefaultPackage.foo(new X(0), "1", 2);
}
}
@@ -0,0 +1,9 @@
fun <caret>foo(x: X, s: String, k: Int): Boolean {
return x.k + s.length() - k > 0
}
class X(val k: Int)
fun test() {
foo(X(0), "1", 2)
}
@@ -0,0 +1,5 @@
class J {
void test() {
_DefaultPackage.foo(new X(0), "1", 2);
}
}
@@ -0,0 +1,9 @@
fun X.foo(s: String, k: Int): Boolean {
return this.k + s.length() - k > 0
}
class X(val k: Int)
fun test() {
X(0).foo("1", 2)
}
@@ -0,0 +1,5 @@
class J {
void test() {
_DefaultPackage.foo("1", new X(0), 2);
}
}
@@ -0,0 +1,9 @@
fun <caret>foo(s: String, x: X, k: Int): Boolean {
return x.k + s.length() - k > 0
}
class X(val k: Int)
fun test() {
foo("1", X(0), 2)
}
@@ -0,0 +1,5 @@
class J {
void test() {
new A(3).foo(new X(0), "1", 2);
}
}
@@ -0,0 +1,19 @@
class A(val k: Int) {
fun X.foo(s: String, k: Int): Boolean {
return this.k + s.length() - k + this@A.k/2 > 0
}
fun test() {
X(0).foo("1", 2)
}
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
with(A(3)) {
X(0).foo("1", 2)
}
}
@@ -0,0 +1,5 @@
class J {
void test() {
new A(3).foo(new X(0), "1", 2);
}
}
@@ -0,0 +1,19 @@
class A(val k: Int) {
fun <caret>foo(x: X, s: String, k: Int): Boolean {
return x.k + s.length() - k + this.k/2 > 0
}
fun test() {
foo(X(0), "1", 2)
}
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
with(A(3)) {
foo(X(0), "1", 2)
}
}
@@ -0,0 +1,5 @@
class J {
void test() {
new A(3).foo(new X(0), "1", 2);
}
}
@@ -0,0 +1,19 @@
class A(val k: Int) {
fun X.foo(s: String, k: Int): Boolean {
return this.k + s.length() - k + this@A.k/2 > 0
}
fun test() {
X(0).foo("1", 2)
}
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
with(A(3)) {
X(0).foo("1", 2)
}
}
@@ -0,0 +1,5 @@
class J {
void test() {
new A(3).foo("1", new X(0), 2);
}
}
@@ -0,0 +1,19 @@
class A(val k: Int) {
fun <caret>foo(s: String, x: X, k: Int): Boolean {
return x.k + s.length() - k + this.k/2 > 0
}
fun test() {
foo("1", X(0), 2)
}
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
with(A(3)) {
foo("1", X(0), 2)
}
}
@@ -0,0 +1,20 @@
class A(val k: Int) {
fun <caret>foo(x: X, s: String, k: Int): Boolean {
return x.k + s.length() - k + this.k/2 > 0
}
fun test() {
foo(X(0), "1", 2)
}
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
A(3).foo(X(0), "1", 2)
with(A(3)) {
foo(X(0), "1", 2)
}
}
@@ -0,0 +1 @@
Explicit receiver is already present in call element: A(3).foo(X(0), &quot;1&quot;, 2)
@@ -0,0 +1,5 @@
class J {
void test() {
_DefaultPackage.foo(new X(0), "1", 2);
}
}
@@ -0,0 +1,14 @@
fun <caret>foo(x: X, s: String, k: Int): Boolean {
return x.k + s.length() - k > 0
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
foo(X(0), "1", 2)
with(X(0)) {
foo(this, "1", 2)
}
}
@@ -0,0 +1,5 @@
class J {
void test() {
_DefaultPackage.foo(new X(0), "1", 2);
}
}
@@ -0,0 +1,14 @@
fun X.<caret>foo(s: String, k: Int): Boolean {
return this.k + s.length() - k > 0
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
X(0).foo("1", 2)
with(X(0)) {
foo("1", 2)
}
}
@@ -0,0 +1,5 @@
class J {
void test() {
_DefaultPackage.foo("1", new X(0), 2);
}
}
@@ -0,0 +1,14 @@
fun <caret>foo(s: String, x: X, k: Int): Boolean {
return x.k + s.length() - k > 0
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
foo("1", X(0), 2)
with(X(0)) {
foo("1", this, 2)
}
}
@@ -0,0 +1,5 @@
class J {
void test() {
_DefaultPackage.foo(new X(0), "1", 2);
}
}
@@ -0,0 +1,14 @@
fun X.<caret>foo(s: String, k: Int): Boolean {
return this.k + s.length() - k > 0
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
X(0).foo("1", 2)
with(X(0)) {
foo("1", 2)
}
}
@@ -0,0 +1,5 @@
class X(val k: Int)
fun foo(abc: X, n: Int): Boolean {
return abc.k > n
}
@@ -0,0 +1,5 @@
class X(val k: Int)
fun X.<caret>foo(n: Int): Boolean {
return this.k > n
}
@@ -0,0 +1,5 @@
class J {
void test() {
new A(3).foo(new X(0), "1", 2);
}
}
@@ -0,0 +1,19 @@
class A(val k: Int) {
fun foo(x: X, s: String, k: Int): Boolean {
return x.k + s.length() - k + this.k/2 > 0
}
fun test() {
foo(X(0), "1", 2)
}
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
with(A(3)) {
foo(X(0), "1", 2)
}
}
@@ -0,0 +1,5 @@
class J {
void test() {
new A(3).foo(new X(0), "1", 2);
}
}
@@ -0,0 +1,19 @@
class A(val k: Int) {
fun X.<caret>foo(s: String, k: Int): Boolean {
return this.k + s.length() - k + this@A.k/2 > 0
}
fun test() {
X(0).foo("1", 2)
}
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
with(A(3)) {
X(0).foo("1", 2)
}
}
@@ -0,0 +1,5 @@
class J {
void test() {
new A(3).foo("1", new X(0), 2);
}
}
@@ -0,0 +1,19 @@
class A(val k: Int) {
fun foo(s: String, x: X, k: Int): Boolean {
return x.k + s.length() - k + this.k/2 > 0
}
fun test() {
foo("1", X(0), 2)
}
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
with(A(3)) {
foo("1", X(0), 2)
}
}
@@ -0,0 +1,5 @@
class J {
void test() {
new A(3).foo(new X(0), "1", 2);
}
}
@@ -0,0 +1,19 @@
class A(val k: Int) {
fun X.<caret>foo(s: String, k: Int): Boolean {
return this.k + s.length() - k + this@A.k/2 > 0
}
fun test() {
X(0).foo("1", 2)
}
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
with(A(3)) {
X(0).foo("1", 2)
}
}
@@ -0,0 +1,7 @@
val x1: Int
class X(val x: Int)
fun foo(x2: X, x: Int): Boolean {
return x2.x + x > x1
}
@@ -0,0 +1,7 @@
val x1: Int
class X(val x: Int)
fun X.<caret>foo(x: Int): Boolean {
return this.x + x > x1
}
@@ -0,0 +1,5 @@
class J {
void test() {
_DefaultPackage.foo("1", 2);
}
}
@@ -0,0 +1,14 @@
fun foo(s: String, k: Int): Boolean {
return this.k + s.length() - k > 0
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
with(X(0)) {
foo("1", 2)
}
foo("1", 2)
}
@@ -0,0 +1,5 @@
class J {
void test() {
_DefaultPackage.foo(new X(0), "1", 2);
}
}
@@ -0,0 +1,14 @@
fun X.<caret>foo(s: String, k: Int): Boolean {
return this.k + s.length() - k > 0
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
with(X(0)) {
foo("1", 2)
}
X(0).foo("1", 2)
}
@@ -0,0 +1,5 @@
class J {
void test() {
new A(3).foo(1, "2");
}
}
@@ -0,0 +1,19 @@
class A(val k: Int) {
fun foo(s: String, n: Int): Boolean {
return s.length() * this.k - n.inc() + this@A.k > 0
}
fun test() {
foo("1", 2)
}
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
with(A(3)) {
foo("1", 2)
}
}
@@ -0,0 +1,5 @@
class J {
void test() {
new A(3).foo(new X(0), 1, "2");
}
}
@@ -0,0 +1,19 @@
class A(val k: Int) {
fun X.<caret>foo(s: String, n: Int): Boolean {
return s.length() * this.k - n.inc() + this@A.k > 0
}
fun test() {
X(0).foo("1", 2)
}
}
class X(val k: Int)
fun <T, R> with(receiver: T, f: T.() -> R): R = receiver.f()
fun test() {
with(A(3)) {
X(0).foo("1", 2)
}
}