From f47e7251ef5ab1e692b258d8351e0275765aa958 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Wed, 20 Jan 2021 02:13:00 +0900 Subject: [PATCH] tweaks for inter-procedural constraint back-prop' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit note that the changes for `isnothing` and `ismissing` aren't necessary, but they reduce the number of method definitions for good reason; the less the number of methods they have, the better we can back-propagate type constraints, because even after a package defines their own new methods for them we can keep to use our `InterConditional` logic as far as far as the number of methods is [≤3](https://github.com/JuliaLang/julia/blob/5c6e21edbfd8f0c7d16ea01c91d1c75c30d4eaa1/base/compiler/types.jl#L119) --- base/essentials.jl | 3 +-- base/show.jl | 2 +- base/some.jl | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/base/essentials.jl b/base/essentials.jl index 4c7e68a7e6ac69..62a63afa55576f 100644 --- a/base/essentials.jl +++ b/base/essentials.jl @@ -817,8 +817,7 @@ const missing = Missing() Indicate whether `x` is [`missing`](@ref). """ -ismissing(::Any) = false -ismissing(::Missing) = true +ismissing(x) = x === missing function popfirst! end diff --git a/base/show.jl b/base/show.jl index 6db1a414f53d38..b668296f875b44 100644 --- a/base/show.jl +++ b/base/show.jl @@ -1382,7 +1382,7 @@ function operator_associativity(s::Symbol) end is_expr(@nospecialize(ex), head::Symbol) = isa(ex, Expr) && (ex.head === head) -is_expr(@nospecialize(ex), head::Symbol, n::Int) = is_expr(ex, head) && length((ex::Expr).args) == n +is_expr(@nospecialize(ex), head::Symbol, n::Int) = is_expr(ex, head) && length(ex.args) == n is_quoted(ex) = false is_quoted(ex::QuoteNode) = true diff --git a/base/some.jl b/base/some.jl index 1f5624502a5837..272ed0e00ce318 100644 --- a/base/some.jl +++ b/base/some.jl @@ -65,8 +65,7 @@ Return `true` if `x === nothing`, and return `false` if not. !!! compat "Julia 1.1" This function requires at least Julia 1.1. """ -isnothing(::Any) = false -isnothing(::Nothing) = true +isnothing(x) = x === nothing """