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

Does Existential Quantification over Values work as described in reference? #4914

Closed
scabug opened this issue Aug 15, 2011 · 5 comments
Closed
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Aug 15, 2011

If I understand §3.2.10 of the language reference correctly then

Map[x.type#S, x.type#S] forSome { val x: T }

should be equivalent to

Map[t#S, t#S] forSome { type t <: T with Singleton }

but they do seem to behave different in practice. When compiling

trait Type {
  type S
}

class ConcreteType extends Type {
  type S = Double
}

trait Base {
  type T <: Type
  val m: Map[t#S, t#S] forSome { type t <: T with Singleton }
  val n: Map[x.type#S, x.type#S] forSome { val x: T }
}

abstract class Derived extends Base {
  override type T = ConcreteType
  override val m = Map[Double, Double]()
  /** This does not work. §3.2.10 indicates that types n is shorthand for type of m. */
  override val n = Map[Double, Double]()
}

There is an error for overriding n, but no error for overriding m. Am I misunderstanding the language reference?

@scabug
Copy link
Author

scabug commented Aug 15, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4914?orig=1
Reporter: Mathias Körner (mkoerner)
Affected Versions: 2.9.0-1, 2.9.1

@scabug
Copy link
Author

scabug commented Aug 15, 2011

@paulp said:
This compiles, which I imagine is sufficient evidence that you're looking at a bug.

trait Type {
  type S
}

trait Base {
  type T <: Type
  type M = Map[t#S, t#S] forSome { type t <: T with Singleton }
  type N = Map[x.type#S, x.type#S] forSome { val x: T }
}

abstract class Derived extends Base {
  type T = Type { type S = Double }
  override type M = Map[Double, Double]
  override type N = Map[Double, Double]
}

abstract class Derived2 extends Derived {
  val m: M = Map()
  val n: N = Map()
}

@scabug
Copy link
Author

scabug commented Feb 12, 2012

@paulp said:
This is a duplicate of #482, but I'm closing that one in favor of this one.

@scabug
Copy link
Author

scabug commented Oct 15, 2013

@gkossakowski said:
Unassigning and rescheduling to M7 as previous deadline was missed.

@scabug
Copy link
Author

scabug commented Jul 22, 2016

@milessabin said:
This is fixed in 2.11.8 and 2.12.x.

PR adding test here: scala/scala#5300

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants