diff --git a/base/boot.jl b/base/boot.jl index f80fd674521ee..270e6fd2ad1ca 100644 --- a/base/boot.jl +++ b/base/boot.jl @@ -8,7 +8,7 @@ #abstract type Vararg{T} end #mutable struct Symbol -# #opaque +## opaque #end #mutable struct TypeName @@ -53,28 +53,43 @@ #abstract type DenseArray{T,N} <: AbstractArray{T,N} end #mutable struct Array{T,N} <: DenseArray{T,N} +## opaque #end #mutable struct Module -# name::Symbol +## opaque +#end + +#mutable struct SimpleVector +## opaque +#end + +#mutable struct String +## opaque #end #mutable struct Method +#... #end #mutable struct MethodInstance +#... #end #mutable struct CodeInstance +#... #end #mutable struct CodeInfo +#... #end #mutable struct TypeMapLevel +#... #end #mutable struct TypeMapEntry +#... #end #abstract type Ref{T} end diff --git a/base/compiler/tfuncs.jl b/base/compiler/tfuncs.jl index 18dec7d839950..19dbae49361b3 100644 --- a/base/compiler/tfuncs.jl +++ b/base/compiler/tfuncs.jl @@ -925,11 +925,11 @@ function fieldtype_tfunc(@nospecialize(s0), @nospecialize(name)) if s0 === Any || s0 === Type || DataType ⊑ s0 || UnionAll ⊑ s0 return Type end - # fieldtype only accepts Types, errors on `Module` - if isa(s0, Const) && (!(isa(s0.val, DataType) || isa(s0.val, UnionAll) || isa(s0.val, Union)) || s0.val === Module) + # fieldtype only accepts Types + if isa(s0, Const) && !(isa(s0.val, DataType) || isa(s0.val, UnionAll) || isa(s0.val, Union)) return Bottom end - if s0 == Type{Module} || s0 == Type{Union{}} || isa(s0, Conditional) + if (s0 isa Type && s0 == Type{Union{}}) || isa(s0, Conditional) return Bottom end diff --git a/src/datatype.c b/src/datatype.c index 6f9358a2016ec..00ed7c2eb23a4 100644 --- a/src/datatype.c +++ b/src/datatype.c @@ -359,7 +359,7 @@ void jl_compute_field_offsets(jl_datatype_t *st) st->layout = &opaque_byte_layout; return; } - else if (st == jl_simplevector_type || st->name == jl_array_typename) { + else if (st == jl_simplevector_type || st == jl_module_type || st->name == jl_array_typename) { static const jl_datatype_layout_t opaque_ptr_layout = {0, 1, -1, sizeof(void*), 0, 0}; st->layout = &opaque_ptr_layout; return; diff --git a/src/jltypes.c b/src/jltypes.c index 4b14f4a4b26ee..e58417149f031 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -2015,8 +2015,9 @@ void jl_init_types(void) JL_GC_DISABLED jl_module_type = jl_new_datatype(jl_symbol("Module"), core, jl_any_type, jl_emptysvec, - jl_perm_symsvec(2, "name", "parent"), - jl_svec(2, jl_symbol_type, jl_any_type), 0, 1, 2); + jl_emptysvec, jl_emptysvec, 0, 1, 0); + jl_module_type->instance = NULL; + jl_compute_field_offsets(jl_module_type); jl_value_t *symornothing[2] = { (jl_value_t*)jl_symbol_type, (jl_value_t*)jl_void_type }; jl_linenumbernode_type = diff --git a/test/misc.jl b/test/misc.jl index c4d26e3b223b9..bfac280f83b9c 100644 --- a/test/misc.jl +++ b/test/misc.jl @@ -860,5 +860,5 @@ end end @testset "fieldtypes Module" begin - @test fieldtypes(Module) isa Tuple + @test fieldtypes(Module) === () end