aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/target/jvm/reflection.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/target/jvm/reflection.lux')
-rw-r--r--stdlib/source/lux/target/jvm/reflection.lux43
1 files changed, 26 insertions, 17 deletions
diff --git a/stdlib/source/lux/target/jvm/reflection.lux b/stdlib/source/lux/target/jvm/reflection.lux
index afea0b0c2..4ae3ce64f 100644
--- a/stdlib/source/lux/target/jvm/reflection.lux
+++ b/stdlib/source/lux/target/jvm/reflection.lux
@@ -1,6 +1,7 @@
(.module:
[lux (#- type)
["." host (#+ import:)]
+ ["." type]
[abstract
["." monad (#+ do)]]
[control
@@ -100,7 +101,7 @@
(def: #export (load name)
(-> Text (Error (java/lang/Class java/lang/Object)))
(case (java/lang/Class::forName name)
- (#error.Success [class])
+ (#error.Success class)
(#error.Success class)
(#error.Failure error)
@@ -140,7 +141,7 @@
([[_ (#.Some bound)] #/.Upper]
[[(#.Some bound) _] #/.Lower])
- [#.None #.None]
+ _
(#error.Success (#/.Wildcard #.None)))
_)
(case (host.check java/lang/Class reflection)
@@ -218,21 +219,21 @@
(def: #export (return reflection)
(-> java/lang/reflect/Type (Error /.Return))
- (case (host.check java/lang/Class reflection)
- (#.Some class)
- (case (|> class
- (:coerce (java/lang/Class java/lang/Object))
- java/lang/Class::getName)
- (^ (static reflection.void))
- (#error.Success #.None)
-
- _
- (:: error.monad map (|>> #.Some)
- (..type reflection)))
-
- #.None
- (:: error.monad map (|>> #.Some)
- (..type reflection))))
+ (with-expansions [<else> (as-is (:: error.monad map (|>> #.Some)
+ (..type reflection)))]
+ (case (host.check java/lang/Class reflection)
+ (#.Some class)
+ (case (|> class
+ (:coerce (java/lang/Class java/lang/Object))
+ java/lang/Class::getName)
+ (^ (static reflection.void))
+ (#error.Success #.None)
+
+ _
+ <else>)
+
+ #.None
+ <else>)))
(exception: #export (cannot-correspond {class (java/lang/Class java/lang/Object)}
{type Type})
@@ -277,6 +278,14 @@
(#.Named name anonymousT)
(correspond class anonymousT)
+ (#.Apply inputT abstractionT)
+ (case (type.apply (list inputT) abstractionT)
+ (#.Some outputT)
+ (correspond class outputT)
+
+ #.None
+ (exception.throw ..non-jvm-type [type]))
+
_
(exception.throw ..non-jvm-type [type])))