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

misguided type inference with explicit pt and compound types #7976

Open
scabug opened this issue Nov 17, 2013 · 8 comments
Open

misguided type inference with explicit pt and compound types #7976

scabug opened this issue Nov 17, 2013 · 8 comments
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Nov 17, 2013

object Test extends App {
  trait Foo
  def foo[T](x: T): T with Foo = ???

  class C
  val c: C with Foo = foo(new C)
}

23:40 ~/Projects/Master/sandbox (master)$ s
Test.scala:6: error: type mismatch;
 found   : Test.C
 required: Test.Foo with Test.C
  val c: C with Foo = foo(new C)
                          ^
one error found

Omitting the explicit type for c or qualifying the call to foo with an explicit type argument makes the code compile.

@scabug
Copy link
Author

scabug commented Nov 17, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7976?orig=1
Reporter: @xeno-by
Affected Versions: 2.10.3, 2.11.0-M6

@scabug scabug added the infer label Apr 7, 2017
@SethTisue
Copy link
Member

@Blaisorblade should we close as "unlikely to progress in Scala 2"?

@SethTisue SethTisue added this to the Backlog milestone Mar 2, 2018
@Blaisorblade
Copy link

it looks "easy" (yeah lol), it's fixed in Dotty, but if this is hard or typer is unsupported then OK.

@SethTisue
Copy link
Member

let's see if anyone else comments. if not, we can close it in the next sweep.

@milessabin
Copy link

I think we can make progress on inference bugs in Scala 2. I vote against closing this like this.

@SethTisue
Copy link
Member

@milessabin sure, we can try not to be too trigger-happy with this this overall.

but, I'd prefer to focus on individual tickets, one at a time.

if you feel this bug in particular is both clear and actionable, can you comment with your summary of what you feel the underlying issue is and what you feel a solution might look like? because if we don't have that, the noise starts overwhelming the signal.

@milessabin
Copy link

I have some ongoing work on improving the solver: scala/scala#6127. This looks like the kind of thing it might pick up.

@joroKr21
Copy link
Member

joroKr21 commented Mar 18, 2018

I believe this has more to do with the order in which parents of type refinements are checked for subtyping rather than the type variable solver itself. Note that with is not true intersection in Scala 2. Similar to scala/scala#6257, moving type variables to the end might help, but this might also subtly change the meaning of with.

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

No branches or pull requests

5 participants