Skip to content

Commit cd39cf7

Browse files
committed
Prevent a few more invalidations
1 parent a4e0f47 commit cd39cf7

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

base/char.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Char
4949
(::Type{AbstractChar})(x::Number) = Char(x)
5050
(::Type{T})(x::AbstractChar) where {T<:Union{Number,AbstractChar}} = T(codepoint(x))
5151
(::Type{T})(x::T) where {T<:AbstractChar} = x
52+
AbstractChar(x::AbstractChar) = x
5253

5354
"""
5455
ncodeunits(c::Char) -> Int
@@ -179,6 +180,7 @@ convert(::Type{AbstractChar}, x::Number) = Char(x) # default to Char
179180
convert(::Type{T}, x::Number) where {T<:AbstractChar} = T(x)
180181
convert(::Type{T}, x::AbstractChar) where {T<:Number} = T(x)
181182
convert(::Type{T}, c::AbstractChar) where {T<:AbstractChar} = T(c)
183+
convert(::Type{AbstractChar}, c::AbstractChar) = c
182184
convert(::Type{T}, c::T) where {T<:AbstractChar} = c
183185

184186
rem(x::AbstractChar, ::Type{T}) where {T<:Number} = rem(codepoint(x), T)

base/essentials.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ convert(::Type{Type}, x::Type) = x # the ssair optimizer is strongly dependent o
174174
# in the absence of inlining-enabled
175175
# (due to fields typed as `Type`, which is generally a bad idea)
176176

177+
Union{}(x::Union{}) = throw(MethodError(convert, (Union{}, x)))
178+
177179
"""
178180
@eval [mod,] ex
179181

0 commit comments

Comments
 (0)