From 144143c2970a1e874d74cdbd0f8c622d4282a3c3 Mon Sep 17 00:00:00 2001 From: wisberg Date: Mon, 16 Dec 2002 18:51:06 +0000 Subject: initial version --- tests/new/badCast/Driver.java | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/new/badCast/Driver.java (limited to 'tests/new/badCast/Driver.java') 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; + } +*/ +} -- cgit v1.2.3