google / compile-testing

Testing tools for javac and annotation processors
Apache License 2.0
701 stars 119 forks source link

A deferred diagnostic of a second compilation error on the same element is not reported #124

Open fbiville opened 7 years ago

fbiville commented 7 years ago

Versions

Context

In Neo4j, an aggregation function is defined with an @UserAggregationFunction-annotated method whose returned type's enclosing class (aka aggregation type) must define two methods, one annotated with @UserAggregationUpdate, another @UserAggregationResult.

Now, I have got a unit test that makes sure that an aggregation type without those two annotations triggers two compilation errors (1 for the missing @UserAggregationUpdate, 1 for the missing @UserAggregationResult).

First diagnostic

After debugging a bit com.google.testing.compile.Compiler#compile(java.lang.Iterable<? extends javax.tools.JavaFileObject>), it seems the deferred diagnostic for the second compilation error never comes, despite both errors being sent.

How to reproduce

## setup steps
 $> git clone -b update_compiler_3.2 git@github.com:fbiville/neo4j.git && cd neo4j 
## this one may take some time (https://xkcd.com/303/)
 $> mvn -am -pl community/procedure-compiler/processor clean install -DskipTests
 $> sed -i.bak '/@Ignore/d' community/procedure-compiler/processor/src/test/java/org/neo4j/tooling/procedure/UserAggregationFunctionProcessorTest.java
## actually run the failing test
 $> mvn test -Dtest="UserAggregationFunctionProcessorTest#fails_if_aggregation_function_exposes_return_type_without_aggregation_methods" -f community/procedure-compiler/processor/pom.xml
netdpb commented 3 years ago

Some older versions of the compiler don't report more than one diagnostic on a single line. Are you still seeing this problem? Which JDK are you using?