[FIR-TEST] Add new testdata generated after changes in previous commit
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
// JAVAC_EXPECTED_FILE
|
||||
// FILE: p/G.java
|
||||
|
||||
package p;
|
||||
|
||||
public interface G<TG> {
|
||||
}
|
||||
|
||||
// FILE: p/A.kt
|
||||
|
||||
package p;
|
||||
|
||||
public interface A<TA> {
|
||||
fun foo(p: A<TA>)
|
||||
}
|
||||
|
||||
// FILE: p/B.java
|
||||
|
||||
package p;
|
||||
|
||||
public class B<TB> implements A<TB> {
|
||||
void foo(A<TB> p) {}
|
||||
}
|
||||
|
||||
// FILE: p/C.java
|
||||
|
||||
package p;
|
||||
|
||||
public class C<TC> extends B<TC> implements A<TC> {
|
||||
}
|
||||
|
||||
// FILE: p/P.java
|
||||
|
||||
package p;
|
||||
|
||||
public class P {
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
|
||||
import p.*
|
||||
|
||||
abstract class K: C<P>() {
|
||||
|
||||
}
|
||||
|
||||
abstract class AL: java.util.ArrayList<P>() {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// FILE: p/A.java
|
||||
|
||||
package p;
|
||||
|
||||
public interface A {
|
||||
<TA> void foo(TA p);
|
||||
}
|
||||
|
||||
// FILE: p/B.java
|
||||
|
||||
package p;
|
||||
|
||||
public class B implements A {
|
||||
<TB> void foo(TB p) {}
|
||||
}
|
||||
|
||||
// FILE: p/C.java
|
||||
|
||||
package p;
|
||||
|
||||
public class C extends B implements A {
|
||||
}
|
||||
|
||||
// FILE: k.kt
|
||||
|
||||
import p.*
|
||||
|
||||
abstract class K: C() {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// FILE: Bar.java
|
||||
public class Bar implements Foo {
|
||||
public interface I extends Boo {
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Baz.kt
|
||||
public interface Foo {
|
||||
companion object {
|
||||
public val EMPTY: Foo = object : Foo{}
|
||||
}
|
||||
}
|
||||
|
||||
interface Boo
|
||||
|
||||
public class Baz : Bar.I
|
||||
@@ -0,0 +1,18 @@
|
||||
// FILE: K1.kt
|
||||
open class KFirst() {
|
||||
fun foo() {
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: J1.java
|
||||
public class J1 extends KFirst {
|
||||
void baz() {}
|
||||
}
|
||||
|
||||
// FILE: K2.kt
|
||||
class K2: J1() {
|
||||
fun bar() {
|
||||
foo()
|
||||
baz()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// FILE: K1.kt
|
||||
open class KFirst<T: java.io.Serializable>() {
|
||||
fun foo(t: T): T = t
|
||||
}
|
||||
|
||||
// FILE: J1.java
|
||||
public class J1 extends KFirst<Integer> {
|
||||
void baz() {}
|
||||
}
|
||||
|
||||
// FILE: K2.kt
|
||||
class K2: J1() {
|
||||
fun bar() {
|
||||
foo(1)
|
||||
baz()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// FILE: Aaa.java
|
||||
// http://youtrack.jetbrains.com/issue/KT-1694
|
||||
|
||||
public abstract class Aaa {
|
||||
public abstract void foo(String... args);
|
||||
}
|
||||
|
||||
// FILE: bbb.kt
|
||||
|
||||
class Bbb() : Aaa() {
|
||||
override fun foo(vararg args: String?) = Unit
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// FILE: aa/A.java
|
||||
package aa;
|
||||
|
||||
public class A {
|
||||
public void f() { }
|
||||
}
|
||||
|
||||
// FILE: B.kt
|
||||
import aa.A
|
||||
|
||||
fun foo(a: A) = a.f()
|
||||
@@ -0,0 +1,16 @@
|
||||
// FILE: Aaa.java
|
||||
// http://youtrack.jetbrains.com/issue/KT-1880
|
||||
|
||||
public class Aaa {
|
||||
public static final int i = 1;
|
||||
}
|
||||
|
||||
// FILE: Bbb.java
|
||||
|
||||
public class Bbb extends Aaa {
|
||||
public static final String i = "s";
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
fun foo() = Bbb.<!AMBIGUITY!>i<!>
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
// !CHECK_TYPE
|
||||
// FILE: A.java
|
||||
public class A {}
|
||||
|
||||
// FILE: X.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class X<T> {
|
||||
@NotNull T fooN() {return null;}
|
||||
void barN(@NotNull T a) {}
|
||||
}
|
||||
|
||||
// FILE: Y.java
|
||||
public class Y extends X<String> {
|
||||
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun main() {
|
||||
checkSubtype<Any>(Y().fooN())
|
||||
Y().barN(null);
|
||||
}
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
// !CHECK_TYPE
|
||||
// FILE: A.java
|
||||
public class A {}
|
||||
|
||||
// FILE: X.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class X<T> {
|
||||
@NotNull T fooN() {return null;}
|
||||
void barN(@NotNull T a) {}
|
||||
}
|
||||
|
||||
// FILE: Y.java
|
||||
public class Y extends X<A> {
|
||||
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun main() {
|
||||
checkSubtype<Any>(Y().fooN())
|
||||
Y().barN(null);
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// FILE: A.java
|
||||
public class A {}
|
||||
|
||||
// FILE: X.java
|
||||
public class X<T> {
|
||||
T foo() {return null;}
|
||||
void bar(T a) {}
|
||||
}
|
||||
|
||||
// FILE: Y.java
|
||||
public class Y extends X<String> {
|
||||
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun main() {
|
||||
Y().foo().length
|
||||
Y().bar(null)
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// FILE: A.java
|
||||
public class A {}
|
||||
|
||||
// FILE: X.java
|
||||
public class X<T> {
|
||||
T foo() {return null;}
|
||||
void bar(T a) {}
|
||||
}
|
||||
|
||||
// FILE: Y.java
|
||||
public class Y extends X<A> {
|
||||
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun main() {
|
||||
Y().foo().hashCode()
|
||||
Y().bar(null)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// FILE: a/Test.java
|
||||
package a;
|
||||
|
||||
public class Test<T> {
|
||||
T t() {return null;}
|
||||
}
|
||||
// FILE: b.kt
|
||||
package a
|
||||
|
||||
fun foo() {
|
||||
// If this fails, it means that we have broken the rule that Java returns are always nullable
|
||||
a.<!UNRESOLVED_REFERENCE!>Test<!><Int>().<!UNRESOLVED_REFERENCE!>t<!>() + 1
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Foo {
|
||||
companion object {
|
||||
val bar = 1
|
||||
|
||||
fun test(a: Foo.`object`) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// FILE: A.java
|
||||
import java.io.Closeable;
|
||||
|
||||
public class A {
|
||||
public static void foo(Runnable r) {
|
||||
}
|
||||
|
||||
public static void foo(Closeable c) {
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun main() {
|
||||
A.<!AMBIGUITY!>foo<!> { "Hello!" }
|
||||
A.foo(Runnable { "Hello!" })
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// FILE: A.java
|
||||
@missing.Ann(x = "")
|
||||
public class A {
|
||||
@missing.Ann(1)
|
||||
public String foo() {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun main() {
|
||||
A().foo().length
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// FILE: MyAnnotation.java
|
||||
public @interface MyAnnotation {
|
||||
}
|
||||
// FILE: MyAnnoClass.java
|
||||
public class MyAnnoClass implements MyAnnotation {
|
||||
//...
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
val ann: MyAnnotation = MyAnnoClass()
|
||||
|
||||
fun foo(x: MyAnnoClass) {
|
||||
bar(x)
|
||||
}
|
||||
|
||||
fun bar(y: MyAnnotation) {
|
||||
y.hashCode()
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
// FILE: A.java
|
||||
public class A<T> {
|
||||
public A<T>[] baz() { return null; }
|
||||
}
|
||||
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun foo1(x: A<*>) = x.baz()
|
||||
fun foo2(x: A<*>) {
|
||||
x.baz() checkType { <!UNRESOLVED_REFERENCE!>_<!><Array<out A<*>>>() }
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// FILE: Hello.kt
|
||||
private class Hello()
|
||||
{
|
||||
val a = 4
|
||||
}
|
||||
|
||||
fun test() {
|
||||
// no exception is thrown (see KT-3897)
|
||||
Hello().a
|
||||
}
|
||||
|
||||
// FILE: Hello.java
|
||||
public class Hello {}
|
||||
@@ -0,0 +1,13 @@
|
||||
// FILE: A.java
|
||||
|
||||
public class A {
|
||||
public String foo;
|
||||
public String foo = "";
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun foo() {
|
||||
// no exception is thrown (see KT-3898)
|
||||
A().<!AMBIGUITY!>foo<!>
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
public static void foo() {}
|
||||
public static void foo(String x) {}
|
||||
|
||||
private void foo(int y) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun baz(x: (String) -> Unit) {}
|
||||
|
||||
fun bar() {
|
||||
baz(A::foo)
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// FILE: Super.java
|
||||
public class Super {
|
||||
void foo(Runnable r) {
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Sub.kt
|
||||
class Sub() : Super() {
|
||||
fun foo(r : (() -> Unit)?) {
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// FILE: CharBuffer.java
|
||||
|
||||
public class CharBuffer implements CharSequence {
|
||||
public final int length() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public final char charAt(int index) {
|
||||
return get(position() + checkIndex(index, 1));
|
||||
}
|
||||
|
||||
// The key problem here is that `get` has the same signature as kotlin.CharSequence.get but completely different semantics
|
||||
public abstract char get(int index);
|
||||
public abstract CharBuffer subSequence(int start, int end);
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun test(cb: CharBuffer) {
|
||||
cb.get(0)
|
||||
(cb as CharSequence).get(0)
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
// FILE: CollectionStringImpl.java
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class CollectionStringImpl implements Collection<String> {
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Iterator<String> iterator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return new Object[0];
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] a) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(String s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends String> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
|
||||
}
|
||||
|
||||
public boolean contains(String o) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun test(x: CollectionStringImpl) {
|
||||
x.contains("")
|
||||
(x as Collection<String>).contains("")
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
import java.util.*
|
||||
fun foo() {
|
||||
val al = ArrayList<String>()
|
||||
al.size
|
||||
al.contains(1)
|
||||
al.contains("")
|
||||
|
||||
al.remove("")
|
||||
al.removeAt(1)
|
||||
|
||||
val hs = HashSet<String>()
|
||||
hs.size
|
||||
hs.contains(1)
|
||||
hs.contains("")
|
||||
|
||||
hs.remove("")
|
||||
|
||||
|
||||
val hm = HashMap<String, Int>()
|
||||
hm.size
|
||||
hm.containsKey(1)
|
||||
hm.containsKey("")
|
||||
|
||||
hm[1]
|
||||
hm[""]
|
||||
|
||||
hm.remove("")
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -PARAMETER_NAME_CHANGED_ON_OVERRIDE
|
||||
// JAVAC_EXPECTED_FILE
|
||||
// FILE: A.java
|
||||
|
||||
abstract public class A<T> implements java.util.Collection<T> {
|
||||
public boolean contains(Object x) {return false;}
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
|
||||
abstract public class B implements java.util.Collection<String> {
|
||||
public boolean contains(Object x) {return false;}
|
||||
}
|
||||
|
||||
// FILE: IC.java
|
||||
public interface IC extends java.util.Collection<String> {
|
||||
public boolean contains(Object x);
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
abstract class KA<T> : java.util.AbstractList<T>() {
|
||||
override fun contains(x: T) = false
|
||||
}
|
||||
|
||||
abstract class KB : java.util.AbstractList<String>(), IC {
|
||||
override fun contains(element: String) = false
|
||||
}
|
||||
|
||||
|
||||
// Raw?
|
||||
|
||||
fun foo(
|
||||
a: A<String>, b: B, ic: IC,
|
||||
ka: KA<String>, kb: KB,
|
||||
al: java.util.ArrayList<String>
|
||||
) {
|
||||
a.contains("")
|
||||
a.contains(1)
|
||||
"" in a
|
||||
1 in a
|
||||
|
||||
b.contains("")
|
||||
b.contains(1)
|
||||
"" in b
|
||||
1 in b
|
||||
|
||||
ic.contains("")
|
||||
ic.contains(1)
|
||||
"" in ic
|
||||
1 in ic
|
||||
|
||||
ka.contains("")
|
||||
ka.contains(1)
|
||||
"" in ka
|
||||
1 in ka
|
||||
|
||||
kb.contains("")
|
||||
kb.contains(1)
|
||||
"" in kb
|
||||
1 in kb
|
||||
|
||||
al.contains("")
|
||||
al.contains(1)
|
||||
"" in al
|
||||
1 in al
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -PARAMETER_NAME_CHANGED_ON_OVERRIDE
|
||||
// JAVAC_EXPECTED_FILE
|
||||
// FILE: A.java
|
||||
import java.util.*;
|
||||
|
||||
abstract public class A<T> implements java.util.Collection<T> {
|
||||
public boolean containsAll(Collection<?> x) {return false;}
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
import java.util.*;
|
||||
|
||||
abstract public class B implements java.util.Collection<String> {
|
||||
public boolean containsAll(Collection<?> x) {return false;}
|
||||
}
|
||||
|
||||
// FILE: IC.java
|
||||
import java.util.*;
|
||||
|
||||
public interface IC extends java.util.Collection<String> {
|
||||
public boolean containsAll(Collection<?> x);
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
abstract class KA<T> : java.util.AbstractList<T>() {
|
||||
override fun containsAll(x: Collection<T>) = false
|
||||
}
|
||||
|
||||
abstract class KB : java.util.AbstractList<String>(), IC {
|
||||
override fun containsAll(elements: Collection<String>) = false
|
||||
}
|
||||
|
||||
fun foo(
|
||||
a: A<String>, b: B, ic: IC,
|
||||
ka: KA<String>, kb: KB,
|
||||
al: java.util.ArrayList<String>,
|
||||
cs: Collection<String>, ca: Collection<Any?>
|
||||
) {
|
||||
a.containsAll(cs)
|
||||
a.containsAll(ca)
|
||||
|
||||
b.containsAll(cs)
|
||||
b.containsAll(ca)
|
||||
|
||||
ic.containsAll(cs)
|
||||
ic.containsAll(ca)
|
||||
|
||||
ka.containsAll(cs)
|
||||
ka.containsAll(ca)
|
||||
|
||||
kb.containsAll(cs)
|
||||
kb.containsAll(ca)
|
||||
|
||||
al.containsAll(cs)
|
||||
al.containsAll(ca)
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE -PARAMETER_NAME_CHANGED_ON_OVERRIDE
|
||||
|
||||
// FILE: A.java
|
||||
abstract public class A implements java.util.Collection<String> {
|
||||
public boolean contains(Object x) {return false;}
|
||||
public boolean contains(String x) {return false;}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
abstract class KA : A() {
|
||||
override fun contains(x: String) = false
|
||||
}
|
||||
|
||||
fun foo(a: A, ka: KA) {
|
||||
a.contains("")
|
||||
a.contains(1)
|
||||
"" in a
|
||||
1 in a
|
||||
|
||||
ka.contains("")
|
||||
ka.contains(1)
|
||||
"" in ka
|
||||
1 in ka
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// FILE: A.java
|
||||
abstract public class A implements CharSequence {
|
||||
public char charAt(int x) { }
|
||||
public int length() { return 1; }
|
||||
}
|
||||
|
||||
// FILE: C.java
|
||||
abstract public class C implements CharSequence {
|
||||
public char get(int x) { }
|
||||
public int length() { return 1; }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
abstract class B : A(), CharSequence {
|
||||
override operator fun get(index: Int) = '1'
|
||||
override val length: Int get() = 1
|
||||
}
|
||||
|
||||
fun main(a: A, b: B, c: C) {
|
||||
a[0]
|
||||
b[0]
|
||||
c[0]
|
||||
|
||||
a.get(0)
|
||||
b.get(0)
|
||||
c.get(0)
|
||||
|
||||
a.length + b.length + c.length
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// FILE: A.java
|
||||
|
||||
public abstract class A {
|
||||
abstract public char charAt(int i);
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
|
||||
abstract public class B extends A implements CharSequence {
|
||||
public char charAt(int i) { return '1'; }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
abstract class C1 : B()
|
||||
|
||||
abstract class C2 : B() {
|
||||
override fun get(index: Int) = '1'
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// FILE: AImpl.java
|
||||
|
||||
abstract public class AImpl {
|
||||
public char charAt(int index) {
|
||||
return '1';
|
||||
}
|
||||
|
||||
public final int length() { return 1; }
|
||||
}
|
||||
|
||||
// FILE: A.java
|
||||
public class A extends AImpl implements CharSequence {
|
||||
public CharSequence subSequence(int start, int end) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: X.kt
|
||||
class X : A()
|
||||
|
||||
fun main() {
|
||||
val x = X()
|
||||
x[0]
|
||||
x.length
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// FILE: AImpl.kt
|
||||
|
||||
abstract class AImpl {
|
||||
fun charAt(index: Int): Char {
|
||||
return '1'
|
||||
}
|
||||
|
||||
fun length(): Int {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: A.java
|
||||
public class A extends AImpl implements CharSequence {
|
||||
public CharSequence subSequence(int start, int end) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: X.kt
|
||||
class X : A()
|
||||
|
||||
fun main() {
|
||||
val x = X()
|
||||
x[0]
|
||||
x.length
|
||||
}
|
||||
Vendored
+119
@@ -0,0 +1,119 @@
|
||||
// FILE: AImpl.java
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
public abstract class AImpl {
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean contains(Object o) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public Iterator<String> iterator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object[] toArray() {
|
||||
return new Object[0];
|
||||
}
|
||||
|
||||
public <T> T[] toArray(T[] a) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean add(String s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean remove(Object o) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean addAll(Collection<? extends String> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean addAll(int index, Collection<? extends String> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
|
||||
}
|
||||
|
||||
public String get(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String set(int index, String element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void add(int index, String element) {
|
||||
|
||||
}
|
||||
|
||||
public String remove(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public int indexOf(Object o) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int lastIndexOf(Object o) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ListIterator<String> listIterator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ListIterator<String> listIterator(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> subList(int fromIndex, int toIndex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: A.java
|
||||
import java.util.List;
|
||||
|
||||
public class A extends AImpl implements List<String> {
|
||||
|
||||
}
|
||||
|
||||
// FILE: X.kt
|
||||
class X : A()
|
||||
|
||||
fun main() {
|
||||
val x = X()
|
||||
x[0]
|
||||
x.size
|
||||
x.remove("")
|
||||
x.remove(1)
|
||||
}
|
||||
Vendored
+106
@@ -0,0 +1,106 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// FILE: AImpl.kt
|
||||
|
||||
public abstract class AImpl {
|
||||
fun add(element: String): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun remove(element: String): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun addAll(elements: Collection<String>): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun addAll(index: Int, elements: Collection<String>): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun removeAll(elements: Collection<String>): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun retainAll(elements: Collection<String>): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun clear() {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun set(index: Int, element: String): String {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun add(index: Int, element: String) {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun remove(index: Int): String {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun listIterator(): MutableListIterator<String> {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun listIterator(index: Int): MutableListIterator<String> {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun subList(fromIndex: Int, toIndex: Int): MutableList<String> {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
val size: Int
|
||||
get() = throw UnsupportedOperationException()
|
||||
|
||||
fun isEmpty(): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun contains(element: Any?): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun containsAll(elements: Collection<*>): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun get(index: Int): String {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun indexOf(element: String): Int {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun lastIndexOf(element: String): Int {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun iterator(): MutableIterator<String> {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: A.java
|
||||
import java.util.List;
|
||||
|
||||
public class A extends AImpl implements List<String> {
|
||||
|
||||
}
|
||||
|
||||
// FILE: X.kt
|
||||
class X : A()
|
||||
|
||||
fun main() {
|
||||
val x = X()
|
||||
x[0]
|
||||
x.size
|
||||
x.remove("")
|
||||
x.remove(1)
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// FILE: Dict.java
|
||||
|
||||
public abstract class Dict<K, V> {
|
||||
abstract public V get(Object key);
|
||||
}
|
||||
|
||||
// FILE: MHashtable.java
|
||||
|
||||
abstract public class MHashtable<X, Y> extends Dict<X, Y> implements java.util.Map<X, Y> {
|
||||
public V get(Object key) { return null; }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
abstract class C1 : MHashtable<String, Int>()
|
||||
|
||||
abstract class C2 : MHashtable<String, Int>() {
|
||||
override fun get(key: String) = 1
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VALUE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE
|
||||
// JAVAC_EXPECTED_FILE
|
||||
// FILE: MyMap.java
|
||||
|
||||
abstract public class MyMap extends java.util.AbstractMap<Double, CharSequence> {
|
||||
String get(Object q) { }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun foo(m: MyMap) {
|
||||
var x: String? = m.get(1.0)
|
||||
x = m[2.0]
|
||||
}
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
// FILE: X.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
public class X implements java.util.List<String> {
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean contains(String o) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator<String> iterator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return new Object[0];
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public <T> T[] toArray(T[] a) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(String s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends String> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(int index, Collection<? extends String> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String set(int index, String element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int index, String element) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String remove(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String removeAt(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(Object o) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lastIndexOf(Object o) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ListIterator<String> listIterator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ListIterator<String> listIterator(int index) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<String> subList(int fromIndex, int toIndex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
class Y : X()
|
||||
class Y2 : X() {
|
||||
override fun removeAt(index: Int) = ""
|
||||
}
|
||||
|
||||
fun main() {
|
||||
X().remove("")
|
||||
X().removeAt(1)
|
||||
|
||||
val y: MutableList<String> = Y()
|
||||
y.removeAt(1)
|
||||
|
||||
Y().remove("")
|
||||
Y().removeAt(1)
|
||||
|
||||
X().remove("")
|
||||
X().removeAt(1)
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// JAVAC_EXPECTED_FILE
|
||||
// FILE: A.java
|
||||
abstract public class A<F> extends B<F> {
|
||||
public F remove(int x) { }
|
||||
public boolean remove(Object x) { }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
import java.util.*;
|
||||
|
||||
abstract class B<T> : MutableList<T>, AbstractList<T>() {
|
||||
override fun removeAt(index: Int): T = null!!
|
||||
override fun remove(element: T): Boolean = null!!
|
||||
}
|
||||
|
||||
fun main(a: A<String>, b: B<String>, c: ArrayList<String>) {
|
||||
a.remove("")
|
||||
a.removeAt(0)
|
||||
b.remove("")
|
||||
b.removeAt(0)
|
||||
c.remove("")
|
||||
c.removeAt(0)
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// JAVAC_EXPECTED_FILE
|
||||
// FILE: A.java
|
||||
abstract public class A extends B {
|
||||
public Integer removeAt(int x) { }
|
||||
public boolean remove(Integer x) { }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
import java.util.*;
|
||||
|
||||
abstract class B : MutableList<Int>, AbstractList<Int>() {
|
||||
override fun removeAt(index: Int): Int = null!!
|
||||
override fun remove(element: Int): Boolean = null!!
|
||||
}
|
||||
|
||||
fun main(a: A, b: B, c: ArrayList<Int>) {
|
||||
a.remove(1)
|
||||
a.removeAt(0)
|
||||
b.remove(1)
|
||||
b.removeAt(0)
|
||||
c.<!AMBIGUITY!>remove<!>(1)
|
||||
c.removeAt(0)
|
||||
}
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
// FILE: A.java
|
||||
|
||||
abstract public class A<F> extends MyList<F> {
|
||||
int getSize() { return 0; }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
abstract class MyList<G> : Collection<G> {}
|
||||
|
||||
fun main(a: A<String>) {
|
||||
a.size
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
// SKIP_TXT
|
||||
// FULL_JDK
|
||||
|
||||
import java.util.stream.Collectors
|
||||
import java.util.stream.Stream
|
||||
|
||||
fun test(a: Stream<String>) {
|
||||
a.<!INAPPLICABLE_CANDIDATE!>collect<!>(Collectors.toList()) <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><MutableList<String>>() }
|
||||
// actually the inferred type is platform
|
||||
a.<!INAPPLICABLE_CANDIDATE!>collect<!>(Collectors.toList()) <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><List<String?>>() }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
// FILE: MyFunc.java
|
||||
public interface MyFunc<K, V> {
|
||||
V apply(K String);
|
||||
}
|
||||
|
||||
// FILE: ConcMap.java
|
||||
public interface ConcMap<K, V> {
|
||||
V computeIfAbsent(K key, MyFunc<? super K,? extends V> mappingFunction);
|
||||
}
|
||||
|
||||
// FILE: ConcHashMap.java
|
||||
public class ConcHashMap<K, V> implements ConcMap<K, V> {
|
||||
@Override
|
||||
V computeIfAbsent(K key, MyFunc<? super K,? extends V> mappingFunction) { }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
public fun concurrentMap() {
|
||||
val map = ConcHashMap<String, String>()
|
||||
map.computeIfAbsent("") { "" } // here
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// FILE: A.java
|
||||
import java.util.*;
|
||||
public class A {
|
||||
public static void foo(Iterable<? super CharSequence> x) {}
|
||||
public static void bar(Iterator<? super CharSequence> x) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun test(x: List<String>, y: List<*>, z: MutableList<*>, w: MutableList<in CharSequence>) {
|
||||
A.foo(x)
|
||||
A.foo(y)
|
||||
A.foo(z)
|
||||
A.foo(w)
|
||||
|
||||
A.bar(x.iterator())
|
||||
A.bar(y.iterator())
|
||||
A.bar(z.iterator())
|
||||
A.bar(w.iterator())
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
// FILE: JavaInterface.java
|
||||
|
||||
public interface JavaInterface {
|
||||
static String testStatic() {
|
||||
return "OK";
|
||||
}
|
||||
|
||||
default String test() {
|
||||
return "OK";
|
||||
}
|
||||
|
||||
default String testOverride() {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
import JavaInterface.testStatic
|
||||
|
||||
interface KotlinInterface : JavaInterface {
|
||||
fun fooo() {
|
||||
testStatic()
|
||||
super.test()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val propertyy: String
|
||||
get() {
|
||||
super.test()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
override fun testOverride(): String {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
interface KotlinInterfaceIndirectInheritance : KotlinInterface {
|
||||
fun foooo() {
|
||||
testStatic()
|
||||
super.test()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val propertyyy: String
|
||||
get() {
|
||||
super.test()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
open class KotlinClass : JavaInterface {
|
||||
fun foo() {
|
||||
testStatic()
|
||||
super.test()
|
||||
super.testOverride()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinClass.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val property: String
|
||||
get() {
|
||||
super.test()
|
||||
super.testOverride()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinClass.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
class KotlinClassIndirectInheritance : KotlinClass() {
|
||||
fun foo2(){
|
||||
testStatic()
|
||||
super.test()
|
||||
super.testOverride()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinClassIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val property2: String
|
||||
get() {
|
||||
super.test()
|
||||
super.testOverride()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinClassIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
class KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance {
|
||||
fun foo() {
|
||||
testStatic()
|
||||
super.test()
|
||||
super.testOverride()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinClassIndirectInheritance2.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val property: String
|
||||
get() {
|
||||
super.test()
|
||||
super.testOverride()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinClassIndirectInheritance2.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
JavaInterface.testStatic()
|
||||
KotlinClass().foo()
|
||||
KotlinClass().property
|
||||
KotlinClassIndirectInheritance2().foo()
|
||||
KotlinClassIndirectInheritance2().property
|
||||
|
||||
KotlinClass().test()
|
||||
KotlinClass().property
|
||||
KotlinClass().testOverride()
|
||||
KotlinClassIndirectInheritance().testOverride()
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
// FILE: JavaInterfaceBase.java
|
||||
|
||||
public interface JavaInterfaceBase {
|
||||
default String test() {
|
||||
return "OK";
|
||||
}
|
||||
|
||||
default String testOverride() {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: JavaInterface.java
|
||||
|
||||
public interface JavaInterface extends JavaInterfaceBase {
|
||||
static String testStatic() {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: 1.kt
|
||||
import JavaInterface.testStatic
|
||||
|
||||
interface KotlinInterface : JavaInterface {
|
||||
fun fooo() {
|
||||
testStatic()
|
||||
super.test()
|
||||
test()
|
||||
testOverride()
|
||||
}
|
||||
|
||||
override fun testOverride(): String {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
interface KotlinInterfaceIndirectInheritance : KotlinInterface {
|
||||
fun foooo() {
|
||||
testStatic()
|
||||
super.test()
|
||||
testOverride()
|
||||
super.testOverride()
|
||||
}
|
||||
}
|
||||
|
||||
open class KotlinClass : JavaInterface {
|
||||
fun foo(){
|
||||
testStatic()
|
||||
super.test()
|
||||
super.testOverride()
|
||||
}
|
||||
}
|
||||
|
||||
class KotlinClassIndirectInheritance : KotlinClass() {
|
||||
fun foo2(){
|
||||
testStatic()
|
||||
super.test()
|
||||
super.testOverride()
|
||||
}
|
||||
}
|
||||
|
||||
class KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance {
|
||||
fun foo(){
|
||||
testStatic()
|
||||
super.test()
|
||||
super.testOverride()
|
||||
}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
JavaInterface.testStatic()
|
||||
KotlinClass().foo()
|
||||
KotlinClassIndirectInheritance2().foo()
|
||||
|
||||
KotlinClass().test()
|
||||
KotlinClass().testOverride()
|
||||
KotlinClassIndirectInheritance().testOverride()
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
//!LANGUAGE: -DefaultMethodsCallFromJava6TargetError
|
||||
// FILE: JavaInterface.java
|
||||
|
||||
public interface JavaInterface {
|
||||
static String testStatic() {
|
||||
return "OK";
|
||||
}
|
||||
|
||||
default String test() {
|
||||
return "OK";
|
||||
}
|
||||
|
||||
default String testOverride() {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
import JavaInterface.testStatic
|
||||
|
||||
interface KotlinInterface : JavaInterface {
|
||||
fun fooo() {
|
||||
testStatic()
|
||||
super.test()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val propertyy: String
|
||||
get() {
|
||||
super.test()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinInterface.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
override fun testOverride(): String {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
interface KotlinInterfaceIndirectInheritance : KotlinInterface {
|
||||
fun foooo() {
|
||||
testStatic()
|
||||
super.test()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val propertyyy: String
|
||||
get() {
|
||||
super.test()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinInterfaceIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
open class KotlinClass : JavaInterface {
|
||||
fun foo(){
|
||||
testStatic()
|
||||
super.test()
|
||||
super.testOverride()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinClass.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val property: String
|
||||
get() {
|
||||
super.test()
|
||||
super.testOverride()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinClass.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
class KotlinClassIndirectInheritance : KotlinClass() {
|
||||
fun foo2(){
|
||||
testStatic()
|
||||
super.test()
|
||||
super.testOverride()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinClassIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val property2: String
|
||||
get() {
|
||||
super.test()
|
||||
super.testOverride()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinClassIndirectInheritance.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
class KotlinClassIndirectInheritance2 : KotlinInterfaceIndirectInheritance {
|
||||
fun foo(){
|
||||
testStatic()
|
||||
super.test()
|
||||
super.testOverride()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinClassIndirectInheritance2.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val property: String
|
||||
get() {
|
||||
super.test()
|
||||
super.testOverride()
|
||||
|
||||
object {
|
||||
fun run () {
|
||||
super@KotlinClassIndirectInheritance2.<!UNRESOLVED_REFERENCE!>test<!>()
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
JavaInterface.testStatic()
|
||||
KotlinClass().foo()
|
||||
KotlinClass().property
|
||||
KotlinClassIndirectInheritance2().foo()
|
||||
KotlinClassIndirectInheritance2().property
|
||||
|
||||
KotlinClass().test()
|
||||
KotlinClass().property
|
||||
KotlinClass().testOverride()
|
||||
KotlinClassIndirectInheritance().testOverride()
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// FILE: J.java
|
||||
public interface J {
|
||||
@Deprecated
|
||||
public void foo();
|
||||
|
||||
@Deprecated
|
||||
public String bar();
|
||||
|
||||
@Deprecated
|
||||
public CharSequence baz();
|
||||
}
|
||||
// FILE: J2.java
|
||||
public interface J2 extends J, K {
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
interface K {
|
||||
fun bar(): CharSequence
|
||||
fun baz(): String
|
||||
}
|
||||
|
||||
interface A : J, K
|
||||
|
||||
fun main(j: J, j2: J2, a: A) {
|
||||
j.foo()
|
||||
j2.foo()
|
||||
a.foo()
|
||||
|
||||
j.bar()
|
||||
j2.bar()
|
||||
a.bar()
|
||||
|
||||
j.baz()
|
||||
j2.baz()
|
||||
a.baz()
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
@Deprecated
|
||||
public void foo() {}
|
||||
}
|
||||
// FILE: J2.java
|
||||
public class J2 extends J implements WithDeprecation {
|
||||
@Override
|
||||
public void foo() {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
interface WithDeprecation {
|
||||
@Deprecated("")
|
||||
fun foo()
|
||||
}
|
||||
|
||||
class A : J(), WithDeprecation {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
fun main() {
|
||||
J().foo()
|
||||
|
||||
J2().foo()
|
||||
A().foo()
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// FILE: J.java
|
||||
public interface J {
|
||||
@Deprecated
|
||||
public void foo();
|
||||
|
||||
}
|
||||
// FILE: J2.java
|
||||
public interface J2 extends J {
|
||||
@Override
|
||||
public void foo();
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
interface A : J {
|
||||
override fun foo()
|
||||
}
|
||||
|
||||
fun main(j: J, j2: J2, a: A) {
|
||||
j.foo()
|
||||
j2.foo()
|
||||
a.foo()
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// JAVAC_SKIP
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
public B b() {}
|
||||
public F f() {}
|
||||
}
|
||||
|
||||
class B { public void bar() {} }
|
||||
|
||||
// FILE: C.java
|
||||
class D {
|
||||
public void baz() {}
|
||||
}
|
||||
|
||||
// FILE: E.java
|
||||
class F {
|
||||
public void foobaz() {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun main(x: A) {
|
||||
x.b().<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
x.f().<!UNRESOLVED_REFERENCE!>foobaz<!>()
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>D<!>().<!UNRESOLVED_REFERENCE!>baz<!>()
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// FILE: MyEnum.java
|
||||
|
||||
public enum MyEnum {
|
||||
A;
|
||||
public int getOrdinal() {return "";}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun foo() {
|
||||
MyEnum.A.getOrdinal()
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// JAVAC_EXPECTED_FILE
|
||||
// FILE: VcsException.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class VcsException extends Exception {
|
||||
@Override
|
||||
@NotNull
|
||||
public String getMessage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun foo(e: VcsException) {
|
||||
e.message.contains("")
|
||||
"" in e.message
|
||||
}
|
||||
|
||||
public operator fun CharSequence.contains(other: CharSequence): Boolean = true
|
||||
@@ -0,0 +1,17 @@
|
||||
// FILE: A.java
|
||||
|
||||
public class A {
|
||||
public int size = 1;
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
|
||||
public class B implements A {
|
||||
public int size = 1;
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun foo() {
|
||||
B().<!AMBIGUITY!>size<!>
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
// FILE: A.java
|
||||
|
||||
public class A {
|
||||
public int size = 1;
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
|
||||
public class B extends A {
|
||||
public String size = 1;
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun foo() {
|
||||
B().<!AMBIGUITY!>size<!>.<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// FILE: B.java
|
||||
|
||||
public abstract class B implements A {
|
||||
public int size = 1;
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
interface A {
|
||||
val size: Int
|
||||
}
|
||||
|
||||
class C : B() {
|
||||
override val size: Int get() = 1
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
C().<!AMBIGUITY!>size<!>
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// JAVAC_EXPECTED_FILE
|
||||
// FILE: A.java
|
||||
|
||||
abstract public class A extends java.util.ArrayList<String> {
|
||||
public final int size() { return 0; }
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
class B : A() {
|
||||
override val size: Int = 1
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
// FILE: TestClass.java
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
public class TestClass {
|
||||
public <T> T set(@Nullable String key, @Nullable T t) {
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun run() {
|
||||
val testClass = TestClass()
|
||||
// inferred as `set<Nothing>()`, return type is Nothing!
|
||||
testClass.set("test", null)
|
||||
|
||||
// Should not be unreachable
|
||||
run()
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
// FILE: A.java
|
||||
|
||||
public class A<E> {
|
||||
public <T extends E> A(E x, java.util.List<T> y) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun test(x: List<Int>, y: List<String>) {
|
||||
A("", x) checkType { <!UNRESOLVED_REFERENCE!>_<!><A<Any?>>() }
|
||||
A("", y) checkType { <!UNRESOLVED_REFERENCE!>_<!><A<String?>>() }
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>A<!><CharSequence, String>("", x)
|
||||
A<CharSequence, String>("", y)
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
// FILE: Outer.java
|
||||
|
||||
public class Outer<T> {
|
||||
public class Inner<E> {
|
||||
public <F extends E, G extends T> Inner(E x, java.util.List<F> y, G z) {}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun test(x: List<Int>, y: List<String>) {
|
||||
Outer<Int>().Inner("", y, 1) checkType { <!UNRESOLVED_REFERENCE!>_<!><Outer<Int>.Inner<String>>() }
|
||||
Outer<Int>().<!INAPPLICABLE_CANDIDATE!>Inner<!><CharSequence, String, Int>("", y, 1) <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Outer<Int>.Inner<CharSequence>>() }
|
||||
|
||||
Outer<Int>().Inner("", x, 1) checkType { <!UNRESOLVED_REFERENCE!>_<!><Outer<Int>.Inner<Any>>() }
|
||||
Outer<Int>().<!INAPPLICABLE_CANDIDATE!>Inner<!><CharSequence, String, Int>("", x, 1)
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// FILE: A.java
|
||||
|
||||
public class A {
|
||||
public <T> A(T x, java.util.List<T> y) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun test(x: List<Int>, y: List<String>) {
|
||||
A("", x) // inferred as Any!
|
||||
A("", y)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>A<!><String>("", x)
|
||||
|
||||
A<Any>("", x)
|
||||
A<String>("", y)
|
||||
A<CharSequence>("", y)
|
||||
}
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// FILE: A.java
|
||||
|
||||
public class A {
|
||||
public <T> A(T x, Inv<T> y) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
class Inv<T>
|
||||
|
||||
fun test(x: Inv<Int>, y: Inv<String>) {
|
||||
<!INAPPLICABLE_CANDIDATE!>A<!>("", x)
|
||||
A("", y)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>A<!><String>("", x)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>A<!><Any>("", x)
|
||||
A<String>("", y)
|
||||
<!INAPPLICABLE_CANDIDATE!>A<!><CharSequence>("", y)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// FILE: C.java
|
||||
|
||||
// See KT-10410
|
||||
public class C {
|
||||
public <T extends T> C(T t) {
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun foo() = <!INAPPLICABLE_CANDIDATE!>C<!>()
|
||||
@@ -0,0 +1,19 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// FILE: R.java
|
||||
public class R<T extends R<T>> {
|
||||
public <F extends R<F>> R(F x) {
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: RImpl.java
|
||||
public class RImpl extends R<RImpl> {
|
||||
public RImpl() {
|
||||
<RImpl>super(null);
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun test() {
|
||||
val x: R<RImpl> = R(RImpl())
|
||||
R<RImpl, RImpl>(RImpl())
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
// FILE: A.java
|
||||
|
||||
public class A<E> {
|
||||
public <T extends E> A(E x, java.util.List<T> y) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
class B1(x: List<String>) : A<CharSequence>("", x)
|
||||
class B2(x: List<Int>) : <!INAPPLICABLE_CANDIDATE!>A<CharSequence><!>("", x)
|
||||
|
||||
class C : A<CharSequence> {
|
||||
constructor(x: List<String>) : <!INAPPLICABLE_CANDIDATE!>super<!>("", x)
|
||||
constructor(x: List<Int>, y: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>("", x)
|
||||
}
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
// FILE: A.java
|
||||
|
||||
public class A<E> {
|
||||
public <T extends E, Q> A(E x, java.util.List<E> y) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
// TODO: It's effectively impossible to perform super call to such constructor
|
||||
// if there is not enough information to infer corresponding arguments
|
||||
// May be we could add some special syntax for such arguments
|
||||
class B1(x: List<String>) : A<CharSequence>("", x)
|
||||
class B2(x: List<Int>) : <!INAPPLICABLE_CANDIDATE!>A<CharSequence><!>("", x)
|
||||
|
||||
class C : A<CharSequence> {
|
||||
constructor(x: List<String>) : <!INAPPLICABLE_CANDIDATE!>super<!>("", x)
|
||||
constructor(x: List<Int>, y: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>("", x)
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VALUE -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE
|
||||
// FILE: A.java
|
||||
|
||||
public class A<E> {
|
||||
public <T> A(T x, java.util.List<T> y) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun test(x: List<Int>, y: List<String>) {
|
||||
var z: A<Double> = A("", x) // E inferred from expected type
|
||||
z = A("", y)
|
||||
|
||||
z = <!INAPPLICABLE_CANDIDATE!>A<!><Double, String>("", x)
|
||||
|
||||
z = A<Double, Any>("", x)
|
||||
z = A<Double, String>("", y)
|
||||
z = A<Double, CharSequence>("", y)
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// FILE: J.java
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class J {
|
||||
public <T extends Cloneable & Serializable> J(T t) {}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import java.io.Serializable
|
||||
|
||||
fun cloneable(c: Cloneable) = <!INAPPLICABLE_CANDIDATE!>J<!>(c)
|
||||
|
||||
fun serializable(s: Serializable) = <!INAPPLICABLE_CANDIDATE!>J<!>(s)
|
||||
|
||||
fun <T> both(t: T) where T : Cloneable, T : Serializable = J(t)
|
||||
@@ -0,0 +1,18 @@
|
||||
// FILE: A.java
|
||||
public interface A {
|
||||
void foo(Runnable r);
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
public interface B extends A {
|
||||
public void bar(Runnable r);
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
class C: B {
|
||||
override fun foo(r: Runnable?) {
|
||||
}
|
||||
|
||||
override fun bar(r: Runnable?) {
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// FILE: I.java
|
||||
|
||||
public interface I {
|
||||
int a = 1;
|
||||
static void foo() {}
|
||||
}
|
||||
|
||||
// FILE: C.java
|
||||
|
||||
public class C implements I {
|
||||
static int b = 1;
|
||||
static void bar() {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
class K : C()
|
||||
|
||||
fun main() {
|
||||
I.a
|
||||
I.foo()
|
||||
|
||||
C.a
|
||||
C.b
|
||||
C.foo()
|
||||
C.bar()
|
||||
|
||||
K.a
|
||||
K.b
|
||||
K.foo()
|
||||
K.bar()
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// FILE: a/M.java
|
||||
package a;
|
||||
|
||||
public class M {
|
||||
public class Inner {
|
||||
|
||||
}
|
||||
|
||||
public static class Nested {
|
||||
|
||||
}
|
||||
|
||||
private class PrInner {
|
||||
|
||||
}
|
||||
|
||||
private static class PrNested {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
package b
|
||||
|
||||
fun f() {
|
||||
val c1: a.M.Inner
|
||||
val c2: a.M.Nested
|
||||
val c3: a.M.PrInner
|
||||
val c4: a.M.PrNested
|
||||
|
||||
}
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// FILE: a/M.java
|
||||
package a;
|
||||
|
||||
public class M {
|
||||
int m;
|
||||
}
|
||||
|
||||
// FILE: b/F.java
|
||||
package b;
|
||||
|
||||
import a.M;
|
||||
|
||||
public class F extends M {
|
||||
}
|
||||
|
||||
// FILE: c.kt
|
||||
package c
|
||||
|
||||
import b.F
|
||||
|
||||
fun f() {
|
||||
F().<!INAPPLICABLE_CANDIDATE!>m<!>
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// JAVAC_EXPECTED_FILE
|
||||
// FILE: backend/asmutil/AsmUtil.java
|
||||
package backend.asmutil;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import static frontend.JvmDeclarationOrigin.NO_ORIGIN;
|
||||
|
||||
public class AsmUtil {
|
||||
|
||||
@NotNull
|
||||
public static String doSmth(String s) {
|
||||
Object or = NO_ORIGIN;
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: First.kt
|
||||
package frontend
|
||||
public class JvmDeclarationOrigin {
|
||||
companion object {
|
||||
public val NO_ORIGIN: JvmDeclarationOrigin = JvmDeclarationOrigin()
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Second.kt
|
||||
package backend
|
||||
|
||||
import backend.asmutil.AsmUtil.doSmth
|
||||
|
||||
open public class ECallable {
|
||||
fun test() {
|
||||
doSmth("")
|
||||
}
|
||||
}
|
||||
|
||||
/* KT-5848 */
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// FILE: a/M.java
|
||||
package a;
|
||||
|
||||
public class M {
|
||||
public static class Inner {
|
||||
private int i;
|
||||
public Inner(int i) {
|
||||
this.i = i;
|
||||
}
|
||||
|
||||
public int getI() {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
package b
|
||||
|
||||
import a.M.Inner
|
||||
|
||||
fun foo() {
|
||||
doSmth(Inner(87))
|
||||
}
|
||||
|
||||
fun doSmth(b: Inner) = b
|
||||
@@ -0,0 +1,17 @@
|
||||
//FILE: a/C.java
|
||||
// KT-1431 StackOverflowException in IDE when using JavaFX builders
|
||||
package a;
|
||||
|
||||
public class C<B extends C<B>> {
|
||||
public static C<?> create() { return null; }
|
||||
public C foo() {return null;}
|
||||
}
|
||||
|
||||
//FILE: d.kt
|
||||
package d
|
||||
|
||||
import a.C
|
||||
|
||||
fun test() {
|
||||
C.create().foo()
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// KT-1730 Method which has been implemented by Java is recognized to be abstract.
|
||||
|
||||
// FILE: C.java
|
||||
public class C implements java.lang.CharSequence {
|
||||
@Override
|
||||
public int length() {
|
||||
return 3;
|
||||
}
|
||||
@Override
|
||||
public char charAt(int index) {
|
||||
return 48;
|
||||
}
|
||||
@Override
|
||||
public CharSequence subSequence(int start, int end) {
|
||||
return "ab";
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "abc";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: T.kt
|
||||
class T : C()
|
||||
@@ -0,0 +1,10 @@
|
||||
//FILE: Bbb.kt
|
||||
open class Bbb
|
||||
|
||||
//FILE: Ccc.java
|
||||
public class Ccc extends Bbb {
|
||||
}
|
||||
|
||||
//FILE: Ddd.kt
|
||||
import Ccc
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
//KT-2394 java.lang.Iterable<T> should be visible as kotlin.Iterable<out T>
|
||||
package d
|
||||
|
||||
fun foo(iterable: Iterable<Int>, iterator: Iterator<Int>, comparable: Comparable<Any>) {
|
||||
checkSubtype<Iterable<Any>>(iterable)
|
||||
checkSubtype<Iterator<Any>>(iterator)
|
||||
checkSubtype<Comparable<String>>(comparable)
|
||||
}
|
||||
|
||||
fun bar(c: Collection<Int>) {
|
||||
checkSubtype<Iterable<Any>>(c)
|
||||
checkSubtype<Iterator<Any>>(c.iterator())
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
//KT-2606 Filter java.util.* import
|
||||
package n
|
||||
|
||||
import java.util.*
|
||||
import java.lang.annotation.*
|
||||
|
||||
fun bar() : Iterator<Int>? {
|
||||
val i : Iterable<Integer>
|
||||
val a : Annotation
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//FILE: foo.kt
|
||||
fun main() {
|
||||
val c: Type
|
||||
when (c) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//FILE: Type.java
|
||||
public enum Type {
|
||||
TYPE,
|
||||
NO_TYPE;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
package a
|
||||
|
||||
import java.util.Iterator
|
||||
import java.lang.Comparable as Comp
|
||||
|
||||
fun bar(any: Any): java.lang.Iterable<Int>? {
|
||||
val a: java.lang.Comparable<String>? = null
|
||||
val b: Iterable<Integer>
|
||||
val c : Iterator<String>? = null
|
||||
|
||||
if (any is Iterator<*>) {
|
||||
checkSubtype<Iterator<*>>(any)
|
||||
}
|
||||
any as Iterator<*>
|
||||
return null
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
//FILE:_03_collections/CollectionTest.java
|
||||
package _03_collections;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CollectionTest {
|
||||
public static void add(List<Integer> ints) {
|
||||
ints.add(5);
|
||||
}
|
||||
}
|
||||
|
||||
//FILE:n.kt
|
||||
package _03_collections
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
fun test() {
|
||||
val c = CollectionTest()
|
||||
CollectionTest.add(ArrayList())
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// FILE: Bug.java
|
||||
|
||||
public interface Bug {
|
||||
<RET extends Bug> RET save();
|
||||
}
|
||||
|
||||
// FILE: SubBug.java
|
||||
|
||||
public class SubBug implements Bug {
|
||||
public SubBug save() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Bug.kt
|
||||
|
||||
fun TestBug() {
|
||||
SubBug().save() // can resolve on subtype
|
||||
val bug: Bug = SubBug()
|
||||
bug.save<Bug>() // can resolve on supertype
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// FILE: Super.java
|
||||
public class Super {
|
||||
public boolean foo;
|
||||
public boolean bar;
|
||||
|
||||
public void setFoo(boolean foo) {
|
||||
this.foo = foo;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: b.kt
|
||||
public class Sub: Super() {
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val x = Sub()
|
||||
x.foo = true
|
||||
x.bar = true
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// FILE: AC.kt
|
||||
|
||||
interface A {
|
||||
val a: Int
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
|
||||
public abstract class B implements A {
|
||||
}
|
||||
|
||||
// FILE: C.kt
|
||||
|
||||
class C : B()
|
||||
|
||||
fun main() {
|
||||
C().a
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// FILE: A.java
|
||||
public interface A<T extends A<? super T, ?>, S extends A<? super T, ?>> {}
|
||||
|
||||
// FILE: C.java
|
||||
public class C
|
||||
{
|
||||
public <T extends A<? super T, ?>, S extends A<? super T, ?>> void f(A<T, S> x){}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun foo() {
|
||||
// TODO: uncomment when KT-9597 is fixed
|
||||
// C().f(object : A<*, *> {})
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// FILE: Assert.java
|
||||
|
||||
public class Assert {
|
||||
public static <T> void assertThat(T actual, Matcher<? super T> matcher) {
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Matcher.java
|
||||
public class Matcher<T> {
|
||||
public static <T> Matcher<java.lang.Iterable<? super T>> hasItem(T item) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun test(x: List<String>) {
|
||||
Assert.<!INAPPLICABLE_CANDIDATE!>assertThat<!>(x, Matcher.hasItem("abc"))
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
//FILE:a/JC.java
|
||||
package a;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public interface JC<T> {
|
||||
public Iterator<T> getIterator();
|
||||
|
||||
public void setIterator(Iterator<T> iterator);
|
||||
|
||||
public Iterable<T> getIterable();
|
||||
|
||||
public void setIterable(Iterable<T> iterable);
|
||||
}
|
||||
|
||||
//FILE:n.kt
|
||||
package n
|
||||
|
||||
import a.JC
|
||||
|
||||
fun foo(c: JC<Int>, iterator: Iterator<Int>, iterable: Iterable<Int>) {
|
||||
val mutableIterator: MutableIterator<Int>? = c.getIterator()
|
||||
c.setIterator(mutableIterator)
|
||||
c.setIterator(iterator)
|
||||
|
||||
val mutableIterable: MutableIterable<Int>? = c.getIterable()
|
||||
c.setIterable(mutableIterable)
|
||||
c.setIterable(iterable)
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// FULL_JDK
|
||||
|
||||
import java.util.*
|
||||
import java.util.stream.Stream
|
||||
|
||||
fun <T> Stream<T>?.getIfSingle() =
|
||||
this?.map { Optional.ofNullable(it) }
|
||||
?.reduce(Optional.empty()) { _, _ -> Optional.empty() }
|
||||
?.orElse(null) // <<---- should not be an error
|
||||
@@ -0,0 +1,15 @@
|
||||
//FILE: Foo.java
|
||||
public class Foo<T extends CharSequence> {
|
||||
}
|
||||
|
||||
//FILE: Bar.java
|
||||
public interface Bar {
|
||||
void f(Foo f);
|
||||
}
|
||||
|
||||
//FILE: a.kt
|
||||
class BarImpl: Bar {
|
||||
override fun f(f: Foo<*>?) {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// FILE: MyFunc.java
|
||||
|
||||
public interface MyFunc {
|
||||
String apply(String x);
|
||||
}
|
||||
|
||||
// FILE: A.java
|
||||
public interface A<K> {
|
||||
K foo(K key, MyFunc f);
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
public class B<E> implements A<E> {
|
||||
@Override
|
||||
public E foo(E key, MyFunc f) {return null;}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun main() {
|
||||
B<String>().foo("") { "" }
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// KT-4021 Java's Package visibilty does not work for static methods
|
||||
|
||||
// FILE: foo/Bar.java
|
||||
|
||||
package foo;
|
||||
|
||||
class Bar {
|
||||
static void baz() {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
package foo
|
||||
|
||||
fun main() {
|
||||
Bar.baz()
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
//FILE: a/MyJavaClass.java
|
||||
package a;
|
||||
|
||||
class MyJavaClass {
|
||||
static int staticMethod() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static class NestedClass {
|
||||
static int staticMethodOfNested() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//FILE:a.kt
|
||||
package a
|
||||
|
||||
val mc = MyJavaClass()
|
||||
val x = MyJavaClass.staticMethod()
|
||||
val y = MyJavaClass.NestedClass.staticMethodOfNested()
|
||||
val z = MyJavaClass.NestedClass()
|
||||
|
||||
//FILE: b.kt
|
||||
package b
|
||||
|
||||
import a.MyJavaClass
|
||||
|
||||
val mc1 = <!INAPPLICABLE_CANDIDATE!>MyJavaClass<!>()
|
||||
|
||||
val x = <!INAPPLICABLE_CANDIDATE!>MyJavaClass<!>.<!UNRESOLVED_REFERENCE!>staticMethod<!>()
|
||||
val y = <!INAPPLICABLE_CANDIDATE!>MyJavaClass<!>.<!UNRESOLVED_REFERENCE!>NestedClass<!>.<!UNRESOLVED_REFERENCE!>staticMethodOfNested<!>()
|
||||
val z = <!INAPPLICABLE_CANDIDATE!>MyJavaClass<!>.<!UNRESOLVED_REFERENCE!>NestedClass<!>()
|
||||
|
||||
//FILE: c.kt
|
||||
package a.c
|
||||
|
||||
import a.MyJavaClass
|
||||
|
||||
val mc1 = <!INAPPLICABLE_CANDIDATE!>MyJavaClass<!>()
|
||||
|
||||
val x = <!INAPPLICABLE_CANDIDATE!>MyJavaClass<!>.<!UNRESOLVED_REFERENCE!>staticMethod<!>()
|
||||
val y = <!INAPPLICABLE_CANDIDATE!>MyJavaClass<!>.<!UNRESOLVED_REFERENCE!>NestedClass<!>.<!UNRESOLVED_REFERENCE!>staticMethodOfNested<!>()
|
||||
val z = <!INAPPLICABLE_CANDIDATE!>MyJavaClass<!>.<!UNRESOLVED_REFERENCE!>NestedClass<!>()
|
||||
@@ -0,0 +1,24 @@
|
||||
// JAVAC_EXPECTED_FILE
|
||||
// FILE: B.java
|
||||
public interface B<T1, T2> {
|
||||
double put(int x, double y);
|
||||
T2 put(T1 x, T2 y);
|
||||
}
|
||||
// FILE: A.java
|
||||
import java.util.HashMap;
|
||||
|
||||
public class A extends HashMap<Integer, Double> implements B<Integer, Double> {
|
||||
public double put(int x, double y) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double put(Integer key, Double value) {
|
||||
return super.put(key, value);
|
||||
}
|
||||
}
|
||||
// FILE: main.kt
|
||||
fun test(){
|
||||
val o = A()
|
||||
o.<!AMBIGUITY!>put<!>(1, 2.0)
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// FILE: A.java
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
public class A {
|
||||
public void foo(int x) {}
|
||||
public void bar(@NotNull Double x) {}
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
import org.jetbrains.annotations.*;
|
||||
public class B extends A {
|
||||
public void foo(@NotNull Integer x) {}
|
||||
public void bar(double x) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun foo(b: B) {
|
||||
// See KT-9182
|
||||
b.foo(1)
|
||||
b.bar(2.0)
|
||||
}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
// FILE: AbstractSpecializedMap.java
|
||||
public abstract class AbstractSpecializedMap implements java.util.Map<Integer, Double> {
|
||||
public abstract double put(int x, double y);
|
||||
public abstract double remove(int k);
|
||||
public abstract double get(int k);
|
||||
|
||||
public abstract boolean containsKey(int k);
|
||||
public boolean containsKey(Object x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract boolean containsValue(double v);
|
||||
public boolean containsValue(Object x) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: SpecializedMap.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class SpecializedMap extends AbstractSpecializedMap {
|
||||
public double put(int x, double y) {
|
||||
return 123.0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double get(Object key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double put(Integer key, Double value) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public double remove(int k) {
|
||||
return 456.0;
|
||||
}
|
||||
|
||||
|
||||
public Double remove(Object ok) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public double get(int k) {
|
||||
return 789.0;
|
||||
}
|
||||
|
||||
public boolean containsKey(int k) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean containsValue(double v) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putAll(Map<? extends Integer, ? extends Double> m) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<Integer> keySet() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<Double> values() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<Entry<Integer, Double>> entrySet() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun foo(x: SpecializedMap) {
|
||||
x.containsKey(1)
|
||||
x.containsKey(null)
|
||||
|
||||
x.get(2)
|
||||
x.get(null)
|
||||
|
||||
x.remove(3)
|
||||
x.remove(null)
|
||||
|
||||
x.<!AMBIGUITY!>put<!>(4, 5.0)
|
||||
x.<!AMBIGUITY!>put<!>(4, null)
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// FILE: kt1.kt
|
||||
package kt
|
||||
|
||||
inline class Z(val value: Int)
|
||||
|
||||
interface IFoo<T> {
|
||||
fun foo(): T
|
||||
}
|
||||
|
||||
open class KFooZ : IFoo<Z> {
|
||||
override fun foo(): Z = Z(42)
|
||||
}
|
||||
|
||||
// FILE: j/J.java
|
||||
package j;
|
||||
|
||||
import kt.Z;
|
||||
import kt.KFooZ;
|
||||
|
||||
public class J extends KFooZ {
|
||||
}
|
||||
|
||||
// FILE: kt2.kt
|
||||
package kt
|
||||
|
||||
import j.J
|
||||
|
||||
fun jfoo(x: J) = x.foo()
|
||||
@@ -0,0 +1,19 @@
|
||||
// FILE: B.java
|
||||
|
||||
public abstract class B implements A {
|
||||
private int size = 1;
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
interface A {
|
||||
val size: Int
|
||||
}
|
||||
|
||||
class C : B() {
|
||||
override val size: Int get() = 1
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
C().size
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// KT-4149 static members of Java private nested class are accessible from Kotlin
|
||||
|
||||
// FILE: javaPackage/Foo.java
|
||||
|
||||
package javaPackage;
|
||||
|
||||
public class Foo {
|
||||
private static class Bar {
|
||||
public static void doSmth() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun main() {
|
||||
javaPackage.Foo.Bar.doSmth()
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// FILE: A.java
|
||||
|
||||
public interface A extends B {
|
||||
public int getFoo();
|
||||
public void setFoo(int x);
|
||||
}
|
||||
|
||||
// FILE: BImpl.java
|
||||
|
||||
public class BImpl implements B {
|
||||
public int getFoo() {}
|
||||
public void setFoo(int x) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
interface B {
|
||||
var foo: Int
|
||||
}
|
||||
|
||||
interface C1 : A {
|
||||
override var foo: Int
|
||||
}
|
||||
|
||||
class D : C1, BImpl()
|
||||
|
||||
fun foo() {
|
||||
BImpl().foo = BImpl().foo + 1
|
||||
D().foo = D().foo + 2
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// FILE: A.java
|
||||
|
||||
public class A extends B {
|
||||
public int isFoo() { return 0; }
|
||||
public void setFoo(int x) {}
|
||||
}
|
||||
|
||||
// FILE: F.java
|
||||
|
||||
public class F extends B {
|
||||
public final int isFoo() { return 0; }
|
||||
public final void setFoo(int x) {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
open class B {
|
||||
open var isFoo: Int = 1
|
||||
}
|
||||
|
||||
class C1 : A() {
|
||||
override var isFoo: Int = 2
|
||||
}
|
||||
|
||||
class C2 : F() {
|
||||
override var isFoo: Int = 3
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user