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

SAM type does not support dependent type #9897

Open
scabug opened this issue Aug 20, 2016 · 4 comments
Open

SAM type does not support dependent type #9897

scabug opened this issue Aug 20, 2016 · 4 comments
Labels
dependent types enhancement fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) infer typelevel typer
Milestone

Comments

@scabug
Copy link

scabug commented Aug 20, 2016

$ scala -Xexperimental
Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_77).
Type in expressions for evaluation. Or try :help.

scala>     trait Container {
     |       type Child
     | 
     |       def child: Child
     |     }
defined trait Container

scala>     trait Sam {
     |       def apply(container: Container): container.Child
     |     }
defined trait Sam

scala>     val sam: Sam = { container: Container => container.child }
<console>:13: error: type mismatch;
 found   : container.Child
 required: container.Child
           val sam: Sam = { container: Container => container.child }
                                                 ^
@scabug
Copy link
Author

scabug commented Aug 20, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9897?orig=1
Reporter: @Atry
Affected Versions: 2.11.8, 2.12.0-RC1

@scabug
Copy link
Author

scabug commented Sep 29, 2016

@SethTisue said:
Is it reproducible in 2.12 as well? (The -Xexperimental stuff in 2.11 is now unmaintained.)

@scabug
Copy link
Author

scabug commented Sep 30, 2016

@Atry said:

Welcome to Scala 2.12.0-RC1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_77).
Type in expressions for evaluation. Or try :help.

scala> trait Container {
     |   type Child
     |   def child: Child
     | }
defined trait Container

scala> trait Sam {
     |   def apply(container: Container): container.Child
     | }
defined trait Sam

scala> val sam: Sam = { container: Container => container.child }
<console>:13: error: type mismatch;
 found   : Container => Container#Child
 required: Sam
       val sam: Sam = { container: Container => container.child }
                                             ^

scala> val r: Runnable = { () => }
r: Runnable = $$Lambda$1193/369956118@2c418b3a

TiarkRompf referenced this issue in b-studios/scala-effekt May 25, 2017
@SethTisue SethTisue added this to the Backlog milestone Nov 2, 2023
@SethTisue SethTisue added the fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) label Nov 2, 2023
@SethTisue
Copy link
Member

SethTisue commented Nov 2, 2023

in more conveniently pastable form,

trait Container {
  type Child
  def child: Child
}
trait Sam {
  def apply(container: Container): container.Child
}
val sam: Sam = { (container: Container) => container.child }

error on 2.12.18:

error: type mismatch;
 found   : Container => Container#Child
 required: Sam

error on 2.13.12:

error: type mismatch;
                found   : container.Child
                required: container.Child

it compiles on Scala 3.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependent types enhancement fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) infer typelevel typer
Projects
None yet
Development

No branches or pull requests

3 participants