Skip to content

proposal: spec: disallow impossible interface-interface type assertions #38907

Open
@griesemer

Description

@griesemer

Now that we have introduced a vet check for this (see #4483), once we use modules to select the language version, we should disallow impossible interface-interface type assertions.

A quick refresher: Given a variable x of type interface I1 with a method m(), and an interface I2 with a method of the same name but different signature m(int), the type assertion x.(I2) can never succeed because no value satisfying I1 can also satisfy I2. The compiler can statically detect that this type assertion makes no sense (it will always panic or return false).

Metadata

Metadata

Assignees

Labels

AnalysisIssues related to static analysis (vet, x/tools/go/analysis)LanguageChangeSuggested changes to the Go languageLanguageChangeReviewDiscussed by language change review committeeProposal

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions