-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Inference of higher-kinded type parameters is not precise enough #732
Comments
smarter
added a commit
to smarter/dotty
that referenced
this issue
Jul 22, 2015
This does not work for i553-shuffle.scala because of scala#732
Somehow, the inference seems to only stop working if a higher-kinded type parameter is used in the second parameter list of a method (even if it's used in the first parameter list), unless it is also used in the return type of the method: class Baz[A]
object Test {
def one[CC[X]](ev: CC[Int]): Nothing = ???
def two1[CC[X]](ev: CC[Int])(): Nothing = ???
def two2a[CC[X]]()(ev: CC[Int]): Nothing = ???
def two2b[CC[X]]()(ev: CC[Int]): CC[Int] = ???
def two3a[CC[X]](ev: CC[Int])(ev2: CC[Int]): Nothing = ???
def two3b[CC[X]](ev: CC[Int])(ev2: CC[Int]): CC[Int] = ???
def test = {
val baz: Baz[Int] = new Baz[Int]
one(baz) // Correct: Infer "[hk$0] => Baz[hk$0]"
two1(baz)() // Correct: Infer "[hk$0] => Baz[hk$0]"
two2a()(baz) // Wrong: Infer "[hk$0] => "
two2b()(baz) // Correct: Infer "[hk$0] => Baz[hk$0]"
two3a(baz)(baz) // Wrong: Infer "[hk$0] => "
two3b(baz)(baz) // Correct: Infer "[hk$0] => Baz[hk$0]"
}
} package <empty> {
class Baz[A]() extends Object() {
type Baz$$A
private[this] type A = Baz$$A
}
final lazy module val Test: Test$ = new Test$()
final module class Test$() extends Object() { this: Test.type =>
def one[CC <: [hk$0] => ](ev: CC[Int]): Nothing = ???
def two1[CC <: [hk$0] => ](ev: CC[Int])(): Nothing = ???
def two2a[CC <: [hk$0] => ]()(ev: CC[Int]): Nothing = ???
def two2b[CC <: [hk$0] => ]()(ev: CC[Int]): CC[Int] = ???
def two3a[CC <: [hk$0] => ](ev: CC[Int])(ev2: CC[Int]): Nothing = ???
def two3b[CC <: [hk$0] => ](ev: CC[Int])(ev2: CC[Int]): CC[Int] = ???
def test: Baz[Int] = {
val baz: Baz[Int] = new Baz[Int][Int]()
Test.one[([hk$0] => Baz[hk$0])[hk$0 = Int]](baz)
Test.two1[([hk$0] => Baz[hk$0])[hk$0 = Int]](baz)()
Test.two2a[([hk$0] => )]()(baz)
Test.two2b[([hk$0] => Baz[hk$0])[hk$0 = Int]]()(baz)
Test.two3a[([hk$0] => )](baz)(baz)
Test.two3b[([hk$0] => Baz[hk$0])[hk$0 = Int]](baz)(baz)
}
}
} |
This issue is not specific to higher-kinded types, I've opened #738 to track it and I'm closing this issue for now. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In the following code:
The third implicit in
main
is not correctly inferred, because the type parameter is not precise enough:scalac
handles this correctly:Fixing this is necessary to replace #716 by a proper fix, see the work-in-progress at https://github.com/smarter/dotty/commits/fix/missing-implicits .
@odersky : Note that this also happens after applying #731 .
The text was updated successfully, but these errors were encountered: