This page is no longer maintained — Please continue to the home page at www.scala-lang.org

repl debugger is now $plus$plus

No replies
extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.

I wrangled manifests into telling me something about the parameter
types, and as of r18291 you can do sweet stuff like this:

// here is a line I put in parallelmatching at a strategic spot
// (line 570 of the current ParallelMatching.scala.)
// you put your line wherever you like!
Interpreter.breakIf(true, "lits" -> literals, "mixlit" -> this, literalMap)

// here is an interpreter session after compiling that in
// notice you can supply parameter name, or just let it make one up
scala> (5: Int) match { case 3|4 => true ; case 5 => false }
lits: scala.collection.immutable.List[scala.tools.nsc.ast.Trees$Tree]
mixlit: scala.tools.nsc.matching.ParallelMatching$MatchMatrix$MixLiteralInts
p1: scala.collection.immutable.IntMap[scala.collection.immutable.List[int]]

scala> lits.head
res0: scala.tools.nsc.ast.Trees$Tree = 3

scala> res0.tpe
res1: scala.tools.nsc.symtab.SymbolTable#Type = Int(3)

scala> lits foreach (_ setType res1)

scala> lits(2).tpe
res3: scala.tools.nsc.symtab.SymbolTable#Type = Int(3)

// resume execution! don't be surprised if you broke something
// if you do something less innocuous than the giggle inducer of
// setting the types of 4 and 5 to Int(3).
scala> :quit

// and there's the result of the original match on 5.
res0: Boolean = false

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland