Skip to content

Fix ClassCastException in cql-to-elm-cli with modelinfo#1805

Open
dehall wants to merge 3 commits into
cqframework:mainfrom
dehall:fix/cli-modelinfo
Open

Fix ClassCastException in cql-to-elm-cli with modelinfo#1805
dehall wants to merge 3 commits into
cqframework:mainfrom
dehall:fix/cli-modelinfo

Conversation

@dehall

@dehall dehall commented Jul 9, 2026

Copy link
Copy Markdown

This PR fixes #1803 - a ClassCastException when running the CLI and specifying a modelinfo.

The short explanation is that in Kotlin, unlike Java, anonymous lambdas cannot be cast to interfaces unless they are explicitly marked as functional interfaces (fun interface). So an alternative fix would be to mark ModelInfoProvider as a functional interface, but that may have broader implications. This approach instead creates an anonymous class that explicitly implements the interface.

To test this, run the cli and specify a modelinfo, eg here's an example with files already in the repo:

./gradlew :cql-to-elm-cli:installDist
./cql-to-elm-cli/build/install/cql-to-elm-cli/bin/cql-to-elm-cli  --model ./quick/src/main/resources/org/hl7/fhir/fhir-modelinfo-4.0.1.xml --input ./cql-to-elm/src/jvmTest/resources/org/cqframework/cql/cql2elm/fhir/r4/TestBundle.cql

@dehall

dehall commented Jul 10, 2026

Copy link
Copy Markdown
Author

Apologies, I'm pretty sure the CI is all failing because this PR comes from a fork but I'm not sure what to do about it. I'm open to suggestions

@antvaset

Copy link
Copy Markdown
Contributor

@dehall Looks good to me 👍 The PR only needs another approval and then it can be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClassCastException in cql-to-elm-cli when using modelinfo

2 participants