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

Type inference fails for a class instantiation for a refined class #9775

Open
scabug opened this issue May 14, 2016 · 1 comment
Open

Type inference fails for a class instantiation for a refined class #9775

scabug opened this issue May 14, 2016 · 1 comment

Comments

@scabug
Copy link

scabug commented May 14, 2016

scala> class Foo[T]
defined class Foo

scala> def foo[T](): Foo[T] = new Foo
foo: [T]()Foo[T]

is working, however, when we add a refinement, it doesn't:

scala> def bar[T](): Foo[T] { type U } = new Foo { type U = Int }
<console>:11: error: type mismatch;
 found   : Foo[Nothing]{type U = Int}
 required: Foo[T]{type U}
       def bar[T](): Foo[T] { type U } = new Foo { type U = Int }

as a workaround, it is needed to specify the type explicitly:

scala> def baz[T](): Foo[T] { type U } = new Foo [T] { type U = Int }
baz: [T]()Foo[T]{type U}

(this issue was found while working on #9361)

@scabug
Copy link
Author

scabug commented May 14, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9775?orig=1
Reporter: Sarunas Valaskevicius (rakatan)
Affected Versions: 2.11.7
See #9361

@scabug scabug added the quickfix label Apr 7, 2017
@scabug scabug added this to the Backlog milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants