Skip to content

Type Constructor Inference fails to consider implemented traits #2693

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

Closed
scabug opened this issue Nov 24, 2009 · 3 comments
Closed

Type Constructor Inference fails to consider implemented traits #2693

scabug opened this issue Nov 24, 2009 · 3 comments
Assignees

Comments

@scabug
Copy link

scabug commented Nov 24, 2009

trait T[A]
def usetHk[T[_], A](ta: T[A]) = 0
usetHk(new T[Int]{}: T[Int])
usetHk(new T[Int]{}) // fails with: found: java.lang.Object with T[Int], required: ?T[ ?A ]

Scala Version: 2.8.0.r19664-b20091116020221

@scabug
Copy link
Author

scabug commented Nov 24, 2009

Imported From: https://issues.scala-lang.org/browse/SI-2693?orig=1
Reporter: @retronym

@scabug
Copy link
Author

scabug commented Oct 27, 2010

@paulp said:
(In r23383) A double goodness whammy involving type inference at the borders.

  1. Implicit search preserves singleton type fidelity.
  2. Unification of parent bounds is (closer to) correct.

Result of 1: "implicit def f(x: Foo.type)" will convert object Foo.
Result of 2: "new Trait[Int] { }" may enjoy its type constructor being
inferred, no longer foiled by the anonymous class.

Also included are some clarity-enhnancing renamings and refactorings.
Performance note: I heavily benchmarked the change to isSubArgs and it
is reproducibly faster than the previous implementation. Numbers
and methodology available upon request.

Closes #2693, #3964. Review by moors, who wrote most of this patch
but might like to review the comments.

@scabug
Copy link
Author

scabug commented Oct 28, 2010

@retronym said:
Thanks guys, this should reduce the boilerplate needed to declare type class instances.

While you're in a type unifying frenzy, I'll submit my Christmas wishlist: http://gist.github.com/650709 (Basically #2712, with the concession that the inference could be given a helping hand by the type of the implicit args)

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

No branches or pull requests

2 participants