Skip to content

Commit 50e2539

Browse files
authored
Unchecked Variance (#108)
* try unchecked variance * cleanup
1 parent 736e1e4 commit 50e2539

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

scalarx/shared/src/main/scala/rx/Rx.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package rx
22

33
import rx.opmacros.Factories
44

5+
import scala.annotation.unchecked.uncheckedVariance
56
import scala.collection.mutable
67
import scala.util.Try
78

@@ -146,10 +147,9 @@ object Rx {
146147
* automatically when the [[owner]] recalculates, in order to avoid
147148
* memory leaks from un-used [[Rx]]s hanging around.
148149
*/
149-
class Dynamic[T](func: (Ctx.Owner, Ctx.Data) => T, owner: Option[Ctx.Owner])(implicit name: sourcecode.Name) extends Rx[T] { self =>
150-
//TODO: Be Covariant over T, (currently IsomorphicVar writes into cache, therefore Invariant)
150+
class Dynamic[+T](func: (Ctx.Owner, Ctx.Data) => T, owner: Option[Ctx.Owner])(implicit name: sourcecode.Name) extends Rx[T] { self =>
151151

152-
private[rx] var cached: Try[T] = _
152+
private[rx] var cached: Try[T @uncheckedVariance] = _
153153

154154
private[rx] var depth = 0
155155
private[rx] var dead = false

scalarx/shared/src/test/scala/rx/BasicTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ object BasicTests extends TestSuite{
145145
a() = 0
146146
intercept[Exception]{
147147
b.now
148+
()
148149
}
149150
assertMatch(b.toTry){case Failure(_) =>}
150151
}

0 commit comments

Comments
 (0)