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

ToolBox.typecheck throws assertion error on overridden method #10189

Open
scabug opened this issue Feb 14, 2017 · 2 comments
Open

ToolBox.typecheck throws assertion error on overridden method #10189

scabug opened this issue Feb 14, 2017 · 2 comments

Comments

@scabug
Copy link

scabug commented Feb 14, 2017

ToolBox.typecheck fails an assertion with the message "import failure: cannot determine unique overloaded method alternative from..." when typechecking an overridden interface method.

import scala.reflect.runtime.currentMirror
import scala.tools.reflect.ToolBox
	
val toolBox = currentMirror.mkToolBox()

// the expression prints fine in scala/scalac
println(java.time.Instant.now().plus(24, java.time.temporal.ChronoUnit.HOURS))

val tree = toolBox.parse("""
  java.time.Instant.now().plus(24, java.time.temporal.ChronoUnit.HOURS)
""")

toolBox.typecheck(tree) // throws AssertionError

Stack trace:

java.lang.AssertionError: assertion failed: import failure: cannot determine unique overloaded method alternative from
 def plus(x$1: Long,x$2: java.time.temporal.TemporalUnit): java.time.temporal.Temporal
def plus(x$1: Long,x$2: java.time.temporal.TemporalUnit): java.time.Instant
 that matches method plus:(x$1: Long, x$2: java.time.temporal.TemporalUnit)java.time.Instant
  at scala.reflect.internal.Importers$StandardImporter.disambiguate$1(Importers.scala:183)
  at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:188)
  at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:210)
  at scala.reflect.internal.Importers$StandardImporter.recreatedTreeCompleter(Importers.scala:298)
  at scala.reflect.internal.Importers$StandardImporter.$anonfun$importTree$1(Importers.scala:417)
  at scala.reflect.internal.Importers$StandardImporter.tryFixup(Importers.scala:49)
  at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:418)
  at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:374)
  at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:415)
  at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:29)
  at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl.$anonfun$typecheck$6(ToolBoxFactory.scala:380)
  at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$.apply(ToolBoxFactory.scala:359)
  at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl.typecheck(ToolBoxFactory.scala:371)
  at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl.typecheck(ToolBoxFactory.scala:26)
  ... 29 elided

Thanks for reading!

@scabug
Copy link
Author

scabug commented Feb 14, 2017

Imported From: https://issues.scala-lang.org/browse/SI-10189?orig=1
Reporter: Zach R. D. (zachrd)
Affected Versions: 2.11.8, 2.12.1

@zach-r-d
Copy link

@adriaanm @xeno-by FWIW, the expression works with compile() and eval(), it's just typecheck() that throws an AssertionError.

@SethTisue SethTisue added this to the Backlog milestone Apr 6, 2023
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

4 participants