mirror of
https://github.com/enso-org/enso.git
synced 2024-11-25 10:43:02 +03:00
Yield Type_Error on wrong self argument
This commit is contained in:
parent
6b41eaa036
commit
e279793d95
@ -850,6 +850,17 @@ public abstract class InvokeMethodNode extends BaseNode {
|
||||
instanceof Function function) {
|
||||
if (function.getSchema().getArgumentsCount() == arguments.length - 1
|
||||
&& "self".equals(function.getSchema().getArgumentInfos()[0].getName())) {
|
||||
var ok = false;
|
||||
try {
|
||||
if (interop.isMetaInstance(arguments[0], arguments[1])) {
|
||||
ok = true;
|
||||
}
|
||||
} catch (UnsupportedMessageException ex) {
|
||||
}
|
||||
if (!ok) {
|
||||
var err = ctx.getBuiltins().error().makeTypeError(arguments[0], arguments[1], "self");
|
||||
throw new PanicException(err, this);
|
||||
}
|
||||
var lessArgs = Arrays.copyOfRange(arguments, 1, arguments.length);
|
||||
var lessSchema =
|
||||
Arrays.copyOfRange(
|
||||
|
@ -1,4 +1,5 @@
|
||||
from Standard.Base import all
|
||||
import Standard.Base.Errors.Common.Type_Error
|
||||
from Standard.Test import all
|
||||
|
||||
from project.Data.Polyglot_Extensions import all
|
||||
@ -52,6 +53,9 @@ add_specs suite_builder = suite_builder.group "Polyglot" group_builder->
|
||||
v = IntHolder.value_plus hold 3
|
||||
v . should_equal 45
|
||||
|
||||
group_builder.specify "extension method (static syntax) checks self type" <|
|
||||
Test.expect_panic Type_Error (IntHolder.value_plus 10 12)
|
||||
|
||||
group_builder.specify "static extension method on IntHolder" <|
|
||||
hold = IntHolder.create (6 * 7)
|
||||
hold.value . should_equal 42
|
||||
|
Loading…
Reference in New Issue
Block a user