generics: <T, ...> type parameters on classes and interfaces
- parse_type_params(): accepts an optional `<T, U, ...>` list after a class/interface/trait name and records the names. - The declaration is tagged `__generic` with the comma-joined parameter list (e.g. "T" or "K,V"). Parameters are an erasure model: they are compile-time only, so a generic class is an ordinary class at runtime. - tests/generics.cat + suite: generic class, generic interface, a class implementing a generic interface, and a two-parameter class. Suite 152 -> 155.
This commit is contained in:
1 parent
33a1152958
commit
841c445a05
3 files changed
+91
No files matched your search
@@ -263,6 +263,11 @@ check "trait-robot" "robot is Greeter: true" "`echo "$out" | sed -n 6p`"
|
||||
check "trait-sized" "sized: true" "`echo "$out" | sed -n 7p`"
|
||||
check "trait-sized-fn" "implements Sized: true" "`echo "$out" | sed -n 8p`"
|
||||
|
||||
out=`$BIN tests/generics.cat`
|
||||
check "generic-box" "box: hi T" "`echo "$out" | sed -n 1p`"
|
||||
check "generic-iface" "vec: 3 true" "`echo "$out" | sed -n 2p`"
|
||||
check "generic-pair" "pair: x 9 K,V" "`echo "$out" | sed -n 3p`"
|
||||
|
||||
out=`$BIN tests/aot.cat`
|
||||
exp=`$BIN tests/aot.cat`
|
||||
$BIN --build tests/aot.cat build/tests/aot_native >/dev/null 2>&1
|
||||
|
||||
Reference in new issue
Block a user