summaryrefslogtreecommitdiff
path: root/test/files/run
Commit message (Collapse)AuthorAgeFilesLines
* Checkfile update.Paul Phillips2012-07-301-10/+10
| | | | | | I screwed around with type printing for a long time and now I have to be done, so I suggest we accept the imperfection in here for now because it's still way ahead of "..." as types go.
* Merge pull request #1005 from odersky/topic/worksheetodersky2012-07-302-0/+4
|\ | | | | IDE improvements, with particular focus on making worksheets work.
| * Raw string interpolatorMartin Odersky2012-07-272-0/+4
| | | | | | | | Adds a raw string interpolator raw"..." which does not do any escape sequence processing.
* | SI-4560 - improved testJohannes Rudolph2012-07-242-21/+52
| | | | | | | | | | | | Added all the known cases of failing self-types. Added tests for symbol access (SI-4601) as well which should now be fixed for all of the same cases as well.
* | Fix SI-4560, NoSuchMethodErrors involving self types.Paul Phillips2012-07-242-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Following this commit are reversions of three prior commits which introduced difficulties of their own, plus extra tests for this issue and SI-4601, all of which I pinched from jrudolph. Maybe there was a good reason for some of the complicated code related to this ticket. I took the naive position that if we avoided generating a method call to a particular receiver if the receiver has no such method, we would encounter fewer NoSuchMethodErrors. I would believe one can construct a scenario which this doesn't handle correctly, but it's hard to believe this isn't a big improvement. Review by @jrudolph, @odersky.
* | SI-6111 accept single-subpattern unapply patternAdriaan Moors2012-07-232-0/+28
|/ | | | | | | | | | | | | | | | | | | | | | | | An extractor pattern `X(p)` should type check for any `X.unapply`/`X.unapplySeq` that returns an `Option[_]` -- previously we were confused about the case where it was an `Option[(T1, ... , Tn)]`. In this case, the expected type for the pattern `p` is simply `(T1, ... , Tn)`. While I was at it, tried to clean up unapplyTypeList and friends (by replacing them by extractorFormalTypes). From the spec: 8.1.8 ExtractorPatterns An extractor pattern x(p1, ..., pn) where n ≥ 0 is of the same syntactic form as a constructor pattern. However, instead of a case class, the stable identifier x denotes an object which has a member method named unapply or unapplySeq that matches the pattern. An unapply method in an object x matches the pattern x(p1, ..., pn) if it takes exactly one argument and one of the following applies: n = 0 and unapply’s result type is Boolean. n = 1 and unapply’s result type is Option[T], for some type T. the (only) argument pattern p1 is typed in turn with expected type T n > 1 and unapply’s result type is Option[(T1, ..., Tn)], for some types T1, ..., Tn. the argument patterns p1, ..., pn are typed in turn with expected types T1, ..., Tn
* SI-6090Martin Odersky2012-07-211-0/+6
| | | | Sharpens the test so that only Object_== and Object_!= methods on valueclasses may be rewritten in posterasure, whereas user-defined methods are not rewritten.
* Merge pull request #954 from odersky/optimize/outerAdriaan Moors2012-07-201-0/+26
|\ | | | | Removes redundant outers
| * Removes redundant outersMartin Odersky2012-07-201-0/+26
| | | | | | | | | | | | Widens the criterion when outer fields can be omitted. It used to be that sub- and superclass had to be enclosed by the same outer class. Only in that case was the outer field of the class omitted. We now omit if subclass is contained in an outer class that is itself a subclass of the superclasses outer class. See test case "outertest.scala" for an example.
* | Merge pull request #924 from hubertp/2.10.x-issue/5385Adriaan Moors2012-07-202-0/+24
|\ \ | | | | | | Fix for SI-5385.
| * | Fix for SI-5385.Paul Phillips2012-07-172-0/+24
| | | | | | | | | | | | | | | Nodes which hit EOF with no whitespace afterward had wrong position.
* | | Merge pull request #894 from axel22/topic/static-annot-cherry-2.10.xLukas Rytz2012-07-201-0/+243
|\ \ \ | | | | | | | | Implement @static annotation on singleton object fields.
| * | | WIP add private/lazy checks and a few tests.Aleksandar2012-07-191-0/+38
| | | |
| * | | Implement @static annotation on singleton object fields.Aleksandar Prokopec2012-07-181-0/+205
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit introduces the `@static` annotation on fields of static singleton objects. A static singleton object is a top-level singleton object or an object nested within a static singleton object. The field annotated with `@static` is generated as a true static field in the companion class of the object. The initialization of the field is done in the static initializer of the companion class, instead of the object itself. Here's an example. This: object Foo { @static val FIELD = 123 } class Foo generates : object Foo { def FIELD(): Int = Foo.FIELD } class Foo { <static> val FIELD = 123 } The accessor in `object Foo` is changed to return the static field in `class Foo` (the companion class is generated if it is not already present, and the same is done for getters if `FIELD` is a `var`). Furthermore, all the callsites to accessor `Foo.FIELD` are rewritten to access the static field directly. It is illegal to annotate a field in the singleton object as `@static` if there is already a member of the same name in `class Foo`. This allows better Java interoperability with frameworks which rely on static fields being present in the class. The `AtomicReferenceFieldUpdater`s are one such example. Instead of having a Java base class holding the `volatile` mutable field `f` and a static field containing a reference to the `AtomicReferenceFieldUpdater` that mutates `f` atomically, and extending this Java base class from Scala, we can now simply do: object Foo { @static val arfu = AtomicReferenceUpdater.newUpdater( classOf[Foo], classOf[String], "f" ) } class Foo { @volatile var f = null import Foo._ def CAS(ov: String, nv: String) = arfu.compareAndSet(this, null, "") } In summary, this commit introduces the following: - adds the `@static` annotation - for objects without a companion class and `@static` members, creates a companion class (this is done in `CleanUp`) - checks for conflicting names and if `@static` is used on static singleton object member - creates the `static` field in the companion class for `@static` members - moves the field initialization from the companion object to the static initializer of the class (the initialization of `@static` members is bypassed in the `Constructors` phase, and added to static ctors in `CleanUp`) - all callsites to the accessors of `@static` are rewritten to access the static fields directly (this is done in `GenICode`) - getters and setters to `@static` fields access the static field directly, and the field in the singleton object is not emitted (this is done in `GenICode`) - changes in `GenJVM`, `GenASM` - now computing local var indices in static initializers as well - this was an oversight before, now is necessary Future work: allow the `@static` annotation on methods as well - this will be added in a future commit. Review by @odersky, @dragos, @paulp, @heathermiller.
* | | | Merge pull request #941 from adriaanm/ticket-6104Adriaan Moors2012-07-202-0/+9
|\ \ \ \ | | | | | | | | | | SI-6104 support This pattern
| * | | | SI-6104 support This patternAdriaan Moors2012-07-182-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This(name) is treated just like Ident(name) apparently this pattern was used in 2.9 code, though I'm not sure it's spec'ed
* | | | | Merge pull request #936 from scalamacros/ticket/5999Adriaan Moors2012-07-2025-25/+170
|\ \ \ \ \ | | | | | | | | | | | | SI-5999 consistent behavior for c.reify and c.universe.reify
| * | | | | SI-5999 a real fix to the packageless problemEugene Burmako2012-07-209-5/+150
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After a discussion on a reflection meeting on Jul 17 we concluded that we should split staticModule into staticModule and staticPackage to remove the ambiguity between packageless objects and packageless packages (more in the comments in the body of the commit). The motivation is verbosely outlined in the comments, but the bottom line is that Scala allows packages and packageless objects to have the same name within the same program. Therefore at times we need to disambiguate, hence the introduction of the staticPackage method. As of such staticModule no longer works for packages. In the same fashion staticPackage doesn't work for modules. This is done to ensure robustness of reification. I would like to do the same for getModule in Definitions, but we have to maintain backward compatibility. That's why I retained the old behavior, but replaced getModule invocations with getPackage where appropriate to be in line with staticModule and staticPackage. Another important thing that follows from the discussion is that both staticClass and staticModule prefer parent packages over parent objects in cases of ambiguity. Say, if we have the following snippet of code: object B { class C } next to package B { class C } then staticClass("B.C") will never even consider a C inside the object B. This is how scalac operates, so we decided to be consistent here. Finally reification logic got changed to distinguish between staticModule and staticPackage, and to allow for the fact that staticClass and staticModule prefer parent packages to parent objects.
| * | | | | SI-5999 removes Context.reifyEugene Burmako2012-07-2016-20/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently there are discrepancies between the behavior of c.reify and c.universe.reify. First step in fixing these problems is removing the duplication in the API. That's why I'm cutting away the Context.reify shortcut. Context.reify is a magic macro, hardwired in the fast track mechanism, so removing it requires redeploying the starr (because an old starr will crash if launched on sources that don't contain Context.reify). To cleanly redeploy a starr I've left a Context.reify stub in sources, but hidden it behind a `protected` modifier. When starr is redeployed (in a subsequent commit) the stub will be removed. I've also updated the tests to use c.universe.reify instead of c.reify. This will break some of them, because c.universe.reify uses a standard compiler mirror, which unlike a macro mirror doesn't like packageless classes. That's an annoyance, but I think having clean separation of commits is more important that being 100% consistent.
* | | | | | Merge pull request #927 from dgruntz/issue/5856Adriaan Moors2012-07-201-0/+10
|\ \ \ \ \ \ | | | | | | | | | | | | | | SI-5856 enables use of $this in string interpolation
| * | | | | | SI-5856 enables use of $this in string interpolationDominik Gruntz2012-07-171-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This pull request fixes SI-5856. The scanner has been modified to return the correct token if keywords appear in $-expressions. The parser has been modified to issue an error and to only accept $<identifier>, $this and $block.
* | | | | | | Merge pull request #937 from adriaanm/ticket-5739Adriaan Moors2012-07-205-40/+95
|\ \ \ \ \ \ \ | |_|/ / / / / |/| | | | | | SI-5739 store sub-patterns in local vals
| * | | | | | SI-5739 store sub-patterns in local valsAdriaan Moors2012-07-175-40/+95
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also closes SI-5158 (debuggability), SI-6070 (soundness). To improve both debuggability and soundness, we now store the result of an extractor (user-defined and synthetic) in local variables. For the case class case, this also fixes the soundness bug SI-6070, as this prevents post-match mutation of bound variables. The core of the refactoring consisted of introducing the PreserveSubPatBinders trait, which introduces local variables instead of substituting symbols for the RHS of those variables (so this can be seen as reverting the premature optimization of inline the case-class getters into the case body). Since TreeMakerToCond fuses the substitutions performed in a match to find out which symbolic values binders evaluate to, masquerade PreserveSubPatBinders's binding of subPatBinders and subPatRefs as the corresponding substitution. Consider `case class Foo(bar: Int)`, then `case y@Foo(x) => println(x)` gives rise to `{val x = y.bar; println(x)}` (instead of `println(y.bar)`), and `subPatternsAsSubstitution` pretends we still replace `x` by `y.bar`, instead of storing it in a local variable so that the rest of the analysis need not be modified. Misc notes: - correct type for seq-subpattern - more error resilience (ill-typed patterns sometimes slip past the typechecker -- reopened SI-4425) TODO: come up with a more abstract framework for expressing bound symbols and their values
* | | | | | | Merge pull request #929 from scalamacros/ticket/5895Adriaan Moors2012-07-2014-39/+86
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | fixes field mirrors and also improves docs and exceptions for all mirrors
| * | | | | | | SI-5984 improves error reporting in JavaMirrorsEugene Burmako2012-07-1910-11/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Factors out error raising code and introduces a special exception class for Scala reflection errors. Also adds membership sanity checks to reflectXXX. Previously reflectField, reflectMethod, reflectClass and reflectModule in InstanceMirror didn't check that the symbols being passed to them actually correspond to some member of the related class.
| * | | | | | | SI-5895 fixes FieldMirrorsEugene Burmako2012-07-175-29/+38
| | |_|_|_|/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | reflectField now accepts getters and setters along with the field symbols, it also checks whether a field has a reasonable binary representation (this is necessary, because ctor parameters that are unused outside of their declaring constructors don't get compiled down to Java fields/methods).
* | | | | | | Merge pull request #952 from adriaanm/ticket-4897Adriaan Moors2012-07-192-0/+11
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | SI-4897 derive expected value from single type
| * | | | | | | SI-4897 derive expected value from single typeAdriaan Moors2012-07-192-0/+11
| | |_|_|_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | when the type in a type test is, say, `C.this.A.type`, must use the corresponding term `C.this.A` to test for equality if you use the naive REF(<C.this.A.type>.symbol), you'll get a path like `OwnerOfA.this.A`, where `OwnerOfA` might be a superclass of `C`, and explicitouter won't like that
* | | | | | | Merge pull request #919 from scalamacros/ticket/6086Adriaan Moors2012-07-1910-33/+117
|\ \ \ \ \ \ \ | |/ / / / / / |/| | | | | | SI-6086 magic symbols strike back
| * | | | | | SI-6086 magic symbols strike backEugene Burmako2012-07-1710-33/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some of the symbols inside the compiler get created on the fly, because there are no physical entities in classfiles corresponding to them. This curious fact needs to be taken into account when loading symbols, so that the magic symbols get correctly loaded by reflective mirrors. magicSymbols (as defined in Definitions.scala) include not only top-level classes, but some other stuff (e.g. String_+ or methods on Any). Hence a filtering was done to exclude the stuff that's irrelevant to reflective symbol loading. Unfortunately a filter was configured to accept only _.isClass, which consequently ruled out scala.AnyRef (that is a type alias).
* | | | | | | Merge pull request #922 from dragos/issue/fix-SI-6092Adriaan Moors2012-07-192-0/+39
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | SI-6092 don't leak in LazyAnnotationInfo, don't lift try{}finally{}
| * | | | | | | Fixed SI-6092. Fixed leaky annotations, and relaxed the conditions under ↵Iulian Dragos2012-07-182-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | which a try-catch is lifted out to an inner method. Less known fact: lazy values null-out their dependent values is their accessed only from their initializer. The analysis is not context-dependent (meaning the owner where a reference happens needs to be exactly that lazy value). * Removed no-op code around positions in `LazyAnnotationInfo` * Don't lift expressions that have no `catch` clause The two changes combined fix a memory leak that's been plaguing the IDE: an annotation (even when forced) would hang on to a namer, through the outer field of its call-by-name parameter. The test for the memory leak is in the IDE project (couldn't find a simple way to reproduce it outside the IDE), but there's a test checking that the field is null after initialization.
* | | | | | | | Merge pull request #939 from adriaanm/ticket-6089Adriaan Moors2012-07-192-0/+14
|\ \ \ \ \ \ \ \ | |_|_|_|_|_|/ / |/| | | | | | | SI-6089 better tail position analysis for matches
| * | | | | | | SI-6089 better tail position analysis for matchesAdriaan Moors2012-07-182-0/+14
| | |_|/ / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | we mistakenly went into apply nodes to look for matchEnd-labeldefs in tail positions -- only apply nodes that jump to labels in tailpos should be traversed (this arises for nested matches)
* | | | | | | Merge pull request #940 from axel22/issue/5937Adriaan Moors2012-07-181-0/+12
|\ \ \ \ \ \ \ | |_|_|_|_|_|/ |/| | | | | | SI-5937: Vector updated, +:, and :+ ignore provided builder, breaking type safety
| * | | | | | Fix SI-5937.Aleksandar Prokopec2012-07-181-0/+12
| | |_|_|/ / | |/| | | |
* | | | | | Merge pull request #883 from dgruntz/issue/6061Adriaan Moors2012-07-182-11/+22
|\ \ \ \ \ \ | | | | | | | | | | | | | | SI-6061 adds weakly conformance for number types to resolveOverloaded
| * | | | | | SI-6061 adds weakly conformance for number types to resolveOverloadedDominik Gruntz2012-07-112-11/+22
| | |_|_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fix changes resolveOverloaded in scala.reflect.internal so that numeric widening on the actual argument types is also considered for primitive number types. Needs changes in functions applicable and mostSpecific.
* | | | | | Merge pull request #921 from adriaanm/ticket-spuriousnessAdriaan Moors2012-07-186-237/+0
|\ \ \ \ \ \ | | | | | | | | | | | | | | move test files that fail spuriously to pending
| * | | | | | move test files that fail spuriously to pendingAdriaan Moors2012-07-176-237/+0
| | |_|_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I have this sneaky suspicion that part of these spurious failures are caused by the recent partest optimizations. @axel22 already checked that compiler instances are not shared between test runs. However, except for the benchmark test, they all have a distinct race condition in symbol loading/type checking feel to them. Since, in the end, the tests and/or their corresponding fixes are as likely a culprit as the test framework, moving them out of the way until their owners can get them back in line and they stop throwing primate wenches into our build. We should bring them back as soon as possible, though.
* | | | | | Merge pull request #933 from scalamacros/ticket/5731Adriaan Moors2012-07-1824-0/+72
|\ \ \ \ \ \ | |_|_|_|_|/ |/| | | | | SI-5731 a few fixes for value classes
| * | | | | SI-5731 a few fixes for value classesEugene Burmako2012-07-1724-0/+72
| | |_|_|/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I've faced two gotchas. First of all posterasure, which is supposed to erase ErasedValueType types, didn't look into ConstantType.value that is known to be smuggling types (hi Paul that's a plus one). Secondly ClassManifest.classType[T] assumed that its T is bound by AnyRef, which is not the case for value types. Here I had two choices: a) introduce a special method for manifests of value types, b) remove the upper bound of the type parameter and call it a day. Since manifests are already deprecated and there's no difference which method was used to create which manifest, I went for option b).
* | | | | Merge pull request #932 from hubertp/2.10.x-issue/5588Adriaan Moors2012-07-182-0/+16
|\ \ \ \ \ | |_|_|_|/ |/| | | | Fixes SI-5588. Correct compare for Enumeration.
| * | | | Fixes SI-5588. Correct compare for Enumeration.Hubert Plociniczak2012-07-172-0/+16
| |/ / / | | | | | | | | | | | | | | | | | | | | Slower than the original one but does comparison in the same spirit as IntOrdering. Review by @axel22.
* | | | Merge pull request #904 from adriaanm/ticket-6077Adriaan Moors2012-07-172-0/+14
|\ \ \ \ | |/ / / |/| | | SI-6077 more conservative TreeMakersToConds for CSE
| * | | SI-6077 more conservative TreeMakersToConds for CSEAdriaan Moors2012-07-142-0/+14
| | |/ | |/| | | | | | | | | | | | | | | | we were dropping irrefutable extractor calls (implemented for SI-4691) in common subcondition elimination, which caused bad code to be generated clean up TreeMakersToConds significantly in the process
* | | Merge pull request #910 from adriaanm/redo-847-ticket-6028Adriaan Moors2012-07-172-0/+105
|\ \ \ | |_|/ |/| | SI-6028 Avoid needless symbol renaming in lambdalift
| * | SI-6028 Avoid needless symbol renaming in lambdalift.Jason Zaugg2012-07-142-10/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Preserve names of all referenced free vars. Only the proxy symbols have the fresh names. The resulting natural beauty is evident in the diff of t6028.check. This subsumes the treatment in 0e170e4b that ensured named parameter calls cannot see mangled names; pos/t6028 confirms as much.
| * | A test case that scrutinises lambdalifter's output.Jason Zaugg2012-07-142-0/+106
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | No doubt there are plenty of additional variations that could be added to exercise more code paths. This is the unflattering "before" photo; the next commit will make over the name mangling and reveal the simple beauty of unmangled names. References SI-6028
* | | SI-6011 switches: unreachability, guard-free formAdriaan Moors2012-07-162-0/+12
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A complete overhaul. The original implementation in SI-5830 (#821) was pretty buggy. [from the doc comment of `collapseGuardedCases`:] Collapse guarded cases that switch on the same constant (the last case may be unguarded). Cases with patterns A and B switch on the same constant iff for all values x that match A also match B and vice versa. (This roughly corresponds to equality on trees modulo alpha renaming and reordering of alternatives.) The rewrite only applies if some of the cases are guarded (this must be checked before invoking this method). The rewrite goes through the switch top-down and merges each case with the subsequent cases it is implied by (i.e. it matches if they match, not taking guards into account) If there are no unreachable cases, all cases can be uniquely assigned to a partition of such 'overlapping' cases, save for the default case (thus we jump to it rather than copying it several times). (The cases in a partition are implied by the principal element of the partition.) The overlapping cases are merged into one case with their guards pushed into the body as follows (with P the principal element of the overlapping patterns Pi): `{case Pi if(G_i) => B_i }*` is rewritten to `case P => {if(G_i) B_i}*` The rewrite fails (and returns Nil) when: (1) there is a subsequence of overlapping cases that has an unguarded case in the middle; only the last case of each subsequence of overlapping cases may be unguarded (this is implied by unreachability) (2) there are overlapping cases that differ (tested by `caseImpliedBy`) cases with patterns A and B are overlapping if for SOME value x, A matches x implies B matches y OR vice versa <-- note the difference with case equality defined above for example `case 'a' | 'b' =>` and `case 'b' =>` are different and overlapping (overlapping and equality disregard guards) Improved by @retronym's feedback in the following ways: - fix patternEquals (it's now quadratic, but correct) - update neg/t6011 to test the improved patternEquals - remove side-effect-in-condition ugliness - introduce isGuardedCase - docs & various code clarity Also closes SI-6048 (duplicate).