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).
The text was updated successfully, but these errors were encountered:
griesemer
changed the title
spec: disallow impossible interface-interface type assertions
proposal: spec: disallow impossible interface-interface type assertions
May 6, 2020
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 interfaceI1
with a methodm()
, and an interfaceI2
with a method of the same name but different signaturem(int)
, the type assertionx.(I2)
can never succeed because no value satisfyingI1
can also satisfyI2
. The compiler can statically detect that this type assertion makes no sense (it will always panic or return false).The text was updated successfully, but these errors were encountered: