Variable x is initialized as part of the trait where it belongs Testa. At that moment, your Testc isn't in scope yet, therefore the method fun defined there cannot be used. But the variable is already bound to that method. Therefore, nothing will be printed when Testc is invoked.
If you change the definition of x from val x = fun to lazy val x = fun, by the way, and then invoke this variable after your object m is created, you'll see "test" printed (once). The type of x, though, will still be "Unit", as it was defined in the base trait.
trait Testa {
val loginurl:String
def fun
lazy val x=fun
}
class Testc extends Testa {
val loginurl="test"
def fun={
println(loginurl)
1
}
}
scala> val testc = new Testc
testc: Testc = Testc@4106db23
scala> val testcx = testc.x
test
testcx: Unit = ()
scala> val testcx2 = testc.x
testcx2: Unit = ()