Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failure to infer hk type parameter #10653

Open
martijnhoekstra opened this issue Dec 11, 2017 · 2 comments
Open

failure to infer hk type parameter #10653

martijnhoekstra opened this issue Dec 11, 2017 · 2 comments

Comments

@martijnhoekstra
Copy link

object Foo {
  case class Baz[F[_]](f: F[Int])
  type ListOption[A] = List[Option[A]]

  val l: List[Option[Int]] = List(Option(7))
  val l2: ListOption[Int] = l
  val l3: ({type l[a] = List[Option[a]]})#l[Int] = l
  val baz = Baz(l) //infers Baz[Any]
  val bup = Baz(l2) //correctly infers Baz[ListOption] 
  val bur = Baz(l3) //infers Baz[Any] again
}

val l: List[Option[Int]] = Foo.baz should compile but gives

type mismatch;
 found   : Any
 required: List[Option[Int]]

possibly related to #5075 ?

reproduced in 2.12.3

in dotty the error is

 found:    scala.collection.TraversableOnce.FlattenOps[Int](Foo.baz.f)
   |   required: scala.collection.immutable.List[Option[Int]]

repro: https://scastie.scala-lang.org/martijnhoekstra/k9RFNIjCQk2pcI5vvanzow

@martijnhoekstra
Copy link
Author

martijnhoekstra commented Dec 11, 2017

maybe fixed by scala/scala#6069

I can't verify due to my personal incompetence with the sbt runner (

> scalac -Xsource:2.13 ./sandbox/test.scala
[error] Expected non-whitespace character

)

@SethTisue SethTisue added this to the Backlog milestone Apr 10, 2023
@SethTisue
Copy link
Member

it compiles in 2.12.3 (and 2.12.17)

but then 2.13.10 gives:

On line 8: error: inferred kinds of the type arguments (AnyVal) do not conform to the expected kinds of the type parameters (type F).
       AnyVal's type parameters do not match type F's expected parameters:
       class AnyVal has no type parameters, but type F has one
         val baz = Baz(l) //infers Baz[Any]
                       ^
On line 8: error: type mismatch;
        found   : List[Option[Int]]
        required: F[Int]
         val bur = Baz(l3) //infers Baz[Any] again
                   ^

and Scala 3.3.0-RC3 agrees:

8 |  val baz = Baz(l) //infers Baz[Any]
  |                ^
  |Found:    (Foo.l : List[Option[Int]])
  |Required: F[Int]
  |
  |where:    F is a type variable with constraint <: [_] =>> Any

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants