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

implicit value classes don't work #5759

Closed
scabug opened this issue May 3, 2012 · 2 comments
Closed

implicit value classes don't work #5759

scabug opened this issue May 3, 2012 · 2 comments

Comments

@scabug
Copy link

scabug commented May 3, 2012

The following little snippet blows up:

object Test {
  implicit class DoubleMethods(val x: Double) extends AnyVal {
    def inv: Double = 1.0 / x
  }

  def apply(x: Double) = x.inv
}

The error message is

error: 
     while compiling:  test.scala
       current phase:  typer
     library version:  version 2.10.0-M3
    compiler version:  version 2.10.0-M3
  reconstructed args:  

uncaught exception during compilation: java.util.NoSuchElementException
error: java.util.NoSuchElementException: key not found: value DoubleMethods
	at scala.collection.MapLike$class.default(MapLike.scala:228)
	at scala.collection.AbstractMap.default(Map.scala:57)
	at scala.collection.mutable.HashMap.apply(HashMap.scala:63)
	at scala.tools.nsc.typechecker.MethodSynthesis$MethodSynth$class.addDerivedTrees(MethodSynthesis.scala:237)
	at scala.tools.nsc.typechecker.Namers$Namer.addDerivedTrees(Namers.scala:76)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$45.apply(Typers.scala:1708)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$45.apply(Typers.scala:1708)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$rewrappingWrapperTrees$1.apply(Typers.scala:1646)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$rewrappingWrapperTrees$1.apply(Typers.scala:1643)
	at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:247)
	at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:247)
	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.immutable.List.foreach(List.scala:77)
	at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:247)
	at scala.collection.AbstractTraversable.flatMap(Traversable.scala:112)
	at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1708)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$44.apply(Typers.scala:1618)
	at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1617)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4657)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5015)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2540)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$64$$anonfun$65.apply(Typers.scala:2636)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$64$$anonfun$65.apply(Typers.scala:2636)
	at scala.collection.immutable.List.loop$1(List.scala:163)
	at scala.collection.immutable.List.mapConserve(List.scala:179)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$64.apply(Typers.scala:2636)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2635)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4650)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5015)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5073)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:97)
	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:432)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:89)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:89)
	at scala.collection.Iterator$class.foreach(Iterator.scala:697)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1124)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:89)
	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1336)
	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1309)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1303)
	at scala.tools.nsc.Global$Run.compile(Global.scala:1436)
	at scala.tools.nsc.Driver.doCompile(Driver.scala:31)
	at scala.tools.nsc.Main$.doCompile(Main.scala:81)
	at scala.tools.nsc.Driver.process(Driver.scala:52)
	at scala.tools.nsc.Driver.main(Driver.scala:65)
	at scala.tools.nsc.Main.main(Main.scala)

Exception in thread "main" java.util.NoSuchElementException: key not found: value DoubleMethods
	at scala.collection.MapLike$class.default(MapLike.scala:228)
	at scala.collection.AbstractMap.default(Map.scala:57)
	at scala.collection.mutable.HashMap.apply(HashMap.scala:63)
	at scala.tools.nsc.typechecker.MethodSynthesis$MethodSynth$class.addDerivedTrees(MethodSynthesis.scala:237)
	at scala.tools.nsc.typechecker.Namers$Namer.addDerivedTrees(Namers.scala:76)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$45.apply(Typers.scala:1708)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$45.apply(Typers.scala:1708)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$rewrappingWrapperTrees$1.apply(Typers.scala:1646)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$rewrappingWrapperTrees$1.apply(Typers.scala:1643)
	at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:247)
	at scala.collection.TraversableLike$$anonfun$flatMap$1.apply(TraversableLike.scala:247)
	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.immutable.List.foreach(List.scala:77)
	at scala.collection.TraversableLike$class.flatMap(TraversableLike.scala:247)
	at scala.collection.AbstractTraversable.flatMap(Traversable.scala:112)
	at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1708)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$44.apply(Typers.scala:1618)
	at scala.tools.nsc.typechecker.Typers$Typer.typedModuleDef(Typers.scala:1617)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4657)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5015)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2540)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$64$$anonfun$65.apply(Typers.scala:2636)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$64$$anonfun$65.apply(Typers.scala:2636)
	at scala.collection.immutable.List.loop$1(List.scala:163)
	at scala.collection.immutable.List.mapConserve(List.scala:179)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$64.apply(Typers.scala:2636)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2635)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4650)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5015)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5073)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:97)
	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:432)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:89)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3$$anonfun$run$1.apply(Analyzer.scala:89)
	at scala.collection.Iterator$class.foreach(Iterator.scala:697)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1124)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:89)
	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1336)
	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1309)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1303)
	at scala.tools.nsc.Global$Run.compile(Global.scala:1436)
	at scala.tools.nsc.Driver.doCompile(Driver.scala:31)
	at scala.tools.nsc.Main$.doCompile(Main.scala:81)
	at scala.tools.nsc.Driver.process(Driver.scala:52)
	at scala.tools.nsc.Driver.main(Driver.scala:65)
	at scala.tools.nsc.Main.main(Main.scala)

Removing extends AnyVal or removing implicit and adding the implicit conversion manually both work fine.

@scabug
Copy link
Author

scabug commented May 3, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5759?orig=1
Reporter: Jeff Olson (jdolson)
Affected Versions: 2.10.0-M3
Duplicates #5667

@scabug
Copy link
Author

scabug commented May 4, 2012

@soc said:
Duplicate of #5667.

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

1 participant