File tree Expand file tree Collapse file tree 2 files changed +27
-5
lines changed Expand file tree Collapse file tree 2 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -13,12 +13,11 @@ Broadcast.broadcasted(::typeof(lazy), x) = LazyCast(x)
13
13
Broadcast. materialize (x:: LazyCast ) = x. value
14
14
15
15
16
- is_call (ex:: Expr ) =
17
- ex. head == :call && ! startswith (String (ex. args[1 ]), " ." )
16
+ is_call (ex) = isexpr (ex, :call ) && ! is_dotcall (ex)
18
17
19
- is_dotcall (ex:: Expr ) =
20
- (ex . head == :. && ex. args[2 ]. head === :tuple ) ||
21
- (ex . head == :call && startswith (String (ex. args[1 ]), " ." ))
18
+ is_dotcall (ex) =
19
+ (isexpr (ex, :.) && isexpr ( ex. args[2 ], :tuple ) ) ||
20
+ (isexpr (ex, :call ) && ex . args[ 1 ] isa Symbol && startswith (String (ex. args[1 ]), " ." ))
22
21
# e.g., `f.(x, y, z)` or `x .+ y .+ z`
23
22
24
23
lazy_expr (x) = x
Original file line number Diff line number Diff line change @@ -62,6 +62,29 @@ testparams = [
62
62
end
63
63
end
64
64
65
+ struct CustomProperty end
66
+ Base. getproperty (:: CustomProperty , property:: Symbol ) = property
67
+ Base. getproperty (:: CustomProperty , property) = property
68
+
69
+ complex_number = 1 + 2im
70
+ custom_property = CustomProperty ()
71
+
72
+ expressions_block = quote
73
+ complex_number. im # https://github.com/JuliaArrays/LazyArrays.jl/pull/69
74
+ custom_property." property"
75
+ end
76
+ testparams = [
77
+ (" $(rmlines (ex)) " , ex) for ex in expressions_block. args if ex isa Expr
78
+ ]
79
+
80
+ @testset " @~ non-lazy" begin
81
+ @testset " $label " for (label, ex) in testparams
82
+ desired = @eval $ ex
83
+ actual = @eval @~ $ ex
84
+ @test actual === desired
85
+ end
86
+ end
87
+
65
88
@testset " @~ laziness" begin
66
89
A = ones (1 , 1 )
67
90
x = [1 ]
You can’t perform that action at this time.
0 commit comments