aboutsummaryrefslogtreecommitdiffstats
path: root/tests/new/badCast
diff options
context:
space:
mode:
authorwisberg <wisberg>2002-12-16 18:51:06 +0000
committerwisberg <wisberg>2002-12-16 18:51:06 +0000
commit144143c2970a1e874d74cdbd0f8c622d4282a3c3 (patch)
treeb12383d3d9e76c7e1f25f7fbec83051ef17f81fb /tests/new/badCast
parentfafae443719b26159ab2d7dac1c9b46b5e00b671 (diff)
downloadaspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz
aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip
initial version
Diffstat (limited to 'tests/new/badCast')
-rw-r--r--tests/new/badCast/Driver.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/new/badCast/Driver.java b/tests/new/badCast/Driver.java
new file mode 100644
index 000000000..1a6c04674
--- /dev/null
+++ b/tests/new/badCast/Driver.java
@@ -0,0 +1,46 @@
+import org.aspectj.testing.Tester;
+
+// PR#275 & 276 cast error generated by ajc when type not in signature
+
+public class Driver {
+ public static void main(String[] args) { test(); }
+
+ public static void test() {
+ Tester.checkEqual(new SourcePane().go(), -10);
+ }
+}
+
+class SourcePane {
+ public int go() {
+ Location location = new Location();
+ return location.lineNumber();
+ }
+}
+
+class Location {
+ public int lineNumber() {
+ return 10;
+ }
+}
+
+aspect DriverAspect {
+
+ pointcut locationLineNumber(Location loc):
+ //XXX Fails with a star
+ //calls(int *.lineNumber()) && within(SourcePane);
+ //calls(int loc.lineNumber()) && within(SourcePane);
+ target(loc) && call(int Location.lineNumber()) && within(SourcePane);
+ int around(Location loc): locationLineNumber(loc) {
+ int result = proceed(loc);
+ return result * -1;
+ }
+// The following code won't report the cast error and will work:
+/*
+ pointcut locationLineNumber(SourcePane s, Location loc):
+ calls(loc, int lineNumber()) & within(s);
+ static around(SourcePane s, Location loc) returns int: locationLineNumber(s, loc) {
+ int result = proceed(s, loc);
+ return result * -1;
+ }
+*/
+}