You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@toree.apache.org by "Alexander Gunter (JIRA)" <ji...@apache.org> on 2019/08/13 01:20:00 UTC

[jira] [Updated] (TOREE-503) Cannot Use Scala Enumerations as Method Arguments

     [ https://issues.apache.org/jira/browse/TOREE-503?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexander Gunter updated TOREE-503:
-----------------------------------
    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:_
{code:java}
object ExampleEnum extends Enumeration {
   type ExampleEnum = Value
   val A, B, C = Value
 }{code}
{code:java}
defined object ExampleEnum
{code}
 

_CELL 2:_
{code:java}
def exampleMethod(enum: ExampleEnum.Value): Unit = {
  println(enum.toString)
}

exampleMethod(ExampleEnum.A){code}
{code:java}
exampleMethod: (enum: ExampleEnum.Value)Unit
A
{code}
 

_CELL 3:_
{code:java}
exampleMethod(ExampleEnum.A){code}
{code:java}
Name: Compile Error
Message: <console>:30: error: type mismatch;
 found   : ExampleEnum.Value
 required: ExampleEnum.Value
       exampleMethod(ExampleEnum.A)
                                 ^
StackTrace: 
{code}
 

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

  was:
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}}
{{}}}

 

 
{code:java}
defined object ExampleEnum
{code}
 

 

_CELL 2:_

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

exampleMethod(ExampleEnum.A){code}
 

 
{code:java}
exampleMethod: (enum: ExampleEnum.Value)Unit
A
{code}
 

 

_CELL 3:_

 
{code:java}
exampleMethod(ExampleEnum.A){code}
 

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

 

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


> Cannot Use Scala Enumerations as Method Arguments
> -------------------------------------------------
>
>                 Key: TOREE-503
>                 URL: https://issues.apache.org/jira/browse/TOREE-503
>             Project: TOREE
>          Issue Type: Bug
>          Components: Kernel
>    Affects Versions: 0.3.0
>         Environment: Amazon EMR Release emr-5.10.0, JupyterLab 0.35.4
>            Reporter: Alexander Gunter
>            Priority: Major
>
> 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:_
> {code:java}
> object ExampleEnum extends Enumeration {
>    type ExampleEnum = Value
>    val A, B, C = Value
>  }{code}
> {code:java}
> defined object ExampleEnum
> {code}
>  
> _CELL 2:_
> {code:java}
> def exampleMethod(enum: ExampleEnum.Value): Unit = {
>   println(enum.toString)
> }
> exampleMethod(ExampleEnum.A){code}
> {code:java}
> exampleMethod: (enum: ExampleEnum.Value)Unit
> A
> {code}
>  
> _CELL 3:_
> {code:java}
> exampleMethod(ExampleEnum.A){code}
> {code:java}
> Name: Compile Error
> Message: <console>:30: error: type mismatch;
>  found   : ExampleEnum.Value
>  required: ExampleEnum.Value
>        exampleMethod(ExampleEnum.A)
>                                  ^
> StackTrace: 
> {code}
>  
> 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).



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)