@@ -1697,6 +1697,7 @@ public PrivateInstanceMethodsNode() {
1697
1697
1698
1698
@ NodeChild (value = "module" , type = RubyNode .class )
1699
1699
@ NodeChild (value = "name" , type = RubyNode .class )
1700
+ @ NodeChild (value = "inherit" , type = RubyNode .class )
1700
1701
protected abstract static class AbstractMethodDefinedNode extends CoreMethodNode {
1701
1702
1702
1703
final Visibility visibility ;
@@ -1710,39 +1711,47 @@ protected RubyNode coerceToString(RubyNode name) {
1710
1711
return NameToJavaStringNode .create (name );
1711
1712
}
1712
1713
1713
- @ Specialization
1714
- protected boolean isMethodDefined (RubyModule module , String name ) {
1715
- // TODO (pitr-ch 30-Mar-2016): cache lookup
1716
- return ModuleOperations .lookupMethod (module , name , visibility ) != null ;
1714
+ @ CreateCast ("inherit" )
1715
+ protected RubyNode coerceToBoolean (RubyNode inherit ) {
1716
+ return BooleanCastWithDefaultNodeGen .create (true , inherit );
1717
+ }
1718
+
1719
+ // TODO (pitr-ch 30-Mar-2016): cache lookup
1720
+
1721
+ @ Specialization (guards = "inherit" )
1722
+ protected boolean isMethodDefinedInherit (RubyModule module , String name , boolean inherit ) {
1723
+ final InternalMethod method = ModuleOperations .lookupMethodUncached (module , name , null );
1724
+ return method != null && !method .isUndefined () && !method .isUnimplemented () &&
1725
+ method .getVisibility () == visibility ;
1717
1726
}
1718
1727
1728
+ @ Specialization (guards = "!inherit" )
1729
+ protected boolean isMethodDefinedDontInherit (RubyModule module , String name , boolean inherit ) {
1730
+ final InternalMethod method = module .fields .getMethod (name );
1731
+ return method != null && !method .isUndefined () && !method .isUnimplemented () &&
1732
+ method .getVisibility () == visibility ;
1733
+ }
1719
1734
}
1720
1735
1721
- @ CoreMethod (names = "public_method_defined?" , required = 1 )
1736
+ @ CoreMethod (names = "public_method_defined?" , required = 1 , optional = 1 )
1722
1737
public abstract static class PublicMethodDefinedNode extends AbstractMethodDefinedNode {
1723
-
1724
1738
public PublicMethodDefinedNode () {
1725
1739
super (Visibility .PUBLIC );
1726
1740
}
1727
-
1728
1741
}
1729
1742
1730
- @ CoreMethod (names = "protected_method_defined?" , required = 1 )
1743
+ @ CoreMethod (names = "protected_method_defined?" , required = 1 , optional = 1 )
1731
1744
public abstract static class ProtectedMethodDefinedNode extends AbstractMethodDefinedNode {
1732
-
1733
1745
public ProtectedMethodDefinedNode () {
1734
1746
super (Visibility .PROTECTED );
1735
1747
}
1736
-
1737
1748
}
1738
1749
1739
- @ CoreMethod (names = "private_method_defined?" , required = 1 )
1750
+ @ CoreMethod (names = "private_method_defined?" , required = 1 , optional = 1 )
1740
1751
public abstract static class PrivateMethodDefinedNode extends AbstractMethodDefinedNode {
1741
-
1742
1752
public PrivateMethodDefinedNode () {
1743
1753
super (Visibility .PRIVATE );
1744
1754
}
1745
-
1746
1755
}
1747
1756
1748
1757
@ CoreMethod (names = "instance_methods" , optional = 1 )
0 commit comments