summaryrefslogtreecommitdiff
path: root/test/files/neg/t4425.check
Commit message (Collapse)AuthorAgeFilesLines
* SI-7850 CCE in patmat with invalid isEmpty.Paul Phillips2013-12-151-3/+3
| | | | | | | | Name-based pattern matcher needed some hardening against unapply methods with the right name but wrong types. Only isEmpty methods which return Boolean are acceptable. Catching it directly rather than indirectly also allowed for better error messages.
* Pattern matcher: extractors become name-based.Paul Phillips2013-08-171-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | An extractor is no longer required to return Option[T], and can instead return anything which directly contains methods with these signatures: def isEmpty: Boolean def get: T If the type of get contains methods with the names of product selectors (_1, _2, etc.) then the type and arity of the extraction is inferred from the type of get. If it does not contain _1, then it is a single value extractor analogous like Option[T]. This has significant benefits and opens new territory: - an AnyVal based Option-like class can be used which leverages null as None, and no allocations are necessary - for primitive types the benefit is squared (see below) - the performance difference between case classes and extractors should now be largely eliminated - this in turn allows us to recapture great swaths of memory which are currently squandered (e.g. every TypeRef has fields for pre and args, even though these are more than half the time NoPrefix and Nil) Here is a primitive example: final class OptInt(val x: Int) extends AnyVal { def get: Int = x def isEmpty = x == Int.MinValue // or whatever is appropriate } // This boxes TWICE: Int => Integer => Some(Integer) def unapply(x: Int): Option[Int] // This boxes NONCE def unapply(x: Int): OptInt As a multi-value example, after I contribute some methods to TypeRef: def isEmpty = false def get = this def _1 = pre def _2 = sym def _3 = args Then it's extractor becomes def unapply(x: TypeRef) = x Which, it need hardly be said, involves no allocations.
* SI-4425 do some validity checking on unapplies.Paul Phillips2013-08-171-1/+2
| | | | | | Filter out unapplies which can't be called (such as those with a second non-implicit parameter list) and report the error in a meaningful fashion.
* SI-5739 (bis) vals for subpatterns unless -optimizeAdriaan Moors2012-08-081-3/+2
| | | | | | | | | | | | | | To facilitate debugging pattern matches, we store the values for sub-patterns of extractor (synthetic or user-defined) patterns in local variables. When performing an optimized build, and when possible, we don't do store but inline them directly. For soundness, SI-5158, SI-6070, we must always store the values of mutable case class fields. (Specifying -optimize is the only way to suppress emitting these local variables. An unoptimized build will always generate them, which was deemed the right default during the meeting.) (updated flags for t4425 to get consistent runs on optimized and non-optimized partest runs by always passing -optimize)
* SI-5739 store sub-patterns in local valsAdriaan Moors2012-07-171-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* virtpatmat on by default; chicken out: -XoldpatmatAdriaan Moors2012-04-141-1/+1
| | | | | | | some tests (unreachability, exhaustivity, @switch annotation checking) are still run under -Xoldpatmat, but that will change before we go into RC mode (then the test/ partest of this commit will be reverted) removed irrelevant dependency on patmat
* close #4524 and close #4425, review by odersky.Lukas Rytz2011-05-051-0/+4