summaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAgeFilesLines
...
* | | Revert "#653 -- no lub for statement exprs' types"Adriaan Moors2012-06-032-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | I should not have merged this pull request yet. I didn't notice we didn't have a full successful run of the test suite. It looks like it breaks test/files/continuations-neg/lazy.scala and given the pending amount of changes, I prefer to have a stable master. This reverts commit 037d3dcbc5896864aec0f9121eeda23fcc4cd610.
* | | Merge pull request #653 from dragos/issue/skip-lub-in-blocksAdriaan Moors2012-06-032-3/+3
|\ \ \ | | | | | | | | | | | | Don't compute least upper bounds for if-like exprs in statement position
| * | | Don't compute least upper bounds for expressions in statement positions ↵Iulian Dragos2012-06-032-3/+3
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | inside blocks. This may save huge amount of time (Fixes SI-5862) for complicated lubs. I had to remove the a check in adapt for the part that transforms <expr> into { <expr>; () } when the expected type is Unit. The reason is in the code. As a side effect, we get more warnings for pure expressions in statement positions (see the change in the test file).
* | | Merge pull request #650 from adriaanm/topic-virtpatmatAdriaan Moors2012-06-038-1/+75
|\ \ \ | | | | | | | | | | | | | | | | Unreachability analysis for pattern matches Thanks for reviewing, @retronym!
| * | | Unreachability analysis for pattern matchesAdriaan Moors2012-06-018-1/+75
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Analyze matches for unreachable cases. A case is unreachable if it implies its preceding cases. Call `C` the formula that is satisfiable if the considered case matches. Call `P` the formula that is satisfiable if the cases preceding it match. The case is reachable if there is a model for `-P /\ C`. Thus, the case is unreachable if there is no model for `-(-P /\ C)`, or, equivalently, `P \/ -C`, or `C => P`. Unreachability needs a more precise model for type and value tests than exhaustivity. Before, `{case _: Int => case 1 =>}` would be modeled as `X = Int \/ X = 1.type`, and thus, the second case would be reachable if we can satisfy `X != Int /\ X = 1.type`. Of course, the case isn't reachable, yet the formula is satisfiable, so we must augment our model to take into account that `X = 1.type => X = Int`. This is done by `removeVarEq`, which models the following axioms about equality. It does so to retain the meaning of equality after replacing `V = C` (variable = constant) by a literal (fresh symbol). For each variable: 1. a sealed type test must result in exactly one of its partitions being chosen (the core of exhaustivity) 2. when a type test is true, tests of super types must also be true, and unrelated type tests must be false For example, `V : X ::= A | B | C`, and `A => B` (since `A extends B`). Coverage (1) is formulated as: `A \/ B \/ C`, and the implications of (2) are simply `V=A => V=B /\ V=X`, `V=B => V=X`, `V=C => V=X`. Exclusion for unrelated types typically results from matches such as `{case SomeConst => case OtherConst => }`. Here, `V=SomeConst.type => !V=OtherConst.type`. This is a conservative approximation. If these constants happen to be the same value dynamically (but the types don't tell us this), the last case is actually unreachable. Of course we must err on the safe side. We simplify the equality axioms as follows (in principle this could be done by the solver, but it's easy to do before solving). If we've already excluded a pair of assignments of constants to a certain variable at some point, say `(-A \/ -B)`, then don't exclude the symmetric one `(-B \/ -A)`. (Nor the positive implications `-B \/ A`, or `-A \/ B`, which would entail the equality axioms falsifying the whole formula.) TODO: We should also model dependencies between variables: if `V1` corresponds to `x: List[_]` and `V2` is `x.hd`, `V2` cannot be assigned at all when `V1 = null` or `V1 = Nil`. Right now this is implemented hackily by pruning counter-examples in exhaustivity. Unreachability would also benefit from a more faithful representation. I had to refactor some of the framework, but most of it is shared with exhaustivity. We must allow approximating tree makers twice, sharing variables, but using different approximations for values not statically known. When considering reachability of a case, we must assume, for example, that its unknown guard succeeds (otherwise it would wrongly be considered unreachable), whereas unknown guards in the preceding cases must be considered to fail (otherwise we could never get to those case, and again, it would falsely be considered unreachable). Since this analysis is relatively expensive, you may opt-out using `-Xno-patmat-analysis` (or annotating the selector with @unchecked). We hope to improve the performance in the near future. -Ystatistics has also been extended to provide some numbers on time spent in the equality-rewrite, solving and analyzing.
* / / Closes t5399. Review by adriaanmMartin Odersky2012-06-021-0/+45
|/ /
* | Merge pull request #638 from lrytz/wip/t5843Adriaan Moors2012-05-302-0/+24
|\ \ | | | | | | fix t5843
| * | fix t5843Lukas Rytz2012-05-282-0/+24
| | |
* | | Merge pull request #634 from retronym/ticket/4579Adriaan Moors2012-05-302-0/+519
|\ \ \ | | | | | | | | SI-4579 Yoke the power of lisp.scala as a stress for the optimizer.
| * | | SI-4579 Yoke the power of lisp.scala as a stress for the optimizer.Jason Zaugg2012-05-272-0/+519
| | | | | | | | | | | | | | | | The reported bug was fixed between 2.10.0-M1 and 2.10.0-M2.
* | | | Merge pull request #636 from retronym/ticket/5845Adriaan Moors2012-05-282-0/+23
|\ \ \ \ | | | | | | | | | | SI-5845 Advances the example from a crasher to an inference failure.
| * | | | SI-5845 Advances the example from a crasher to an inference failure.Jason Zaugg2012-05-282-0/+23
| |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The inference failure itself seems like an instance of of SI-3346. But dependent method types (which triggered the crash), can be employed to avoid inferring the type constructor CC. class Num[T] { def mkOps = new Ops class Ops { def +++(rhs: T) = () } } class A { implicit def infixOps[T](lhs: T)(implicit num: Num[T]): num.Ops = num.mkOps implicit val n1: Num[Int] = new Num[Int] { } 5 +++ 5 }
* | | | Merge pull request #635 from adriaanm/topic/virtpatmatAdriaan Moors2012-05-282-6/+12
|\ \ \ \ | |_|/ / |/| | | fixes for exhaustivity
| * | | don't check exhaustivity involving user-defined unapplySeqAdriaan Moors2012-05-282-6/+12
| |/ /
* | | Merge pull request #633 from retronym/topic/value-class-bridgeAdriaan Moors2012-05-273-0/+19
|\ \ \ | |/ / |/| | Fix a NSDNHAO in extension methods.
| * | Fix a NSDNHAO in extension methods.Jason Zaugg2012-05-273-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A bridge method, created when we override a method from a superclass and refine the return type, was appearing as an overloaded alternative. (`erasure` doesn't create new scopes, so the bridges it builds are visible at earlier phases.) The problem was masked when compiling with specialization, which *does* create a new scope, shielding the code in question from the artefacts of erasure. To fix the problem, we filter out bridge methods from the overloaded alternatives returned by `.decl`, as would happen internally in `.member`.
* | | Orphan checkfile remover.Paul Phillips2012-05-2637-1013/+0
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Are these -msil checkfiles used in some secret fashion? The level of activity suggest otherwise. Since scala-nightly-msil has been disabled for over a year, it's an easy rm unless someone speaks up. % tools/rm-orphan-checkfiles Scanning for orphan check files... rm 'test/disabled/run/code.check' rm 'test/files/jvm/t1652.check' rm 'test/files/neg/macro-argtype-mismatch.check' rm 'test/files/neg/macro-noncompilertree.check' rm 'test/files/neg/macro-nontree.check' rm 'test/files/run/Course-2002-01-msil.check' rm 'test/files/run/Course-2002-02-msil.check' rm 'test/files/run/Course-2002-03-msil.check' rm 'test/files/run/Course-2002-04-msil.check' rm 'test/files/run/Course-2002-08-msil.check' rm 'test/files/run/Course-2002-09-msil.check' rm 'test/files/run/Course-2002-10-msil.check' rm 'test/files/run/absoverride-msil.check' rm 'test/files/run/bitsets-msil.check' rm 'test/files/run/boolord-msil.check' rm 'test/files/run/bugs-msil.check' rm 'test/files/run/impconvtimes-msil.check' rm 'test/files/run/infix-msil.check' rm 'test/files/run/iq-msil.check' rm 'test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.check' rm 'test/files/run/macro-rettype-mismatch.check' rm 'test/files/run/misc-msil.check' rm 'test/files/run/promotion-msil.check' rm 'test/files/run/richs-msil.check' rm 'test/files/run/runtime-msil.check' rm 'test/files/run/tuples-msil.check' rm 'test/pending/jvm/t1464.check' rm 'test/pending/run/subarray.check' rm 'test/pending/run/t0446.check' rm 'test/pending/run/t5629.check' Scanning for orphan flags files... rm 'test/files/neg/macro-argtype-mismatch.flags' rm 'test/files/neg/macro-noncompilertree.flags' rm 'test/files/neg/macro-nontree.flags' rm 'test/files/pos/anyval-children.flags' rm 'test/files/pos/t3097.flags' rm 'test/files/run/macro-invalidret-doesnt-conform-to-impl-rettype.flags' rm 'test/files/run/macro-rettype-mismatch.flags'
* | Merge pull request #612 from adriaanm/ticket/5829Adriaan Moors2012-05-261-0/+18
|\ \ | | | | | | fix SI-5829: refinement typeref has a prefix
| * | fix SI-5829: refinement typeref has a prefixAdriaan Moors2012-05-241-0/+18
| |/
* | Merge pull request #626 from retronym/ticket/4818Adriaan Moors2012-05-262-0/+13
|\ \ | | | | | | Test case closes SI-4818
| * | Test case closes SI-4818Jason Zaugg2012-05-252-0/+13
| |/ | | | | | | Fixed between 2.10.0 M2 and M3, with both the old and new pattern matcher.
* | Merge pull request #630 from retronym/ticket/5041Adriaan Moors2012-05-261-0/+9
|\ \ | | | | | | Test case closes SI-5041.
| * | Test case closes SI-5041.Jason Zaugg2012-05-261-0/+9
| | |
* | | Test case closes SI-4911.Jason Zaugg2012-05-262-0/+17
|/ / | | | | | | The unchecked warning departed sometime between 4afae5be...278a225.
* | Merge pull request #625 from retronym/ticket/5318-3Adriaan Moors2012-05-256-0/+45
|\ \ | | | | | | SI-5318 Make implicit divergence checking PolyType aware.
| * | SI-5318 Make implicit divergence checking PolyType aware.Jason Zaugg2012-05-256-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replaces the two active subclasses of `SymCollector` with direct use of traversal methods of `Type`. Wildcard free class type parameters, not just method type parameters, when stripping the core type of candidate implicits. The spec doesn't make any such distinction, and the enclosed test, t5318c, crashes without this change.
* | | Merge pull request #613 from hubertp/issue/5821Adriaan Moors2012-05-254-1/+19
|\ \ \ | | | | | | | | Closes SI-5821.
| * | | Closes SI-5821.Hubert Plociniczak2012-05-244-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was an interesting one. Basically an erroneous import was creating an erroneous symbol for Array (similary for other symbols that were 'found' in this import) which was leading to all sorts of inconsistencies and spurious errors. This wasn't a bug in ContextErrors but rather something that existed for ages and was hidden from the general audience. Review by @paulp.
* | | | Merge pull request #623 from adriaanm/ticket/switch-warning-not-errorAdriaan Moors2012-05-251-0/+1
|\ \ \ \ | | | | | | | | | | don't error when not emitting required switch
| * | | | don't error when not emitting required switchAdriaan Moors2012-05-251-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | we don't handle switches with guards, whereas the old patmat did to ease the transition, let's not error out and see how we can resolve this
* | | | | Removing non-deterministic actor migration tests.Vojin Jovanovic2012-05-2522-1293/+0
|/ / / / | | | | | | | | | | | | Testing these issues takes significant amounts of time so I am temporarely removing them from the master. The issue is not in the code but in the tests output order.
* | | | Merge pull request #618 from axel22/issue/5428Adriaan Moors2012-05-252-0/+30
|\ \ \ \ | | | | | | | | | | Fixes SI-5428.
| * | | | Fixes SI-5428.Aleksandar Prokopec2012-05-242-0/+30
| | |_|/ | |/| |
* / | | Move implicit ExecutionContext to be determined by lexical scopephaller2012-05-241-0/+121
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Port of a pull request originally submitted by @havocp. - declare the invariant that all app callbacks have an associated ExecutionContext provided at the place the callback is passed to a method on Future - always run callbacks in their associated EC - since all callbacks have their own EC, Promise does not need one - "internal" callbacks don't need to defer execution either since we know the ultimate app callback will do so, therefore we can use an immediate executor for these
* | | Widen types in names/defaults transformations.Paul Phillips2012-05-232-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | We were getting away with this somehow, but the types are wrong after typer and that sort of thing is noticed by more people now. I took the opportunity to add our first -Ycheck:all test, which is at least as much about helping -Ycheck:all remain in good working order as it is about this test.
* | | Usability improvements to Origins.Paul Phillips2012-05-232-2/+2
| | |
* | | Pending and passing tests.Paul Phillips2012-05-238-3/+236
| | | | | | | | | | | | | | | | | | | | | | | | Move now-passing SI-963 test into neg. Test for partial specialization. Pending test for SI-5008. Pending test for SI-4649. Abstract array type test.
* | | Relax -Xlint warning for implicit classes. Closes SI-5809.Paul Phillips2012-05-232-0/+11
| | |
* | | more tests for SI-3761Lukas Rytz2012-05-234-1/+49
| | |
* | | Merge pull request #595 from som-snytt/ticket/3761-overload-byname-onlyLukas Rytz2012-05-232-0/+29
|\ \ \ | | | | | | | | SI-3761: Overload resolution fails on by-name parameter
| * | | SI-3761: Overload resolution fails on by-name parameter (amended per lrytz)Som Snytt2012-05-222-0/+7
| | | | | | | | | | | | | | | | Lukas noted the stopgap at methTypeArgs isn't needed. What! No black tie formals.
| * | | SI-3761: Overload resolution fails on by-name parameterSom Snytt2012-05-212-0/+22
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When isAsSpecific checks if method m applies to args of types of formal params of m1, a by-name parameter was converted to its underlying result type for the params (of m) but not the args (of m1). This had the useful effect of making m(A) more specific than m(=>A), which is the specified prioritization for implicit views, but also made m(=>A) and m(=>A, B*) ambiguous. To handle this edge case, the isCompatible test for A and =>A is made explicit, and by-name params are no longer converted.
* | | Merge pull request #575 from vjovanov/actors-migration-kitAdriaan Moors2012-05-2322-0/+1293
|\ \ \ | | | | | | | | Adding the Actor Migration Kit.
| * | | Adding the Actor Migration Kit.Vojin Jovanovic2012-05-1822-0/+1293
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Kit consists of: 1) The StashingActor which adopts an interface similar to Akka. 2) Props mockup for creating Akka like code 3) Pattern mockup 4) Test cases for every step in the migration. 5) MigrationSystem which will paired on the Akka side. Review of the code : @phaller Review of the build: @jsuereth
* | | | Merge pull request #601 from adriaanm/3f7b8b58748eb70aec4269f1ef63853b5ad4af60Adriaan Moors2012-05-2327-114/+170
|\ \ \ \ | | | | | | | | | | virtpatmat: treemaker approximation refactorings and exhaustivity
| * | | | Exhaustivity: TreeMakers as boolean propositionsAdriaan Moors2012-05-2226-114/+170
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We check exhaustivity by representing a match as a formula in finite-domain propositional logic (FDPL) that is false when the match may fail. The variables in the formula represent tested trees in the match (type tests/value equality tests). The approximation uses the same framework as the CSE analysis. A matrix of tree makers is turned into a DAG, where sharing represents the same value/type being tested. We reduce FDPL to Boolean PL as follows. For all assignments, V_i = c_i_j, we introduce a proposition P_i_j that is true iff V_i is equal to the constant c_i_j, for a given i, and all j, P_i_j are mutually exclusive (a variable cannot have multiple values). If the variable's domain is closed, we assert that one of P_i_j must be true for each i and some j. The conjunction of these propositions constitutes the equality axioms. After going through negational normal form to conjunctive normal form, we use a small SAT solver (the DPLL algorithm) to find a model under which the equational axioms hold but the match fails. The formula: EqAxioms /\ -MatchSucceeds. Note that match failure expresses nicely in CNF: the negation of each case (which yields a disjunction) is anded. We then turn this model into variable assignments (what's the variable (not) equal to, along with recursive assignments for its fields). Valid assignments (no ill-typed field assignments) are then presented to the user as counter examples. A counter example is a value, a type test, a constructor call or a wildcard. We prune the example set and only report the most general examples. (Finally, we sort the output to yield stable, i.e. testable, warning messages.) A match is only checked for exhaustivity when the type of the selector is "checkable" (has a sealed type or is a tuple with at least one component of sealed type). We consider statically known guard outcomes, but generally back off (don't check exhaustivity) when a match has guards or user-defined extractor calls. (Sometimes constant folding lets us statically decide a guard.) We ignore possibly failing null checks (which are performed before calling extractors, for example), though this could be done easily in the current framework. The problem is false positives. People don't usually put nulls in tuples or lists. To improve the exhaustivity checks, we rewrite `List()` to Nil. TODO: more general rewrite of List(a, b, ..., z) to `a :: b :: ... :: z`. When presenting counter examples, we represent lists in the user-friendly List(a,...,z) format. (Similarly for tuples.) There are no exhaustivity checks for a match-defined PartialFunction. misc notes: - fix pure case of dpll solver impure set (symbol that occurs both as a positive and negative literal) was always empty since I was looking for literals (which are not equal if positivity is not equal) but should have been looking for symbols - FDPL -> BoolPL translation collects all syms in props since propForEqualsTo generates an Or, must traverse the prop rather than assuming only top-level Syms are relevant... also, propForEqualsTo will not assume Or'ing a whole domain is equivalent to True (which it isn't, since the type test may fail in general) - improve counter example description - treat as constructor call when we either have definite type information about a real class, or we have no equality information at all, but the variable's type is a class and we gathered constraints about its fields (typically when selector is a tuple) - flatten a :: b :: ... :: Nil to List(a, b, ...) - don't print tuple constructor names, so instead of "Tuple2(a, b)", say "(a, b)" - filter out more statically impossible subtypes the static types convey more information than is actually checkable at run time this is good, as it allows us to narrow down the subtypes of a sealed type, however, when modeling the corresponding run-time checks we need to "erase" the uncheckable parts (using existentials so that the types are still well-kinded), so that we can use static subtyping as a sound model for dynamic type checks - experimental java enum handling seals enum class before, we created a refinement class as the placeholder for the sealed children it seems more direct to use the enum class for that this way, the new pattern matcher's exhaustiveness checker just works for java enums
| * | | | TreeMaker approximation refactorings and bug fixesAdriaan Moors2012-05-221-0/+0
| | |/ / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - TypeTestTreeMaker subsumes the old TypeTestTM and TypeAndEqualityTM its type- and equality-testing logic is configurable so that it can: - generate trees (main purpose) - check whether this tree maker is a pure type test - generate the proposition that models this tree maker (for exhaustivity and other analyses) - [CSE] subst binders of dropped tm's to stored ones somehow the refactoring broke the replacement of the binder of dropped treemakers by the binder of the reused treemaker when replacing TM1(x1 => ...) >> TM2(x2 => ...) >> TM3(x3 => ...) >> ... TM1'(x1' => ...) >> TM2'(x2' => ...) >> TM3(x3' => ...) >> ... by Memo1(x1 => ...) >> TM2(x2 => ...) >> Memo2(x3 => ...) >> ... Reuse(Memo2)... you need to replace x1' and x2' by x1 since TM2 tested a shared condition but was not memo-ised, that implies it simply passed x1 through to x3 unmodified, and x2' can simply use the stored x1 - type of first uniqued binder sets type of tree when approximating a tree of treemakers as a DAG, where sharing indicates the same value is tested, use the type of the binder that was first used to create a unique tree as the type of that tree, and thus all trees used for the same binder in the future - track substitution of alternatives when approximating - error on unswitchable @switch annotated matches if we can't turn a match (with more than two cases) into a switch, but the user insists, emit an error misc notes: - when all you need is nextBinder, FunTreeMaker is your guy - must pass flag to TypeTestTM for extractorarg test case TypeTestTreeMaker(prevBinder, testedBinder, expectedTp, nextBinderTp) (prevBinder eq testedBinder) does not imply it's a pure type test for an extractor call note that the expected type for an extractor argument is not a type pattern, thus we only do a classic type test -- the idea was to detect that case by noticing we're being called with the same previous and tested binder, but that case also arises for Typed patterns
* | | | Merge pull request #599 from som-snytt/ticket/5779-numeq-warnAdriaan Moors2012-05-221-0/+13
|\ \ \ \ | | | | | | | | | | SI-5779: Wrong warning message (comparing Number)
| * | | | SI-5779: Wrong warning message (comparing values of types Float/Double and ↵Som Snytt2012-05-211-0/+13
| |/ / / | | | | | | | | | | | | | | | | | | | | Number using `==' will always yield false) BoxesRuntime knows how to compare java.lang.Number, so we must not warn.
* | | | Merge pull request #602 from hubertp/issue/5735Adriaan Moors2012-05-222-0/+13
|\ \ \ \ | | | | | | | | | | Closes SI-5735. Review by @adriaanm.