summaryrefslogtreecommitdiff
path: root/test/files/neg/switch.scala
Commit message (Collapse)AuthorAgeFilesLines
* Cull extraneous whitespace.Paul Phillips2013-09-181-8/+8
| | | | | | | | | | | | | | | | | | | | | One last flurry with the broom before I leave you slobs to code in your own filth. Eliminated all the trailing whitespace I could manage, with special prejudice reserved for the test cases which depended on the preservation of trailing whitespace. Was reminded I cannot figure out how to eliminate the trailing space on the "scala> " prompt in repl transcripts. At least reduced the number of such empty prompts by trimming transcript code on the way in. Routed ConsoleReporter's "printMessage" through a trailing whitespace stripping method which might help futureproof against the future of whitespace diseases. Deleted the up-to-40 lines of trailing whitespace found in various library files. It seems like only yesterday we performed whitespace surgery on the whole repo. Clearly it doesn't stick very well. I suggest it would work better to enforce a few requirements on the way in.
* SI-5830 switches: support guards, unreachabilityAdriaan Moors2012-07-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | turn switches with guards into guard-free switches by collecting all cases that are (possibly) guarded by different guards but that switch on the same constant, and pushing the implied if-then-else into the collapsed case body ``` case C if G1 => B1 case C if Gi => Bi case C if GN => BN ``` becomes ``` case C => if (G1) B1 else if (Gi) Bi else if (GN) BN else default() // not necessary if GN == EmptyTree ``` default() is a jump to the default case; to enable this, we wrap a default() { } labeldef around the last case's body (the user-defined default or the synthetic case that throws the matcherror) so we can jump to the default case after the last guard is checked (assuming unreachability is checked, once we ended up in a non-default case, one of the guards either matches or we go to the default case) the unreachability analysis is minimal -- we simply check (after rewriting to guard-free form) that: - there are no duplicate cases - the default case comes last misc notes: - can't jump in exception handlers (TODO: a more fine-grained analysis on when we need to jump) - work around SI-6015 (test file run/t5830.scala crashed the inliner) - propagate type of case body to label def of default case (needed for existentials, see e.g., t2683) - the default(){} LabelDef breaks SelectiveANFTransform -- workaround: don't write guarded switches in CPS code (do the above transformation manually)
* Begone t1737...Hubert Plociniczak2011-11-021-8/+8
|
* [no content change] Fixed all SVN properties: m...Gilles Dubochet2009-09-241-1/+1
| | | | | | | | [no content change] Fixed all SVN properties: mimes, EOL, executable. Id expansion is consistently enabled for Scala/Java/C# sources in 'src/' and consistently disabled and removed from everywhere else: there should not be any dead Id tags anymore.
* The birth of the @switch and @tailrec annotations.Paul Phillips2009-03-161-0/+66
They are located in package scala.annotation. Also in this patch: * numerous test cases for both annotations * addition of @tailrec and @switch in a few strategic locations * fixes for critical section NewScanners methods which were not being compiled into switches, immediately proving the value of @switch * tail recursive implementations for Iterator.{ dropWhile, drop} and List.dropWhile tagged with @tailrec, closing bug #1376