mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-16 15:45:50 +01:00
* Accept obscure update to package-lock.json * Make global state local in Collector.IsVoidAlias predicate * Add protection against potential nil dereference * Update test data * Fix typo in doc comment Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update UNRELEASED_CHANGELOG.md --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
28 lines
768 B
Go
28 lines
768 B
Go
package collect
|
|
|
|
import (
|
|
"go/types"
|
|
)
|
|
|
|
// IsVoidAlias returns true when the given type or object is the application.Void named type that stands in for the void TS type.
|
|
func (collector *Collector) IsVoidAlias(typOrObj any) bool {
|
|
var obj types.Object
|
|
switch to := typOrObj.(type) {
|
|
case types.Object:
|
|
obj = to
|
|
case interface{ Obj() *types.TypeName }:
|
|
obj = to.Obj()
|
|
default:
|
|
return false
|
|
}
|
|
|
|
if vt := collector.appVoidType.Load(); vt != nil && obj == vt {
|
|
return true
|
|
} else if vt == nil && obj.Name() == "Void" && obj.Pkg() != nil && obj.Pkg().Path() == collector.systemPaths.ApplicationPackage { // Check name before package to fail fast
|
|
// Cache void alias for faster checking
|
|
collector.appVoidType.Store(obj)
|
|
return true
|
|
}
|
|
|
|
return false
|
|
}
|