Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
fd0f79ca
Commit
fd0f79ca
authored
Apr 06, 2017
by
Kouichi Nakanishi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get constant of parent class even if child class is defined in signleton class; fix #3575
parent
e5b61d34
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
src/class.c
src/class.c
+10
-1
test/t/class.rb
test/t/class.rb
+14
-0
No files found.
src/class.c
View file @
fd0f79ca
...
@@ -127,10 +127,19 @@ MRB_API struct RClass*
...
@@ -127,10 +127,19 @@ MRB_API struct RClass*
mrb_class_outer_module
(
mrb_state
*
mrb
,
struct
RClass
*
c
)
mrb_class_outer_module
(
mrb_state
*
mrb
,
struct
RClass
*
c
)
{
{
mrb_value
outer
;
mrb_value
outer
;
struct
RClass
*
cls
;
outer
=
mrb_obj_iv_get
(
mrb
,
(
struct
RObject
*
)
c
,
mrb_intern_lit
(
mrb
,
"__outer__"
));
outer
=
mrb_obj_iv_get
(
mrb
,
(
struct
RObject
*
)
c
,
mrb_intern_lit
(
mrb
,
"__outer__"
));
if
(
mrb_nil_p
(
outer
))
return
NULL
;
if
(
mrb_nil_p
(
outer
))
return
NULL
;
return
mrb_class_ptr
(
outer
);
cls
=
mrb_class_ptr
(
outer
);
if
(
cls
->
tt
==
MRB_TT_SCLASS
)
{
mrb_value
klass
;
klass
=
mrb_obj_iv_get
(
mrb
,
(
struct
RObject
*
)
cls
,
mrb_intern_lit
(
mrb
,
"__attached__"
));
cls
=
mrb_class_ptr
(
klass
);
}
return
cls
;
}
}
static
void
static
void
...
...
test/t/class.rb
View file @
fd0f79ca
...
@@ -410,6 +410,20 @@ assert('class variable in module and class << self style class method') do
...
@@ -410,6 +410,20 @@ assert('class variable in module and class << self style class method') do
assert_equal
(
"value"
,
ClassVariableInModuleTest
.
class_variable
)
assert_equal
(
"value"
,
ClassVariableInModuleTest
.
class_variable
)
end
end
assert
(
'child class/module defined in singleton class get parent constant'
)
do
actual
=
module
GetParentConstantTest
EXPECT
=
"value"
class
<<
self
class
CHILD
class
<<
self
EXPECT
end
end
end
end
assert_equal
(
"value"
,
actual
)
end
assert
(
'overriding class variable with a module (#3235)'
)
do
assert
(
'overriding class variable with a module (#3235)'
)
do
module
ModuleWithCVar
module
ModuleWithCVar
@@class_variable
=
1
@@class_variable
=
1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment