Uploaded image for project: 'Scala Programming Language'
  1. Scala Programming Language
  2. SI-10008

Unable to convert inner.F to Inner#F if Inner is an abstract type

    Details

      Description

      Welcome to Scala 2.11.8 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_102).
      Type in expressions for evaluation. Or try :help.
       
      scala> :paste
      // Entering paste mode (ctrl-D to finish)
       
      trait Converter {
        type To
        type From
      }
      object Converter {
        type Aux[-From0, +To0] = Converter {
          type To <: To0
          type From >: From0
        }
      }
      trait Outer {
        trait InnerLike { this: Inner =>
          type To
          type From
          type F = Converter.Aux[From, To]
        }
        type Inner <: InnerLike
        def cast(inner: Inner)(f: inner.F): Inner#F = f
      }
       
      // Exiting paste mode, now interpreting.
       
      <console>:28: error: type mismatch;
       found   : inner.F
          (which expands to)  Converter{type To <: inner.To; type From >: inner.From}
       required: Converter{type To <: _2.To; type From >: _2.From} forSome { val _2: Outer.this.Inner }
               def cast(inner: Inner)(f: inner.F): Inner#F = f
                                                             ^
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              atry 杨博
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: