Infer final expression returns in lambdas
This commit is contained in:
parent
773c34f3f4
commit
72606e7818
6 changed files with 300 additions and 7 deletions
|
|
@ -51,6 +51,11 @@ type ImportedClassType struct {
|
|||
func (ImportedClassType) typeNode() {}
|
||||
func (t ImportedClassType) String() string { return t.Package + "." + t.Class.Name }
|
||||
|
||||
type GoInterfaceType struct{ Name string }
|
||||
|
||||
func (GoInterfaceType) typeNode() {}
|
||||
func (t GoInterfaceType) String() string { return t.Name }
|
||||
|
||||
type NullableType struct{ Element Type }
|
||||
|
||||
func (NullableType) typeNode() {}
|
||||
|
|
@ -330,6 +335,17 @@ func inferTypeBindings(parameter, argument Type, bindings map[string]Type) {
|
|||
inferTypeBindings(expected.Args[index], actual.Args[index], bindings)
|
||||
}
|
||||
}
|
||||
case FunctionType:
|
||||
actual, ok := argument.(FunctionType)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
for index := range expected.Params {
|
||||
if index < len(actual.Params) {
|
||||
inferTypeBindings(expected.Params[index], actual.Params[index], bindings)
|
||||
}
|
||||
}
|
||||
inferTypeBindings(expected.Result, actual.Result, bindings)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -341,6 +357,8 @@ func renderGoType(typ Type) string {
|
|||
return "*" + value.Class.Name
|
||||
case ImportedClassType:
|
||||
return "*" + value.Package + "." + value.Class.Name
|
||||
case GoInterfaceType:
|
||||
return value.Name
|
||||
case NullableType:
|
||||
element := renderGoType(value.Element)
|
||||
switch value.Element.(type) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue