can not bind Int

4 views
Skip to first unread message

Илья Фивейский

unread,
Feb 16, 2012, 11:48:40 AM2/16/12
to sindi...@googlegroups.com
Well, new problem.
If I try something like 
bind[Int] to 1 
then I get error
type arguments [Int] do not conform to method bind's type parameter bounds [T <: AnyRef]

Is it by design? If yes then why?

Alois Cochard

unread,
Feb 16, 2012, 2:53:15 PM2/16/12
to sindi...@googlegroups.com
Hello Ilya,

It was a design choice, but it's not anymore.

Explanation:
It's because before 0.4 caching of binding was done using object reference (which doesn't exist on unboxed primitive), now caching is done using closure, unfortunately type signature wasn't updated in 0.4.
I just fixed the type signatures, and unboxed/primitive (in fact any type) can be injected using last 0.5-SNAPSHOT (I just committed this change).

Could you please update to 0.5-SNAPSHOT?

In order to use snapshot version you should add the Sonatype OSS Snapshots repository, for SBT:
resolvers += "Sonatype OSS Releases" at "http://oss.sonatype.org/content/repositories/snapshots/"
... and then change version of sindi-core and sindi-compiler to 0.5-SNAPSHOT.

As a side note I recommend you using qualifier when working with primitive because there is very high probability that you going to bind multiple primitive of same type in a given context.

Here is an example in the functional specification:
https://github.com/aloiscochard/sindi/blob/master/sindi-core/src/test/scala/FunctionalSpec.scala#L91

Let me know if you run into any other issue!

Cheers,

--
Alois Cochard

Reply all
Reply to author
Forward
0 new messages