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

regression in implicit search after changes to stabilty/volatility in subtyping #8301

Closed
scabug opened this issue Feb 17, 2014 · 7 comments
Closed
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Feb 17, 2014

trait Universe {
  type Symbol >: Null <: AnyRef with SymbolApi
  trait SymbolApi

  type TypeSymbol >: Null <: TypeSymbolApi with Symbol
  trait TypeSymbolApi

  implicit class CompatibleSymbol(sym: Symbol) {
    def asFreeType: TypeSymbol = ???
  }
}

object Test extends App {
  val u: Universe = ???
  import u._

  val sym: Symbol = ???
  sym.asFreeType
}
@scabug
Copy link
Author

scabug commented Feb 17, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8301?orig=1
Reporter: @retronym
Affected Versions: 2.11.0-M3
See #8304

@scabug
Copy link
Author

scabug commented Feb 17, 2014

@retronym said:
scala/scala#3545

@scabug
Copy link
Author

scabug commented Feb 17, 2014

@retronym said (edited on Feb 17, 2014 9:27:42 PM UTC):
Copying Eugene's unanswered questions from the duplicate ticket:

This is a change in behavior in comparison with 2.10.x (regression?).
FreeTypeSymbol is now designated as volatile, which prevents: 1) pattern matching against vals of such type, 2) extension methods that return such type. If I change `FreeTypeSymbolApi with Symbol` to `Symbol with FreeTypeSymbolApi`, it makes everything work fine, but then erasures of Symbol and FreeTypeSymbol start clashing.
I have several questions actually:
1) Is the change in volatility correct? FreeTypeSymbol transitively extends AnyRef, so why is it volatile?
2) Why do we disregard extension methods that return volatile types?

@scabug
Copy link
Author

scabug commented Feb 17, 2014

@xeno-by said:
So as you can see, question #1 shows my lack of knowledge about volatility. I misread the spec and ended up being confused. Nevertheless, it would be nice if you could elaborate on what volatility is, because comments on isVolatile also don't help much.

  1. I actually have another question, which is why values of volatile types can't be matched as-is:
// cf. pos/t8300-patmat.scala
trait Universe {
  type Name >: Null <: AnyRef with NameApi
  trait NameApi

  type TermName >: Null <: TermNameApi with Name
  trait TermNameApi extends NameApi
}

object Test extends App {
  val u: Universe = ???
  import u._

  locally {
    val ScalaName: TermName = ???
    ??? match {
      case ScalaName => ???
    }
  }
}
t8300-patmat.scala:17: error: stable identifier required, but ScalaName found.
 Note that value ScalaName is not stable because its type, Test.u.TermName, is volatile.
      case ScalaName => ???
           ^
one error found

@scabug
Copy link
Author

scabug commented Feb 17, 2014

@retronym said:
I'll take a better look tomorrow but in the meantime check out scala/scala#2374

@scabug
Copy link
Author

scabug commented Feb 17, 2014

@adriaanm said:
The only reason I can think of is that they can be bound to a variable (x@ScalaName), so that x would then have to be tracked as unstable. We already do that through its type. I think it's more likely to be fall out of conflating volatility and stability. For stable identifier patterns, I don't see a compelling reason to exclude volatile types.

@scabug
Copy link
Author

scabug commented Feb 17, 2014

@xeno-by said:
Adriaan, I've just submitted #8304 with critical priority since it's a regression since 2.10.x. Don't know whether I should've marked it as a blocker.

@scabug scabug closed this as completed Feb 18, 2014
@scabug scabug added this to the 2.11.0-RC1 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants