Skip to content

Unhandled exception in ArgumentParameterSwap (take 2) #490

@Stephan202

Description

@Stephan202

This issue was first reported in a comment to #453, but the fix for #453 has since been released, so a new issue seems in order.


Minimal reproduction case:

import com.google.common.collect.ImmutableMap;
import java.util.Optional;

final class Dummy {
    private Dummy(final ImmutableMap<?, ?> map, final Optional<?> optional) {
        /* Assignment to field not necessary to trigger issue. */
    }

    static Dummy create() {
        return new Dummy(ImmutableMap.of(), Optional.empty());
    }
}

Stacktrace:

/some/local/path/including/company/package/name/Dummy.java:12: error: An unhandled exception was thrown by the Error Prone static analysis plugin.
        return new Dummy(ImmutableMap.of(), Optional.empty());
               ^
     Please report this at https://github.com/google/error-prone/issues/new and include the following:

     error-prone version: 2.0.15-SNAPSHOT
     Stack Trace:
     java.lang.ClassCastException: com.sun.tools.javac.code.Type$ForAll cannot be cast to com.sun.tools.javac.code.Type$MethodType
    at com.google.errorprone.bugpatterns.AbstractArgumentParameterChecker.isSubtypeHandleCompletionFailures(AbstractArgumentParameterChecker.java:217)
    at com.google.errorprone.bugpatterns.AbstractArgumentParameterChecker.lambda$findReplacements$1(AbstractArgumentParameterChecker.java:191)
    at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174)
    at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
    at java.util.Iterator.forEachRemaining(Iterator.java:116)
    at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.reduce(ReferencePipeline.java:479)
    at java.util.stream.ReferencePipeline.max(ReferencePipeline.java:515)
    at com.google.errorprone.bugpatterns.AbstractArgumentParameterChecker.findReplacements(AbstractArgumentParameterChecker.java:198)
    at com.google.errorprone.bugpatterns.AbstractArgumentParameterChecker.matchNewClass(AbstractArgumentParameterChecker.java:135)
    at com.google.errorprone.bugpatterns.ArgumentParameterSwap.matchNewClass(ArgumentParameterSwap.java:42)
    at com.google.errorprone.scanner.ErrorProneScanner.visitNewClass(ErrorProneScanner.java:997)
    at com.google.errorprone.scanner.ErrorProneScanner.visitNewClass(ErrorProneScanner.java:144)
    at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1675)
    at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:72)
    at com.google.errorprone.scanner.Scanner.scan(Scanner.java:89)
    at com.google.errorprone.scanner.Scanner.scan(Scanner.java:43)
    at com.sun.source.util.TreeScanner.visitReturn(TreeScanner.java:470)
    at com.google.errorprone.scanner.ErrorProneScanner.visitReturn(ErrorProneScanner.java:1066)
    at com.google.errorprone.scanner.ErrorProneScanner.visitReturn(ErrorProneScanner.java:144)
    at com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1518)
    at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:72)
    at com.google.errorprone.scanner.Scanner.scan(Scanner.java:89)
    at com.google.errorprone.scanner.Scanner.scan(Scanner.java:43)
    at com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
    at com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:249)
    at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:575)
    at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:144)
    at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:996)
    at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:72)
    at com.google.errorprone.scanner.Scanner.scan(Scanner.java:89)
    at com.google.errorprone.scanner.Scanner.scan(Scanner.java:43)
    at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:91)
    at com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:207)
    at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:943)
    at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:144)
    at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:868)
    at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:72)
    at com.google.errorprone.scanner.Scanner.scan(Scanner.java:89)
    at com.google.errorprone.scanner.Scanner.scan(Scanner.java:43)
    at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:91)
    at com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
    at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:114)
    at com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:188)
    at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:635)
    at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:144)
    at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:778)
    at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:72)
    at com.google.errorprone.scanner.Scanner.scan(Scanner.java:89)
    at com.google.errorprone.scanner.Scanner.scan(Scanner.java:43)
    at com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
    at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:114)
    at com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:145)
    at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:650)
    at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:144)
    at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:561)
    at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:53)
    at com.google.errorprone.scanner.Scanner.scan(Scanner.java:68)
    at com.google.errorprone.scanner.ErrorProneScannerTransformer.apply(ErrorProneScannerTransformer.java:43)
    at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:145)
    at com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:113)
    at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1303)
    at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1247)
    at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:858)
    at com.sun.tools.javac.main.Main.compile(Main.java:253)
    at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:214)
    at com.google.errorprone.BaseErrorProneCompiler.run(BaseErrorProneCompiler.java:106)
    at com.google.errorprone.ErrorProneCompiler.run(ErrorProneCompiler.java:128)
    at com.google.errorprone.ErrorProneCompiler.compile(ErrorProneCompiler.java:70)
    at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne$CompilerInvoker.compile(JavacCompilerWithErrorProne.java:219)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.compiler.javac.errorprone.JavacCompilerWithErrorProne.performCompile(JavacCompilerWithErrorProne.java:91)
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:943)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:137)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:185)
    at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call(MultiThreadedBuilder.java:181)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions