TODO
- some channel errors are not reported for generic variables
- error messages should be better
Change-Id: Ie388d6811b605645ea092481eee3a850c7ceb77b
Contract instantiation (= contracts with explicit type
arguments) should work now but has some implementation
restrictions:
- The type arguments provided to a contract must be
type parameters from the type parameter list using
the contract or the type parameter list of the en-
closing contract (in case of contract embedding).
- Each type argument may be used at most once per
contract expression.
Change-Id: Ia9f9d81e95d84f11ff3821b9f17b74eadab201f8
The typestring for embedded fields in structs was changed
by 8d30bd752d4 (type checking of function type parameters)
but this test was not updated.
Change-Id: I0d9438e3000939de09aa298c33ad1e9604a59fe8
Interface.is already takes care of iterating through all types of
a generic type bound; use it instead of writing custom loops each
time.
Change-Id: Ie0f91b27e5a7b65ea85a8c3847a954db1e9f24fe
This enables the distinction between a method M(int) and an
embedded instantiated (parameterized) interface (M(int)).
Change-Id: I150d1b1cd53a2b14ddc0ad6336d84078fcb41ad6
This simplifies the use of missingMethod again but moving the lazy
instantiation of methods into missingMethod. Method comparison now
also takes method type paramaters into account.
This change enables the first examples of parameterized methods
to type-check.
Change-Id: I4c629fb7b1f8959184c6ce5196365893d11b197d
Fixes bug with generic min being accepted even though the contract
or interface bound doesn't enumerate any types (or is missing).
Change-Id: Icdfc62fbd2b73ece397d5b5f1ebe27e52ed9b32f
This step further consolidates all parameter types (except for the
receiver) in an ast.FuncType which now matches more closely the
representation of a types.Signature. As a result, fewer parameters
need to passed around because we can just use an *ast.FuncType or
a *types.Signature instead.
As an immediate (and implicit) consequence, parameterized interface
methods now type-check. (But we cannot yet "implement" them with a
matching concrete type.)
Change-Id: I2ea24694ade9838488625ffec48d5e98070d1006
This is a generalization of type parameters to methods.
Being able to type-check them (even if we don't have an
idea how to actually implement such methods) is likely
going to inform the structure the type-checker: If the
code is organized correctly, the generalization should
mostly just work (and consist of the elimination of
extra checks).
So far, this first step only exposed some minor scoping
issues (where does the scope of type parameters start).
Change-Id: I8658ea8d1876a0ce9c62c0e9a7e943301e9cc19d
This follows the approach used for methods, but there is no error
reporting yet if a type is (explicitly) declared multiple times in
an interface.
Change-Id: I52428174ae278577a7c538b0817c6fb7af1c369e
Type parameters are now collected as part of signature type
checking, as they are part of the type not the object. This
opens the door to more uniform handling of type parameters,
also for concrete methods and interface methods (future use).
Cleaned up confusion between Signature.mtparams and tparams:
tparams are explicitly declared function type parameters.
mtparams is gone and replaced with rparams which are the
receiver type parameters used in the function.
Various related cleanups.
Change-Id: Id8422b57cc8fbc18ffdca12a69d890aef83c3f80
A signature that's instantiated but doesn't have any incoming
or result (value) parameters doesn't get a copy automatically.
This leads to bugs because the instantiated signature doesn't
lose its type parameters when it should.
Make a copy outside for now, this fixes some (but not all cases)
and added test cases.
Also, factored out printing of type parameters in type printing.
Change-Id: I0ec3a4226c7473cddfb16704a2218992dd411593
This change completes the prior change by adjusting the go/types
implementation accordingly. As a consequence, contracts may now
not occur in type context anymore and errors are reported if they
do.
With this change, all tests pass again.
Change-Id: Id984b3d24b7cb6ff2fceb74fd3c33fd0af91fdce
Progress snapshot.
This change makes a contract declaration a proper declaration (as it is
envisioned in the design draft). Specifically, contracts cannot be used
in type position anymore, and a contract declaration is not treated as
a type declaration with the type being a contract.
The change has not been pushed through go/types yet; this change will
temporarily brake go/types.
Change-Id: Ia4034caebab07dac449a02cdd362d6ce5d61c4a3
Once a generic function is instantiated, it's not generic anymore.
Also: Added various additional test cases.
Change-Id: Ic2304b6c252cfdf41e526825dda64b8a77023d47
The new lazy method substitution code seems to work. The bug was
in the test, not in the implementation!
Change-Id: I39794743a01e9725d57f49ccd7c3751376cd01d6
When instantiating a type, we should also instantiate its methods (at least their
signatures) so that they have the correct type when being looked up. Unfortunately,
methods may not yet be type-checked; and worse, when we type-check them, typing
their receiver means instantiating that type again which would require updating
(= instantiating) the methods...
Instead, we keep the original list of methods (*Funcs) with each (named) type
and only update the method signatures when looking them up. The problem with this
approach is that we need to know with which values to substitute the method (i.e.,
receiver) type parameters, and this is currently not working.
Change-Id: Ie1835919dc8bfb8161a6a9e3d784c3bbbeb958c4
This CL introduces an update mechanism to customize method signatures
with the correct type parameters before comparing them for equality.
The mechanism is not correctly used, yet.
Change-Id: Ib88af88e151578a3fb3a648ed70d3f462a936c9b