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

alternatives error message should not be empty #6138

Closed
scabug opened this issue Jul 25, 2012 · 5 comments
Closed

alternatives error message should not be empty #6138

scabug opened this issue Jul 25, 2012 · 5 comments

Comments

@scabug
Copy link

scabug commented Jul 25, 2012

scala> def getClassSafe(fullName: String): Option[String] = try {
     |                Some(definitions.getClass(newTypeName(fullName)))
     |              } catch {
     |                case _: MissingRequirementError => None
     |              }
<console>:39: error: too many arguments for overloaded method value getClass with alternatives:


                      Some(definitions.getClass(newTypeName(fullName)))
                                               ^

note the cliff hanger, there -- no alternatives are reported

I think the problem is that the getClass symbol is overloaded, but the tree's type is already by the time the error message is synthesized (the error arises from the erroroneous return type Option[String])

Taking the relevant pieces of code:

if (sym.isOverloaded) overloadedMessage

def overloadedMessage = "overloaded method " + sym + " with alternatives:\n" + alternativesString(tree)

def alternativesString(tree: Tree) =
  alternatives(tree) map (x => "  " + methodTypeErrorString(x)) mkString ("", " <and>\n", "\n")

def alternatives(tree: Tree): List[Type] = tree.tpe match {
  case OverloadedType(pre, alternatives)  => alternatives map pre.memberType

this assumes tree.symbol.isOverloaded implies tree.tpe.isInstanceOf[OverloadedType], which this bug illustrates is not necessarily the case

@scabug
Copy link
Author

scabug commented Jul 25, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6138?orig=1
Reporter: @adriaanm

@scabug
Copy link
Author

scabug commented Jul 25, 2012

@hubertp said:
Surprisingly, this is not a regression. I wonder how it survived for so long.

@scabug
Copy link
Author

scabug commented May 20, 2013

@JamesIry said:
2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.

1 similar comment
@scabug
Copy link
Author

scabug commented May 20, 2013

@JamesIry said:
2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.

@scabug
Copy link
Author

scabug commented May 22, 2013

@retronym said:
scala/scala#2578

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