File tree Expand file tree Collapse file tree 2 files changed +43
-43
lines changed
Expand file tree Collapse file tree 2 files changed +43
-43
lines changed Original file line number Diff line number Diff line change 11Testing Symbol.isAbstract...
22=======class C=======
3- class C => true
4- constructor C => false
5- value x1 => true
6- value x2 => false
7- value x2 => false
8- method y1 => true
9- method y2 => false
10- type T1 => true
11- type T2 => false
3+ class C => abstract
4+ constructor C => concrete
5+ value xAbs => abstract
6+ value x => concrete
7+ value x => concrete
8+ method yAbs => abstract
9+ method y => concrete
10+ type TAbs => abstract
11+ type T => concrete
1212=======trait T=======
13- trait T => true
14- method $init$ => false
15- value z1 => true
16- value z2 => true
17- method w1 => true
18- method w2 => false
19- type U1 => true
20- type U2 => false
21- method T$_setter_$z2_ = => true
22- =======class D =======
23- class D => false
24- constructor D => false
25- value x1 => false
26- value x1 => false
27- method y1 => false
13+ trait T => abstract
14+ method $init$ => concrete
15+ value zAbs => abstract
16+ value z => concrete
17+ method wAbs => abstract
18+ method w => concrete
19+ type UAbs => abstract
20+ type U => concrete
21+ method T$_setter_$z_ = => abstract
22+ =======class AllConcrete =======
23+ class AllConcrete => concrete
24+ constructor AllConcrete => concrete
25+ value xAbs => concrete
26+ value xAbs => concrete
27+ method yAbs => concrete
2828=======object M=======
29- object M => false
30- constructor M => false
29+ object M => concrete
30+ constructor M => concrete
Original file line number Diff line number Diff line change 11import scala .reflect .runtime .universe ._
22
33abstract class C {
4- val x1 : Int
5- val x2 : Int = 2
6- def y1 : Int
7- def y2 : Int = 2
8- type T1 <: Int
9- type T2 = Int
4+ val xAbs : Int
5+ val x : Int = 2
6+ def yAbs : Int
7+ def y : Int = 2
8+ type TAbs <: Int
9+ type T = Int
1010}
1111trait T {
12- val z1 : Int
13- val z2 : Int = 2
14- def w1 : Int
15- def w2 : Int = 2
16- type U1 <: Int
17- type U2 = Int
12+ val zAbs : Int
13+ val z : Int = 2
14+ def wAbs : Int
15+ def w : Int = 2
16+ type UAbs <: Int
17+ type U = Int
1818}
19- class D extends C {
20- val x1 = 3
21- def y1 = 3
19+ class AllConcrete extends C {
20+ val xAbs = 3
21+ def yAbs = 3
2222}
2323object M
2424
@@ -27,12 +27,12 @@ object Test extends App {
2727 def test [T : TypeTag ] = {
2828 val sym = typeOf[T ].typeSymbol
2929 println(s " ======= $sym======= " )
30- def printAbstract (sym : Symbol ) = println(s " $sym => ${sym.isAbstract}" )
30+ def printAbstract (sym : Symbol ) = println(s " $sym => ${if ( sym.isAbstract) " abstract " else " concrete " }" )
3131 printAbstract(sym)
3232 sym.info.decls.sorted.foreach(printAbstract)
3333 }
3434 test[C ]
3535 test[T ]
36- test[D ]
36+ test[AllConcrete ]
3737 test[M .type ]
3838}
You can’t perform that action at this time.
0 commit comments