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

Method parameter lists: allow parameters that have dependent types to come earlier than their dependencies #5502

Closed
scabug opened this issue Feb 19, 2012 · 3 comments

Comments

@scabug
Copy link

scabug commented Feb 19, 2012

I'd love to be able to write:

def foo(tree: context.Tree)(implicit context: Context): context.Tree

More info here: http://groups.google.com/group/scala-internals/browse_thread/thread/e73e55f5b2456bd8

@scabug
Copy link
Author

scabug commented Feb 19, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5502?orig=1
Reporter: @xeno-by

@scabug
Copy link
Author

scabug commented Mar 6, 2012

@lrytz said:
maybe workaround:

foo[T <: Singleton with Context](tree: T#Tree)(implicit ctx: T): ctx.Tree

for now, close as "need a sip" at least

@scabug scabug closed this as completed Mar 6, 2012
@scabug
Copy link
Author

scabug commented Mar 6, 2012

@milessabin said:
A bit of a disappointing resolution. Nevertheless the workaround is ... workable. Version that actually compiles looks like this,

scala> trait Context { trait Tree }
defined trait Context

scala> def foo [T <: Context](tree : T#Tree)(implicit ctx : T) : ctx.Tree = null
foo: [T <: Context](tree: T#Tree)(implicit ctx: T)ctx.Tree

scala> implicit val context = new Context {}
context: Object with Context = $anon$1@757456c4

scala> val tree = new context.Tree {}
tree: Object with context.Tree = $anon$1@1f5311a4

scala> foo(tree)
res0: context.Tree = null

Nb. no Singleton.

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

1 participant