Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 12 for assertableTo (0.12 sec)

  1. src/cmd/vendor/golang.org/x/tools/go/analysis/passes/ifaceassert/ifaceassert.go

    	Requires: []*analysis.Analyzer{inspect.Analyzer},
    	Run:      run,
    }
    
    // assertableTo checks whether interface v can be asserted into t. It returns
    // nil on success, or the first conflicting method on failure.
    func assertableTo(free *typeparams.Free, v, t types.Type) *types.Func {
    	if t == nil || v == nil {
    		// not assertable to, but there is no missing method
    		return nil
    	}
    	// ensure that v and t are interfaces
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Apr 02 02:20:05 UTC 2024
    - 2.8K bytes
    - Viewed (0)
  2. src/cmd/compile/internal/types2/api_predicates.go

    package types2
    
    // AssertableTo reports whether a value of type V can be asserted to have type T.
    //
    // The behavior of AssertableTo is unspecified in three cases:
    //   - if T is Typ[Invalid]
    //   - if V is a generalized interface; i.e., an interface that may only be used
    //     as a type constraint in Go code
    //   - if T is an uninstantiated generic type
    func AssertableTo(V *Interface, T Type) bool {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Apr 08 16:36:08 UTC 2024
    - 3.3K bytes
    - Viewed (0)
  3. src/go/types/api_predicates.go

    package types
    
    // AssertableTo reports whether a value of type V can be asserted to have type T.
    //
    // The behavior of AssertableTo is unspecified in three cases:
    //   - if T is Typ[Invalid]
    //   - if V is a generalized interface; i.e., an interface that may only be used
    //     as a type constraint in Go code
    //   - if T is an uninstantiated generic type
    func AssertableTo(V *Interface, T Type) bool {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Apr 08 16:36:08 UTC 2024
    - 3.5K bytes
    - Viewed (0)
  4. src/cmd/compile/internal/types2/lookup.go

    	w.pkgInfo = pkgInfo
    	w.paramNames = false
    	w.signature(f.typ.(*Signature))
    	return buf.String()
    }
    
    // assertableTo reports whether a value of type V can be asserted to have type T.
    // The receiver may be nil if assertableTo is invoked through an exported API call
    // (such as AssertableTo), i.e., when all methods have been type-checked.
    // The underlying type of V must be an interface.
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Feb 22 19:32:17 UTC 2024
    - 19.8K bytes
    - Viewed (0)
  5. src/go/types/lookup.go

    	w.pkgInfo = pkgInfo
    	w.paramNames = false
    	w.signature(f.typ.(*Signature))
    	return buf.String()
    }
    
    // assertableTo reports whether a value of type V can be asserted to have type T.
    // The receiver may be nil if assertableTo is invoked through an exported API call
    // (such as AssertableTo), i.e., when all methods have been type-checked.
    // The underlying type of V must be an interface.
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Apr 03 18:48:38 UTC 2024
    - 19.9K bytes
    - Viewed (0)
  6. src/cmd/compile/internal/types2/api_test.go

    		V := test.T
    		T := test.V
    		want := false
    		if _, ok := T.Underlying().(*Interface); (ok || Implements(T, V)) && T != Bad {
    			want = true
    		}
    		if got := AssertableTo(V, T); got != want {
    			t.Errorf("AssertableTo(%s, %s) = %t, want %t", V, T, got, want)
    		}
    	}
    }
    
    func TestMissingMethodAlternative(t *testing.T) {
    	const src = `
    package p
    type T interface {
    	m()
    }
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue May 07 20:08:23 UTC 2024
    - 93.3K bytes
    - Viewed (0)
  7. src/go/types/api_test.go

    		V := test.T
    		T := test.V
    		want := false
    		if _, ok := T.Underlying().(*Interface); (ok || Implements(T, V)) && T != Bad {
    			want = true
    		}
    		if got := AssertableTo(V, T); got != want {
    			t.Errorf("AssertableTo(%s, %s) = %t, want %t", V, T, got, want)
    		}
    	}
    }
    
    func TestMissingMethodAlternative(t *testing.T) {
    	const src = `
    package p
    type T interface {
    	m()
    }
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 01:00:11 UTC 2024
    - 94.2K bytes
    - Viewed (0)
  8. src/go/types/expr.go

    	}
    	return x
    }
    
    // typeAssertion checks x.(T). The type of x must be an interface.
    func (check *Checker) typeAssertion(e ast.Expr, x *operand, T Type, typeSwitch bool) {
    	var cause string
    	if check.assertableTo(x.typ, T, &cause) {
    		return // success
    	}
    
    	if typeSwitch {
    		check.errorf(e, ImpossibleAssert, "impossible type switch case: %s\n\t%s cannot have dynamic type %s %s", e, x, T, cause)
    		return
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed May 29 02:09:54 UTC 2024
    - 49.7K bytes
    - Viewed (0)
  9. api/go1.5.txt

    pkg go/types, const UntypedNil BasicKind
    pkg go/types, const UntypedRune = 21
    pkg go/types, const UntypedRune BasicKind
    pkg go/types, const UntypedString = 24
    pkg go/types, const UntypedString BasicKind
    pkg go/types, func AssertableTo(*Interface, Type) bool
    pkg go/types, func AssignableTo(Type, Type) bool
    pkg go/types, func Comparable(Type) bool
    pkg go/types, func ConvertibleTo(Type, Type) bool
    pkg go/types, func DefPredeclaredTestFuncs()
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Jul 30 21:14:09 UTC 2015
    - 46.6K bytes
    - Viewed (0)
  10. src/cmd/compile/internal/types2/expr.go

    	}
    	return x
    }
    
    // typeAssertion checks x.(T). The type of x must be an interface.
    func (check *Checker) typeAssertion(e syntax.Expr, x *operand, T Type, typeSwitch bool) {
    	var cause string
    	if check.assertableTo(x.typ, T, &cause) {
    		return // success
    	}
    
    	if typeSwitch {
    		check.errorf(e, ImpossibleAssert, "impossible type switch case: %s\n\t%s cannot have dynamic type %s %s", e, x, T, cause)
    		return
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed May 29 02:09:54 UTC 2024
    - 51.7K bytes
    - Viewed (0)
Back to top