github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/simple/s1002/testdata/src/example.com/CheckIfBoolCmp/bool-cmp_generics.go (about)

     1  //go:build go1.18
     2  
     3  package pkg
     4  
     5  func tpfn1[T any]() T { var zero T; return zero }
     6  
     7  func tpfn() {
     8  	if tpfn1[bool]() == true { //@ diag(`simplified to tpfn1[bool]()`)
     9  	}
    10  	if tpfn1[any]() == true {
    11  	}
    12  }
    13  
    14  func tpfn2[T bool](x T) {
    15  	if x == true { //@ diag(`omit comparison to bool constant`)
    16  	}
    17  }
    18  
    19  func tpfn3[T ~bool](x T) {
    20  	if x == true { //@ diag(`omit comparison to bool constant`)
    21  	}
    22  }
    23  
    24  type MyBool bool
    25  
    26  func tpfn4[T bool | MyBool](x T) {
    27  	if x == true { //@ diag(`omit comparison to bool constant`)
    28  	}
    29  }