Skip to content

Scala 2.12.4 upgrade + improve input type resolution #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

keithschulze
Copy link
Collaborator

Upgrades Scala to latest stable version.

Also, automatically cast input parameters to correct type to reduce boilerplate on developers. Previously, running the following with blob.gif open would give a ScriptException:

// @Dataset img
println(s"Img has ${img.getChannels} channel/channels")

// output: javax.script.ScriptException: value getChannels is not a member of Object 
// in println(s"Img has ${img.getChannels} channel/s")

This is because input parameters are injected into the script Bindings (i.e., Map<String, Object>), where type information is lost. This could be fixed by explicitly casting img to Dataset e.g., img.asInstanceOf[Dataset].getChannels. After this change, this is no longer necessary since we cast for input parameters to correct type automatically (i.e., through callback in ScriptModule). So, the following works:

// @Dataset img
println(s"Img has ${img.getChannels} channel/channels")

// output: Img has 1 channel/channels

… to the correct type.

Thus we no longer need boilerplatey `.asInstanceOf` casts to use input parameters.
@imagejan
Copy link
Member

I assume this was closed in favor of #7?

@ctrueden ctrueden removed the to do label Apr 24, 2023
@ctrueden ctrueden mentioned this pull request Apr 24, 2023
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.

3 participants