Scala Programming Language
  1. Scala Programming Language
  2. SI-5502

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

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Out of Scope
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Misc Compiler
    • Labels:
      None

      Description

      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

        Activity

        Hide
        Lukas Rytz added a comment -

        maybe workaround:

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

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

        Show
        Lukas Rytz added a comment - maybe workaround: foo [T <: Singleton with Context] (tree: T#Tree)(implicit ctx: T): ctx.Tree for now, close as "need a sip" at least
        Hide
        Miles Sabin added a comment -

        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.

        Show
        Miles Sabin added a comment - 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 .

          People

          • Assignee:
            Unassigned
            Reporter:
            Eugene Burmako
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development