Skip to content

Commit c817b09

Browse files
committed
Fix #65
1 parent 9f17efc commit c817b09

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Diff for: src/main/scala/net/codingwell/scalaguice/TypeConversions.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ private [scalaguice] object TypeConversions {
6262
case ExistentialType(_, underlying) => scalaTypeToJavaType(underlying, mirror)
6363
case ArrayType(argType) => arrayOf(scalaTypeToJavaType(argType, mirror, allowPrimative=true))
6464
case ClassType(symbol, args) => {
65-
val rawType = mirror.runtimeClass(symbol)
65+
//You would think `symbol` would be sufficient but in some cases (such as (=> Unit)) instead of
66+
//resolving to `Function0[Unit]` You get Scala<byname> which isn't real and can't be located
67+
val rawType = mirror.runtimeClass(scalaType.erasure.dealias.typeSymbol.asInstanceOf[ClassSymbol])
6668
val ownerType = findOwnerOf(symbol, mirror)
6769
if(symbol == symbolOf[Unit]) {
6870
classOf[scala.runtime.BoxedUnit]

Diff for: src/test/scala/net/codingwell/scalaguice/ScalaModuleSpec.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class ScalaModuleSpec extends WordSpec with Matchers {
144144
}
145145

146146
//This test needs work to resolve #65
147-
"allow binding by name to Unit" ignore {
147+
"allow binding by name to Unit" in {
148148
try {
149149
val foo:(=> Unit) => String = (a) => "dog"
150150
val module = new AbstractModule with ScalaModule {

0 commit comments

Comments
 (0)