File tree Expand file tree Collapse file tree 2 files changed +48
-1
lines changed
Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -27,3 +27,32 @@ test: "two-method nested send expression not refactorable to send+"
2727(define (f obj x y)
2828 (send (send obj m1 x) m2 y))
2929--------------------
30+
31+
32+ test: "instantiate without by-name arguments refactorable to make-object "
33+ --------------------
34+ (define (f cls x y z)
35+ (instantiate cls (x y z)))
36+ --------------------
37+ --------------------
38+ (define (f cls x y z)
39+ (make-object cls x y z))
40+ --------------------
41+
42+
43+ test: "instantiate without by-position arguments refactorable to new "
44+ --------------------
45+ (define (f cls x y z)
46+ (instantiate cls () [x x] [y y] [z z]))
47+ --------------------
48+ --------------------
49+ (define (f cls x y z)
50+ (new cls [x x] [y y] [z z]))
51+ --------------------
52+
53+
54+ test: "instantiate without any arguments not refactorable "
55+ --------------------
56+ (define (f cls)
57+ (instantiate cls ()))
58+ --------------------
Original file line number Diff line number Diff line change 4242 (send+ chain.initial-object (chain.method chain.arg ... ) ... ))
4343
4444
45+ (define-refactoring-rule instantiate-to-make-object
46+ #:description "The `instantiate` form is for mixing positional and by-name constructor arguments. \
47+ When no by-name arguments are needed, use `make-object` instead. "
48+ #:literals (instantiate )
49+ (instantiate cls (by-position-arg ...+))
50+ (make-object cls by-position-arg ... ))
51+
52+
53+ (define-refactoring-rule instantiate-to-new
54+ #:description "The `instantiate` form is for mixing positional and by-name constructor arguments. \
55+ When no positional arguments are needed, use `new` instead. "
56+ #:literals (instantiate )
57+ (instantiate cls () by-name-arg ...+)
58+ (new cls by-name-arg ... ))
59+
60+
4561(define-refactoring-suite class-shortcuts
46- #:rules (send-chain-to-send+))
62+ #:rules (instantiate-to-make-object
63+ instantiate-to-new
64+ send-chain-to-send+))
You can’t perform that action at this time.
0 commit comments