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

Incomplete error message for higher-kinded bounds violations #4164

Closed
smarter opened this issue Mar 23, 2018 · 2 comments
Closed

Incomplete error message for higher-kinded bounds violations #4164

smarter opened this issue Mar 23, 2018 · 2 comments
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug

Comments

@smarter
Copy link
Member

smarter commented Mar 23, 2018

class Foo[X]
object Test {
  def bla[M <: [X] => Foo[X]] = ???
  bla[Foo] // OK
  bla[[X <: Int] => Foo[X]] // error
}
-- [E057] Type Mismatch Error: try/i4160.scala:5:17 ----------------------------
5 |  bla[[X <: Int] => Foo[X]] // error
  |                 ^
  |                 Type argument Foo does not conform to upper bound Foo 

The type argument is incorrectly reduced to Foo leading to a meaningless error message.

@smarter smarter added itype:bug area:reporting Error reporting including formatting, implicit suggestions, etc labels Mar 23, 2018
@Blaisorblade
Copy link
Contributor

A few more testcases (assuming #4108 goes in), not sure if they need to be tested separately. This is right:

scala> trait Foo[F <: AnyKind]
scala> type Bar1 = [F <: AnyKind] => Foo[F]
// defined alias type Bar1 = Foo

but this is not:

scala> type Bar2 = [F] => Foo[F]
// defined alias type Bar2 = Foo
scala> type Bar3 = [F <: Any] => Foo[F]
// defined alias type Bar3 = Foo

since Bar2/Bar3 and Foo have different argument bounds. Luckily this only affects the output:

scala> val v: Bar1[Bar1] = null
val v: Foo[Bar1] = null
scala> val v: Bar2[Bar2] = null
1 |val v: Bar2[Bar2] = null
  |            ^^^^
  |            Type argument Bar2 has not the same kind as its bound
scala> val v: Bar3[Bar3] = null
1 |val v: Bar3[Bar3] = null
  |            ^^^^
  |            Type argument Bar3 has not the same kind as its bound

@bishabosha
Copy link
Member

I believe this is fixed:

scala> class Foo[X]                                                                                                     
     | object Test {
     |   def bla[M <: [X] =>> Foo[X]] = ???
     |   bla[Foo] // OK
     |   bla[[X <: Int] =>> Foo[X]] // error
     | }
5 |  bla[[X <: Int] =>> Foo[X]] // error
  |                 ^
  |   Type argument [X <: Int] =>> Foo[X] does not conform to upper bound Foo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc itype:bug
Projects
None yet
Development

No branches or pull requests

3 participants