summaryrefslogtreecommitdiff
path: root/test/files/neg/unchecked-abstract.check
Commit message (Collapse)AuthorAgeFilesLines
* SI-8597 Improved pattern unchecked warningsJason Zaugg2014-11-091-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The spec says that `case _: List[Int]` should be always issue an unchecked warning: > Types which are not of one of the forms described above are > also accepted as type patterns. However, such type patterns > will be translated to their erasure (§3.7). The Scala compiler > will issue an “unchecked” warning for these patterns to flag > the possible loss of type-safety. But the implementation goes a little further to omit warnings based on the static type of the scrutinee. As a trivial example: def foo(s: Seq[Int]) = s match { case _: List[Int] => } need not issue this warning. These discriminating unchecked warnings are domain of `CheckabilityChecker`. Let's deconstruct the reported bug: def nowarn[T] = (null: Any) match { case _: Some[T] => } We used to determine that if the first case matched, the scrutinee type would be `Some[Any]` (`Some` is covariant). If this statically matches `Some[T]` in a pattern context, we don't need to issue an unchecked warning. But, our blanket use of `existentialAbstraction` in `matchesPattern` loosened the pattern type to `Some[Any]`, and the scrutinee type was deemed compatible. I've added a new method, `scrutConformsToPatternType` which replaces pattern type variables by wildcards, but leaves other abstract types intact in the pattern type. We have to use this inside `CheckabilityChecker` only. If we were to make `matchesPattern` stricter in the same way, tests like `pos/t2486.scala` would fail. I have introduced a new symbol test to (try to) identify pattern type variables introduced by `typedBind`. Its not pretty, and it might be cleaner to reserve a new flag for these. I've also included a test variation exercising with nested matches. The pattern type of the inner case can't, syntactically, refer to the pattern type variable of the enclosing case. If it could, we would have to be more selective in our wildcarding in `ptMatchesPatternType` by restricting ourselves to type variables associated with the closest enclosing `CaseDef`. As some further validation of the correctness of this patch, four stray warnings have been teased out of neg/unchecked-abstract.scala I also had to changes `typeArgsInTopLevelType` to extract the type arguments of `Array[T]` if `T` is an abstract type. This avoids the "Checkability checker says 'Uncheckable', but uncheckable type cannot be found" warning and consequent overly lenient analysis. Without this change, the warning was suppressed for: def warnArray[T] = (null: Any) match { case _: Array[T] => }
* Merge remote-tracking branch 'origin/2.10.0-wip' into merge-2.10Paul Phillips2012-10-071-16/+16
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * origin/2.10.0-wip: MethodSymbol.params => MethodSymbol.paramss SI-6471 Update jquery from 1.4.2 to 1.8.2 undeprecates manifests for 2.10.0 SI-6451: Rename classes in `unchecked-abstract.scala` test. Put more implementation restrictions on value classes. Fixed problem in SI-6408 Revised restrictions for value classes and unversal traits SI-6436 Handle ambiguous string processors fixes a bug in a weak cache in runtime reflection Conflicts: test/files/neg/classmanifests_new_deprecations.check test/files/neg/unchecked-abstract.check
| * SI-6451: Rename classes in `unchecked-abstract.scala` test.Grzegorz Kossakowski2012-10-031-16/+16
| | | | | | | | | | | | | | | | | | | | As reported Miguel, `Con` is problematic name of a class on Windows and makes this test to fail. Renamed classes to something else which hopefully make Windows build happy again. Closes SI-6451. Review by @magarciaEPFL or @paulp.
* | Merge branch '2.10.x' into 210-mergePaul Phillips2012-09-281-9/+11
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 2.10.x: (37 commits) Added logic and tests for unchecked refinements. Moved isNonRefinementClassType somewhere logical. Moved two tests to less breaky locations. Nailed down the "impossible match" logic. Finish docs for string interpolation. moves Context.ParseError outside the cake revives macros.Infrastructure moves Context.runtimeUniverse to TreeBuild.mkRuntimeUniverseRef a more precise type for Context.mirror gets rid of macros.Infrastructure simplifies Context.Run and Context.CompilationUnit exposes Position.source as SourceFile removes extraneous stuff from macros.Infrastructure merges macros.CapturedVariables into macros.Universe merges macros.Exprs and macros.TypeTags into Context removes front ends from scala-reflect.jar PositionApi => Position hides BuildUtils from Scaladoc MirrorOf => Mirror docs.pre-lib now checks for mods in reflect ... Conflicts: test/files/neg/t4302.check test/files/neg/unchecked.check test/files/neg/unchecked2.check
* Nailed down the "impossible match" logic.Paul Phillips2012-09-271-0/+25
I will again defer to a comment. /** Given classes A and B, can it be shown that nothing which is * an A will ever be a subclass of something which is a B? This * entails not only showing that !(A isSubClass B) but that the * same is true of all their subclasses. Restated for symmetry: * the same value cannot be a member of both A and B. * * 1) A must not be a subclass of B, nor B of A (the trivial check) * 2) One of A or B must be completely knowable (see isKnowable) * 3) Assuming A is knowable, the proposition is true if * !(A' isSubClass B) for all A', where A' is a subclass of A. * * Due to symmetry, the last condition applies as well in reverse. */