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
- print type bounds when printing function signatures
- store (named) tyep bound rather than underlying type
- first example using parameterized interface type bound working
Change-Id: Ic7110039d1e09838c8f33040e887e6a4f038d75d
Accept (parse and type-check) parameterized interfaces with literal
type constraints, as in contracts. For instance, instead of
contract C(T) {
T add(T) T
T int, string
}
one can write
type C(type T) interface {
add(T) T
type int, string
}
Their use as type bounds still needs some work, though.
Change-Id: I9d59681dc0ba38054ee5627be141fc6e8a78381b
- set correct token position for ast.ContractType
- print "best effort" interface position in "complete interface" traces
- don't print trace output for types that are already set up
- print contract "signtature" when printing Contract type
Also: rebased on top of today's master branch
Change-Id: I6a528ce51a4152c25ad5d83ad52e01df8e89d283
This change expands type inference to parameterized named types
and clarifies handling of type parameters during type inference
(specifically, an inferred type may be a type parameter itself).
The change also implements method selectors with parameterized
receiver types by using type inference to deduce the receiver
type parameters.
Add more tests and enable many disabled tests that now work
correctly.
Change-Id: I8e10f9166fec9a8454f14b8fb089230c70422a1b
Also: disabled aggressive rewriting of methods upon type instantiation
(Need to first figure out what we really need to do.)
Change-Id: I6fba78d60963534ebfe130164058ac1fbed7e5a3
A parameterized named type is in one of two states: not yet
instantiated, or instantiated. It may be instantiated with
any type, including (outer) type parameters. An instantiated
parameterized type may needs its type parameters substituted
if it is part of an enclosing type (or function) that is
instantiated.
A Named type has an extra field targs which is set to the
type arguments if the type is instantiated.
As a result, we don't need a representation for (partially)
instantiated parameterized types anymore: the Parameterized type
is now unused (but still present in the code).
Added a unique id field to TypeParam types so they can be
printed with a unique name. This permits the creation of a
unique type name for instantiated types which then can be used
for hashing that type name.
Also, made interfaces as type bounds work in more cases.
A handful of places (in testdata/map.go2, map2.go2) are broken
(commented out) and need investigation.
Change-Id: I137d352b419b2520eadde1b07f823375e0273dab
Always accept them but complain if they are not permitted.
The analogous parser check was lost in a recent change.
Also: Fix index computation in collectTypeParams.
Change-Id: I7cb89944984df6dadd7f603b56f0c3941d60f7c5
- implemented for comparisons for now
- can type-check generic min
- also: rebased on top of Go tip
Change-Id: Id35582a59c4cddcb2b4ae9c7d7154ef8e41580ab
Also: Recognize method expressions with parameterized receivers
and report an error for now (not implemented yet).
Change-Id: I96405b2b739d8e9fff6e9840347d3e78bfe8b6ec
To make the import work, the import needs to be changed into
`import "./chan"`, the file testdata/chans.go2 needs to be
copies into a new directory testdata/chan and the file must
be renamed to chans.go.
But this exposes some problem with instantiating parameterized
types with other type parameters. Delaying this for now.
Change-Id: I1cd784fb89c2374131f3b1105493492eb0189abc
... and various related smaller fixes
We can now type-check the slices, chans, and maps
examples from the design doc (with the maps example
prodcing an error because importing chans doesn't
work yet). Progress!
Change-Id: Ifc00359a9a1cdad3bde1659a7de2028ac2544469
- moved type parameter collection out of resolver and into decl phase
- collect (meta-) type information (contracts) for type parameters
- first cut at checking contract satisfaction (methods only for now)
Change-Id: I46707969a172423738171aaea9d5282fb4b25a44
- collect contract methods in respective interfaces
- basic checking on contract type constraints
Contracts are not yet tested against or used to type check
function bodies.
Change-Id: I13b00c44524e599f92f1ba5b4b5d6734e2bf22e1
- type parameters can be printed
- empty contracts can be printed
- contract constraints are missing (only started)
Change-Id: I787898203aeb064b0b2ac49a7b858313cee5f45b