Skip to content

Commit ffbdbe7

Browse files
authored
Merge pull request #21182 from JuliaLang/jb/fix21178
fix #21178, lowering of static params with `<:T` syntax
2 parents f65b8ab + 58f9f20 commit ffbdbe7

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/julia-syntax.scm

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -228,15 +228,16 @@
228228

229229
;; extract static parameter names from a (method ...) expression
230230
(define (method-expr-static-parameters m)
231-
(if (eq? (car (caddr m)) 'block)
232-
(let ((lst '()))
233-
(pattern-replace
234-
(pattern-set
235-
(pattern-lambda (= v (call (core (-/ TypeVar)) (quote T) ...))
236-
(begin (set! lst (cons T lst)) __)))
237-
(butlast (cdr (caddr m))))
238-
(reverse! lst))
239-
'()))
231+
(let ((type-ex (caddr m)))
232+
(if (eq? (car type-ex) 'block)
233+
;; extract ssavalue labels of sparams from the svec-of-sparams argument to `method`
234+
(let ((sp-ssavals (cddr (last (last type-ex)))))
235+
(map (lambda (a) ;; extract T from (= v (call (core TypeVar) (quote T) ...))
236+
(cadr (caddr (caddr a))))
237+
(filter (lambda (e)
238+
(and (pair? e) (eq? (car e) '=) (member (cadr e) sp-ssavals)))
239+
(cdr type-ex))))
240+
'())))
240241

241242
;; expressions of the form a.b.c... where everything is a symbol
242243
(define (sym-ref? e)

test/core.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4782,3 +4782,8 @@ let a = Array{Core.TypeofBottom, 1}(2)
47824782
@test a[1] == Union{}
47834783
@test a == [Union{}, Union{}]
47844784
end
4785+
4786+
# issue #21178
4787+
struct F21178{A,B} end
4788+
b21178(::F1,::F2) where {B1,B2,F1<:F21178{B1,<:Any},F2<:F21178{B2}} = F1,F2,B1,B2
4789+
@test b21178(F21178{1,2}(),F21178{1,2}()) == (F21178{1,2}, F21178{1,2}, 1, 1)

0 commit comments

Comments
 (0)