You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@toree.apache.org by "Kevin Bates (Jira)" <ji...@apache.org> on 2019/08/22 16:00:00 UTC

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

    [ https://issues.apache.org/jira/browse/TOREE-503?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16913444#comment-16913444 ] 

Kevin Bates commented on TOREE-503:
-----------------------------------

Hi Alexander - thank you opening the issue.

I can reproduce this on Spark 2.3 systems.  However, running Toree against Spark 2.4 does *not* reproduce the issue.  I see that emr-5.10 uses Spark 2.2.  Are you in a position to try against [emr-5.20+|https://docs.aws.amazon.com/emr/latest/ReleaseGuide/emr-release-5x.html] (which uses Spark 2.4)?  

Interestingly enough, the issue doesn't reproduce in any version of the spark-shell, but I suspect there could be some subtlety where the Spark 2.4 REPL happens to address this.

> 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
(v8.3.2#803003)