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

explicit declaration of return type with compound type parameter fails #7647

Open
scabug opened this issue Jul 10, 2013 · 1 comment
Open
Labels
fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) typer
Milestone

Comments

@scabug
Copy link

scabug commented Jul 10, 2013

From StackOverflow: http://stackoverflow.com/questions/17559687/compile-time-constraints-on-the-order-of-function-composition-in-scala

Compilation fails for a method that explicitly declares a return a type with a compound type parameter, but succeeds and infers the same type when the return type is not explicitly declared:

scala> trait Foo[A] { def bar[B](b: B): Foo[A with B] }
defined trait Foo
 
scala> def baz[A](foo: Foo[A]) = foo bar 1
baz: [A](foo: Foo[A])Foo[A with Int]
 
scala> def baz[A](foo: Foo[A]): Foo[A with Int] = foo bar 1
<console>:8: error: type mismatch;
 found   : Int(1)
 required: Nothing
       def baz[A](foo: Foo[A]): Foo[A with Int] = foo bar 1
                                                          ^
@scabug
Copy link
Author

scabug commented Jul 10, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7647?orig=1
Reporter: Steven Bethard (bethard)
Affected Versions: 2.10.2

@scabug scabug added the typer label Apr 7, 2017
@scabug scabug added this to the Backlog milestone Apr 7, 2017
@adriaanm adriaanm removed their assignment Sep 28, 2018
@SethTisue SethTisue added the fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) label Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) typer
Projects
None yet
Development

No branches or pull requests

3 participants