File tree 1 file changed +18
-3
lines changed
src/main/kotlin/gg/scala/flavor
1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ class Flavor(
96
96
}
97
97
}
98
98
99
- fun tracked (lambda : () -> Unit ): Long
99
+ private fun tracked (lambda : () -> Unit ): Long
100
100
{
101
101
val start = System .currentTimeMillis()
102
102
lambda.invoke()
@@ -106,8 +106,15 @@ class Flavor(
106
106
107
107
private fun scanAndInject (clazz : KClass <* >, instance : Any? = null)
108
108
{
109
- val singleton = instance ? : InjectScope .SINGLETON
110
- .instanceCreator.invoke(clazz)
109
+ val singletonRaw = try
110
+ {
111
+ InjectScope .SINGLETON
112
+ .instanceCreator.invoke(clazz)
113
+ } catch (exception: Exception )
114
+ {
115
+ null
116
+ }
117
+ val singleton = instance ? : singletonRaw!!
111
118
112
119
for (field in clazz.java.fields)
113
120
{
@@ -138,6 +145,14 @@ class Flavor(
138
145
val accessability = field.isAccessible
139
146
140
147
binder?.let {
148
+ if (binder.scope == InjectScope .SINGLETON )
149
+ {
150
+ if (singletonRaw == null )
151
+ {
152
+ return @let
153
+ }
154
+ }
155
+
141
156
field.isAccessible = false
142
157
field.set(singleton, it.instance)
143
158
field.isAccessible = accessability
You can’t perform that action at this time.
0 commit comments