mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
moved java resolve tests to community
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: ik
|
||||
* Date: 22.01.2003
|
||||
* Time: 11:15:19
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class Test1 {
|
||||
public static class A{
|
||||
protected void foo(){}
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
new A(){
|
||||
protected void foo(){
|
||||
super.<ref>foo();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class Array{
|
||||
void foo(){
|
||||
int[] array;
|
||||
array.<ref>clone();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: ik
|
||||
* Date: 22.01.2003
|
||||
* Time: 14:46:09
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class Bug7968 {
|
||||
public static void foo (String s, String s1, String s2, Object[] oa)
|
||||
{
|
||||
Bar.<ref>bar (s, s1, s2, oa);
|
||||
}
|
||||
class Bar
|
||||
{
|
||||
public static void bar (Object o, String s1, String s2, Object[] ao) {}
|
||||
public static void bar (String s, String s1, String s2, Object o) {}
|
||||
public static void bar (String s, String s1, String s2, Object[] ao) {}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
class Z{
|
||||
public interface A { Object clone(); }
|
||||
|
||||
interface B extends A { }
|
||||
|
||||
|
||||
|
||||
|
||||
class C implements B {
|
||||
Object clone() {
|
||||
C c = new C();
|
||||
((A) c).clone();
|
||||
((B) c).<ref>clone();
|
||||
return c.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
public class Cycle1{
|
||||
public interface A{
|
||||
void foo();
|
||||
}
|
||||
|
||||
public interface B{
|
||||
void foo();
|
||||
}
|
||||
|
||||
public static class C
|
||||
implements A{
|
||||
void foo(){}
|
||||
}
|
||||
|
||||
public static class D extends C
|
||||
implements B{
|
||||
void foo(int ggg){}
|
||||
|
||||
void foo1(){
|
||||
<ref>foo();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class A{
|
||||
A(){
|
||||
<ref>super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
abstract public class YYY implements I,II{
|
||||
private void f(YYY y) {
|
||||
II i = y.<ref>foo();
|
||||
}
|
||||
}
|
||||
interface I {
|
||||
I foo();
|
||||
}
|
||||
interface II extends I {
|
||||
II foo();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class A{
|
||||
{
|
||||
"aaa".<ref>indexOf('a');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: ik
|
||||
* Date: 23.01.2003
|
||||
* Time: 18:44:34
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class Inner1 {
|
||||
private int a(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
private class A extends B{
|
||||
{
|
||||
int j = <ref>a();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
public int a(){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
class A{
|
||||
public int askdh(){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A{
|
||||
public void askdh(){
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
class Super1 extends B{
|
||||
{
|
||||
super.<ref>askdh();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
public class InnerClass {
|
||||
void foo() {}
|
||||
|
||||
class Inner {
|
||||
void foo(int i) {}
|
||||
|
||||
void bar() {
|
||||
<ref>foo();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class A{
|
||||
interface A{}
|
||||
interface B{}
|
||||
|
||||
class C implements A, B{
|
||||
void foo(A a){}
|
||||
void foo(B b){}
|
||||
}
|
||||
{
|
||||
new C().<ref>foo(new C())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Test{
|
||||
{
|
||||
new Runnable(){
|
||||
{
|
||||
<ref>run();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class A{
|
||||
void foo(Object a, String b){
|
||||
}
|
||||
|
||||
void foo(){
|
||||
<ref>foo("aaa", true);
|
||||
}
|
||||
|
||||
void foo(String a, boolean b){
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
class A {
|
||||
B b1;
|
||||
static B b2;
|
||||
public class Z extends B{
|
||||
public void akshdkjasdh(){}
|
||||
}
|
||||
private class B{
|
||||
public void f() {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class C extends A {
|
||||
{
|
||||
b1.<ref>f();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import java.io.Serializable;
|
||||
|
||||
interface PublicCloneable {
|
||||
Object clone();
|
||||
}
|
||||
interface Extension extends Serializable, PublicCloneable {}
|
||||
class Test {
|
||||
void foo(Extension bar) {
|
||||
bar.<ref>clone();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
class A{
|
||||
public abstract class IntegerPredicateBase implements Predicate{
|
||||
public boolean applies(Object obj){
|
||||
return <ref>applies((Integer)obj);
|
||||
}
|
||||
}
|
||||
public interface Predicate{
|
||||
boolean applies(Object obj);
|
||||
boolean applies(Integer myObj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
class A{
|
||||
private void foo(String s){}
|
||||
public void foo(Object o){}
|
||||
}
|
||||
|
||||
class B{
|
||||
{
|
||||
new A().<ref>foo("a");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Outer {
|
||||
private void foo() {}
|
||||
|
||||
static class Inner extends Outer {
|
||||
void bar() {
|
||||
<ref>foo();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Outer {
|
||||
private void foo() {}
|
||||
|
||||
class Inner extends Outer {
|
||||
void bar() {
|
||||
<ref>foo();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
class Xc extends JComponent {
|
||||
JComponent component;
|
||||
|
||||
protected void paintComponent(final Graphics g) {
|
||||
component.<ref>paintComponent(g);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
public class Remove1{
|
||||
void foo(Object o){}
|
||||
void foo(String o){}
|
||||
public static class A extends Remove{
|
||||
void foo(Object o){
|
||||
}
|
||||
void foo(String o){
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(){
|
||||
new A().<ref>foo("aaa");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import java.util.ArrayList;
|
||||
public class Remove2{
|
||||
private static ArrayList lst = new ArrayList();
|
||||
public static void main(){
|
||||
lst.<ref>remove("aaa");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package psi.resolve.method;
|
||||
|
||||
import com.intellij.util.containers.trove.THashMap;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: ik
|
||||
* Date: 17.01.2003
|
||||
* Time: 15:08:26
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class Remove3{
|
||||
THashMap map = new THashMap();
|
||||
|
||||
void foo(){
|
||||
map.<ref>size();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package ;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: ik
|
||||
* Date: 17.01.2003
|
||||
* Time: 19:11:56
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class Remove4 {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
interface I {
|
||||
boolean foo(Object obj);
|
||||
|
||||
boolean foo(Integer myObj);
|
||||
}
|
||||
|
||||
abstract class C implements I {
|
||||
public boolean foo(Object obj) {
|
||||
return <ref>foo((Integer)obj);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
class Base {
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
}
|
||||
|
||||
class Server {
|
||||
static Base sub(Base p1, Base p2) {
|
||||
}
|
||||
|
||||
static Derived sub(Derived p1, Base p2) {
|
||||
}
|
||||
|
||||
static Derived sub(Base p1, Derived p2) {
|
||||
}
|
||||
|
||||
static Derived sub(Derived p1, Derived p2) {
|
||||
}
|
||||
}
|
||||
|
||||
class Client {
|
||||
{
|
||||
Derived arg = null;
|
||||
Server.<ref>sub(arg, arg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class A{
|
||||
String toHex(int i) {}
|
||||
String toHex(short i) {}
|
||||
|
||||
void f(){
|
||||
<ref>toHex('i');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class Simple {
|
||||
public void method(String s) {
|
||||
}
|
||||
|
||||
static {
|
||||
Simple a = new Simple();
|
||||
a.<ref>method("blah");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Sout {
|
||||
static {
|
||||
System.out.<ref>println();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
public class Foo {
|
||||
public void foo() {}
|
||||
|
||||
public static void foo(char c){}
|
||||
}
|
||||
|
||||
class A{
|
||||
{
|
||||
Foo.<ref>foo();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class A{
|
||||
public void askdh(){
|
||||
}
|
||||
}
|
||||
|
||||
class Super1 extends A{
|
||||
{
|
||||
super.<ref>askdh();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
interface I {
|
||||
Object clone();
|
||||
}
|
||||
|
||||
interface J extends I {
|
||||
}
|
||||
|
||||
class CBase implements I {
|
||||
}
|
||||
|
||||
class C extends CBase implements J {
|
||||
{
|
||||
super.<ref>clone();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: ik
|
||||
* Date: 28.05.2003
|
||||
* Time: 16:24:03
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class TestOverloading1 {
|
||||
class A{
|
||||
void foo(){}
|
||||
}
|
||||
class B extends A{
|
||||
void foo(){}
|
||||
}
|
||||
|
||||
{
|
||||
new B().<ref>foo(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class A{
|
||||
void foo() throws Exception{
|
||||
throw <ref>Exception();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class A{
|
||||
void foo() throws Exception{
|
||||
throw <ref>Exception();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class A{
|
||||
void foo(){
|
||||
String.<ref>valueOf(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class Ambiguous {
|
||||
void f(Object o1, Object o2) {}
|
||||
void f(int o1, int o2) {}
|
||||
|
||||
void g(Integer i)
|
||||
{
|
||||
<ref>f(1, i);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
public class Foo {
|
||||
|
||||
public void foo(Comparable c) {
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
<ref>foo(1L);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
<T> Foo(T t) {
|
||||
|
||||
}
|
||||
|
||||
static {
|
||||
Foo f = <String>new <ref>Foo();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
interface F {
|
||||
Object o();
|
||||
}
|
||||
interface E extends F {
|
||||
String o();
|
||||
}
|
||||
interface B extends E,F { }
|
||||
|
||||
class User {
|
||||
void x(B a) {
|
||||
String o = a.<ref>o();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class X<T> {
|
||||
class XX extends X<X> {}
|
||||
void <T> f(X<T> x, T t) {
|
||||
f(new XX(), new X());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
interface Runnable{}
|
||||
interface Class<T>{}
|
||||
|
||||
public class Foo implements Runnable{
|
||||
static <T> void foo(Class<T> aClass, T t) { }
|
||||
|
||||
Class<Foo> getC(){ return new Class<Foo>(){};}
|
||||
public void run() {
|
||||
}
|
||||
|
||||
{
|
||||
<ref>foo(new Class<Runnable>(){}, this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class Foo {
|
||||
<T> T f() {
|
||||
}
|
||||
|
||||
{
|
||||
this.<String><ref>f();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class Foo {
|
||||
<T> Foo<T> f() {
|
||||
}
|
||||
|
||||
static {
|
||||
new Foo().<Integer><ref>f();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
class Test{
|
||||
interface Map<K, V>{
|
||||
K put(K k, V v);
|
||||
}
|
||||
|
||||
class HashMap implements Map<Integer, Integer>{
|
||||
}
|
||||
|
||||
{
|
||||
HashMap map = new HashMap();
|
||||
map.put(new Integer(1), new Integer(1)).<ref>byteValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class Test1 {
|
||||
public static void method(Object o, boolean b) {
|
||||
System.out.println("Object");
|
||||
}
|
||||
|
||||
public static void method(String s, Object o) {
|
||||
System.out.println("String");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
<ref>method("Hello, World", false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class Cast {
|
||||
public void f(Object o1, String ... o) {
|
||||
|
||||
}
|
||||
|
||||
public void f(String s, Integer o) {
|
||||
|
||||
}
|
||||
|
||||
public void g() {
|
||||
// Code is green - but we need a cast here
|
||||
<ref>f(null, null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class Cast {
|
||||
public void f(String ... o) {
|
||||
|
||||
}
|
||||
|
||||
public void f(Integer o) {
|
||||
|
||||
}
|
||||
|
||||
public void g() {
|
||||
// Code is green - but we need a cast here
|
||||
<ref>f(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
class A {}
|
||||
class B extends A{}
|
||||
class Cast {
|
||||
public void f(A... o) {
|
||||
|
||||
}
|
||||
|
||||
public void f(A o) {
|
||||
|
||||
}
|
||||
|
||||
public void g() {
|
||||
// Code is green - but we need a cast here
|
||||
<ref>f(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
class A {}
|
||||
class B extends A{}
|
||||
class Cast {
|
||||
public void f(A... o) {
|
||||
|
||||
}
|
||||
|
||||
public void f(A o) {
|
||||
|
||||
}
|
||||
|
||||
public void g() {
|
||||
// Casts ensures correct candidates filtering
|
||||
<ref>f((A) null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import java.util.List;
|
||||
|
||||
class A {
|
||||
static List<String> listOf(String... elements) {
|
||||
System.out.println("in varargs");
|
||||
return null;
|
||||
}
|
||||
|
||||
static List<String> listOf(Object elements) {
|
||||
System.out.println("in nonvarargs");
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
//resolves to nonvarargs method
|
||||
List<String> uhoh = <ref>listOf("");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import java.util.List;
|
||||
|
||||
class A {
|
||||
static <T> List<T> listOf(T... elements) {
|
||||
System.out.println("in varargs");
|
||||
return null;
|
||||
}
|
||||
|
||||
static <T> List<T> listOf(T elements) {
|
||||
System.out.println("in nonvarargs");
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String[] array = {"foo", "bar"};
|
||||
//resolves to varargs method
|
||||
List<String> uhoh = <ref>listOf(array);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import java.util.List;
|
||||
|
||||
class A {
|
||||
static <T> List<T[]> listOf(T[]... elements) {
|
||||
System.out.println("in multiple");
|
||||
return Arrays.asList(elements);
|
||||
}
|
||||
|
||||
static <T> List<T[]> listOf(T[] elements) {
|
||||
System.out.println("in single");
|
||||
return Collections.singletonList(elements);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String[] array = {"foo", "bar"};
|
||||
//resolves to nonvarargs method
|
||||
List<String[]> listOfString = <ref>listOf(array);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class HH {
|
||||
HH(Object o1, Object o2) {
|
||||
<ref>this(o1, o2);
|
||||
}
|
||||
|
||||
|
||||
HH(Object... os) {}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class ParentOf {
|
||||
public static <T extends PsiElement> T getParentOfType(PsiElement element, Class<T> aClass, boolean strict) {
|
||||
return null;
|
||||
}
|
||||
public static <T extends PsiElement> T getParentOfType(PsiElement element, Class<? extends T>... classes) {
|
||||
return null;
|
||||
}
|
||||
|
||||
void f(PsiElement e) {
|
||||
<ref>getParentOfType(e, PsiElement.class, PsiElement.class);
|
||||
}
|
||||
|
||||
static class PsiElement {}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class XY {
|
||||
public static Object getLocalizedObject(Object... objects) {
|
||||
System.out.println("in first");
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Object getLocalizedObject(Integer i, String string, Object... objects) {
|
||||
System.out.println("in second");
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
<ref>getLocalizedObject(null, "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class XY {
|
||||
private void f(byte... bs) {}
|
||||
|
||||
private void f(int... is) {}
|
||||
|
||||
public static void main(String[] args) {
|
||||
<ref>f((byte)0, (byte)1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
interface Foo extends Comparable {
|
||||
void compareTo(Foo foo);
|
||||
}
|
||||
|
||||
class User {
|
||||
void foo (Foo foo) {
|
||||
foo.<ref>compareTo(foo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import java.util.*;
|
||||
|
||||
class Foo<T> {
|
||||
void f(ArrayList<T> t) {}
|
||||
<V> void f(List<V> t) {}
|
||||
}
|
||||
|
||||
class User {
|
||||
void foo (Foo<String> foo) {
|
||||
foo.<ref>f(new ArrayList<String>());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import java.util.*;
|
||||
|
||||
public class AAA {
|
||||
<T> void f(java.util.List<T> t) {
|
||||
}
|
||||
|
||||
void f(Collection<String> s) {
|
||||
}
|
||||
|
||||
void y(List<String> strings) {
|
||||
<ref>f(strings);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import java.util.*;
|
||||
|
||||
public class AAA {
|
||||
<T> void f(Collection<T> t) {
|
||||
}
|
||||
|
||||
void f(java.util.List<String> s) {
|
||||
}
|
||||
|
||||
void y(List<String> strings) {
|
||||
<ref>f(strings);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
public class AAA {
|
||||
<T> void g(T t) {
|
||||
}
|
||||
|
||||
void g(String s) {
|
||||
}
|
||||
|
||||
{
|
||||
<ref>g("");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
public class AAA {
|
||||
<T> void g(T... t) {
|
||||
}
|
||||
|
||||
void g(String... s) {
|
||||
}
|
||||
|
||||
{
|
||||
<ref>g("");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
class Key<T> { T t; }
|
||||
|
||||
class WKey<W, T> extends Key<T> { W w; }
|
||||
|
||||
class Items {
|
||||
<T> void addItem(Key<T> key, T value) {}
|
||||
|
||||
<T, W> void addItem(WKey<W, T> key, T value) {}
|
||||
}
|
||||
|
||||
class IBug {
|
||||
public IBug() {
|
||||
Items items = new Items();
|
||||
|
||||
WKey<Object, String> sk = new WKey<Object, String>();
|
||||
|
||||
items.<ref>addItem(sk, "");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
class ContainerUtil {
|
||||
interface Condition<T> {
|
||||
boolean value(T object);
|
||||
}
|
||||
|
||||
public static <T> T find(Iterable<? extends T> iterable, final T equalTo) {
|
||||
return <ref>find(iterable, new Condition<T>() {
|
||||
public boolean value(final T object) {
|
||||
return equalTo == object || equalTo.equals(object);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static <T> T find(Iterable<? extends T> iterable, Condition<T> condition) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
<ref>method("a", "b", "c");
|
||||
}
|
||||
|
||||
public static <T> T method(T... a) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void method(String... a) {}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Test {
|
||||
public static void main(String[] args) {
|
||||
"sss".<ref>getClass();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
public abstract class BaseTest
|
||||
{
|
||||
private Object f() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
class S {
|
||||
private Object f() {
|
||||
new BaseTest() {
|
||||
{
|
||||
<ref>f();
|
||||
}
|
||||
};
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
class Test{
|
||||
|
||||
class A <T>{
|
||||
B<T> x;
|
||||
class B <Z>{
|
||||
public void put(T x, Z y){}
|
||||
public Z getZ(){}
|
||||
public T getT(){}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
new A<Integer>().x.getT().<ref>byteValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
class Test{
|
||||
|
||||
class A <T>{
|
||||
B x;
|
||||
class B <Z>{
|
||||
public void put(T x, Z y){}
|
||||
public Z getZ(){}
|
||||
public T getT(){}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
new A<Integer>().new B<Boolean>().getZ().<ref>booleanValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
class Test{
|
||||
|
||||
class A <T>{
|
||||
B x;
|
||||
class B <Z>{
|
||||
public void put(T x, Z y){}
|
||||
public Z getZ(){}
|
||||
public T getT(){}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
new A<Integer>().new B<Boolean>().getT().<ref>byteValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
class Test{
|
||||
|
||||
class A <T>{
|
||||
B x;
|
||||
class B <Z>{
|
||||
public void put(T x, Z y){}
|
||||
public Z getZ(){}
|
||||
public T getT(){}
|
||||
}
|
||||
}
|
||||
|
||||
class C extends A<Integer>{}
|
||||
|
||||
{
|
||||
new C().new B<Boolean>().getT().<ref>byteValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class Test <T>{
|
||||
{
|
||||
Test<Test<Test>> test = new Test<Test>();
|
||||
{
|
||||
test.put("");
|
||||
{
|
||||
test.get().get().get().<ref>get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
T get(){ return null; }
|
||||
void put(T x){}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import java.util.*;
|
||||
|
||||
class SSS {
|
||||
public <T> void x(List<T> matcher) {
|
||||
System.out.println("<T>");
|
||||
}
|
||||
|
||||
public int x(List<Long> matcher) {
|
||||
System.out.println("long");
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static <T> List<T> any(Class<T> type) {
|
||||
return null;
|
||||
}
|
||||
void f() {
|
||||
<ref>x(any(Long.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
interface TestInterface {
|
||||
|
||||
<E extends Enum<E>> void doStuff(E thing);
|
||||
}
|
||||
|
||||
class TestImpl implements TestInterface {
|
||||
@Override
|
||||
public <I extends Enum<I>> void doStuff(I thing){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
enum TestEnum {
|
||||
THING
|
||||
}
|
||||
|
||||
class Testx {
|
||||
public void doTest(){
|
||||
TestImpl impl = new TestImpl();
|
||||
impl.<ref>doStuff(TestEnum.THING);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import java.util.Arrays;
|
||||
|
||||
public class MyClass
|
||||
{
|
||||
public static <T> void process(T obj)
|
||||
{
|
||||
System.out.println("Processing object: " + obj);
|
||||
}
|
||||
|
||||
public static <T> void process(T[] arr)
|
||||
{
|
||||
System.out.println("Processing array: " + Arrays.toString(arr));
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
String[] myArray = new String[] { "a", "b", "c" };
|
||||
|
||||
proc<ref>ess(myArray); // Ctr-Left-Click on "process" takes me to the wrong method!!!
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class A{
|
||||
class B<T>{}
|
||||
<T> void foo(T a, B<T> b){}
|
||||
|
||||
{
|
||||
<ref>foo("", new B());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
class TestClassT {
|
||||
static {
|
||||
B.<ref>foo(TestClassT.class);
|
||||
}
|
||||
|
||||
public static class A {
|
||||
public static A foo(Class<?> type) {
|
||||
return new A();
|
||||
}
|
||||
}
|
||||
public static class B extends A {
|
||||
public static B foo(Class type) {
|
||||
return new B();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import java.util.Comparator;
|
||||
|
||||
abstract class Z<T extends Z.NameRef> implements Comparator<T> {
|
||||
static abstract class NameRef implements java.lang.Comparable<T.<ref>NameRef> {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import static java.util.Arrays.*;
|
||||
import static java.util.Collections.sort;
|
||||
|
||||
class C {
|
||||
{
|
||||
int[] array = null;
|
||||
<ref>sort(array);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import static java.lang.Integer.parseInt;
|
||||
|
||||
public class X {
|
||||
|
||||
private String str;
|
||||
|
||||
public X(String str) {
|
||||
this.str = str;
|
||||
}
|
||||
|
||||
public int parseInt(){
|
||||
//The following line is rejected by the compiler but not by IntelliJ.
|
||||
return <ref>parseInt(str);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
X x=new X("123");
|
||||
int i=x.parseInt();
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import static java.util.Arrays.asList;
|
||||
import java.util.*;
|
||||
|
||||
class C {
|
||||
{
|
||||
List<String> s = <ref>asList(new String[0]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import static java.util.Arrays.toString;
|
||||
|
||||
class ImportDuty {
|
||||
public static void main(String[] args) {
|
||||
new ImportDuty().printArgs(1, 2, 3, 4, 5);
|
||||
}
|
||||
|
||||
void printArgs(Object... args) {
|
||||
System.out.println(<ref>toString(args));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import static java.util.Arrays.*;
|
||||
import java.util.*;
|
||||
|
||||
class C {
|
||||
{
|
||||
List<String> s = <ref>asList(new String[0]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import java.util.Collection;
|
||||
|
||||
public class SomeClass {
|
||||
public static Object find(Collection collection, Object criteria) {
|
||||
return criteria;
|
||||
}
|
||||
static class SomeSubClass extends SomeClass {
|
||||
public static <T> T find(Collection<T> collection, Object criteria) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
<T>void f()
|
||||
{
|
||||
Collection<T> c = null;
|
||||
Object criteria = null;
|
||||
|
||||
// IntelliJ finds the find(Collection, Object) method, and reports a non-existent compile error.
|
||||
T someInstance = SomeSubClass.<ref>find(c, criteria);
|
||||
}
|
||||
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: ik
|
||||
* Date: 28.05.2003
|
||||
* Time: 16:50:51
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class TestGenericMethodOverloading1 {
|
||||
class A<T extends List>{
|
||||
public boolean equals(T t){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
{
|
||||
new A().<ref>equals(new Object());
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: ik
|
||||
* Date: 28.05.2003
|
||||
* Time: 16:50:51
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class TestGenericMethodOverloading2 {
|
||||
class A<T>{
|
||||
public boolean equals(T t){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
{
|
||||
new A().<ref>equals(new Object());
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: ik
|
||||
* Date: 28.05.2003
|
||||
* Time: 16:50:51
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class TestGenericMethodOverloading3 {
|
||||
class A<T>{
|
||||
public boolean equals(T t){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
{
|
||||
new A<String>().<ref>equals(new Object());
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: ik
|
||||
* Date: 28.05.2003
|
||||
* Time: 16:50:51
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class TestGenericMethodOverloading4 {
|
||||
class A<T>{
|
||||
public boolean equals(T t){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
{
|
||||
new A<String>().<ref>equals(new String());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: ik
|
||||
* Date: 28.05.2003
|
||||
* Time: 16:50:51
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class TestReturnType1 {
|
||||
class A<T extends Runnable>{
|
||||
public T foo(T t){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
{
|
||||
new A<String>().foo(new String()).<ref>toCharArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: ik
|
||||
* Date: 28.05.2003
|
||||
* Time: 16:50:51
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class TestReturnType2 {
|
||||
class A<T extends Runnable>{
|
||||
public T foo(T t){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
{
|
||||
new A().foo(new String()).<ref>toCharArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
public class WithInner<T> {
|
||||
T foo () {
|
||||
return null;
|
||||
}
|
||||
|
||||
class Inner {
|
||||
T foo () {
|
||||
return <ref>WithInner.this.foo();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
class B{
|
||||
void b(){};
|
||||
}
|
||||
|
||||
interface E{
|
||||
void e();
|
||||
}
|
||||
|
||||
class C extends B{
|
||||
void c(){}
|
||||
}
|
||||
|
||||
class D extends B implements E{
|
||||
void d(){}
|
||||
void e(){}
|
||||
}
|
||||
|
||||
|
||||
class A<Z>{
|
||||
<T> T foo(T t, A<T> a){ return null; }
|
||||
|
||||
{
|
||||
foo(new C(), new A<D>()).<ref>b();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import java.util.*;
|
||||
|
||||
class Thing {
|
||||
}
|
||||
class Testergen {
|
||||
<T extends Thing> T x(T thing) {
|
||||
return null;
|
||||
}
|
||||
|
||||
<T extends Thing> T x(Collection<T> thing) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
class TestergenUser {
|
||||
public void context(Testergen test) {
|
||||
// the error is shown when x is called:
|
||||
Collection<Thing> t = null;
|
||||
test.<ref>x(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user