File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change 1- trait Foo {
2- // println("hello")
1+ trait NoInit {
2+ def meth (x : Int ): Int
3+ }
4+
5+ trait WithInit {
6+ val i = 1
37 def meth (x : Int ): Int
48}
59
610trait Bar (x : Int )
711
8- class C extends Foo () with Bar (1 ) {
12+ class NoInitClass extends NoInit () with Bar (1 ) {
13+ def meth (x : Int ) = x
14+ }
15+
16+ class WithInitClass extends WithInit () with Bar (1 ) {
917 def meth (x : Int ) = x
1018}
1119
12- object Test extends C with App
20+ object Test {
21+ def hasInit (cls : Class [_]) = cls.getMethods.map(_.toString).exists(_.contains(" $init$" ))
22+ def main (args : Array [String ]): Unit = {
23+ val noInit = new NoInitClass {}
24+ val withInit = new WithInitClass {}
25+
26+ assert(! hasInit(noInit.getClass))
27+ assert(hasInit(withInit.getClass))
28+ }
29+ }
You can’t perform that action at this time.
0 commit comments