mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
don't instrument bridge methods for @NotNull (IDEA-146977)
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class SkipBridgeMethods {
|
||||
public static void main() {
|
||||
A a = new B();
|
||||
a.getObject(null);
|
||||
}
|
||||
}
|
||||
|
||||
class A {
|
||||
@NotNull
|
||||
public Object getObject(Object arg) {
|
||||
return new Object();
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
@NotNull
|
||||
public String getObject(@NotNull Object arg) {
|
||||
return arg.toString();
|
||||
}
|
||||
}
|
||||
+17
-1
@@ -19,12 +19,13 @@ import com.intellij.JavaTestUtil;
|
||||
import com.intellij.compiler.PsiClassWriter;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.testFramework.IdeaTestCase;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
import com.intellij.testFramework.fixtures.IdeaProjectTestFixture;
|
||||
import com.intellij.testFramework.fixtures.JavaTestFixtureFactory;
|
||||
import com.intellij.testFramework.fixtures.TestFixtureBuilder;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ExceptionUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.org.objectweb.asm.ClassReader;
|
||||
@@ -172,6 +173,21 @@ public class NotNullVerifyingInstrumenterTest extends UsefulTestCase {
|
||||
assertNotNull(aClass.newInstance());
|
||||
}
|
||||
|
||||
public void testSkipBridgeMethods() throws Exception {
|
||||
final Class<?> testClass = prepareTest();
|
||||
try {
|
||||
testClass.getMethod("main").invoke(null);
|
||||
fail();
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
//noinspection ThrowableResultOfMethodCallIgnored
|
||||
assertInstanceOf(e.getCause(), IllegalArgumentException.class);
|
||||
String trace = ExceptionUtil.getThrowableText(e.getCause());
|
||||
assertEquals("Exception should happen in real, non-bridge method: " + trace,
|
||||
2, StringUtil.getOccurrenceCount(trace, "B.getObject(SkipBridgeMethods"));
|
||||
}
|
||||
}
|
||||
|
||||
private static void verifyCallThrowsException(String expectedError, @Nullable Object instance, Member member, @Nullable Object... args) throws Exception {
|
||||
String exceptionText = null;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user