defclass3.scm 932 B

12345678910111213141516171819202122232425262728293031323334353637
  1. ;; Test references to fields in superclasses,
  2. ;; of not-yet-compiled classes.
  3. ;; (Alas, references to methods doesn't work yet.)
  4. ;; Test subclass before superclass.
  5. (define-simple-class C1 (A1)
  6. ((bar) (list aval)))
  7. (define-simple-class A1 ()
  8. (aval ::integer)
  9. ((toString)::java.lang.String (format "A1[aval:~w]" aval))
  10. ((foo) aval)
  11. )
  12. (define-simple-class B1 (A1)
  13. ((bar) (list aval ));(foo)
  14. ((toString)::java.lang.String (format "B1[aval:~w]" aval)))
  15. (! b1 (B1 aval: 10))
  16. (format #t "b1:bar->~w~%" (b1:bar))
  17. ;; Output: b1:bar->(10)
  18. (define-class C2 (A2)
  19. ((bar) (list aval ;(foo)
  20. )))
  21. (define-class A2 ()
  22. (aval ::integer)
  23. ;((toString)::java.lang.String (format "A2[aval:~w]" aval))
  24. ;((foo) aval)
  25. )
  26. (define-class B2 (A2)
  27. ((bar) (list aval ));(foo)
  28. ((toString)::java.lang.String (format "B2[aval:~w]" aval)))
  29. (! b2 (B2 aval: 20))
  30. (format #t "b2:bar->~w~%" (b2:bar))
  31. ;; Output: b2:bar->(20)