Details

      Description

      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)
      

        Issue Links

          Activity

          Hide
          A. P. Marki added a comment - - edited

          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 }
            }
            */
          }
          
          Show
          A. P. Marki added a comment - - edited 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 } } */ }
          Hide
          Paul Phillips added a comment -

          This should have been a blocker, I think.

          Show
          Paul Phillips added a comment - This should have been a blocker, I think.
          Show
          Martin Odersky added a comment - https://github.com/scala/scala/pull/1427
          Hide
          Adriaan Moors added a comment -
          Show
          Adriaan Moors added a comment - superseded by https://github.com/scala/scala/pull/1442
          Hide
          Grzegorz Kossakowski added a comment -
          Show
          Grzegorz Kossakowski added a comment - Fixed in https://github.com/scala/scala/pull/1442

            People

            • Assignee:
              Martin Odersky
              Reporter:
              Paul Phillips
            • Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development