Scala Programming Language
  1. Scala Programming Language
  2. SI-6320

Generics on selectDynamic appear to get lost in REPL

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.0-M7
    • Fix Version/s: Scala 2.10.0
    • Component/s: Repl / Interpreter
    • Labels:
    • Environment:

      Scala version 2.10.0-M7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_31).
      Linux 2.6.39-gentoo-r3 #1 SMP Wed Nov 2 22:04:26 GMT 2011 x86_64 Intel(R) Core(TM) i7 CPU Q 740 @ 1.73GHz GenuineIntel GNU/Linux

      Description

      Note that the following works fine when compiled using scalac:

      scala> class Dyn(m: Map[String, Any]) extends Dynamic

      { def selectDynamic[T](s: String): T = m(s).asInstanceOf[T] }

      defined class Dyn

      scala> new Dyn(Map("foo" -> 10)).foo[Int]
      java.lang.ClassCastException: java.lang.Integer cannot be cast to scala.runtime.Nothing$
      at .<init>(<console>:9)
      at .<clinit>(<console>)
      at .<init>(<console>:7)
      at .<clinit>(<console>)
      at $print(<console>)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:732)
      at scala.tools.nsc.interpreter.IMain$Request.loadAndRun(IMain.scala:981)
      at scala.tools.nsc.interpreter.IMain.loadAndRunReq$1(IMain.scala:571)
      at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:602)
      at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:566)
      at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:745)
      at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:790)
      at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:702)
      at scala.tools.nsc.interpreter.ILoop.processLine$1(ILoop.scala:566)
      at scala.tools.nsc.interpreter.ILoop.innerLoop$1(ILoop.scala:573)
      at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:576)
      at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:867)
      at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:822)
      at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:822)
      at scala.tools.nsc.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:135)
      at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:822)
      at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:83)
      at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:96)
      at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:105)
      at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

        Activity

        Show
        Paul Phillips added a comment - https://github.com/scala/scala/pull/1681
        Show
        Jason Zaugg added a comment - https://github.com/scala/scala/commit/edbcc64483ac0009eeeb58fe31e57a411da9e4c6

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Jon Pretty
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development