mirror of
https://github.com/golang/go
synced 2024-09-05 07:54:46 +00:00
[dev.typeparams] go/types, types2: set tset when constructing interfaces in the universe
As of CL 334894, type sets are lazily evaluated on interfaces. For the universe interfaces error and comparable, this can lead to data races when type checking concurrently. Fix this by computing their type set when they are defined. Tested using the repro from #47345. I considered checking this in as a test, but it probably wouldn't add much value going forward. Fixes #47345 Change-Id: I014a511b8e3c092c86201a8bfc7f5f494f8f20e8 Reviewed-on: https://go-review.googlesource.com/c/go/+/336910 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
6992dcdad9
commit
9f928f9318
|
@ -88,7 +88,9 @@ func defPredeclaredTypes() {
|
||||||
res := NewVar(nopos, nil, "", Typ[String])
|
res := NewVar(nopos, nil, "", Typ[String])
|
||||||
sig := NewSignature(nil, nil, NewTuple(res), false)
|
sig := NewSignature(nil, nil, NewTuple(res), false)
|
||||||
err := NewFunc(nopos, nil, "Error", sig)
|
err := NewFunc(nopos, nil, "Error", sig)
|
||||||
typ := NewNamed(obj, NewInterfaceType([]*Func{err}, nil), nil)
|
ityp := NewInterfaceType([]*Func{err}, nil)
|
||||||
|
computeTypeSet(nil, nopos, ityp) // prevent races due to lazy computation of tset
|
||||||
|
typ := NewNamed(obj, ityp, nil)
|
||||||
sig.recv = NewVar(nopos, nil, "", typ)
|
sig.recv = NewVar(nopos, nil, "", typ)
|
||||||
def(obj)
|
def(obj)
|
||||||
}
|
}
|
||||||
|
@ -99,7 +101,9 @@ func defPredeclaredTypes() {
|
||||||
obj.setColor(black)
|
obj.setColor(black)
|
||||||
sig := NewSignature(nil, nil, nil, false)
|
sig := NewSignature(nil, nil, nil, false)
|
||||||
eql := NewFunc(nopos, nil, "==", sig)
|
eql := NewFunc(nopos, nil, "==", sig)
|
||||||
typ := NewNamed(obj, NewInterfaceType([]*Func{eql}, nil), nil)
|
ityp := NewInterfaceType([]*Func{eql}, nil)
|
||||||
|
computeTypeSet(nil, nopos, ityp) // prevent races due to lazy computation of tset
|
||||||
|
typ := NewNamed(obj, ityp, nil)
|
||||||
sig.recv = NewVar(nopos, nil, "", typ)
|
sig.recv = NewVar(nopos, nil, "", typ)
|
||||||
def(obj)
|
def(obj)
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,9 @@ func defPredeclaredTypes() {
|
||||||
res := NewVar(token.NoPos, nil, "", Typ[String])
|
res := NewVar(token.NoPos, nil, "", Typ[String])
|
||||||
sig := NewSignature(nil, nil, NewTuple(res), false)
|
sig := NewSignature(nil, nil, NewTuple(res), false)
|
||||||
err := NewFunc(token.NoPos, nil, "Error", sig)
|
err := NewFunc(token.NoPos, nil, "Error", sig)
|
||||||
typ := NewNamed(obj, NewInterfaceType([]*Func{err}, nil), nil)
|
ityp := NewInterfaceType([]*Func{err}, nil)
|
||||||
|
computeTypeSet(nil, token.NoPos, ityp) // prevent races due to lazy computation of tset
|
||||||
|
typ := NewNamed(obj, ityp, nil)
|
||||||
sig.recv = NewVar(token.NoPos, nil, "", typ)
|
sig.recv = NewVar(token.NoPos, nil, "", typ)
|
||||||
def(obj)
|
def(obj)
|
||||||
}
|
}
|
||||||
|
@ -100,7 +102,9 @@ func defPredeclaredTypes() {
|
||||||
obj.setColor(black)
|
obj.setColor(black)
|
||||||
sig := NewSignature(nil, nil, nil, false)
|
sig := NewSignature(nil, nil, nil, false)
|
||||||
eql := NewFunc(token.NoPos, nil, "==", sig)
|
eql := NewFunc(token.NoPos, nil, "==", sig)
|
||||||
typ := NewNamed(obj, NewInterfaceType([]*Func{eql}, nil), nil)
|
ityp := NewInterfaceType([]*Func{eql}, nil)
|
||||||
|
computeTypeSet(nil, token.NoPos, ityp) // prevent races due to lazy computation of tset
|
||||||
|
typ := NewNamed(obj, ityp, nil)
|
||||||
sig.recv = NewVar(token.NoPos, nil, "", typ)
|
sig.recv = NewVar(token.NoPos, nil, "", typ)
|
||||||
def(obj)
|
def(obj)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue