2014-04-16 54 views
1

爲什麼我面對遇到的不可循環解決進口?我評論了對象定義,但仍然沒有工作。代碼是無意義的,但只是想知道它爲什麼不編譯。階:遇到的不可循環解決進口

object abc 
{ 
trait test[T]{ 
    def prt(x:T):Unit 
} 
//object test 
    val b="hello word" 
} 

object my 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 to myfirstproject (in build file:/D:/my/test/) 
[info] Compiling 1 Scala source to D:\my\test\target\scala-2.10\classes... 
[error] D:\my\test\Hello.scala:11: encountered unrecoverable cycle resolving import. 
[error] Note: this is often due in part to a class depending on a definition nested within its companion. 
[error] If applicable, you may wish to try moving some members into another object. 
[error] import abc._ 
[error]   ^
[error] D:\my\test\Hello.scala:15: not found: value b 
[error] println(b) 
[error]   ^
[error] two errors found 
[error] (compile:compile) Compilation failed 
[error] Total time: 3 s, completed Apr 16, 2014 4:45:35 AM 
+0

除了導入,'ABC DEF [O] =新的測試[O]'是未由階句法支持一個無義表達 –

回答

2

這是沒有意義的,這就是爲什麼它不編譯:)

要導入abc然後試圖從包重新定義一個元素(def abc[0]?),在那之後你想創建特性new test[O]的實例,其值爲0而不是類型。

相關問題