Skip to content

Commit 015835f

Browse files
committed
implement getfield overloading
fix #16226 (close #16195) fix #16195
1 parent 9fe9d2c commit 015835f

File tree

11 files changed

+116
-91
lines changed

11 files changed

+116
-91
lines changed

base/boot.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export
140140
Expr, GotoNode, LabelNode, LineNumberNode, QuoteNode,
141141
GlobalRef, NewvarNode, SSAValue, Slot, SlotNumber, TypedSlot,
142142
# object model functions
143-
fieldtype, getfield, setfield!, nfields, throw, tuple, ===, isdefined, eval,
143+
fieldtype, nfields, throw, tuple, ===, isdefined, eval,
144144
# sizeof # not exported, to avoid conflicting with Base.sizeof
145145
# type reflection
146146
<:, typeof, isa, typeassert,

base/coreimg.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Main.Core.eval(Main.Core, :(baremodule Inference
44
using Core.Intrinsics
5-
import Core: print, println, show, write, unsafe_write, STDOUT, STDERR
5+
import Core: print, println, show, write, unsafe_write, STDOUT, STDERR, getfield, setfield!
66

77
ccall(:jl_set_istopmod, Void, (Any, Bool), Inference, false)
88

base/exports.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,8 @@ export
910910

911911
# types
912912
convert,
913+
getfield,
914+
setfield!,
913915
fieldoffset,
914916
fieldname,
915917
fieldnames,

base/namedtuple.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ another named tuple.
3535
function NamedTuple{names}(nt::NamedTuple) where {names}
3636
if @generated
3737
types = Tuple{(fieldtype(nt, n) for n in names)...}
38-
Expr(:new, :(NamedTuple{names, $types}), Any[ :(getfield(nt, $(QuoteNode(n)))) for n in names ]...)
38+
Expr(:new, :(NamedTuple{names, $types}), Any[ :(Core.getfield(nt, $(QuoteNode(n)))) for n in names ]...)
3939
else
4040
types = Tuple{(fieldtype(typeof(nt), n) for n in names)...}
41-
NamedTuple{names, types}(Tuple(getfield(nt, n) for n in names))
41+
NamedTuple{names, types}(Tuple(Core.getfield(nt, n) for n in names))
4242
end
4343
end
4444

@@ -47,11 +47,11 @@ end # if Base
4747
length(t::NamedTuple) = nfields(t)
4848
start(t::NamedTuple) = 1
4949
done(t::NamedTuple, iter) = iter > nfields(t)
50-
next(t::NamedTuple, iter) = (getfield(t, iter), iter + 1)
50+
next(t::NamedTuple, iter) = (Core.getfield(t, iter), iter + 1)
5151
endof(t::NamedTuple) = nfields(t)
52-
getindex(t::NamedTuple, i::Int) = getfield(t, i)
53-
getindex(t::NamedTuple, i::Symbol) = getfield(t, i)
54-
indexed_next(t::NamedTuple, i::Int, state) = (getfield(t, i), i+1)
52+
getindex(t::NamedTuple, i::Int) = Core.getfield(t, i)
53+
getindex(t::NamedTuple, i::Symbol) = Core.getfield(t, i)
54+
indexed_next(t::NamedTuple, i::Int, state) = (Core.getfield(t, i), i+1)
5555
isempty(::NamedTuple{()}) = true
5656
isempty(::NamedTuple) = false
5757

@@ -66,7 +66,7 @@ function show(io::IO, t::NamedTuple)
6666
n = nfields(t)
6767
for i = 1:n
6868
# if field types aren't concrete, show full type
69-
if typeof(getfield(t, i)) !== fieldtype(typeof(t), i)
69+
if typeof(Core.getfield(t, i)) !== fieldtype(typeof(t), i)
7070
show(io, typeof(t))
7171
print(io, "(")
7272
show(io, Tuple(t))
@@ -79,7 +79,7 @@ function show(io::IO, t::NamedTuple)
7979
else
8080
print(io, "(")
8181
for i = 1:n
82-
print(io, fieldname(typeof(t),i), " = "); show(io, getfield(t, i))
82+
print(io, fieldname(typeof(t),i), " = "); show(io, Core.getfield(t, i))
8383
if n == 1
8484
print(io, ",")
8585
elseif i < n
@@ -118,7 +118,7 @@ function map(f, nt::NamedTuple{names}, nts::NamedTuple...) where names
118118
if @generated
119119
N = length(names)
120120
M = length(nts)
121-
args = Expr[:(f($(Expr[:(getfield(nt, $j)), (:(getfield(nts[$i], $j)) for i = 1:M)...]...))) for j = 1:N]
121+
args = Expr[:(f($(Expr[:(Core.getfield(nt, $j)), (:(Core.getfield(nts[$i], $j)) for i = 1:M)...]...))) for j = 1:N]
122122
:( NT(($(args...),)) )
123123
else
124124
NT(map(f, map(Tuple, (nt, nts...))...))
@@ -164,12 +164,12 @@ function merge(a::NamedTuple{an}, b::NamedTuple{bn}) where {an, bn}
164164
if @generated
165165
names = merge_names(an, bn)
166166
types = merge_types(names, a, b)
167-
vals = Any[ :(getfield($(sym_in(n, bn) ? :b : :a), $(QuoteNode(n)))) for n in names ]
167+
vals = Any[ :(Core.getfield($(sym_in(n, bn) ? :b : :a), $(QuoteNode(n)))) for n in names ]
168168
:( NamedTuple{$names,$types}(($(vals...),)) )
169169
else
170170
names = merge_names(an, bn)
171171
types = merge_types(names, typeof(a), typeof(b))
172-
NamedTuple{names,types}(map(n->getfield(sym_in(n, bn) ? b : a, n), names))
172+
NamedTuple{names,types}(map(n->Core.getfield(sym_in(n, bn) ? b : a, n), names))
173173
end
174174
end
175175

@@ -205,8 +205,8 @@ end
205205
keys(nt::NamedTuple{names}) where {names} = names
206206
values(nt::NamedTuple) = Tuple(nt)
207207
haskey(nt::NamedTuple, key::Union{Integer, Symbol}) = isdefined(nt, key)
208-
get(nt::NamedTuple, key::Union{Integer, Symbol}, default) = haskey(nt, key) ? getfield(nt, key) : default
209-
get(f::Callable, nt::NamedTuple, key::Union{Integer, Symbol}) = haskey(nt, key) ? getfield(nt, key) : f()
208+
get(nt::NamedTuple, key::Union{Integer, Symbol}, default) = haskey(nt, key) ? Core.getfield(nt, key) : default
209+
get(f::Callable, nt::NamedTuple, key::Union{Integer, Symbol}) = haskey(nt, key) ? Core.getfield(nt, key) : f()
210210

211211
@pure function diff_names(an::Tuple{Vararg{Symbol}}, bn::Tuple{Vararg{Symbol}})
212212
names = Symbol[]
@@ -228,11 +228,11 @@ function structdiff(a::NamedTuple{an}, b::Union{NamedTuple{bn}, Type{NamedTuple{
228228
if @generated
229229
names = diff_names(an, bn)
230230
types = Tuple{Any[ fieldtype(a, n) for n in names ]...}
231-
vals = Any[ :(getfield(a, $(QuoteNode(n)))) for n in names ]
231+
vals = Any[ :(Core.getfield(a, $(QuoteNode(n)))) for n in names ]
232232
:( NamedTuple{$names,$types}(($(vals...),)) )
233233
else
234234
names = diff_names(an, bn)
235235
types = Tuple{Any[ fieldtype(typeof(a), n) for n in names ]...}
236-
NamedTuple{names,types}(map(n->getfield(a, n), names))
236+
NamedTuple{names,types}(map(n->Core.getfield(a, n), names))
237237
end
238238
end

base/sysimg.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
baremodule Base
44

55
using Core.Intrinsics
6+
getfield(x, f) = Core.getfield(x, f)
7+
setfield!(x, f, v) = Core.setfield!(x, f, convert(Core.fieldtype(Core.typeof(x), f), v))
8+
9+
getfield(x::Module, f::Symbol) = Core.getfield(x, f)
10+
setfield!(x::Module, f::Symbol, v) = Core.setfield!(x, f, v)
11+
getfield(x::Type, f::Symbol) = Core.getfield(x, f)
12+
setfield!(x::Type, f::Symbol, v) = Core.setfield!(x, f, v)
13+
getfield(x::Type, f::Int) = Core.getfield(x, f)
14+
setfield!(x::Type, f::Int, v) = Core.setfield!(x, f, v)
15+
616
ccall(:jl_set_istopmod, Void, (Any, Bool), Base, true)
717

818
function include(mod::Module, path::AbstractString)

base/tuple.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ NTuple
1818
length(t::Tuple) = nfields(t)
1919
endof(t::Tuple) = length(t)
2020
size(t::Tuple, d) = (d == 1) ? length(t) : throw(ArgumentError("invalid tuple dimension $d"))
21-
@eval getindex(t::Tuple, i::Int) = getfield(t, i, $(Expr(:boundscheck)))
22-
@eval getindex(t::Tuple, i::Real) = getfield(t, convert(Int, i), $(Expr(:boundscheck)))
21+
@eval getindex(t::Tuple, i::Int) = Core.getfield(t, i, $(Expr(:boundscheck)))
22+
@eval getindex(t::Tuple, i::Real) = Core.getfield(t, convert(Int, i), $(Expr(:boundscheck)))
2323
getindex(t::Tuple, r::AbstractArray{<:Any,1}) = ([t[ri] for ri in r]...,)
2424
getindex(t::Tuple, b::AbstractArray{Bool,1}) = length(b) == length(t) ? getindex(t, find(b)) : throw(BoundsError(t, b))
2525

src/julia-syntax.scm

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,7 @@
17521752
(if (and (pair? e) (eq? (car e) '|.|))
17531753
(let ((f (cadr e)) (x (caddr e)))
17541754
(cond ((or (eq? (car x) 'quote) (eq? (car x) 'inert) (eq? (car x) '$))
1755-
`(call (core getfield) ,f ,x))
1755+
`(call (top getfield) ,f ,x))
17561756
((eq? (car x) 'tuple)
17571757
(make-fuse f (cdr x)))
17581758
(else
@@ -2039,10 +2039,12 @@
20392039
,.(if (eq? aa a) '() `((= ,aa ,(expand-forms a))))
20402040
,.(if (eq? bb b) '() `((= ,bb ,(expand-forms b))))
20412041
,.(if (eq? rr rhs) '() `((= ,rr ,(expand-forms rhs))))
2042-
(call (core setfield!) ,aa ,bb
2043-
(call (top convert)
2044-
(call (core fieldtype) (call (core typeof) ,aa) ,bb)
2045-
,rr))
2042+
(call (top setfield!) ,aa ,bb
2043+
(if (call (top ===) (top setfield!) (core setfield!))
2044+
(call (top convert)
2045+
(call (core fieldtype) (call (core typeof) ,aa) ,bb)
2046+
,rr)
2047+
,rr))
20462048
(unnecessary ,rr)))))
20472049
((tuple)
20482050
;; multiple assignment

test/core.jl

Lines changed: 72 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -997,36 +997,44 @@ end
997997

998998
let
999999
local z = complex(3, 4)
1000-
v = Int[0,0]
1001-
for i=1:2
1002-
v[i] = getfield(z, i)
1000+
v = Int[0, 0]
1001+
for i = 1:2
1002+
v[i] = Core.getfield(z, i)
10031003
end
1004-
@test v == [3,4]
1005-
@test_throws BoundsError getfield(z, -1)
1006-
@test_throws BoundsError getfield(z, 0)
1007-
@test_throws BoundsError getfield(z, 3)
1004+
@test v == [3, 4]
1005+
@test_throws BoundsError(z, -1) Core.getfield(z, -1)
1006+
@test_throws BoundsError(z, 0) Core.getfield(z, 0)
1007+
@test_throws BoundsError(z, 3) Core.getfield(z, 3)
10081008

10091009
strct = LoadError("yofile", 0, "bad")
1010-
@test_throws BoundsError getfield(strct, 10)
1011-
@test_throws ErrorException setfield!(strct, 0, "")
1012-
@test_throws ErrorException setfield!(strct, 4, "")
1010+
@test nfields(strct) == 3 # sanity test
1011+
@test_throws BoundsError(strct, 10) Core.getfield(strct, 10)
1012+
@test_throws BoundsError(strct, 10) getfield(strct, 10)
1013+
@test_throws ErrorException("type LoadError is immutable") Core.setfield!(strct, 0, "")
1014+
@test_throws ErrorException("type LoadError is immutable") Core.setfield!(strct, 4, "")
1015+
@test_throws BoundsError(LoadError, 0) setfield!(strct, 0, "")
1016+
@test_throws BoundsError(LoadError, 4) setfield!(strct, 4, "")
10131017
@test strct.file == "yofile"
10141018
@test strct.line == 0
10151019
@test strct.error == "bad"
1016-
@test getfield(strct, 1) == "yofile"
1017-
@test getfield(strct, 2) == 0
1018-
@test getfield(strct, 3) == "bad"
1020+
@test Core.getfield(strct, 1) == "yofile"
1021+
@test Core.getfield(strct, 2) == 0
1022+
@test Core.getfield(strct, 3) == "bad"
10191023

10201024
mstrct = TestMutable("melm", 1, nothing)
1021-
setfield!(mstrct, 2, 8)
1025+
setfield!(mstrct, 2, 8.0)
10221026
@test mstrct.line == 8
1023-
setfield!(mstrct, 3, "hi")
1027+
@test_throws TypeError(:setfield!, "", Int, 8.0) Core.setfield!(mstrct, 2, 8.0)
1028+
Core.setfield!(mstrct, 3, "hi")
10241029
@test mstrct.error == "hi"
1025-
setfield!(mstrct, 1, "yo")
1030+
Core.setfield!(mstrct, 1, "yo")
10261031
@test mstrct.file == "yo"
1027-
@test_throws BoundsError getfield(mstrct, 10)
1028-
@test_throws BoundsError setfield!(mstrct, 0, "")
1029-
@test_throws BoundsError setfield!(mstrct, 4, "")
1032+
@test_throws BoundsError(mstrct, 10) Core.getfield(mstrct, 10)
1033+
@test_throws BoundsError(mstrct, 0) Core.setfield!(mstrct, 0, "")
1034+
@test_throws BoundsError(mstrct, 4) Core.setfield!(mstrct, 4, "")
1035+
@test_throws BoundsError(mstrct, 10) getfield(mstrct, 10)
1036+
@test_throws BoundsError(TestMutable, 0) setfield!(mstrct, 0, "")
1037+
@test_throws BoundsError(TestMutable, 4) setfield!(mstrct, 4, "")
10301038
end
10311039

10321040
# allow typevar in Union to match as long as the arguments contain
@@ -2175,10 +2183,9 @@ g7652() = fieldtype(DataType, :types)
21752183
h7652() = setfield!(a7652, 1, 2)
21762184
h7652()
21772185
@test a7652.a == 2
2178-
# commented out due to issue #16195: setfield! does not perform conversions
2179-
# i7652() = setfield!(a7652, 1, 3.0)
2180-
# i7652()
2181-
# @test a7652.a == 3
2186+
i7652() = setfield!(a7652, 1, 3.0)
2187+
i7652()
2188+
@test a7652.a == 3
21822189

21832190
# issue #7679
21842191
@test map(f->f(), Any[ ()->i for i=1:3 ]) == Any[1,2,3]
@@ -2358,49 +2365,53 @@ let
23582365
end
23592366

23602367
# pull request #9534
2361-
@test try; a,b,c = 1,2; catch ex; (ex::BoundsError).a === (1,2) && ex.i == 3; end
2362-
# @test try; [][]; catch ex; isempty((ex::BoundsError).a::Array{Any,1}) && ex.i == (1,); end # TODO: Re-enable after PLI
2363-
@test try; [][1,2]; catch ex; isempty((ex::BoundsError).a::Array{Any,1}) && ex.i == (1,2); end
2364-
@test try; [][10]; catch ex; isempty((ex::BoundsError).a::Array{Any,1}) && ex.i == (10,); end
2365-
f9534a() = (a=1+2im; getfield(a, -100))
2366-
f9534a(x) = (a=1+2im; getfield(a, x))
2367-
@test try; f9534a() catch ex; (ex::BoundsError).a === 1+2im && ex.i == -100; end
2368-
@test try; f9534a(3) catch ex; (ex::BoundsError).a === 1+2im && ex.i == 3; end
2369-
f9534b() = (a=(1,2.,""); a[5])
2370-
f9534b(x) = (a=(1,2.,""); a[x])
2371-
@test try; f9534b() catch ex; (ex::BoundsError).a == (1,2.,"") && ex.i == 5; end
2372-
@test try; f9534b(4) catch ex; (ex::BoundsError).a == (1,2.,"") && ex.i == 4; end
2373-
f9534c() = (a=(1,2.); a[3])
2374-
f9534c(x) = (a=(1,2.); a[x])
2375-
@test try; f9534c() catch ex; (ex::BoundsError).a === (1,2.) && ex.i == 3; end
2376-
@test try; f9534c(0) catch ex; (ex::BoundsError).a === (1,2.) && ex.i == 0; end
2377-
f9534d() = (a=(1,2,4,6,7); a[7])
2378-
f9534d(x) = (a=(1,2,4,6,7); a[x])
2379-
@test try; f9534d() catch ex; (ex::BoundsError).a === (1,2,4,6,7) && ex.i == 7; end
2380-
@test try; f9534d(-1) catch ex; (ex::BoundsError).a === (1,2,4,6,7) && ex.i == -1; end
2381-
f9534e(x) = (a=IOBuffer(); setfield!(a, x, 3))
2382-
@test try; f9534e(-2) catch ex; isa((ex::BoundsError).a,Base.IOBuffer) && ex.i == -2; end
2383-
f9534f() = (a=IOBuffer(); getfield(a, -2))
2384-
f9534f(x) = (a=IOBuffer(); getfield(a, x))
2385-
@test try; f9534f() catch ex; isa((ex::BoundsError).a,Base.IOBuffer) && ex.i == -2; end
2386-
@test try; f9534f(typemin(Int)+2) catch ex; isa((ex::BoundsError).a,Base.IOBuffer) && ex.i == typemin(Int)+2; end
2368+
@test_throws BoundsError((1, 2), 3) begin; a, b, c = 1, 2; end
2369+
let a = []
2370+
@test_broken try; a[]; catch ex; (ex::BoundsError).a === a && ex.i == (1,); end # TODO: Re-enable after PLI
2371+
@test_throws BoundsError(a, (1, 2)) a[1, 2]
2372+
@test_throws BoundsError(a, (10,)) a[10]
2373+
end
2374+
f9534a() = (a = 1 + 2im; Core.getfield(a, -100))
2375+
f9534a(x) = (a = 1 + 2im; Core.getfield(a, x))
2376+
@test_throws BoundsError(1 + 2im, -100) f9534a()
2377+
@test_throws BoundsError(1 + 2im, 3) f9534a(3)
2378+
f9534b() = (a = (1, 2., ""); a[5])
2379+
f9534b(x) = (a = (1, 2., ""); a[x])
2380+
@test_throws BoundsError((1, 2., ""), 5) f9534b()
2381+
@test_throws BoundsError((1, 2., ""), 4) f9534b(4)
2382+
f9534c() = (a = (1, 2.); a[3])
2383+
f9534c(x) = (a = (1, 2.); a[x])
2384+
@test_throws BoundsError((1, 2.), 3) f9534c()
2385+
@test_throws BoundsError((1, 2.), 0) f9534c(0)
2386+
f9534d() = (a = (1, 2, 4, 6, 7); a[7])
2387+
f9534d(x) = (a = (1, 2, 4, 6, 7); a[x])
2388+
@test_throws BoundsError((1, 2, 4, 6, 7), 7) f9534d()
2389+
@test_throws BoundsError((1, 2, 4, 6, 7), -1) f9534d(-1)
2390+
let a = IOBuffer()
2391+
f9534e(x) = Core.setfield!(a, x, 3)
2392+
@test_throws BoundsError(a, -2) f9534e(-2)
2393+
f9534f() = Core.getfield(a, -2)
2394+
f9534f(x) = Core.getfield(a, x)
2395+
@test_throws BoundsError(a, -2) f9534f()
2396+
@test_throws BoundsError(a, typemin(Int) + 2) f9534f(typemin(Int) + 2)
2397+
end
23872398
x9634 = 3
2388-
@test try; getfield(1+2im, x9634); catch ex; (ex::BoundsError).a === 1+2im && ex.i == 3; end
2389-
@test try; throw(BoundsError()) catch ex; !isdefined((ex::BoundsError), :a) && !isdefined((ex::BoundsError), :i); end
2390-
@test try; throw(BoundsError(Int)) catch ex; (ex::BoundsError).a == Int && !isdefined((ex::BoundsError), :i); end
2391-
@test try; throw(BoundsError(Int, typemin(Int))) catch ex; (ex::BoundsError).a == Int && (ex::BoundsError).i == typemin(Int); end
2392-
@test try; throw(BoundsError(Int, (:a,))) catch ex; (ex::BoundsError).a == Int && (ex::BoundsError).i == (:a,); end
2393-
f9534g(a,b,c...) = c[0]
2394-
@test try; f9534g(1,2,3,4,5,6) catch ex; (ex::BoundsError).a === (3,4,5,6) && ex.i == 0; end
2395-
f9534h(a,b,c...) = c[a]
2396-
@test f9534h(4,2,3,4,5,6) == 6
2397-
@test try; f9534h(5,2,3,4,5,6) catch ex; (ex::BoundsError).a === (3,4,5,6) && ex.i == 5; end
2399+
@test_throws BoundsError(1 + 2im, 3) Core.getfield(1 + 2im, x9634)
2400+
@test try; throw(BoundsError()); catch ex; !isdefined((ex::BoundsError), :a) && !isdefined((ex::BoundsError), :i); end
2401+
@test try; throw(BoundsError(Int)); catch ex; (ex::BoundsError).a == Int && !isdefined((ex::BoundsError), :i); end
2402+
@test_throws BoundsError(Int, typemin(Int)) throw(BoundsError(Int, typemin(Int)))
2403+
@test_throws BoundsError(Int, (:a,)) throw(BoundsError(Int, (:a,)))
2404+
f9534g(a, b, c...) = c[0]
2405+
@test_throws BoundsError((3, 4, 5, 6), 0) f9534g(1, 2, 3, 4, 5, 6)
2406+
f9534h(a, b, c...) = c[a]
2407+
@test f9534h(4, 2, 3, 4, 5, 6) == 6
2408+
@test_throws BoundsError((3, 4, 5, 6), 5) f9534h(5, 2, 3, 4, 5, 6)
23982409

23992410
# issue #7978, comment 332352438
24002411
f7978a() = 1
2401-
@test try; a, b = f7978a() catch ex; (ex::BoundsError).a == 1 && ex.i == 2; end
2412+
@test_throws BoundsError(1, 2) begin; a, b = f7978a(); end
24022413
f7978b() = 1, 2
2403-
@test try; a, b, c = f7978b() catch ex; (ex::BoundsError).a == (1, 2) && ex.i == 3; end
2414+
@test_throws BoundsError((1, 2), 3) begin; a, b, c = f7978b(); end
24042415

24052416
# issue #9535
24062417
counter9535 = 0

test/reflection.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -505,14 +505,14 @@ test_typed_ast_printing(g15714, Tuple{Vector{Float32}},
505505
@test used_dup_var_tested15714
506506
@test used_unique_var_tested15714
507507

508-
let li = typeof(getfield).name.mt.cache.func::Core.MethodInstance,
508+
let li = typeof(fieldtype).name.mt.cache.func::Core.MethodInstance,
509509
lrepr = string(li),
510510
mrepr = string(li.def),
511511
lmime = stringmime("text/plain", li),
512512
mmime = stringmime("text/plain", li.def)
513513

514-
@test lrepr == lmime == "MethodInstance for getfield(...)"
515-
@test mrepr == mmime == "getfield(...) in Core"
514+
@test lrepr == lmime == "MethodInstance for fieldtype(...)"
515+
@test mrepr == mmime == "fieldtype(...) in Core"
516516
end
517517

518518

test/stacktraces.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ let src = Meta.lower(Main, quote let x = 1 end end).args[1]::CodeInfo,
109109
repr = string(sf)
110110
@test repr == "Toplevel MethodInstance thunk at b:3"
111111
end
112-
let li = typeof(getfield).name.mt.cache.func::Core.MethodInstance,
112+
let li = typeof(fieldtype).name.mt.cache.func::Core.MethodInstance,
113113
sf = StackFrame(:a, :b, 3, li, false, false, 0),
114114
repr = string(sf)
115-
@test repr == "getfield(...) at b:3"
115+
@test repr == "fieldtype(...) at b:3"
116116
end
117117

118118
let ctestptr = cglobal((:ctest, "libccalltest")),

test/vecelement.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ const _llvmtypes = Dict{DataType, String}(
9090
"""
9191
return quote
9292
Base.@_inline_meta
93-
Base.llvmcall($exp, Vec{$N, $T}, Tuple{Vec{$N, $T}, Vec{$N, $T}}, x, y)
93+
Core.getfield(Base, :llvmcall)($exp, Vec{$N, $T}, Tuple{Vec{$N, $T}, Vec{$N, $T}}, x, y)
9494
end
9595
end
9696

0 commit comments

Comments
 (0)