Permalink
Browse files

Rename subtype to issubtype

  • Loading branch information...
1 parent 238fa74 commit 187ad98ef697af02bd173cab08618b10fbdc2742 @kmsquire kmsquire committed Aug 23, 2013
Showing with 47 additions and 47 deletions.
  1. +1 −1 base/boot.jl
  2. +1 −1 base/darray.jl
  3. +15 −15 base/inference.jl
  4. +1 −1 base/int.jl
  5. +1 −1 base/operators.jl
  6. +1 −1 base/reflection.jl
  7. +2 −2 base/set.jl
  8. +1 −1 contrib/julia.lang
  9. +2 −2 doc/stdlib/base.rst
  10. +1 −1 src/builtins.c
  11. +21 −21 test/core.jl
View
@@ -138,7 +138,7 @@ export
setfield, yieldto, throw, tuple, tuplelen, tupleref, is, ===, isdefined,
convert_default, convert_tuple, kwcall,
# type reflection
- subtype, typeassert, typeof, apply_type, isa,
+ issubtype, typeassert, typeof, apply_type, isa,
# method reflection
applicable, invoke, method_exists,
# constants
View
@@ -164,7 +164,7 @@ end
function convert{S,T,N}(::Type{Array{S,N}}, s::SubDArray{T,N})
I = s.indexes
d = s.parent
- if isa(I,(Range1{Int}...)) && subtype(S,T) && subtype(T,S)
+ if isa(I,(Range1{Int}...)) && issubtype(S,T) && issubtype(T,S)
l = locate(d, map(first, I)...)
if isequal(d.indexes[l...], I)
# SubDArray corresponds to a chunk
View
@@ -118,7 +118,7 @@ t_func[eval(Core.Intrinsics,:cglobal)] =
(1, 2, (fptr, t...)->(isempty(t) ? Ptr{Void} :
isType(t[1]) ? Ptr{t[1].parameters[1]} : Ptr))
t_func[is] = (2, 2, cmp_tfunc)
-t_func[subtype] = (2, 2, cmp_tfunc)
+t_func[issubtype] = (2, 2, cmp_tfunc)
t_func[isa] = (2, 2, cmp_tfunc)
t_func[isdefined] = (1, 2, (args...)->Bool)
t_func[Union] = (0, Inf,
@@ -131,31 +131,31 @@ t_func[method_exists] = (2, 2, cmp_tfunc)
t_func[applicable] = (1, Inf, (f, args...)->Bool)
t_func[tuplelen] = (1, 1, x->Int)
t_func[arraylen] = (1, 1, x->Int)
-#t_func[arrayref] = (2,Inf,(a,i...)->(isa(a,DataType) && subtype(a,Array) ?
+#t_func[arrayref] = (2,Inf,(a,i...)->(isa(a,DataType) && issubtype(a,Array) ?
# a.parameters[1] : Any))
#t_func[arrayset] = (3, Inf, (a,v,i...)->a)
#arraysize_tfunc(a, d) = Int
arraysize_tfunc = function (a, d...)
if !is(d,())
return Int
end
- if isa(a,DataType) && subtype(a,Array)
+ if isa(a,DataType) && issubtype(a,Array)
N = a.parameters[2]
return isa(N,Int) ? NTuple{N,Int} : (Int...)
else
return (Int...)
end
end
t_func[arraysize] = (1, 2, arraysize_tfunc)
-t_func[pointerref] = (2,2,(a,i)->(isa(a,DataType)&&subtype(a,Ptr) ? a.parameters[1] : Any))
+t_func[pointerref] = (2,2,(a,i)->(isa(a,DataType) && issubtype(a,Ptr) ? a.parameters[1] : Any))
t_func[pointerset] = (3, 3, (a,v,i)->a)
function static_convert(to::ANY, from::ANY)
if !isa(to,Tuple) || !isa(from,Tuple)
if isa(to,TypeVar)
return to
end
- if subtype(from, to)
+ if issubtype(from, to)
return from
end
t = typeintersect(from,to)
@@ -379,7 +379,7 @@ function builtin_tfunction(f::ANY, args::ANY, argtypes::ANY)
return None
end
a = argtypes[1]
- return (isa(a,DataType) && subtype(a,Array) ?
+ return (isa(a,DataType) && issubtype(a,Array) ?
a.parameters[1] : Any)
elseif is(f,Expr)
if length(argtypes) < 1
@@ -773,7 +773,7 @@ function abstract_eval(e::ANY, vtypes, sv::StaticVarInfo)
t0 = abstract_eval(e.args[1], vtypes, sv)
# intersect with Any to remove Undef
t = typeintersect(t0, Any)
- if is(t,None) && subtype(Undef,t0)
+ if is(t,None) && issubtype(Undef,t0)
# the first time we see this statement the variable will probably
# be Undef; return None so this doesn't contribute to the type
# we eventually pick.
@@ -914,7 +914,7 @@ function abstract_interpret(e::Expr, vtypes, sv::StaticVarInfo)
return vtypes
end
-tchanged(n::ANY, o::ANY) = is(o,NF) || (!is(n,NF) && !subtype(n,o))
+tchanged(n::ANY, o::ANY) = is(o,NF) || (!is(n,NF) && !issubtype(n,o))
function stchanged(new::Union(StateUpdate,VarTable), old, vars)
if is(old,())
@@ -959,17 +959,17 @@ function tmerge(typea::ANY, typeb::ANY)
if is(typeb,NF)
return typea
end
- if subtype(typea,typeb)
+ if issubtype(typea,typeb)
return typeb
end
- if subtype(typeb,typea)
+ if issubtype(typeb,typea)
return typea
end
u = Union(typea, typeb)
if length(u.types) > MAX_TYPEUNION_LEN || type_too_complex(u, 0)
# don't let type unions get too big
# TODO: something smarter, like a common supertype
- return subtype(Undef,u) ? Top : Any
+ return issubtype(Undef,u) ? Top : Any
end
return u
end
@@ -1244,7 +1244,7 @@ function typeinf(linfo::LambdaStaticData,atypes::Tuple,sparams::Tuple, def, cop)
# type_goto provides a special update rule for the
# listed vars: it feeds types directly to the
# target statement as long as they are *different*,
- # not !subtype like usual. this is because we want
+ # not !issubtype like usual. this is because we want
# the specific type inferred at the point of the
# type_goto, not just any type containing it.
# Otherwise "None" doesn't work; see issue #3821
@@ -1370,7 +1370,7 @@ function eval_annotate(e::ANY, vtypes::ANY, sv::StaticVarInfo, decls, clo)
e = e::SymbolNode
curtype = e.typ
t = abstract_eval(e.name, vtypes, sv)
- if !subtype(curtype, t) || typeseq(curtype, t)
+ if !issubtype(curtype, t) || typeseq(curtype, t)
record_var_type(e.name, t, decls)
e.typ = t
end
@@ -1658,7 +1658,7 @@ function inlineable(f, e::Expr, sv, enclosing_ast)
if is(f, convert_default) && length(atypes)==3
# builtin case of convert. convert(T,x::S) => x, when S<:T
if isType(atypes[1]) && isleaftype(atypes[1]) &&
- subtype(atypes[2],atypes[1].parameters[1])
+ issubtype(atypes[2],atypes[1].parameters[1])
# todo: if T expression has side effects??!
return (e.args[3],())
end
@@ -1699,7 +1699,7 @@ function inlineable(f, e::Expr, sv, enclosing_ast)
# when 1 method matches the inferred types, there is still a chance
# of a no-method error at run time, unless the inferred types are a
# subset of the method signature.
- if !subtype(atypes, meth[1])
+ if !issubtype(atypes, meth[1])
return NF
end
linfo = meth[3].func.code
View
@@ -258,7 +258,7 @@ for to in _inttypes, from in _inttypes
if to.size < from.size
@eval convert(::Type{$to}, x::($from)) = box($to,trunc_int($to,unbox($from,x)))
elseif from.size < to.size || from===Bool
- if subtype(from, Signed)
+ if issubtype(from, Signed)
@eval convert(::Type{$to}, x::($from)) = box($to,sext_int($to,unbox($from,x)))
else
@eval convert(::Type{$to}, x::($from)) = box($to,zext_int($to,unbox($from,x)))
View
@@ -1,6 +1,6 @@
## types ##
-const (<:) = subtype
+const (<:) = issubtype
super(T::DataType) = T.super
View
@@ -39,7 +39,7 @@ isbits(x) = isbits(typeof(x))
isleaftype(t::ANY) = ccall(:jl_is_leaf_type, Int32, (Any,), t) != 0
typeintersect(a::ANY,b::ANY) = ccall(:jl_type_intersection, Any, (Any,Any), a, b)
-typeseq(a::ANY,b::ANY) = subtype(a,b)&&subtype(b,a)
+typeseq(a::ANY,b::ANY) = issubtype(a,b) && issubtype(b,a)
function fieldoffsets(x::DataType)
offsets = Array(Int, length(x.names))
View
@@ -44,8 +44,8 @@ function union(s::Set, sets::Set...)
if U != Any
for t in sets
T = eltype(t)
- U = subtype(T,U) ? U :
- subtype(U,T) ? T : Any # TODO: tigher upper bound
+ U = issubtype(T,U) ? U :
+ issubtype(U,T) ? T : Any # TODO: tigher upper bound
end
end
u = Set{U}()
View
@@ -200,7 +200,7 @@
<context id="builtin-function" style-ref="builtin-function">
<keyword>is</keyword>
<keyword>typeof</keyword>
- <keyword>subtype</keyword>
+ <keyword>issubtype</keyword>
<keyword>isa</keyword>
<keyword>typeassert</keyword>
<keyword>apply</keyword>
View
@@ -180,13 +180,13 @@ Types
Return the supertype of DataType T
-.. function:: subtype(type1, type2)
+.. function:: issubtype(type1, type2)
True if and only if all values of ``type1`` are also of ``type2``. Can also be written using the ``<:`` infix operator as ``type1 <: type2``.
.. function:: <:(T1, T2)
- Subtype operator, equivalent to ``subtype(T1,T2)``.
+ Subtype operator, equivalent to ``issubtype(T1,T2)``.
.. function:: subtypes(T::DataType)
View
@@ -1021,7 +1021,7 @@ void jl_init_primitives(void)
{
add_builtin_func("is", jl_f_is);
add_builtin_func("typeof", jl_f_typeof);
- add_builtin_func("subtype", jl_f_subtype);
+ add_builtin_func("issubtype", jl_f_subtype);
add_builtin_func("isa", jl_f_isa);
add_builtin_func("typeassert", jl_f_typeassert);
add_builtin_func("apply", jl_f_apply);
View
@@ -17,20 +17,20 @@
@test !(Array{Int8,1} <: Array{Any,1})
@test !(Array{Any,1} <: Array{Int8,1})
@test Array{Int8,1} <: Array{Int8,1}
-@test !subtype(Type{None}, Type{Int32})
-@test !subtype(Vector{Float64},Vector{Union(Float64,Float32)})
+@test !issubtype(Type{None}, Type{Int32})
+@test !issubtype(Vector{Float64},Vector{Union(Float64,Float32)})
@test is(None, typeintersect(Vector{Float64},Vector{Union(Float64,Float32)}))
@test !isa(Array,Type{Any})
-@test subtype(Type{Complex},DataType)
+@test issubtype(Type{Complex},DataType)
@test isa(Complex,Type{Complex})
-@test !subtype(Type{Ptr{None}},Type{Ptr})
-@test !subtype(Type{Rational{Int}}, Type{Rational})
+@test !issubtype(Type{Ptr{None}},Type{Ptr})
+@test !issubtype(Type{Rational{Int}}, Type{Rational})
let T = TypeVar(:T,true)
@test !is(None, typeintersect(Array{None},AbstractArray{T}))
@test is(None, typeintersect((Type{Ptr{Uint8}},Ptr{None}),
(Type{Ptr{T}},Ptr{T})))
- @test !subtype(Type{T},TypeVar)
+ @test !issubtype(Type{T},TypeVar)
@test isequal(typeintersect((Range{Int},(Int,Int)),(AbstractArray{T},Dims)),
(Range{Int},(Int,Int)))
@@ -67,11 +67,11 @@ let N = TypeVar(:N,true)
end
@test is(None, typeintersect(Type{Any},Type{Complex}))
@test is(None, typeintersect(Type{Any},Type{TypeVar(:T,Real)}))
-@test !subtype(Type{Array{Integer}},Type{AbstractArray{Integer}})
-@test !subtype(Type{Array{Integer}},Type{Array{TypeVar(:T,Integer)}})
+@test !issubtype(Type{Array{Integer}},Type{AbstractArray{Integer}})
+@test !issubtype(Type{Array{Integer}},Type{Array{TypeVar(:T,Integer)}})
@test is(None, typeintersect(Type{Function},UnionType))
@test is(Type{Int32}, typeintersect(Type{Int32},DataType))
-@test !subtype(Type,TypeVar)
+@test !issubtype(Type,TypeVar)
@test !is(None, typeintersect(DataType, Type))
@test !is(None, typeintersect(UnionType, Type))
@test !is(None, typeintersect(DataType, Type{Int}))
@@ -80,22 +80,22 @@ end
@test isa(Int,Type{TypeVar(:T,Number)})
@test !isa(DataType,Type{TypeVar(:T,Number)})
-@test subtype(DataType,Type{TypeVar(:T,Type)})
+@test issubtype(DataType,Type{TypeVar(:T,Type)})
@test isa((),Type{()})
-@test subtype((DataType,),Type{TypeVar(:T,Tuple)})
-@test !subtype((Int,),Type{TypeVar(:T,Tuple)})
+@test issubtype((DataType,),Type{TypeVar(:T,Tuple)})
+@test !issubtype((Int,),Type{TypeVar(:T,Tuple)})
@test isa((Int,),Type{TypeVar(:T,Tuple)})
@test !isa(Type{(Int,Int)},Tuple)
-@test subtype(Type{(Int,Int)},Tuple)
-@test subtype(Type{(Int,)}, (DataType,))
+@test issubtype(Type{(Int,Int)},Tuple)
+@test issubtype(Type{(Int,)}, (DataType,))
# this is fancy: know that any type T<:Number must be either a DataType or a UnionType
-@test subtype(Type{TypeVar(:T,Number)},Union(DataType,UnionType))
-@test !subtype(Type{TypeVar(:T,Number)},DataType)
-@test subtype(Type{TypeVar(:T,Tuple)},Union(Tuple,UnionType))
-@test !subtype(Type{TypeVar(:T,Tuple)},Union(DataType,UnionType))
+@test issubtype(Type{TypeVar(:T,Number)},Union(DataType,UnionType))
+@test !issubtype(Type{TypeVar(:T,Number)},DataType)
+@test issubtype(Type{TypeVar(:T,Tuple)},Union(Tuple,UnionType))
+@test !issubtype(Type{TypeVar(:T,Tuple)},Union(DataType,UnionType))
@test !is(None, typeintersect((DataType,DataType),Type{TypeVar(:T,(Number,Number))}))
@test !is(None, typeintersect((DataType,UnionType),Type{(Number,None)}))
@@ -140,14 +140,14 @@ nttest1{n}(x::NTuple{n,Int}) = n
abstract Sup_{A,B}
abstract Qux_{T} <: Sup_{Qux_{Int},T}
-@test subtype(Qux_{Int}.super, Sup_)
+@test issubtype(Qux_{Int}.super, Sup_)
@test is(Qux_{Int}, Qux_{Int}.super.parameters[1])
@test is(Qux_{Int}.super.parameters[2], Int)
-@test subtype(Qux_{Char}.super, Sup_)
+@test issubtype(Qux_{Char}.super, Sup_)
@test is(Qux_{Int}, Qux_{Char}.super.parameters[1])
@test is(Qux_{Char}.super.parameters[2], Char)
-@test subtype(Qux_.super.parameters[1].super, Sup_)
+@test issubtype(Qux_.super.parameters[1].super, Sup_)
@test is(Qux_{Int}, Qux_.super.parameters[1].super.parameters[1])
@test is(Int, Qux_.super.parameters[1].super.parameters[2])

0 comments on commit 187ad98

Please sign in to comment.