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

Unable to refer to existing type starting with a lower-case letter #11406

oscar-broman opened this Issue Feb 18, 2019 · 1 comment


None yet
2 participants
Copy link

oscar-broman commented Feb 18, 2019

In this example there's a Var which is potentially expensive to update, so updates are chained together.

class Var[T](private var value: T) {
  def get: T = value
  def update(newValue: T) = value = newValue

type UpdatePair[T] = (Var[T], T => T)

This works:

  def doUpdates(updateChain: List[UpdatePair[_]]) = {
    updateChain.groupBy(_._1) foreach {
      case (v: Var[t], ops) =>
        var current: t = v.get
        // This is what I want to get rid of:
        type Op = t => t
        ops foreach {
          case (_, op: Op) =>
            current = op(current)
        v() = current

Removing the Op type alias does not work:

ops foreach {
  case (_, op: Function1[`t`, `t`]) =>
  current = op(current)

This also doesn't work:

ops foreach {
  case (_, op: (`t`) => `t`) =>
  current = op(current)

Furthermore, the fact that I even need the t type alias seems unnecessary!


This comment has been minimized.

Copy link

oscar-broman commented Feb 19, 2019

Appears to be fixed in dotty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.