scala - Json4S Recursive method parse needs a result type -


i using json4s library in scala program.

my build.sbt looks like

librarydependencies ++= seq(   "org.json4s" % "json4s-native_2.11" % "3.3.0" ) 

in code, have function

import org.json4s._ import org.json4s.native.jsonmethods._ import org.json4s.jvalue class foo {     def parse(content: string) = {       val json  = parse(content)     } } 

but ide complains "recursive method parse needs result type"

the scala compiler infers return type of methods based on implementations, has trouble inferring type of recursive methods.

the message recursive method parse needs result type due shortcoming. def parse(content: string) recurses calling parse(content). makes method recursive (infinitely so, i'm assuming planning on changing later). in order compile, you'll need explicitly state return type, e.g. def parse(content: string): unit.

i'm going take further guess , there parse method being imported either json4s or jsonmethods. being shadowed own parse method due having same method signature. if want call jsonmethods.parse, you'll need jsonmethods.parse clarify ambiguity.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

dataset - MPAndroidchart returning no chart Data available -

java - No use of nillable="0" in SOAP Webservice -