cushon / issues-import

0 stars 0 forks source link

Ordering.from fails if 'from' method is statically imported #239

Open cushon opened 10 years ago

cushon commented 10 years ago

Original issue created by ignacio.bacamt on 2014-03-16 at 11:43 AM


The attached patch contains a tests which fails and a fix to pass this test.

What steps will reproduce the problem?

  1. Add import static com.google.common.collect.Ordering.from;
  2. Add Ordering<String> ord = from(new Comparator<String>() {
  3. Run error-prone

What is the expected output? What do you see instead? Expect to work, but instead... [ERROR] error-prone version: 1.1.1 [ERROR] Stack Trace: [ERROR] java.lang.ClassCastException: com.sun.tools.javac.tree.JCTree$JCIdent cannot be cast to com.sun.tools.javac.tree.JCTree$JCFieldAccess [ERROR] at com.google.errorprone.bugpatterns.OrderingFrom.matchMethodInvocation(OrderingFrom.java:84) [ERROR] at com.google.errorprone.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:727) [ERROR] at com.google.errorprone.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:40) [ERROR] at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1333) [ERROR] at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67) [ERROR] at com.google.errorprone.Scanner.scan(Scanner.java:116) [ERROR] at com.google.errorprone.Scanner.scan(Scanner.java:42) [ERROR] at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80) [ERROR] at com.sun.source.util.TreeScanner.visitAssignment(TreeScanner.java:294) [ERROR] at com.google.errorprone.ErrorProneScanner.visitAssignment(ErrorProneScanner.java:482) [ERROR] at com.google.errorprone.ErrorProneScanner.visitAssignment(ErrorProneScanner.java:40) [ERROR] at com.sun.tools.javac.tree.JCTree$JCAssign.accept(JCTree.java:1473) [ERROR] at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67) [ERROR] at com.google.errorprone.Scanner.scan(Scanner.java:116) [ERROR] at com.google.errorprone.Scanner.scan(Scanner.java:42) [ERROR] at com.sun.source.util.TreeScanner.visitExpressionStatement(TreeScanner.java:240) [ERROR] at com.google.errorprone.ErrorProneScanner.visitExpressionStatement(ErrorProneScanner.java:629) [ERROR] at com.google.errorprone.ErrorProneScanner.visitExpressionStatement(ErrorProneScanner.java:40) [ERROR] at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1173) [ERROR] at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67) [ERROR] at com.google.errorprone.Scanner.scan(Scanner.java:116) [ERROR] at com.google.errorprone.Scanner.scan(Scanner.java:42) [ERROR] at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80) [ERROR] at com.sun.source.util.TreeScanner.scan(TreeScanner.java:90) [ERROR] at com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:159) [ERROR] at com.google.errorprone.ErrorProneScanner.visitBlock(ErrorProneScanner.java:502) [ERROR] at com.google.errorprone.ErrorProneScanner.visitBlock(ErrorProneScanner.java:40) [ERROR] at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:790) [ERROR] at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67) [ERROR] at com.google.errorprone.Scanner.scan(Scanner.java:116) [ERROR] at com.google.errorprone.Scanner.scan(Scanner.java:42) [ERROR] at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80) [ERROR] at com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:142) [ERROR] at com.google.errorprone.ErrorProneScanner.visitMethod(ErrorProneScanner.java:719) [ERROR] at com.google.errorprone.ErrorProneScanner.visitMethod(ErrorProneScanner.java:40) [ERROR] at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:690) [ERROR] at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:67) [ERROR] at com.google.errorprone.Scanner.scan(Scanner.java:116) [ERROR] at com.google.errorprone.Scanner.scan(Scanner.java:42) [ERROR] at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:80) [ERROR] at com.sun.source.util.TreeScanner.scan(TreeScanner.java:90) [ERROR] at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:98) [ERROR] at com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:132) [ERROR] at com.google.errorprone.ErrorProneScanner.visitClass(ErrorProneScanner.java:542) [ERROR] at com.google.errorprone.ErrorProneScanner.visitClass(ErrorProneScanner.java:40) [ERROR] at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:618) [ERROR] at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:49) [ERROR] at com.google.errorprone.Scanner.scan(Scanner.java:77) [ERROR] at com.google.errorprone.ErrorProneAnalyzer.reportReadyForAnalysis(ErrorProneAnalyzer.java:101) [ERROR] at com.google.errorprone.ErrorReportingJavaCompiler.postFlow(ErrorReportingJavaCompiler.java:149) [ERROR] at com.google.errorprone.ErrorReportingJavaCompiler.flow(ErrorReportingJavaCompiler.java:113) [ERROR] at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1218) [ERROR] at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:870) [ERROR] at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:829) [ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:439) [ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:353) [ERROR] at com.google.errorprone.ErrorProneCompiler.compile(ErrorProneCompiler.java:154) [ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:342) [ERROR] at com.sun.tools.javac.main.Main.compile(Main.java:333) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [ERROR] at java.lang.reflect.Method.invoke(Method.java:606) [ERROR] at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne.compileInProcessWithProperClassloader(JavacCompilerWithErrorProne.java:180) [ERROR] at org.codehaus.plexus.compiler.javac.JavacCompiler.compileInProcess(JavacCompiler.java:538) [ERROR] at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:174) [ERROR] at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:785) [ERROR] at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129) [ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106) [ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) [ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) [ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) [ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) [ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) [ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) [ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) [ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317) [ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152) [ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555) [ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214) [ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:158) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [ERROR] at java.lang.reflect.Method.invoke(Method.java:606) [ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) [ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) [ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) [ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) [ERROR] at org.codehaus.classworlds.Launcher.main(Launcher.java:46) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [ERROR] at java.lang.reflect.Method.invoke(Method.java:606) [ERROR] at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) [ERROR] -> [Help 1]

What version of the product are you using? On what operating system? error-prone version: 1.1.1

Please provide any additional information below.

cushon commented 10 years ago

Original comment posted by eaftan@google.com on 2014-04-07 at 10:24 PM


(No comment entered for this change.)


Status: Accepted Owner: eaftan@google.com Labels: -Priority-Medium, Priority-High