mirror of https://github.com/exaloop/codon.git
Rename function overload 'super' to 'superf'
parent
a32e945dc1
commit
cb0a6ea443
|
@ -88,9 +88,10 @@ SimplifyVisitor::apply(Cache *cache, const StmtPtr &node, const std::string &fil
|
|||
}
|
||||
// Reserve the following static identifiers.
|
||||
for (auto name : {"staticlen", "compile_error", "isinstance", "hasattr", "type",
|
||||
"TypeVar", "Callable", "argv", "super"})
|
||||
"TypeVar", "Callable", "argv", "super", "superf", "fn"})
|
||||
stdlib->generateCanonicalName(name);
|
||||
stdlib->add(SimplifyItem::Var, "super", "super", true);
|
||||
stdlib->add(SimplifyItem::Var, "superf", "superf", true);
|
||||
|
||||
// This code must be placed in a preamble (these are not POD types but are
|
||||
// referenced by the various preamble Function.N and Tuple.N stubs)
|
||||
|
|
|
@ -1038,15 +1038,15 @@ ExprPtr TypecheckVisitor::transformCall(CallExpr *expr, const types::TypePtr &in
|
|||
seenNames.insert(i.name);
|
||||
}
|
||||
|
||||
if (expr->expr->isId("super")) {
|
||||
if (expr->expr->isId("superf")) {
|
||||
if (ctx->bases.back().supers.empty())
|
||||
error("no matching super methods are available");
|
||||
error("no matching superf methods are available");
|
||||
auto parentCls = ctx->bases.back().type->getFunc()->funcParent;
|
||||
auto m =
|
||||
findMatchingMethods(parentCls ? CAST(parentCls, types::ClassType) : nullptr,
|
||||
ctx->bases.back().supers, expr->args);
|
||||
if (m.empty())
|
||||
error("no matching super methods are available");
|
||||
error("no matching superf methods are available");
|
||||
// LOG("found {} <- {}", ctx->bases.back().type->getFunc()->toString(),
|
||||
// m[0]->toString());
|
||||
ExprPtr e = N<CallExpr>(N<IdExpr>(m[0]->ast->name), expr->args);
|
||||
|
|
|
@ -299,19 +299,19 @@ def foo2(x):
|
|||
foo2(1) #: 2
|
||||
foo2('s') #: 1
|
||||
|
||||
#%% super,barebones
|
||||
#%% superf,barebones
|
||||
class Foo:
|
||||
def foo(a):
|
||||
# super(a)
|
||||
# superf(a)
|
||||
print 'foo-1', a
|
||||
def foo(a: int):
|
||||
super(a)
|
||||
superf(a)
|
||||
print 'foo-2', a
|
||||
def foo(a: str):
|
||||
super(a)
|
||||
superf(a)
|
||||
print 'foo-3', a
|
||||
def foo(a):
|
||||
super(a)
|
||||
superf(a)
|
||||
print 'foo-4', a
|
||||
Foo.foo(1)
|
||||
#: foo-1 1
|
||||
|
@ -324,21 +324,21 @@ class Bear:
|
|||
@extend
|
||||
class Bear:
|
||||
def woof(x):
|
||||
return super(x) + f' bear w--f {x}'
|
||||
return superf(x) + f' bear w--f {x}'
|
||||
print Bear.woof('!')
|
||||
#: bear woof ! bear w--f !
|
||||
|
||||
class PolarBear(Bear):
|
||||
def woof():
|
||||
return 'polar ' + super('@')
|
||||
return 'polar ' + superf('@')
|
||||
print PolarBear.woof()
|
||||
#: polar bear woof @ bear w--f @
|
||||
|
||||
#%% super_error,barebones
|
||||
#%% superf_error,barebones
|
||||
class Foo:
|
||||
def foo(a):
|
||||
super(a)
|
||||
superf(a)
|
||||
print 'foo-1', a
|
||||
Foo.foo(1)
|
||||
#! no matching super methods are available
|
||||
#! no matching superf methods are available
|
||||
#! while realizing Foo.foo:0
|
||||
|
|
Loading…
Reference in New Issue