aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/target/jvm/reflection.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/target/jvm/reflection.lux22
1 files changed, 16 insertions, 6 deletions
diff --git a/stdlib/source/lux/target/jvm/reflection.lux b/stdlib/source/lux/target/jvm/reflection.lux
index e65b6061f..afea0b0c2 100644
--- a/stdlib/source/lux/target/jvm/reflection.lux
+++ b/stdlib/source/lux/target/jvm/reflection.lux
@@ -23,7 +23,8 @@
(import: #long java/lang/String)
(import: #long java/lang/Object
- (toString [] java/lang/String))
+ (toString [] java/lang/String)
+ (getClass [] (java/lang/Class java/lang/Object)))
(import: #long java/lang/reflect/Type
(getTypeName [] java/lang/String))
@@ -89,10 +90,10 @@
(template [<name>]
[(exception: #export (<name> {jvm-type java/lang/reflect/Type})
(exception.report
- ["Type" (java/lang/reflect/Type::getTypeName jvm-type)]))]
+ ["Type" (java/lang/reflect/Type::getTypeName jvm-type)]
+ ["Class" (|> jvm-type java/lang/Object::getClass java/lang/Object::toString)]))]
[not-a-class]
- [cannot-convert-to-a-parameter]
[cannot-convert-to-a-lux-type]
)
@@ -120,13 +121,22 @@
_)
(case (host.check java/lang/reflect/WildcardType reflection)
(#.Some reflection)
+ ## TODO: Instead of having single lower/upper bounds, should
+ ## allow for multiple ones.
(case [(array.read 0 (java/lang/reflect/WildcardType::getLowerBounds reflection))
(array.read 0 (java/lang/reflect/WildcardType::getUpperBounds reflection))]
(^template [<pattern> <kind>]
<pattern>
- (do error.monad
- [bound (generic bound)]
- (wrap (#/.Wildcard (#.Some [<kind> bound])))))
+ (case (host.check java/lang/reflect/GenericArrayType bound)
+ (#.Some _)
+ ## TODO: Array bounds should not be "erased" as they
+ ## are right now.
+ (#error.Success (#/.Wildcard #.None))
+
+ _
+ (:: error.monad map
+ (|>> [<kind>] #.Some #/.Wildcard)
+ (generic bound))))
([[_ (#.Some bound)] #/.Upper]
[[(#.Some bound) _] #/.Lower])