Created
May 17, 2011 03:11
-
-
Save yuroyoro/975846 to your computer and use it in GitHub Desktop.
DelayedInitを継承したクラスでは初期化ブロック内からコンストラクタ引数を参照できないんだけど、これはどうにかして欲しい。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scala> class Foo(i:Int) extends DelayedInit{ | |
| | println("aaaaaa:" + i ) | |
| | val d = new java.util.Date | |
| | println( d ) | |
| | | |
| | def delayedInit(x: => Unit){ | |
| | println("delayed init") | |
| | println("-" * 80) | |
| | x | |
| | println("-" * 80) | |
| | } | |
| | } | |
| defined class Foo | |
| scala> val foo = new Foo(99) | |
| delayed init | |
| -------------------------------------------------------------------------------- | |
| java.lang.NoSuchFieldError: i | |
| at Foo.i(<console>:7) | |
| at Foo$delayedInit$body.apply(<console>:8) | |
| at scala.Function0$class.apply$mcV$sp(Function0.scala:34) | |
| at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12) | |
| at Foo.delayedInit(<console>:15) | |
| at Foo.<init>(<console>:7) | |
| at .<init>(<console>:8) | |
| at .<clinit>(<console>) | |
| at .<init>(<console>:11) | |
| at .<clinit>(<console>) | |
| at $export(<console>) | |
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) | |
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) | |
| at java.lang.reflect.Method.invoke(Method.java:597) | |
| at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:592) | |
| at scala.tools.nsc.interpreter.IMain$Request$$anonfun$10.apply(IMain.scala:828) | |
| at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV$sp(Line.scala:43) | |
| at scala.tools.nsc.io.package$$anon$2.run(package.scala:31) | |
| at java.lang.Thread.run(Thread.java:680) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment