go/test/typeparam/issue48337a.dir/a.go
Dan Scales cea7a71d40 cmd/compile: fix generic type handling in crawler
There are a bunch of nodes beside ONAME and OTYPE, (such as OSTRUCTLIT
and OCOMPLIT) which can introduce a generic type that we need to mark.
So, just mark any generic type on any node in markInlBody. In this
particular issue, the type is introduced by an OSTRUCTLIT node.

Updates #48337

Change-Id: I271932518f0c1fb54d91a603e01a855c69df631d
Reviewed-on: https://go-review.googlesource.com/c/go/+/349909
Trust: Dan Scales <danscales@google.com>
Trust: Carlos Amedee <carlos@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-09-17 19:50:04 +00:00

33 lines
551 B
Go

// Copyright 2021 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package a
import (
"fmt"
"sync"
)
type WrapperWithLock[T any] interface {
PrintWithLock()
}
func NewWrapperWithLock[T any](value T) WrapperWithLock[T] {
return &wrapperWithLock[T]{
Object: value,
}
}
type wrapperWithLock[T any] struct {
Lock sync.Mutex
Object T
}
func (w *wrapperWithLock[T]) PrintWithLock() {
w.Lock.Lock()
defer w.Lock.Unlock()
fmt.Println(w.Object)
}