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

resolveOverloaded returns NoSymbol instead of the expected method symbol

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.0
    • Fix Version/s: Scala 2.10.0-M5
    • Component/s: Reflection
    • Labels:
      None
    • Environment:

      Welcome to Scala version 2.10.0-20120710-144914-026a70d555 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_24).

      Description

      Consider the following class with the overloaded method a:

      class C {
        def a(x: Int) = 1
        def a(x: String) = 2
      }
      

      Invocation of method a with a argument of type Char returns 1 (numeric widening):

      scala> new C().a(32 : Char)
      res4: Int = 1
      

      resolveOverload on the term symbol a however returns NoSymbol (signalling an overload ambiguity):

      scala> import scala.reflect.runtime.universe._
      import scala.reflect.runtime.universe._
      
      scala> import scala.reflect.runtime.{ currentMirror => cm }
      import scala.reflect.runtime.{currentMirror=>cm}
      
      scala> class C {
           |   def a(x: Int) = 1
           |   def a(x: String) = 2
           | }
      defined class C
      
      scala> val t = typeOf[C]
      t: reflect.runtime.universe.Type = C
      
      scala> val a = t.member(newTermName("a")).asTermSymbol
      a: reflect.runtime.universe.TermSymbol = value a
      
      scala> a.alternatives.size
      res5: Int = 2
      
      scala> val aSymb = a.resolveOverloaded(posVargs = List(typeOf[Char]))
      aSymb: reflect.runtime.universe.Symbol = <none>
      
      scala> aSymb == NoSymbol
      res6: Boolean = true
      

      In order to reproduce this bug use the following input:

      import scala.reflect.runtime.universe._
      import scala.reflect.runtime.{ currentMirror => cm }
      class C {
        def a(x: Int) = 1
        def a(x: String) = 2
      }
      val t = typeOf[C]
      val a = t.member(newTermName("a")).asTermSymbol
      val aSymb = a.resolveOverloaded(posVargs = List(typeOf[Char]))
      aSymb == NoSymbol
      

        Activity

        Hide
        Dominik Gruntz added a comment -
        Show
        Dominik Gruntz added a comment - proposed fix in https://github.com/scala/scala/pull/883

          People

          • Assignee:
            Christopher Vogt
            Reporter:
            Dominik Gruntz
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development