Uploaded image for project: 'TOREE'
  1. TOREE
  2. TOREE-503

Cannot Use Scala Enumerations as Method Arguments

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Workaround
    • 0.3.0
    • 0.3.0
    • Kernel
    • None
    • Amazon EMR Release emr-5.10.0, JupyterLab 0.35.4

    Description

      Under common circumstances, cells containing method calls where an argument is an Enumeration will fail to compile when using the Toree kernel in JupyterLab. The circumstances relate to the scoping between notebook cells. The arrangement below will fail to compile, producing the shown output.

       

      CELL 1:

      object ExampleEnum extends Enumeration {
         type ExampleEnum = Value
         val A, B, C = Value
       }
      defined object ExampleEnum
      

       

      CELL 2:

      def exampleMethod(enum: ExampleEnum.Value): Unit = {
        println(enum.toString)
      }
      
      exampleMethod(ExampleEnum.A)
      exampleMethod: (enum: ExampleEnum.Value)Unit
      A
      

       

      CELL 3:

      exampleMethod(ExampleEnum.A)
      Name: Compile Error
      Message: <console>:30: error: type mismatch;
       found   : ExampleEnum.Value
       required: ExampleEnum.Value
             exampleMethod(ExampleEnum.A)
                                       ^
      StackTrace: 
      

       

      Note that exampleMethod() works as expected when called inside the same cell as its definition (demo'd in Cell 2). It also works as expected in all cells if it is instead defined in Cell 1 alongside ExampleEnum (i.e. if you merge Cell1 and Cell 2).

      Attachments

        Activity

          People

            kbates Kevin Bates
            akgunter Alexander Gunter
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: