scala:encountered unrecoverable cycle resolving import -
why face encountered unrecoverable cycle resolving import? commented out object definition ,but still doens't work. code non-sense, want know why doesn't compile.
object abc { trait test[t]{ def prt(x:t):unit } //object test val b="hello word" } object extends app{ import abc._ def abc[o]=new test[o]{ def prt(x:int)=println("testabcd") } println(b) println("test1") } sbt run [info] set current project myfirstproject (in build file:/d:/my/test/) [info] compiling 1 scala source d:\my\test\target\scala-2.10\classes... [error] d:\my\test\hello.scala:11: encountered unrecoverable cycle resolving import. [error] note: due in part class depending on definition nested within companion. [error] if applicable, may wish try moving members object. [error] import abc._ [error] ^ [error] d:\my\test\hello.scala:15: not found: value b [error] println(b) [error] ^ [error] 2 errors found [error] (compile:compile) compilation failed [error] total time: 3 s, completed apr 16, 2014 4:45:35
it doesn't make sense , why not compile :)
you importing abc trying redefine first element package (def abc[0]?), , after trying create instance of trait new test[o] giving value 0 instead of type.
Comments
Post a Comment