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

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

Open
scabug opened this Issue Oct 26, 2016 · 2 comments

Comments

Projects
None yet
1 participant
@scabug
Copy link

scabug commented Oct 26, 2016

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
                                                       ^
@scabug

This comment has been minimized.

Copy link

scabug commented Oct 26, 2016

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

@scabug

This comment has been minimized.

Copy link

scabug commented Nov 1, 2016

@Atry said (edited on Nov 1, 2016 2:22:39 PM UTC):

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] <: Converter.Aux[From, To] // This works
  }
  type Inner <: InnerLike
  def cast(inner: Inner)(f: inner.F): Inner#F = f
}

A workaround is making F an abstract type.

@scabug scabug added this to the Backlog milestone Apr 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment