Skip to content

Commit 509d9f9

Browse files
xgopilotvisualfc
andcommitted
ssa: fix prog.Type error for instantiated generic types
When converting instantiated generic types (e.g., nistCurve[*P256Point]), the Instantiate function was using types.Instantiate with validate=true. This caused validation to fail because: 1. cvtNamed creates new type parameters with types.NewTypeParam() 2. The constraint on these new type parameters still references the OLD type parameter from the origin type 3. When validating, the method signatures don't match because the constraint expects methods with the old type param (e.g., Add(Point, Point)) but the type argument has methods with concrete types (e.g., Add(*P256Point, *P256Point)) The fix is to use validate=false since the original type was already validated by the Go type checker. Fixes #1636 Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: visualfc <714279+visualfc@users.noreply.github.com>
1 parent 9c8b6b3 commit 509d9f9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ssa/type_cvt.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ func Instantiate(orig types.Type, t *types.Named) (types.Type, bool) {
170170
for i := 0; i < tp.Len(); i++ {
171171
targs[i] = tp.At(i)
172172
}
173-
if typ, err := types.Instantiate(nil, orig, targs, true); err == nil {
173+
// Use validate=false because the newly created type parameters may not
174+
// match the original constraint references. The original type was already
175+
// validated by the Go type checker, so we can skip validation here.
176+
if typ, err := types.Instantiate(nil, orig, targs, false); err == nil {
174177
return typ, true
175178
}
176179
}

0 commit comments

Comments
 (0)