Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-8168

When using Interface: BigDecimal cannot be cast to Double

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.10
    • 5.0.0-alpha-1
    • None
    • None

    Description

      Execute the following code.

      interface SomeOperation {
          double calculate(int i)
      }
      SomeOperation operation = { return 1.0 }
      operation.calculate(2)
      

      Results in exception:

       java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.lang.Double
      	at com.sun.proxy.$Proxy21.calculate(Unknown Source)
      	at SomeOperation$calculate.call(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
      	at ideaGroovyConsole.run(ideaGroovyConsole.groovy:5)
      	at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263)
      	at groovy.lang.GroovyShell.run(GroovyShell.java:518)
      	at groovy.lang.GroovyShell.run(GroovyShell.java:497)
      	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:483)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:169)
      	at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:71)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
      	at console.run(console.txt:25)
      	at groovy.ui.GroovyMain.processReader(GroovyMain.java:632)
      	at groovy.ui.GroovyMain.processFiles(GroovyMain.java:540)
      	at groovy.ui.GroovyMain.run(GroovyMain.java:382)
      	at groovy.ui.GroovyMain.process(GroovyMain.java:370)
      	at groovy.ui.GroovyMain.processArgs(GroovyMain.java:129)
      	at groovy.ui.GroovyMain.main(GroovyMain.java:109)
      	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:483)
      	at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:109)
      	at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131)
      	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:483)
      	at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:65)
      

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              artemik Artem
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: