frees-io / freestyle

A cohesive & pragmatic framework of FP centric Scala libraries

Home Page:http://frees.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

inferred type arguments [Any] do not conform to method type parameter bounds

muradm opened this issue · comments

commented
  @free trait Algebra2 {
    def selectOne(): FS[Int]
    def selectArg[T <: Int](arg1: T): FS[String]
  }

compile from SBT:

[error] <macro>:19: inferred type arguments [Any] do not conform to method selectArg's type parameter bounds [T <: Int]
[error]           selectArg(fresh36.arg1)
[error]           ^
[error] <macro>:19: type mismatch;
[error]  found   : Any
[error]  required: T
[error]           selectArg(fresh36.arg1)
[error]                             ^
[error] two errors found
[error] (testing/compile:compileIncremental) Compilation failed
[error] Total time: 9 s, completed Nov 6, 2017 4:26:37 AM

Issue is how @free macro expands type arguments:

        case 1 =>
          val fresh348: SelectArgOp[_root_.scala.Any] = fa$347.asInstanceOf[SelectArgOp[_root_.scala.Any]]

for now, workaround is to expand macro and fix type arguments manually, replace [root.scala.Any] to whatever type argument should be
then if Algebra2 should be changed, I remove the expanded code, add/remove function declarations, then expand it back and fix type arguments