checker: revert embedded methods fix (#7780)
parent
2e8f187819
commit
5ae3637d27
|
@ -41,9 +41,9 @@ pub fn (mut app App) index() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut app App) text() vweb.Result {
|
fn (mut app App) text() vweb.Result {
|
||||||
return app.text('Hello, world from vweb!')
|
return app.Context.text('Hello, world from vweb!')
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (mut app App) time() vweb.Result {
|
fn (mut app App) time() vweb.Result {
|
||||||
return app.text(time.now().format())
|
return app.Context.text(time.now().format())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1289,15 +1289,7 @@ pub fn (mut c Checker) call_method(mut call_expr ast.CallExpr) table.Type {
|
||||||
method = m
|
method = m
|
||||||
has_method = true
|
has_method = true
|
||||||
} else {
|
} else {
|
||||||
if left_type_sym.kind == .aggregate {
|
|
||||||
// the error message contains the problematic type
|
|
||||||
unknown_method_msg = err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// check even if method is found, we could be overriding a method (TODO: should this be allowed?)
|
|
||||||
// can this logic be moved to table.type_find_method() so it can be used from anywhere
|
// can this logic be moved to table.type_find_method() so it can be used from anywhere
|
||||||
// TODO: should overriden methods use embed type name to access it's methods?
|
|
||||||
// eg go does: `fn (mut app App) text() vweb.Result { return app.Context.text() }`
|
|
||||||
if left_type_sym.info is table.Struct {
|
if left_type_sym.info is table.Struct {
|
||||||
mut found_methods := []table.Fn{}
|
mut found_methods := []table.Fn{}
|
||||||
mut embed_of_found_methods := []table.Type{}
|
mut embed_of_found_methods := []table.Type{}
|
||||||
|
@ -1317,6 +1309,11 @@ pub fn (mut c Checker) call_method(mut call_expr ast.CallExpr) table.Type {
|
||||||
c.error('ambiguous method `$method_name`', call_expr.pos)
|
c.error('ambiguous method `$method_name`', call_expr.pos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if left_type_sym.kind == .aggregate {
|
||||||
|
// the error message contains the problematic type
|
||||||
|
unknown_method_msg = err
|
||||||
|
}
|
||||||
|
}
|
||||||
if has_method {
|
if has_method {
|
||||||
if !method.is_pub && !c.is_builtin_mod && !c.pref.is_test && left_type_sym.mod != c.mod &&
|
if !method.is_pub && !c.is_builtin_mod && !c.pref.is_test && left_type_sym.mod != c.mod &&
|
||||||
left_type_sym.mod != '' { // method.mod != c.mod {
|
left_type_sym.mod != '' { // method.mod != c.mod {
|
||||||
|
|
Loading…
Reference in New Issue