Skip to content

Commit 61ad8cf

Browse files
committed
[Truffle] Fix handling of CoreMethod.constructor.
* The method should be defined on the singleton class.
1 parent 454db3a commit 61ad8cf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

truffle/src/main/java/org/jruby/truffle/nodes/core/CoreMethodNodeManager.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,23 @@ private void addCoreMethod(MethodDetails methodDetails) {
102102
if (method.onSingleton()) {
103103
System.err.println("WARNING: Either onSingleton or isModuleFunction for " + methodDetails.getIndicativeName());
104104
}
105+
if (method.constructor()) {
106+
System.err.println("WARNING: Either constructor or isModuleFunction for " + methodDetails.getIndicativeName());
107+
}
105108
if (!module.isOnlyAModule()) {
106109
System.err.println("WARNING: Using isModuleFunction on a Class for " + methodDetails.getIndicativeName());
107110
}
108111
}
112+
if (method.onSingleton() && method.constructor()) {
113+
System.err.println("WARNING: Either onSingleton or isModuleFunction for " + methodDetails.getIndicativeName());
114+
}
109115

110116
final RubyRootNode rootNode = makeGenericMethod(context, methodDetails);
111117

112118
if (method.isModuleFunction()) {
113119
addMethod(module, rootNode, names, Visibility.PRIVATE);
114120
addMethod(getSingletonClass(module), rootNode, names, Visibility.PUBLIC);
115-
} else if (method.onSingleton()) {
121+
} else if (method.onSingleton() || method.constructor()) {
116122
addMethod(getSingletonClass(module), rootNode, names, visibility);
117123
} else {
118124
addMethod(module, rootNode, names, visibility);

0 commit comments

Comments
 (0)