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

extension methods for cake members are very brittle #8300

Closed
scabug opened this issue Feb 17, 2014 · 3 comments
Closed

extension methods for cake members are very brittle #8300

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

Comments

@scabug
Copy link

scabug commented Feb 17, 2014

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

  type FreeTypeSymbol >: Null <: FreeTypeSymbolApi with Symbol
  trait FreeTypeSymbolApi extends SymbolApi

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

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

  val sym: Symbol = ???
  sym.asFreeType
}
21:43 ~/Projects/palladium0/sandbox (topic/palladium0)$ s
Test.scala:18: error: value asFreeType is not a member of Test.u.Symbol
  sym.asFreeType
      ^
one error found
@scabug
Copy link
Author

scabug commented Feb 17, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8300?orig=1
Reporter: @xeno-by
Affected Versions: 2.11.0-M8
See #8301

@scabug
Copy link
Author

scabug commented Feb 17, 2014

@xeno-by said (edited on Feb 17, 2014 8:48:09 PM UTC):
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

@retronym said:
I opened #8301 on this a few moments before I saw this one. Marking this as a duplicate.

@scabug scabug closed this as completed Feb 17, 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