Skip to content

Commit 6c473d3

Browse files
committed
Adding type signatures to Mock modules to workaround scala/scala3#8764
error: ``` [error] -- Error: PureModule.scala:77:86 [error] 77 | val static = ZIO.accessM[PureModule](_.get.static) [error] | ^ [error] |could not find implicit value for izumi.reflect.Tag[zio.test.mock.module.PureModule.Service]. Did you forget to put on a Tag, TagK or TagKK context bound on one of the parameters in zio.test.mock.module.PureModule.Service? e.g. def x[T: Tag, F[_]: TagK] = .... [error] |I found: [error] | [error] | { [error] | izumi.reflect.Tag.apply[zio.test.mock.module.PureModule.Service](classOf[Any] [error] | , [error] | { [error] | <empty> :izumi.reflect.macrortti.LightTypeTag [error] | } [error] | ):izumi.reflect.Tag[zio.test.mock.module.PureModule.Service] [error] | } [error] | [error] |But method tagFromTagMacro in object Tag does not match type izumi.reflect.Tag[zio.test.mock.module.PureModule.Service]. [error] | [error] |The following import might make progress towards fixing the problem: [error] | [error] | import izumi.reflect.Tag.tagFromTagMacro ```
1 parent 7262eae commit 6c473d3

File tree

3 files changed

+62
-51
lines changed

3 files changed

+62
-51
lines changed

test-tests/shared/src/test/scala/zio/test/mock/module/ImpureModule.scala

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
package zio.test.mock.module
1818

1919
import com.github.ghik.silencer.silent
20-
21-
import zio.{ Tagged, ZIO }
20+
import zio.{ Tagged, URIO, ZIO }
2221

2322
/**
2423
* Example of impure module used for testing ZIO Mock framework.
@@ -75,30 +74,35 @@ object ImpureModule {
7574
): String
7675
}
7776

78-
def zeroParams = ZIO.access[ImpureModule](_.get.zeroParams)
79-
def zeroParamsWithParens() = ZIO.access[ImpureModule](_.get.zeroParamsWithParens())
80-
def singleParam(a: Int) = ZIO.access[ImpureModule](_.get.singleParam(a))
81-
def manyParams(a: Int, b: String, c: Long) = ZIO.access[ImpureModule](_.get.manyParams(a, b, c))
82-
def manyParamLists(a: Int)(b: String)(c: Long) = ZIO.access[ImpureModule](_.get.manyParamLists(a)(b)(c))
83-
def command = ZIO.access[ImpureModule](_.get.command)
84-
def parameterizedCommand(a: Int) = ZIO.access[ImpureModule](_.get.parameterizedCommand(a))
85-
def overloaded(n: Int) = ZIO.access[ImpureModule](_.get.overloaded(n))
86-
def overloaded(n: Long) = ZIO.access[ImpureModule](_.get.overloaded(n))
87-
def polyInput[I: Tagged](v: I) = ZIO.access[ImpureModule](_.get.polyInput(v))
88-
def polyError[E <: Throwable: Tagged](v: String) = ZIO.access[ImpureModule](_.get.polyError(v))
89-
def polyOutput[A: Tagged](v: String) = ZIO.access[ImpureModule](_.get.polyOutput(v))
90-
def polyInputError[I: Tagged, E <: Throwable: Tagged](v: I) = ZIO.access[ImpureModule](_.get.polyInputError[I, E](v))
91-
def polyInputOutput[I: Tagged, A: Tagged](v: I) = ZIO.access[ImpureModule](_.get.polyInputOutput[I, A](v))
92-
def polyErrorOutput[E <: Throwable: Tagged, A: Tagged](v: String) =
77+
def zeroParams: URIO[ImpureModule, String] = ZIO.access[ImpureModule](_.get.zeroParams)
78+
def zeroParamsWithParens(): URIO[ImpureModule, String] = ZIO.access[ImpureModule](_.get.zeroParamsWithParens())
79+
def singleParam(a: Int): URIO[ImpureModule, String] = ZIO.access[ImpureModule](_.get.singleParam(a))
80+
def manyParams(a: Int, b: String, c: Long): URIO[ImpureModule, String] =
81+
ZIO.access[ImpureModule](_.get.manyParams(a, b, c))
82+
def manyParamLists(a: Int)(b: String)(c: Long): URIO[ImpureModule, String] =
83+
ZIO.access[ImpureModule](_.get.manyParamLists(a)(b)(c))
84+
def command: URIO[ImpureModule, Unit] = ZIO.access[ImpureModule](_.get.command)
85+
def parameterizedCommand(a: Int): URIO[ImpureModule, Unit] = ZIO.access[ImpureModule](_.get.parameterizedCommand(a))
86+
def overloaded(n: Int): URIO[ImpureModule, String] = ZIO.access[ImpureModule](_.get.overloaded(n))
87+
def overloaded(n: Long): URIO[ImpureModule, String] = ZIO.access[ImpureModule](_.get.overloaded(n))
88+
def polyInput[I: Tagged](v: I): URIO[ImpureModule, String] = ZIO.access[ImpureModule](_.get.polyInput(v))
89+
def polyError[E <: Throwable: Tagged](v: String): URIO[ImpureModule, String] =
90+
ZIO.access[ImpureModule](_.get.polyError(v))
91+
def polyOutput[A: Tagged](v: String): URIO[ImpureModule, A] = ZIO.access[ImpureModule](_.get.polyOutput(v))
92+
def polyInputError[I: Tagged, E <: Throwable: Tagged](v: I): URIO[ImpureModule, String] =
93+
ZIO.access[ImpureModule](_.get.polyInputError[I, E](v))
94+
def polyInputOutput[I: Tagged, A: Tagged](v: I): URIO[ImpureModule, A] =
95+
ZIO.access[ImpureModule](_.get.polyInputOutput[I, A](v))
96+
def polyErrorOutput[E <: Throwable: Tagged, A: Tagged](v: String): URIO[ImpureModule, A] =
9397
ZIO.access[ImpureModule](_.get.polyErrorOutput[E, A](v))
94-
def polyInputErrorOutput[I: Tagged, E <: Throwable: Tagged, A: Tagged](v: I) =
98+
def polyInputErrorOutput[I: Tagged, E <: Throwable: Tagged, A: Tagged](v: I): URIO[ImpureModule, A] =
9599
ZIO.access[ImpureModule](_.get.polyInputErrorOutput[I, E, A](v))
96-
def polyMixed[A: Tagged] = ZIO.access[ImpureModule](_.get.polyMixed[A])
97-
def polyBounded[A <: AnyVal: Tagged] = ZIO.access[ImpureModule](_.get.polyBounded[A])
98-
def varargs(a: Int, b: String*) = ZIO.access[ImpureModule](_.get.varargs(a, b: _*))
99-
def curriedVarargs(a: Int, b: String*)(c: Long, d: Char*) =
100+
def polyMixed[A: Tagged]: URIO[ImpureModule, (A, String)] = ZIO.access[ImpureModule](_.get.polyMixed[A])
101+
def polyBounded[A <: AnyVal: Tagged]: URIO[ImpureModule, A] = ZIO.access[ImpureModule](_.get.polyBounded[A])
102+
def varargs(a: Int, b: String*): URIO[ImpureModule, String] = ZIO.access[ImpureModule](_.get.varargs(a, b: _*))
103+
def curriedVarargs(a: Int, b: String*)(c: Long, d: Char*): URIO[ImpureModule, String] =
100104
ZIO.access[ImpureModule](_.get.curriedVarargs(a, b: _*)(c, d: _*))
101-
def byName(a: => Int) = ZIO.access[ImpureModule](_.get.byName(a))
105+
def byName(a: => Int): URIO[ImpureModule, String] = ZIO.access[ImpureModule](_.get.byName(a))
102106
def maxParams(
103107
a: Int,
104108
b: Int,
@@ -122,5 +126,6 @@ object ImpureModule {
122126
t: Int,
123127
u: Int,
124128
v: Int
125-
) = ZIO.access[ImpureModule](_.get.maxParams(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v))
129+
): URIO[ImpureModule, String] =
130+
ZIO.access[ImpureModule](_.get.maxParams(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v))
126131
}

test-tests/shared/src/test/scala/zio/test/mock/module/PureModule.scala

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -74,31 +74,36 @@ object PureModule {
7474
): IO[String, String]
7575
}
7676

77-
val static = ZIO.accessM[PureModule](_.get.static)
78-
def zeroParams = ZIO.accessM[PureModule](_.get.zeroParams)
79-
def zeroParamsWithParens() = ZIO.accessM[PureModule](_.get.zeroParamsWithParens())
80-
def singleParam(a: Int) = ZIO.accessM[PureModule](_.get.singleParam(a))
81-
def manyParams(a: Int, b: String, c: Long) = ZIO.accessM[PureModule](_.get.manyParams(a, b, c))
82-
def manyParamLists(a: Int)(b: String)(c: Long) = ZIO.accessM[PureModule](_.get.manyParamLists(a)(b)(c))
83-
def command = ZIO.accessM[PureModule](_.get.command)
84-
def parameterizedCommand(a: Int) = ZIO.accessM[PureModule](_.get.parameterizedCommand(a))
85-
def looped(a: Int) = ZIO.accessM[PureModule](_.get.looped(a))
86-
def overloaded(n: Int) = ZIO.accessM[PureModule](_.get.overloaded(n))
87-
def overloaded(n: Long) = ZIO.accessM[PureModule](_.get.overloaded(n))
88-
def polyInput[I: Tagged](v: I) = ZIO.accessM[PureModule](_.get.polyInput(v))
89-
def polyError[E: Tagged](v: String) = ZIO.accessM[PureModule](_.get.polyError(v))
90-
def polyOutput[A: Tagged](v: String) = ZIO.accessM[PureModule](_.get.polyOutput(v))
91-
def polyInputError[I: Tagged, E: Tagged](v: I) = ZIO.accessM[PureModule](_.get.polyInputError[I, E](v))
92-
def polyInputOutput[I: Tagged, A: Tagged](v: I) = ZIO.accessM[PureModule](_.get.polyInputOutput[I, A](v))
93-
def polyErrorOutput[E: Tagged, A: Tagged](v: String) = ZIO.accessM[PureModule](_.get.polyErrorOutput[E, A](v))
94-
def polyInputErrorOutput[I: Tagged, E: Tagged, A: Tagged](v: I) =
77+
val static: ZIO[PureModule, String, String] = ZIO.accessM[PureModule](_.get.static)
78+
def zeroParams: ZIO[PureModule, String, String] = ZIO.accessM[PureModule](_.get.zeroParams)
79+
def zeroParamsWithParens(): ZIO[PureModule, String, String] = ZIO.accessM[PureModule](_.get.zeroParamsWithParens())
80+
def singleParam(a: Int): ZIO[PureModule, String, String] = ZIO.accessM[PureModule](_.get.singleParam(a))
81+
def manyParams(a: Int, b: String, c: Long): ZIO[PureModule, String, String] =
82+
ZIO.accessM[PureModule](_.get.manyParams(a, b, c))
83+
def manyParamLists(a: Int)(b: String)(c: Long): ZIO[PureModule, String, String] =
84+
ZIO.accessM[PureModule](_.get.manyParamLists(a)(b)(c))
85+
def command: ZIO[PureModule, Unit, Unit] = ZIO.accessM[PureModule](_.get.command)
86+
def parameterizedCommand(a: Int): ZIO[PureModule, Unit, Unit] = ZIO.accessM[PureModule](_.get.parameterizedCommand(a))
87+
def looped(a: Int): ZIO[PureModule, Nothing, Nothing] = ZIO.accessM[PureModule](_.get.looped(a))
88+
def overloaded(n: Int): ZIO[PureModule, String, String] = ZIO.accessM[PureModule](_.get.overloaded(n))
89+
def overloaded(n: Long): ZIO[PureModule, String, String] = ZIO.accessM[PureModule](_.get.overloaded(n))
90+
def polyInput[I: Tagged](v: I): ZIO[PureModule, String, String] = ZIO.accessM[PureModule](_.get.polyInput[I](v))
91+
def polyError[E: Tagged](v: String): ZIO[PureModule, E, String] = ZIO.accessM[PureModule](_.get.polyError[E](v))
92+
def polyOutput[A: Tagged](v: String): ZIO[PureModule, String, A] = ZIO.accessM[PureModule](_.get.polyOutput[A](v))
93+
def polyInputError[I: Tagged, E: Tagged](v: I): ZIO[PureModule, E, String] =
94+
ZIO.accessM[PureModule](_.get.polyInputError[I, E](v))
95+
def polyInputOutput[I: Tagged, A: Tagged](v: I): ZIO[PureModule, String, A] =
96+
ZIO.accessM[PureModule](_.get.polyInputOutput[I, A](v))
97+
def polyErrorOutput[E: Tagged, A: Tagged](v: String): ZIO[PureModule, E, A] =
98+
ZIO.accessM[PureModule](_.get.polyErrorOutput[E, A](v))
99+
def polyInputErrorOutput[I: Tagged, E: Tagged, A: Tagged](v: I): ZIO[PureModule, E, A] =
95100
ZIO.accessM[PureModule](_.get.polyInputErrorOutput[I, E, A](v))
96-
def polyMixed[A: Tagged] = ZIO.accessM[PureModule](_.get.polyMixed[A])
97-
def polyBounded[A <: AnyVal: Tagged] = ZIO.accessM[PureModule](_.get.polyBounded[A])
98-
def varargs(a: Int, b: String*) = ZIO.accessM[PureModule](_.get.varargs(a, b: _*))
99-
def curriedVarargs(a: Int, b: String*)(c: Long, d: Char*) =
101+
def polyMixed[A: Tagged]: ZIO[PureModule, String, (A, String)] = ZIO.accessM[PureModule](_.get.polyMixed[A])
102+
def polyBounded[A <: AnyVal: Tagged]: ZIO[PureModule, String, A] = ZIO.accessM[PureModule](_.get.polyBounded[A])
103+
def varargs(a: Int, b: String*): ZIO[PureModule, String, String] = ZIO.accessM[PureModule](_.get.varargs(a, b: _*))
104+
def curriedVarargs(a: Int, b: String*)(c: Long, d: Char*): ZIO[PureModule, String, String] =
100105
ZIO.accessM[PureModule](_.get.curriedVarargs(a, b: _*)(c, d: _*))
101-
def byName(a: => Int) = ZIO.accessM[PureModule](_.get.byName(a))
106+
def byName(a: => Int): ZIO[PureModule, String, String] = ZIO.accessM[PureModule](_.get.byName(a))
102107
def maxParams(
103108
a: Int,
104109
b: Int,
@@ -122,5 +127,6 @@ object PureModule {
122127
t: Int,
123128
u: Int,
124129
v: Int
125-
) = ZIO.accessM[PureModule](_.get.maxParams(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v))
130+
): ZIO[PureModule, String, String] =
131+
ZIO.accessM[PureModule](_.get.maxParams(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v))
126132
}

test-tests/shared/src/test/scala/zio/test/mock/module/StreamModule.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package zio.test.mock.module
1818

19-
import zio.ZIO
19+
import zio.{ URIO, ZIO }
2020
import zio.stream.{ Sink, Stream }
2121

2222
/**
@@ -29,6 +29,6 @@ object StreamModule {
2929
def stream(a: Int): Stream[String, Int]
3030
}
3131

32-
def sink(a: Int) = ZIO.access[StreamModule](_.get.sink(a))
33-
def stream(a: Int) = ZIO.access[StreamModule](_.get.stream(a))
32+
def sink(a: Int): URIO[StreamModule, Sink[String, Nothing, Int, List[Int]]] = ZIO.access[StreamModule](_.get.sink(a))
33+
def stream(a: Int): URIO[StreamModule, Stream[String, Int]] = ZIO.access[StreamModule](_.get.stream(a))
3434
}

0 commit comments

Comments
 (0)