mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 23:39:39 +07:00
[java-refactoring] IDEA-71792 Support inlining of abstract methods having one implementation
GitOrigin-RevId: 00491acff53aff96705a866e0d799dfe22873d23
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ce73510eb1
commit
09bd11efd8
@@ -0,0 +1,18 @@
|
||||
import java.util.List;
|
||||
|
||||
public class InlineSingleImplementation {
|
||||
interface MyIface<T> {
|
||||
void mySimpleMethod();
|
||||
}
|
||||
|
||||
static class MyIfaceImpl<E extends CharSequence> implements MyIface<E> {
|
||||
@Override
|
||||
public void mySimpleMethod() {
|
||||
System.out.println("Impl");
|
||||
}
|
||||
}
|
||||
|
||||
void test(MyIface<String> iface) {
|
||||
iface.<caret>mySimpleMethod();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
public class InlineSingleImplementation {
|
||||
interface MyIface<T> {
|
||||
void mySimpleMethod();
|
||||
}
|
||||
|
||||
static class MyIfaceImpl<E extends CharSequence> implements MyIface<E> {
|
||||
@Override
|
||||
public void mySimpleMethod() {
|
||||
System.out.println("Impl");
|
||||
}
|
||||
}
|
||||
|
||||
void test(MyIface<String> iface) {
|
||||
System.out.println("Impl");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import java.util.List;
|
||||
|
||||
public class InlineSingleImplementation {
|
||||
interface MyIface<T> {
|
||||
void myUseGenericMethod(T t);
|
||||
}
|
||||
|
||||
static class MyIfaceImpl<E extends CharSequence> implements MyIface<E> {
|
||||
@Override
|
||||
public void myUseGenericMethod(E e) {
|
||||
E e1 = e;
|
||||
System.out.println("Impl: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
void test(MyIface<String> iface) {
|
||||
iface.<caret>myUseGenericMethod("hello");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
public class InlineSingleImplementation {
|
||||
interface MyIface<T> {
|
||||
void myUseGenericMethod(T t);
|
||||
}
|
||||
|
||||
static class MyIfaceImpl<E extends CharSequence> implements MyIface<E> {
|
||||
@Override
|
||||
public void myUseGenericMethod(E e) {
|
||||
E e1 = e;
|
||||
System.out.println("Impl: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
void test(MyIface<String> iface) {
|
||||
String e1 = "hello";
|
||||
System.out.println("Impl: " + "hello");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import java.util.List;
|
||||
|
||||
public class InlineSingleImplementation {
|
||||
interface MyIface<T> {
|
||||
<M> M myGenericMethod(M m, T t);
|
||||
}
|
||||
|
||||
static class MyIfaceImpl<E extends CharSequence> implements MyIface<E> {
|
||||
@Override
|
||||
public <M1> M1 myGenericMethod(M1 m, E e) {
|
||||
M1 m1 = m;
|
||||
E e1 = e;
|
||||
if (m == null) return null;
|
||||
System.out.println("Impl: " + m1 + " : " + e);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
void test(MyIface<String> iface) {
|
||||
int x = iface.<caret>myGenericMethod(123, "hello");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
public class InlineSingleImplementation {
|
||||
interface MyIface<T> {
|
||||
<M> M myGenericMethod(M m, T t);
|
||||
}
|
||||
|
||||
static class MyIfaceImpl<E extends CharSequence> implements MyIface<E> {
|
||||
@Override
|
||||
public <M1> M1 myGenericMethod(M1 m, E e) {
|
||||
M1 m1 = m;
|
||||
E e1 = e;
|
||||
if (m == null) return null;
|
||||
System.out.println("Impl: " + m1 + " : " + e);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
void test(MyIface<String> iface) {
|
||||
Integer result = null;
|
||||
Integer m1 = 123;
|
||||
String e1 = "hello";
|
||||
if ((Integer) 123 != null) {
|
||||
System.out.println("Impl: " + m1 + " : " + "hello");
|
||||
result = 123;
|
||||
}
|
||||
int x = result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user