From a56c33b6a470939a1396015972f09e19dc493245 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 27 Sep 2010 19:51:27 +0000 Subject: Bringing the tree and icode checkers back to life. build/pack/bin/scalac -d /tmp -Ycheck-debug -Ycheck:all \ src/compiler/scala/tools/nsc/Global.scala That blows up in constructors as most files do, so also try it with -Ycheck:icode to see the pretty icode output (for a little while anyway, after which it will again blow up.) Our work has only just begun! See test/checker-tests/fail*.scala for 11 examples of places where the checker cries foul. Many of them are telling us about real issues and we should listen, but I will need help to figure out which are legitimate and which should be eliminated by altering the checkers. This patch also hacks on some territory the checkers drew me into, especially TypeKinds, where I figured anything which had been commented out since 2005 was fair game. (Optional) review by dragos. (The one place I know I could use a look is in Checkers.scala, because I had to relax some checks and add at least one newer opcode.) --- test/checker-tests/fail10.scala | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test/checker-tests/fail10.scala (limited to 'test/checker-tests/fail10.scala') diff --git a/test/checker-tests/fail10.scala b/test/checker-tests/fail10.scala new file mode 100644 index 0000000000..6d4e6c27c9 --- /dev/null +++ b/test/checker-tests/fail10.scala @@ -0,0 +1,23 @@ +class ClassCounts extends scala.collection.mutable.HashMap[Class[_], Int] { } + +class A { + def f(xs: ClassCounts) { + // ok + xs(getClass) = xs(getClass) + 1 + // not ok + xs(getClass) += 1 + } +} + +// [Not checkable: parser] +// [Not checkable: namer] +// [Not checkable: packageobjects] +// [Now checking: typer] +// test/checker-tests/fail10.scala:8: error: +// **** ERROR DURING INTERNAL CHECKING **** +// type mismatch; +// found : java.lang.Class[?0(in value ev$1)] where type ?0(in value ev$1) +// required: java.lang.Class[?0(in method f)] where type ?0(in method f) +// xs(getClass) += 1 +// ^ +// one error found -- cgit v1.2.3