File tree 1 file changed +8
-4
lines changed
common/jvm/src/main/scala/org/specs2/reflect 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 1
1
package org .specs2
2
2
package reflect
3
3
4
- import scala .reflect .ClassTag
4
+ import scala .reflect .{ ClassTag , NameTransformer }
5
5
import ClassName ._
6
6
import control ._
7
7
import scala .util .control .NonFatal
@@ -70,9 +70,13 @@ trait Classes extends ClassOperations {
70
70
defaultInstances : => List [AnyRef ]): Operation [T ] = {
71
71
72
72
constructor.setAccessible(true )
73
- if (constructor.getParameterTypes.isEmpty)
74
- newInstance(klass, constructor.newInstance())
75
-
73
+ if (constructor.getParameterTypes.isEmpty) {
74
+ if (klass.getName.endsWith(" $" )) {
75
+ newInstance(klass, klass.getDeclaredField(NameTransformer .MODULE_INSTANCE_NAME ).get(null ))
76
+ } else {
77
+ newInstance(klass, constructor.newInstance())
78
+ }
79
+ }
76
80
else if (constructor.getParameterTypes.size == 1 ) {
77
81
defaultInstances.find(i => constructor.getParameterTypes.apply(0 ) isAssignableFrom i.getClass) match {
78
82
case None =>
You can’t perform that action at this time.
0 commit comments