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

resolveOverloaded returns NoSymbol instead of the expected method symbol #6061

Closed
scabug opened this issue Jul 11, 2012 · 2 comments
Closed
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Jul 11, 2012

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
@scabug
Copy link
Author

scabug commented Jul 11, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6061?orig=1
Reporter: @dgruntz
Affected Versions: 2.10.0

@scabug
Copy link
Author

scabug commented Jul 11, 2012

@dgruntz said:
proposed fix in scala/scala#883

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