Skip to content

Commit 778e079

Browse files
authored
Add explicit imports for types and fix bugs (JuliaLang#57302)
I was playing with strengthening the semantics around JuliaLang#57290. However, the particular change I was trying turned out too breaking (I may try a weaker version of it). Still, there were a number of good changes found in two categories: 1. We should explicitly import types when defining constructors. This has been allowed for a long time, but we may want to consider removing it, especially given the new binding semantics which make it more confusing as in JuliaLang#57290. 2. There were a couple of places where I don't think it was intended for generic functions in question not to extend Base.
1 parent e553fc8 commit 778e079

File tree

16 files changed

+36
-12
lines changed

16 files changed

+36
-12
lines changed

Compiler/src/Compiler.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ using Base.Order
7272

7373
import Base: ==, _topmod, append!, convert, copy, copy!, findall, first, get, get!,
7474
getindex, haskey, in, isempty, isready, iterate, iterate, last, length, max_world,
75-
min_world, popfirst!, push!, resize!, setindex!, size
75+
min_world, popfirst!, push!, resize!, setindex!, size, intersect
7676

7777
const getproperty = Core.getfield
7878
const setproperty! = Core.setfield!

base/Base_compiler.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ function cld end
224224
function fld end
225225

226226
# Lazy strings
227+
import Core: String
227228
include("strings/lazy.jl")
228229

229230
# array structures

base/bool.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3+
import Core: Bool
4+
35
# promote Bool to any other numeric type
46
promote_rule(::Type{Bool}, ::Type{T}) where {T<:Number} = T
57

base/char.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3+
import Core: AbstractChar, Char
4+
35
"""
46
The `AbstractChar` type is the supertype of all character implementations
57
in Julia. A character represents a Unicode code point, and can be converted

base/coreir.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ while processing a call, then `Conditional` everywhere else.
4949
"""
5050
Core.InterConditional
5151

52-
InterConditional(var::SlotNumber, @nospecialize(thentype), @nospecialize(elsetype)) =
52+
Core.InterConditional(var::SlotNumber, @nospecialize(thentype), @nospecialize(elsetype)) =
5353
InterConditional(slot_id(var), thentype, elsetype)

base/deprecated.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ end
353353
@deprecate one(i::CartesianIndex) oneunit(i)
354354
@deprecate one(I::Type{CartesianIndex{N}}) where {N} oneunit(I)
355355

356+
import .MPFR: BigFloat
356357
@deprecate BigFloat(x, prec::Int) BigFloat(x; precision=prec)
357358
@deprecate BigFloat(x, prec::Int, rounding::RoundingMode) BigFloat(x, rounding; precision=prec)
358359
@deprecate BigFloat(x::Real, prec::Int) BigFloat(x; precision=prec)

base/filesystem.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ export File,
137137
S_IROTH, S_IWOTH, S_IXOTH, S_IRWXO
138138

139139
import .Base:
140-
IOError, _UVError, _sizeof_uv_fs, check_open, close, eof, eventloop, fd, isopen,
141-
bytesavailable, position, read, read!, readavailable, seek, seekend, show,
140+
IOError, _UVError, _sizeof_uv_fs, check_open, close, closewrite, eof, eventloop, fd, isopen,
141+
bytesavailable, position, read, read!, readbytes!, readavailable, seek, seekend, show,
142142
skip, stat, unsafe_read, unsafe_write, write, transcode, uv_error,
143143
setup_stdio, rawhandle, OS_HANDLE, INVALID_OS_HANDLE, windowserror, filesize,
144-
isexecutable, isreadable, iswritable, MutableDenseArrayType
144+
isexecutable, isreadable, iswritable, MutableDenseArrayType, truncate
145145

146146
import .Base.RefValue
147147

base/float.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
const IEEEFloat = Union{Float16, Float32, Float64}
44

5+
import Core: Float16, Float32, Float64, AbstractFloat
6+
import Core: Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128
7+
58
## floating point traits ##
69

710
"""

base/gmp.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import .Base: *, +, -, /, <, <<, >>, >>>, <=, ==, >, >=, ^, (~), (&), (|), xor,
1313
sign, hastypemax, isodd, iseven, digits!, hash, hash_integer, top_set_bit,
1414
clamp, unsafe_takestring
1515

16+
import Core: Signed, Float16, Float32, Float64
17+
1618
if Clong == Int32
1719
const ClongMax = Union{Int8, Int16, Int32}
1820
const CulongMax = Union{UInt8, UInt16, UInt32}

base/hamt.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,19 +239,19 @@ or grows the HAMT by inserting a new trie instead.
239239
end
240240
end
241241

242-
length(::Leaf) = 1
243-
length(trie::HAMT) = sum((length(trie.data[i]) for i in eachindex(trie.data)), init=0)
242+
Base.length(::Leaf) = 1
243+
Base.length(trie::HAMT) = sum((length(trie.data[i]) for i in eachindex(trie.data)), init=0)
244244

245-
isempty(::Leaf) = false
246-
function isempty(trie::HAMT)
245+
Base.isempty(::Leaf) = false
246+
function Base.isempty(trie::HAMT)
247247
if islevel_empty(trie)
248248
return true
249249
end
250250
return all(isempty(trie.data[i]) for i in eachindex(trie.data))
251251
end
252252

253253
# DFS
254-
function iterate(trie::HAMT, state=nothing)
254+
function Base.iterate(trie::HAMT, state=nothing)
255255
if state === nothing
256256
state = (;parent=nothing, trie, i=1)
257257
end

0 commit comments

Comments
 (0)