openclover / clover

This repository contains source code of OpenClover Core as well as its integrations: Clover-for-Ant, Clover-for-Eclipse and Clover-for-IDEA plugins. Sources are licensed under Apache 2.0 license.
Other
57 stars 14 forks source link

The instanceof pattern matching is not working for 4.5.2 #257

Closed mloayzagahona closed 2 months ago

mloayzagahona commented 2 months ago

I have this code

import org.springframework.http.ResponseEntity;
...
if (outcome instanceof ResponseEntity<?> outcomeCast)

Error Message


[INFO] --- clover-maven-plugin:4.5.2:setup (default-cli) @ fargate ---
[INFO] OpenClover Version 4.5.2, built on 2024-01-31
[INFO] Creating new database at '/..../target/clover/clover.db'.
[INFO] Processing files at JAVA_17 source level.
[INFO] Clover all over. Instrumented 150 files (30 packages).
[INFO] OpenClover Version 4.5.2, built on 2024-01-31
[INFO] Updating existing database at '.../clover.db'.
[INFO] Processing files at JAVA_17 source level.
[INFO] Clover all over. Instrumented 46 files (16 packages).
[INFO] 185 test methods detected.
.....
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] ....../aspect/CountMetricAspect.java:[81,53] cannot find symbol
  symbol:   variable outcomeCast
  location: class CountMetricAspect
...
[INFO] 3 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  12.731 s (Wall Clock)
[INFO] Finished at: 2024-04-11T14:40:09-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile (java-compile) on project fargate: Compilation failure: Compilation failure:
[ERROR] /demo/target/clover/src/demo/ClientLatencyAspect.java:[61,51] cannot find symbol
[ERROR]   symbol:   variable outcomeCast
[ERROR]   location: class demo.ClientLatencyAspect

The same code works for Jacoco + JDK 17
marek-parfianowicz commented 2 months ago

Thank you for reporting this. It's a duplicate of #253 and #237. The bug has been solved but it's waiting for the release. I intended to release 4.6.0 on March, 31 but I have a delay, because I'm working also on code refactoring and Groovy 4 support. I hope to complete these till end of May.