From cbb9f7bdf6e9a46577c2e0c08adfd0db06900be5 Mon Sep 17 00:00:00 2001 From: Kathy Gray Date: Sat, 21 Jan 2006 23:14:52 +0000 Subject: [PATCH] Bug correction for classes with private methods svn: r1920 --- collects/profj/to-scheme.ss | 6 +++--- collects/tests/profj/advanced-tests.ss | 26 ++++++++++++++++++++------ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/collects/profj/to-scheme.ss b/collects/profj/to-scheme.ss index c5ae70348c..860e73940c 100644 --- a/collects/profj/to-scheme.ss +++ b/collects/profj/to-scheme.ss @@ -509,7 +509,7 @@ (restricted-methods (make-method-names ;(append (accesses-package methods) (accesses-protected methods);) overridden-methods)) - #;(make-gen-name + (make-gen-name (lambda (m) (build-generic-name (class-name) ((if (constructor? (id-string (method-name m))) build-constructor-name mangle-method-name) @@ -520,7 +520,7 @@ (append (accesses-public methods) (accesses-package methods) (accesses-protected methods)))) - #;(private-generics (map make-gen-name (accesses-private methods))) + (private-generics (map make-gen-name (accesses-private methods))) (names-for-dynamic (generate-dynamic-names (append (accesses-public methods) (accesses-package methods) (accesses-protected methods)) @@ -660,7 +660,7 @@ (define private-methods ,(if (null? (accesses-private methods)) '(make-hash-table) - (build-method-table (accesses-private methods) null #;private-generics))) + (build-method-table (accesses-private methods) private-generics))) ,@(map (lambda (i) (translate-initialize (initialize-static i) (initialize-block i) diff --git a/collects/tests/profj/advanced-tests.ss b/collects/tests/profj/advanced-tests.ss index 449a308896..d0ddf89928 100644 --- a/collects/tests/profj/advanced-tests.ss +++ b/collects/tests/profj/advanced-tests.ss @@ -4,12 +4,12 @@ (prepare-for-tests "Advanced") ;;Execution tests without errors - - (interact-test - 'advanced - '("null.m()") - '(error) - "Calling a method on null") + + (execute-test + "public class X { + private int x() { return 3; } + }" + 'advanced #f "Class with private method") (execute-test "public class Something { @@ -228,6 +228,20 @@ class WeeklyPlanner{ ;;Interaction tests, mix of right and error + (interact-test + "public class X { + private int x() { return 3; } + }" + 'advanced '("X y = new X();" "y.x()") + '((void) error) "Creating class with private method, and trying to access the method") + + + (interact-test + 'advanced + '("null.m()") + '(error) + "Calling a method on null") + (interact-test 'advanced (list "new int[3] instanceof int[] && true" "((int[]) new int[3])[1]" "3/2")