Details
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).