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
When type-checking contracts, construct a parameterized named
interface for each of the contract parameters. Use those iterfaces
as type bounds for the type parameters.
This simplifies and cleans up the implementation.
Change-Id: I688e38542fa7fa83dd436439dd9ebe35af2f0458
Context-specific customization of parameterized interface methods of
type parameter bounds is missing; as a result some of linalg.go2 fails.
Change-Id: I3e749ee040d2b3ae8f73ae26680984bc1b4b79ef
If the type argument is itself a type parameter, we must use that
type parameter's bound to check against the bound of the type
parameter matching the type argument.
Change-Id: If5128115a9fc10af8163c37b1f75645447ead766
- type instantiations checks parameter count
- better positions for error messages
- removed some (now) dead code
Change-Id: Icf70642bbfd4e45a7762b002ea94704dc3d56475
This (temporarily) disables the use of recursively defined
generic types w/o repeating the type arguments, but such
type definitions need some more (type-checking) love anyway
before all conditions are checked.
Change-Id: I173f5ce2296b1c484ac95a3a887812c0b1f88245