Commit fbd6485
committed
Context: fix injection of Context parameters
The previous test was:
type.isAssignableFrom(getClass())
The idea being that if the @parameter type is FooContext, and our
context is a BarContext, then it should not be assigned. But the order
was backwards: e.g., if we had an Object @parameter and a BarContext,
the test would pass, and the BarContext would be assigned to the Object.
However, we do not want contexts to be assigned to just *any* Object,
but only to Context @parameters and subtypes thereof. So we update the
test as follows:
Context.class.isAssignableFrom(type) && type.isInstance(this)
The new test first checks whether the type is a Context or subtype, and
if so, whether the context is assignment compatible with the type of the
@parameter. The test "type.isInstance(this)" is equivalent to, but
hopefully more succinct and easier to understand than, the previous
"type.isAssignableFrom(getClass())" test.1 parent ca6905e commit fbd6485
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
287 | 287 | | |
288 | 288 | | |
289 | 289 | | |
290 | | - | |
| 290 | + | |
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
| |||
0 commit comments