mirror of
https://github.com/golang/go
synced 2024-11-17 17:04:47 -07:00
4068fb6c21
This CL configures the parser to always accept 1.18 syntax (type parameters, type instantiations, interface elements), even when -lang is set to an earlier release. Instead, the type checker looks for 1.18 operations and complains if the language version is set to an earlier release. Doing these checks during type checking is necessary because it it is possible to write "generic" code using pre-1.18 syntax; for instance, an imported generic function may be implicitly instantiated (as in imported.Max(2, 3)), or an imported constraint interface may be embedded in an "ordinary" interface. Fixes #47818. Change-Id: I83ec302b3f4ba7196c0a4743c03670cfb901310d Reviewed-on: https://go-review.googlesource.com/c/go/+/344871 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
19 lines
459 B
Go
19 lines
459 B
Go
// errorcheck -lang=go1.17
|
|
|
|
// Copyright 2015 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.
|
|
|
|
// Issue 10975: Returning an invalid interface would cause
|
|
// `internal compiler error: getinarg: not a func`.
|
|
|
|
package main
|
|
|
|
type I interface {
|
|
int // ERROR "interface contains embedded non-interface|embedding non-interface type"
|
|
}
|
|
|
|
func New() I {
|
|
return struct{}{}
|
|
}
|