mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-10-18 04:24:12 +07:00
introduce param object: pass substitution around which won't be available after method signature is changed (IDEA-154208)
This commit is contained in:
1 parent
d9288e4b42
commit
1ce6f8d2fa
15 files changed
+107
-50
No files matched your search
+13
@@ -0,0 +1,13 @@
|
||||
import java.util.List;
|
||||
|
||||
public class Param<T> {
|
||||
private final List<T> y;
|
||||
|
||||
public Param(List<T> y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public List<T> getY() {
|
||||
return y;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public static <T> String foo(Param<T> param) {
|
||||
return null;
|
||||
}
|
||||
|
||||
void bar(List<Integer> list) {
|
||||
System.out.println(foo(new Param<>(list)));
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public static <T> String foo(List<T> y) {
|
||||
return null;
|
||||
}
|
||||
|
||||
void bar(List<Integer> list) {
|
||||
System.out.println(foo(list));
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,9 @@ package com.intellij.refactoring;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.refactoring.changeSignature.JavaMethodDescriptor;
|
||||
@@ -132,6 +134,18 @@ public class IntroduceParameterObjectTest extends MultiFileTestCase{
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTypeParametersWithSubstitution() throws Exception {
|
||||
final LanguageLevelProjectExtension projectExtension = LanguageLevelProjectExtension.getInstance(getProject());
|
||||
final LanguageLevel oldLevel = projectExtension.getLanguageLevel();
|
||||
try {
|
||||
projectExtension.setLanguageLevel(LanguageLevel.HIGHEST);
|
||||
doTest();
|
||||
}
|
||||
finally {
|
||||
projectExtension.setLanguageLevel(oldLevel);
|
||||
}
|
||||
}
|
||||
|
||||
public void testSameTypeAndVarargs() throws Exception {
|
||||
doTest(false, false, method -> {
|
||||
final PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||
|
||||
Reference in new issue
Block a user