scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

type error without line number with Long and higher-kinded types #8463

Closed scabug closed 9 years ago

scabug commented 10 years ago

This seems related to: #8219

Reproduce code:

  case class Foo[+T[_]](activity:T[Long])
  type Cell[T] = T
  def insertCell(u:Foo[Cell]) = ???
  insertCell(Foo(5))

Expected result: Type error with line numer.

Actual result:

[error] type mismatch;
[error]  found   : Long
[error]  required: ?T
[error] Note that implicit conversions are not applicable because they are ambiguous:
[error]  both method longWrapper in class LowPriorityImplicits of type (x: Long)scala.runtime.RichLong
[error]  and method any2Ensuring in object Predef of type [A](x: A)Ensuring[A]
[error]  are possible conversion functions from Long to ?T

It seems to be related to using a type alias and a long. Those all produce type errors with line numbers:

  case class Foo2[+T[_]](color:T[String])
  def insertCell2(u:Foo2[Cell]) = ???
  insertCell2(Foo2("color"))

  def insertOption(u:Foo[Option]) = ???
  insertOption(Foo(5))

  def insertOption2(u:Foo2[Option]) = ???
  insertOption2(Foo2("color"))

Another code sample that produces the same error message without line number:

  class DefaultType[Name]
  case class Foo[+T[_]](
    activity:T[Long]
  )(t:DefaultType[T[_]])
  Foo(3)(new DefaultType[Option[_]])
scabug commented 10 years ago

Imported From: https://issues.scala-lang.org/browse/SI-8463?orig=1 Reporter: @cvogt Affected Versions: 2.10.4

scabug commented 10 years ago

@retronym said: Dup of #8219. I'll add this test case to that ticket.

I tried to fix that for 2.11.0 (in https://github.com/scala/scala/pull/3460) but ran into #8230.

scabug commented 10 years ago

@retronym said: Oh, I just realised that #8219 is closed. I'll reopen this ticket instead.

scabug commented 10 years ago

@retronym said: This fixes the unpositioned part: https://github.com/scala/scala/pull/3670

But the error message is still suboptimal.

scabug commented 10 years ago

@cvogt said: awesome :D!

scabug commented 10 years ago

@gkossakowski said: The 2.11.2 is out so I'm rescheduling the issue for 2.11.3.

scabug commented 9 years ago

@retronym said: Updating fix-by version to 2.11.5.

scabug commented 9 years ago

@retronym said: We forgot to close this ticket when the fix was merged into 2.11.1