generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: implement extensive inspections for `MethodHandles#tableSwit…
…ch` (#91)
- Loading branch information
Showing
8 changed files
with
130 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import java.lang.invoke.MethodHandle; | ||
import static java.lang.invoke.MethodHandles.*; | ||
import static java.lang.invoke.MethodType.*; | ||
|
||
class MethodHandlesTableSwitch { | ||
void switching() { | ||
// missing cases | ||
<info descr="(int)int">MethodHandle ts0 = <info descr="(int)int">tableSwitch(<info descr="(int)int">identity(int.class)</info>)</info>;</info> | ||
// that works | ||
<info descr="(int)int">MethodHandle ts1 = <info descr="(int)int">tableSwitch(<info descr="(int)int">identity(int.class)</info>, <info descr="(int)int">identity(int.class)</info>)</info>;</info> | ||
// no leading int param | ||
<info descr="TopSignature">MethodHandle ts2 = <info descr="TopSignature">tableSwitch(<info descr="(String)String">identity(String.class)</info>, <info descr="(String)String">identity(String.class)</info>)</info>;</info> | ||
// parameter list differs in length | ||
<info descr="TopSignature">MethodHandle ts3 = <info descr="TopSignature">tableSwitch(<info descr="(int)void">empty(<info descr="(int)void">methodType(void.class, int.class)</info>)</info>, <info descr="(int,String)void">empty(<info descr="(int,String)void">methodType(void.class, int.class, String.class)</info>)</info>)</info>;</info> | ||
// parameter list is empty | ||
<info descr="TopSignature">MethodHandle ts4 = <info descr="TopSignature">tableSwitch(<info descr="()void">empty(<info descr="()void">methodType(void.class)</info>)</info>, <info descr="()void">empty(<info descr="()void">methodType(void.class)</info>)</info>)</info>;</info> | ||
// parameter list differs in types | ||
<info descr="TopSignature">MethodHandle ts5 = <info descr="TopSignature">tableSwitch(<info descr="(int,CharSequence)void">empty(<info descr="(int,CharSequence)void">methodType(void.class, int.class, CharSequence.class)</info>)</info>, <info descr="(int,String)void">empty(<info descr="(int,String)void">methodType(void.class, int.class, String.class)</info>)</info>)</info>;</info> | ||
// return types differ | ||
<info descr="TopSignature">MethodHandle ts6 = <info descr="TopSignature">tableSwitch(<info descr="(int)String">empty(<info descr="(int)String">methodType(String.class, int.class)</info>)</info>, <info descr="(int)CharSequence">empty(<info descr="(int)CharSequence">methodType(CharSequence.class, int.class)</info>)</info>)</info>;</info> | ||
// that works but is more complex | ||
<info descr="(int,String)int">MethodHandle ts7 = <info descr="(int,String)int">tableSwitch( | ||
<info descr="(int,String)int">empty(<info descr="(int,String)int">methodType(int.class, int.class, String.class)</info>)</info>, | ||
<info descr="(int,String)int">empty(<info descr="(int,String)int">methodType(int.class, int.class, String.class)</info>)</info>, | ||
<info descr="(int,String)int">empty(<info descr="(int,String)int">methodType(int.class, int.class, String.class)</info>)</info> | ||
)</info>;</info> | ||
} | ||
} |