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

Value class calls private method: crash #6215

Closed
scabug opened this issue Aug 10, 2012 · 6 comments
Closed

Value class calls private method: crash #6215

scabug opened this issue Aug 10, 2012 · 6 comments
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Aug 10, 2012

class Foo(val v: String) extends AnyVal { private def len = v.length ; def f = len }
no-symbol does not have an owner
	at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:46)
	at scala.tools.nsc.Global.abort(Global.scala:249)
	at scala.reflect.internal.Symbols$NoSymbol.owner(Symbols.scala:3026)
	at scala.reflect.internal.TreeGen.mkAttributedRef(TreeGen.scala:130)
	at scala.tools.nsc.transform.Erasure$ErasureTransformer$$anon$1.preErase(Erasure.scala:1072)
	at scala.tools.nsc.transform.Erasure$ErasureTransformer$$anon$1.transform(Erasure.scala:1136)
	at scala.tools.nsc.transform.Erasure$ErasureTransformer$$anon$1.transform(Erasure.scala:930)
	at scala.reflect.internal.Trees$$anonfun$itransform$5.apply(Trees.scala:1181)
	at scala.reflect.internal.Trees$$anonfun$itransform$5.apply(Trees.scala:1179)
	at scala.reflect.api.Trees$Transformer.atOwner(Trees.scala:684)
	at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:38)
	at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:31)
	at scala.tools.nsc.transform.TypingTransformers$TypingTransformer.atOwner(TypingTransformers.scala:19)
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 10, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6215?orig=1
Reporter: @paulp
Affected Versions: 2.10.0
Other Milestones: 2.10.0

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Sep 28, 2012

@som-snytt said (edited on Sep 28, 2012 5:30:10 PM UTC):
Me, too. I'm kind of surprised I was surprised by this bug, i.e., in the balance of fixability and people using a new feature and doing the obvious thing and then it doesn't work. By obvious I mean, I don't want to expose my helper method to impliciting. I also went back to the SIP to see if this is prohibited for some clever reason. (I also built today's scalac, because I see there is lots of recent work to nail down the release. By way of show of support.)

I realize that in Scala there is no expectation of privacy.

object `package` {
  /* crashes
  implicit class MaybeInt(val s: String) extends AnyVal {
    def toInt_? : Option[Int] = if (s.isEmpty) None else convert
    private def convert = try { Some(Integer.parseInt(s)) } catch { case _: NumberFormatException => None }
  }
  */
  /* OK
  implicit class MaybeInt(val s: String) extends AnyVal {
    def toInt_? : Option[Int] = if (s.isEmpty) None else convert
    def convert = try { Some(Integer.parseInt(s)) } catch { case _: NumberFormatException => None }
  }
  */
  /* OK
  implicit class MaybeInt(val s: String) {
    def toInt_? : Option[Int] = if (s.isEmpty) None else convert
    private def convert = try { Some(Integer.parseInt(s)) } catch { case _: NumberFormatException => None }
  }
  */
}
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Sep 28, 2012

@paulp said:
This should have been a blocker, I think.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Sep 29, 2012

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Oct 2, 2012

@adriaanm said:
superseded by scala/scala#1442

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Oct 8, 2012

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.