Kabeer Ahmed created TOREE-520: ---------------------------------- Summary: Invalid error - Unapplied methods are only converted to functions when a function type is expected Key: TOREE-520 URL: https://issues.apache.org/jira/browse/TOREE-520 Project: TOREE Issue Type: Bug Affects Versions: 0.3.0 Environment: Jupyter Notebook on Ubuntu 20.04 Reporter: Kabeer Ahmed
The below code results in an error when executed in Toree on Jupyter notebook. Please note that the first time execution would proceed without issues but subsequent executions by pressing ctrl+Enter will result in the error being thrown. +*Code*+ // polymorphic functions def findFirst[A](as: List[A], p: A => Boolean): Int = \{ val listLength = as.length @annotation.tailrec def go(n: Int): Int = { if (n >= listLength) -1 else if (p(as(n))) n else go(n + 1) } go(0) } def passFun(x: Int): Boolean = x == 2 val l: List[Int] = List(1, 2, 3) // println("The findFirst of function is: ") println(s"Answer is: ${findFirst(l, passFun)}") Error thrown when the same code is executed twice is below: <console>:28: error: missing argument list for method findFirst Unapplied methods are only converted to functions when a function type is expected. You can make this conversion explicit by writing `findFirst _` or `findFirst(_,_)` instead of `findFirst`. findFirst ^ lastException: Throwable = null findFirst: [A](as: List[A], p: A => Boolean)Int passFun: (x: Int)Boolean -- This message was sent by Atlassian Jira (v8.3.4#803005)