diff options
author | Eduardo Julian | 2022-03-16 16:44:40 -0400 |
---|---|---|
committer | Eduardo Julian | 2022-03-16 16:44:40 -0400 |
commit | 49387dbbf08a9b06b815a662d117c7aa37120482 (patch) | |
tree | f9be901f65271f0a4a8a331f4aadc3ff84099c9f | |
parent | bf53ee92fc3c33a4885aa227e55d24f7ba3cb2c4 (diff) |
JVM interop now allows importing inherited virtual/interface methods.
16 files changed, 258 insertions, 254 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 11861f6b0..813fd5c75 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ jobs: steps: - uses: actions/checkout@v2 # Setup Aedifex - - run: wget https://github.com/LuxLang/lux/releases/download/0.6.5/aedifex_do_not_touch_2.jar && mv aedifex_do_not_touch_2.jar aedifex.jar + - run: wget https://github.com/LuxLang/lux/releases/download/0.6.5/aedifex_do_not_touch_3.jar && mv aedifex_do_not_touch_3.jar aedifex.jar - run: mv ./shell/lux.sh ./lux.sh # Test on the JVM # https://github.com/actions/setup-java diff --git a/lux-bootstrapper/src/lux/host.clj b/lux-bootstrapper/src/lux/host.clj index 00763ade3..7b114a772 100644 --- a/lux-bootstrapper/src/lux/host.clj +++ b/lux-bootstrapper/src/lux/host.clj @@ -111,10 +111,10 @@ lookup-field false ) -(do-template [<name> <static?> <method-type>] +(do-template [<name> <static?> <method-type> <options>] (defn <name> [class-loader target method-name args] (|let [target-class (Class/forName target true class-loader)] - (if-let [[^Method method ^Class declarer] (first (for [^Method =method (.getDeclaredMethods target-class) + (if-let [[^Method method ^Class declarer] (first (for [^Method =method (<options> target-class) :when (and (.equals ^Object method-name (.getName =method)) (.equals ^Object <static?> (Modifier/isStatic (.getModifiers =method))) (let [param-types (&/->list (seq (.getParameterTypes =method)))] @@ -125,22 +125,20 @@ (&/|map #(.getName ^Class %) param-types)))))] [=method (.getDeclaringClass =method)]))] - (if (= target-class declarer) - (|let [parent-gvars (->> target-class .getTypeParameters seq &/->list) - gvars (->> method .getTypeParameters seq &/->list) - gargs (->> method .getGenericParameterTypes seq &/->list) - _ (when (.getAnnotation method java.lang.Deprecated) - (println (str "[Host Warning] Deprecated method: " target "." method-name " " (->> args &/->seq print-str))))] - (return (&/T [(.getGenericReturnType method) - (->> method .getExceptionTypes &/->list (&/|map #(.getName ^Class %))) - parent-gvars - gvars - gargs]))) - (&/fail-with-loc (str "[Host Error] " <method-type> " method " (pr-str method-name) " for " "(" (->> args (&/|interpose ", ") (&/fold str "")) ")" " belongs to parent " (.getName declarer) " instead of " target))) + (|let [parent-gvars (->> target-class .getTypeParameters seq &/->list) + gvars (->> method .getTypeParameters seq &/->list) + gargs (->> method .getGenericParameterTypes seq &/->list) + _ (when (.getAnnotation method java.lang.Deprecated) + (println (str "[Host Warning] Deprecated method: " target "." method-name " " (->> args &/->seq print-str))))] + (return (&/T [(.getGenericReturnType method) + (->> method .getExceptionTypes &/->list (&/|map #(.getName ^Class %))) + parent-gvars + gvars + gargs]))) (&/fail-with-loc (str "[Host Error] " <method-type> " method does not exist: " target "." method-name " " "(" (->> args (&/|interpose ", ") (&/fold str "")) ")"))))) - lookup-static-method true "Static" - lookup-virtual-method false "Virtual" + lookup-static-method true "Static" .getDeclaredMethods + lookup-virtual-method false "Virtual" .getMethods ) (defn lookup-constructor [class-loader target args] diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index 7a80d68e7..df53c5058 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -4903,7 +4903,7 @@ _ (failure (..wrong_syntax_error (symbol ..$)))))) - (as_is)) + (as_is (def: .public parameter ""))) (macro: .public (using _imports) (do meta_monad diff --git a/stdlib/source/library/lux/control/parser/cli.lux b/stdlib/source/library/lux/control/parser/cli.lux index 83af80f87..11010725a 100644 --- a/stdlib/source/library/lux/control/parser/cli.lux +++ b/stdlib/source/library/lux/control/parser/cli.lux @@ -1,14 +1,14 @@ (.using - [library - [lux "*" - [abstract - [monad {"+" do}]] - [control - ["[0]" try {"+" Try}]] - [data - ["[0]" text ("[1]#[0]" equivalence) - ["%" format {"+" format}]]]]] - ["[0]" //]) + [library + [lux {"-" parameter} + [abstract + [monad {"+" do}]] + [control + ["[0]" try {"+" Try}]] + [data + ["[0]" text ("[1]#[0]" equivalence) + ["%" format {"+" format}]]]]] + ["[0]" //]) (type: .public (Parser a) (//.Parser (List Text) a)) diff --git a/stdlib/source/library/lux/control/parser/type.lux b/stdlib/source/library/lux/control/parser/type.lux index 6587f2270..3e772e237 100644 --- a/stdlib/source/library/lux/control/parser/type.lux +++ b/stdlib/source/library/lux/control/parser/type.lux @@ -1,6 +1,6 @@ (.using [library - [lux {"-" function local} + [lux {"-" function local parameter} [abstract ["[0]" monad {"+" do}]] [control diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux index 922f1da3c..9380fce55 100644 --- a/stdlib/source/library/lux/data/text.lux +++ b/stdlib/source/library/lux/data/text.lux @@ -286,15 +286,15 @@ (def: (hash input) (for @.old (|> input - (is (Primitive "java.lang.String")) - "jvm invokevirtual:java.lang.String:hashCode:" + (is (Primitive "java.lang.Object")) + "jvm invokevirtual:java.lang.Object:hashCode:" "jvm convert int-to-long" (as Nat)) @.jvm (|> input - (as (Primitive "java.lang.String")) - ("jvm member invoke virtual" [] "java.lang.String" "hashCode" []) + (as (Primitive "java.lang.Object")) + ("jvm member invoke virtual" [] "java.lang.Object" "hashCode" []) "jvm conversion int-to-long" "jvm object cast" (is (Primitive "java.lang.Long")) diff --git a/stdlib/source/library/lux/math.lux b/stdlib/source/library/lux/math.lux index 7395cb180..028ed346b 100644 --- a/stdlib/source/library/lux/math.lux +++ b/stdlib/source/library/lux/math.lux @@ -2,6 +2,7 @@ [library [lux "*" [extension {"+" analysis:}] + ["@" target] ["[0]" static] [abstract ["[0]" monad {"+" do}]] @@ -61,168 +62,169 @@ last prevs))))) -(with_expansions [<@> (static.text (let [[@ _] (symbol .._)] @)) - <ratio/0> [ratio.#numerator 0 ratio.#denominator 1] - <ratio/1> [ratio.#numerator 1 ratio.#denominator 1] - <complex/0> [complex.#real +0.0 complex.#imaginary +0.0] - <complex/1> [complex.#real +1.0 complex.#imaginary +0.0]] - (as_is (template [<name> <scenarios>'] - [(with_expansions [<extension> (static.seed) - <extension> (template.text [<@> " " <extension>]) - <scenarios> (template.spliced <scenarios>')] - (as_is (analysis: (<extension> self phase archive [operands (<>.some <code>.any)]) - (<| type.with_var - (function (_ [$it :it:])) - (do [! phase.monad] - [operands (monad.each ! (|>> (phase archive) (type.expecting :it:)) - operands) - _ (type.inference :it:) - :it: (type.check (check.identity (list) $it))] - (case (list.reversed operands) - (pattern (list single)) - (in single) - - (pattern (list)) - (`` (cond (check.subsumes? .I64 :it:) - (phase.except ..no_arithmetic_for [:it:]) - - (~~ (template [<type> <0> <+>] - [(check.subsumes? <type> :it:) - <0>] - - <scenarios>)) - - ... else - (phase.except ..no_arithmetic_for [:it:]))) - - (pattern (list& last prevs)) - (`` (cond (check.subsumes? .I64 :it:) - (phase.except ..no_arithmetic_for [:it:]) - - (~~ (template [<type> <0> <+>] - [(check.subsumes? <type> :it:) - (..composite phase archive (` <+>) last prevs)] - - <scenarios>)) - - ... else - (phase.except ..no_arithmetic_for [:it:]))))))) - (syntax: .public (<name> [operands (<>.some <code>.any)]) - (in (list (` (<extension> (~+ operands))))))))] - - [+ [[.Nat (in (analysis.nat 0)) "lux i64 +"] - [.Int (in (analysis.int +0)) "lux i64 +"] - [.Rev (in (analysis.rev .0)) "lux i64 +"] - [.Frac (in (analysis.frac +0.0)) "lux f64 +"] - [Ratio (type.expecting Ratio (phase archive (` <ratio/0>))) ratio.+] - [Complex (type.expecting Complex (phase archive (` <complex/0>))) complex.+]]] - [- [[.Nat (in (analysis.nat 0)) "lux i64 -"] - [.Int (in (analysis.int -0)) "lux i64 -"] - [.Rev (in (analysis.rev .0)) "lux i64 -"] - [.Frac (in (analysis.frac -0.0)) "lux f64 -"] - [Ratio (type.expecting Ratio (phase archive (` <ratio/0>))) ratio.-] - [Complex (type.expecting Complex (phase archive (` <complex/0>))) complex.-]]] - [* [[.Nat (in (analysis.nat 1)) nat.*] - [.Int (in (analysis.int +1)) "lux i64 *"] - [.Rev (in (analysis.rev rev./1)) rev.*] - [.Frac (in (analysis.frac +1.0)) "lux f64 *"] - [Ratio (type.expecting Ratio (phase archive (` <ratio/1>))) ratio.*] - [Complex (type.expecting Complex (phase archive (` <complex/1>))) complex.*]]] - [/ [[.Nat (in (analysis.nat 1)) nat./] - [.Int (in (analysis.int +1)) "lux i64 /"] - [.Rev (in (analysis.rev rev./1)) rev./] - [.Frac (in (analysis.frac +1.0)) "lux f64 /"] - [Ratio (type.expecting Ratio (phase archive (` <ratio/1>))) ratio./] - [Complex (type.expecting Complex (phase archive (` <complex/1>))) complex./]]] - ) - (template [<name> <scenarios>'] - [(with_expansions [<extension> (static.seed) - <extension> (template.text [<@> " " <extension>]) - <scenarios> (template.spliced <scenarios>')] - (as_is (analysis: (<extension> self phase archive [left <code>.any - right <code>.any]) - (<| type.with_var - (function (_ [$it :it:])) - (do [! phase.monad] - [left (type.expecting :it: (phase archive left)) - right (type.expecting :it: (phase archive right)) - _ (type.inference .Bit) - :it: (type.check (check.identity (list) $it))] - (`` (cond (check.subsumes? .I64 :it:) - (phase.except ..no_arithmetic_for [:it:]) - - (~~ (template [<type> <+>] - [(check.subsumes? <type> :it:) - (..composite phase archive (` <+>) right (list left))] - - <scenarios>)) - - ... else - (phase.except ..no_arithmetic_for [:it:])))))) - (syntax: .public (<name> [left <code>.any - right <code>.any]) - (in (list (` (<extension> (~ left) (~ right))))))))] - - [= [[.Nat "lux i64 ="] - [.Int "lux i64 ="] - [.Rev "lux i64 ="] - [.Frac "lux f64 ="] - [Ratio ratio.=] - [Complex complex.=]]] - [< [[.Nat nat.<] - [.Int "lux i64 <"] - [.Rev rev.<] - [.Frac "lux f64 <"] - [Ratio ratio.<]]] - [> [[.Nat nat.>] - [.Int int.>] - [.Rev rev.>] - [.Frac frac.>] - [Ratio ratio.>]]] - [<= [[.Nat nat.<=] - [.Int int.<=] - [.Rev rev.<=] - [.Frac frac.<=] - [Ratio ratio.<=]]] - [>= [[.Nat nat.>=] - [.Int int.>=] - [.Rev rev.>=] - [.Frac frac.>=] - [Ratio ratio.>=]]] - ) - (template [<name> <scenarios>'] - [(with_expansions [<extension> (static.seed) - <extension> (template.text [<@> " " <extension>]) - <scenarios> (template.spliced <scenarios>')] - (as_is (analysis: (<extension> self phase archive [left <code>.any - right <code>.any]) - (<| type.with_var - (function (_ [$it :it:])) - (do [! phase.monad] - [left (type.expecting :it: (phase archive left)) - right (type.expecting :it: (phase archive right)) - _ (type.inference :it:) - :it: (type.check (check.identity (list) $it))] - (`` (cond (check.subsumes? .I64 :it:) - (phase.except ..no_arithmetic_for [:it:]) - - (~~ (template [<type> <+>] - [(check.subsumes? <type> :it:) - (..composite phase archive (` <+>) right (list left))] - - <scenarios>)) - - ... else - (phase.except ..no_arithmetic_for [:it:])))))) - (syntax: .public (<name> [left <code>.any - right <code>.any]) - (in (list (` (<extension> (~ left) (~ right))))))))] - - [% [[.Nat nat.%] - [.Int "lux i64 %"] - [.Rev rev.%] - [.Frac "lux f64 %"] - [Ratio ratio.%] - [Complex complex.%]]] - ) - )) +(for @.old (as_is) + (with_expansions [<@> (static.text (let [[@ _] (symbol .._)] @)) + <ratio/0> [ratio.#numerator 0 ratio.#denominator 1] + <ratio/1> [ratio.#numerator 1 ratio.#denominator 1] + <complex/0> [complex.#real +0.0 complex.#imaginary +0.0] + <complex/1> [complex.#real +1.0 complex.#imaginary +0.0]] + (as_is (template [<name> <scenarios>'] + [(with_expansions [<extension> (static.seed) + <extension> (template.text [<@> " " <extension>]) + <scenarios> (template.spliced <scenarios>')] + (as_is (analysis: (<extension> self phase archive [operands (<>.some <code>.any)]) + (<| type.with_var + (function (_ [$it :it:])) + (do [! phase.monad] + [operands (monad.each ! (|>> (phase archive) (type.expecting :it:)) + operands) + _ (type.inference :it:) + :it: (type.check (check.identity (list) $it))] + (case (list.reversed operands) + (pattern (list single)) + (in single) + + (pattern (list)) + (`` (cond (check.subsumes? .I64 :it:) + (phase.except ..no_arithmetic_for [:it:]) + + (~~ (template [<type> <0> <+>] + [(check.subsumes? <type> :it:) + <0>] + + <scenarios>)) + + ... else + (phase.except ..no_arithmetic_for [:it:]))) + + (pattern (list& last prevs)) + (`` (cond (check.subsumes? .I64 :it:) + (phase.except ..no_arithmetic_for [:it:]) + + (~~ (template [<type> <0> <+>] + [(check.subsumes? <type> :it:) + (..composite phase archive (` <+>) last prevs)] + + <scenarios>)) + + ... else + (phase.except ..no_arithmetic_for [:it:]))))))) + (syntax: .public (<name> [operands (<>.some <code>.any)]) + (in (list (` (<extension> (~+ operands))))))))] + + [+ [[.Nat (in (analysis.nat 0)) "lux i64 +"] + [.Int (in (analysis.int +0)) "lux i64 +"] + [.Rev (in (analysis.rev .0)) "lux i64 +"] + [.Frac (in (analysis.frac +0.0)) "lux f64 +"] + [Ratio (type.expecting Ratio (phase archive (` <ratio/0>))) ratio.+] + [Complex (type.expecting Complex (phase archive (` <complex/0>))) complex.+]]] + [- [[.Nat (in (analysis.nat 0)) "lux i64 -"] + [.Int (in (analysis.int -0)) "lux i64 -"] + [.Rev (in (analysis.rev .0)) "lux i64 -"] + [.Frac (in (analysis.frac -0.0)) "lux f64 -"] + [Ratio (type.expecting Ratio (phase archive (` <ratio/0>))) ratio.-] + [Complex (type.expecting Complex (phase archive (` <complex/0>))) complex.-]]] + [* [[.Nat (in (analysis.nat 1)) nat.*] + [.Int (in (analysis.int +1)) "lux i64 *"] + [.Rev (in (analysis.rev rev./1)) rev.*] + [.Frac (in (analysis.frac +1.0)) "lux f64 *"] + [Ratio (type.expecting Ratio (phase archive (` <ratio/1>))) ratio.*] + [Complex (type.expecting Complex (phase archive (` <complex/1>))) complex.*]]] + [/ [[.Nat (in (analysis.nat 1)) nat./] + [.Int (in (analysis.int +1)) "lux i64 /"] + [.Rev (in (analysis.rev rev./1)) rev./] + [.Frac (in (analysis.frac +1.0)) "lux f64 /"] + [Ratio (type.expecting Ratio (phase archive (` <ratio/1>))) ratio./] + [Complex (type.expecting Complex (phase archive (` <complex/1>))) complex./]]] + ) + (template [<name> <scenarios>'] + [(with_expansions [<extension> (static.seed) + <extension> (template.text [<@> " " <extension>]) + <scenarios> (template.spliced <scenarios>')] + (as_is (analysis: (<extension> self phase archive [left <code>.any + right <code>.any]) + (<| type.with_var + (function (_ [$it :it:])) + (do [! phase.monad] + [left (type.expecting :it: (phase archive left)) + right (type.expecting :it: (phase archive right)) + _ (type.inference .Bit) + :it: (type.check (check.identity (list) $it))] + (`` (cond (check.subsumes? .I64 :it:) + (phase.except ..no_arithmetic_for [:it:]) + + (~~ (template [<type> <+>] + [(check.subsumes? <type> :it:) + (..composite phase archive (` <+>) right (list left))] + + <scenarios>)) + + ... else + (phase.except ..no_arithmetic_for [:it:])))))) + (syntax: .public (<name> [left <code>.any + right <code>.any]) + (in (list (` (<extension> (~ left) (~ right))))))))] + + [= [[.Nat "lux i64 ="] + [.Int "lux i64 ="] + [.Rev "lux i64 ="] + [.Frac "lux f64 ="] + [Ratio ratio.=] + [Complex complex.=]]] + [< [[.Nat nat.<] + [.Int "lux i64 <"] + [.Rev rev.<] + [.Frac "lux f64 <"] + [Ratio ratio.<]]] + [> [[.Nat nat.>] + [.Int int.>] + [.Rev rev.>] + [.Frac frac.>] + [Ratio ratio.>]]] + [<= [[.Nat nat.<=] + [.Int int.<=] + [.Rev rev.<=] + [.Frac frac.<=] + [Ratio ratio.<=]]] + [>= [[.Nat nat.>=] + [.Int int.>=] + [.Rev rev.>=] + [.Frac frac.>=] + [Ratio ratio.>=]]] + ) + (template [<name> <scenarios>'] + [(with_expansions [<extension> (static.seed) + <extension> (template.text [<@> " " <extension>]) + <scenarios> (template.spliced <scenarios>')] + (as_is (analysis: (<extension> self phase archive [left <code>.any + right <code>.any]) + (<| type.with_var + (function (_ [$it :it:])) + (do [! phase.monad] + [left (type.expecting :it: (phase archive left)) + right (type.expecting :it: (phase archive right)) + _ (type.inference :it:) + :it: (type.check (check.identity (list) $it))] + (`` (cond (check.subsumes? .I64 :it:) + (phase.except ..no_arithmetic_for [:it:]) + + (~~ (template [<type> <+>] + [(check.subsumes? <type> :it:) + (..composite phase archive (` <+>) right (list left))] + + <scenarios>)) + + ... else + (phase.except ..no_arithmetic_for [:it:])))))) + (syntax: .public (<name> [left <code>.any + right <code>.any]) + (in (list (` (<extension> (~ left) (~ right))))))))] + + [% [[.Nat nat.%] + [.Int "lux i64 %"] + [.Rev rev.%] + [.Frac "lux f64 %"] + [Ratio ratio.%] + [Complex complex.%]]] + ) + ))) diff --git a/stdlib/source/library/lux/target/jvm/reflection.lux b/stdlib/source/library/lux/target/jvm/reflection.lux index 29776163c..bc587e90c 100644 --- a/stdlib/source/library/lux/target/jvm/reflection.lux +++ b/stdlib/source/library/lux/target/jvm/reflection.lux @@ -1,6 +1,6 @@ (.using [library - [lux {"-" Primitive type} + [lux {"-" Primitive type parameter} ["[0]" ffi {"+" import:}] ["[0]" type] [abstract diff --git a/stdlib/source/library/lux/target/jvm/type/alias.lux b/stdlib/source/library/lux/target/jvm/type/alias.lux index 6f24b61ee..9c802f924 100644 --- a/stdlib/source/library/lux/target/jvm/type/alias.lux +++ b/stdlib/source/library/lux/target/jvm/type/alias.lux @@ -1,6 +1,6 @@ (.using [library - [lux {"-" Type Primitive int char type} + [lux {"-" Type Primitive int char type parameter} [abstract ["[0]" monad {"+" do}]] [control diff --git a/stdlib/source/library/lux/target/jvm/type/lux.lux b/stdlib/source/library/lux/target/jvm/type/lux.lux index c89fabc2a..c608b7a94 100644 --- a/stdlib/source/library/lux/target/jvm/type/lux.lux +++ b/stdlib/source/library/lux/target/jvm/type/lux.lux @@ -1,6 +1,6 @@ (.using [library - [lux {"-" Primitive int char type} + [lux {"-" Primitive int char type parameter} [abstract ["[0]" monad {"+" do}]] [control @@ -16,7 +16,7 @@ ["[0]" array] ["[0]" dictionary {"+" Dictionary}]]] [type - abstract + [abstract {"-" pattern}] ["[0]" check {"+" Check} ("[1]#[0]" monad)]]]] ["[0]" // [category {"+" Void Value Return Method Primitive Object Class Array Var Parameter}] diff --git a/stdlib/source/library/lux/target/jvm/type/parser.lux b/stdlib/source/library/lux/target/jvm/type/parser.lux index a1bea32fc..b576c8d5b 100644 --- a/stdlib/source/library/lux/target/jvm/type/parser.lux +++ b/stdlib/source/library/lux/target/jvm/type/parser.lux @@ -1,6 +1,6 @@ (.using [library - [lux {"-" Type Primitive int char} + [lux {"-" Type Primitive int char parameter} [abstract [monad {"+" do}]] [control diff --git a/stdlib/source/library/lux/target/php.lux b/stdlib/source/library/lux/target/php.lux index 1dd67843b..f0a2d560c 100644 --- a/stdlib/source/library/lux/target/php.lux +++ b/stdlib/source/library/lux/target/php.lux @@ -1,6 +1,6 @@ (.using [library - [lux {"-" Location Code Global Label static int if cond or and not comment for try global the} + [lux {"-" Location Code Global Label static int if cond or and not comment for try global the parameter} ["@" target] [abstract [equivalence {"+" Equivalence}] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux index ea51560df..999331c91 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux @@ -1173,7 +1173,7 @@ (monad.each try.monad reflection!.type) phase.lifted) .let [modifiers (java/lang/reflect/Method::getModifiers method) - correct_class? (java/lang/Object::equals class (java/lang/reflect/Method::getDeclaringClass method)) + correct_class? (java/lang/Class::isAssignableFrom class (java/lang/reflect/Method::getDeclaringClass method)) correct_method? (text#= method_name (java/lang/reflect/Method::getName method)) same_static? (case method_style {#Static} @@ -1188,7 +1188,8 @@ _ true) - same_inputs? (and (n.= (list.size inputsJT) (list.size parameters)) + same_inputs? (and (n.= (list.size inputsJT) + (list.size parameters)) (list.every? (function (_ [expectedJC actualJC]) (jvm#= expectedJC (de_aliased aliasing actualJC))) (list.zipped/2 parameters inputsJT)))]] @@ -1372,14 +1373,47 @@ (list#each parser.name expected)) (dictionary.of_list text.hash))) -(def: (method_candidate class_loader actual_class_tvars class_name actual_method_tvars method_name method_style inputsJT) - (-> java/lang/ClassLoader (List (Type Var)) External (List (Type Var)) Text Method_Style (List (Type Value)) (Operation Method_Signature)) +(def: (family_tree' it) + (-> (java/lang/Class java/lang/Object) + (List (java/lang/Class java/lang/Object))) + (let [interfaces (array.list {.#None} (java/lang/Class::getInterfaces it)) + supers (case (java/lang/Class::getSuperclass it) + {.#Some class} + (list& class interfaces) + + {.#None} + interfaces)] + (|> supers + (list#each family_tree') + list#conjoint + (list& it)))) + +(def: family_tree + (-> (java/lang/Class java/lang/Object) + (List (java/lang/Class java/lang/Object))) + (|>> ..family_tree' + ... De-duplication + (list#mix (function (_ class all) + (dictionary.has (java/lang/Class::getName class) class all)) + (dictionary.empty text.hash)) + dictionary.values)) + +(def: (all_declared_methods it) + (-> (java/lang/Class java/lang/Object) + (List java/lang/reflect/Method)) + (|> it + ..family_tree + (list#each (|>> java/lang/Class::getDeclaredMethods (array.list {.#None}))) + list#conjoint)) + +(def: (method_candidate allow_inheritance? class_loader actual_class_tvars class_name actual_method_tvars method_name method_style inputsJT) + (-> Bit java/lang/ClassLoader (List (Type Var)) External (List (Type Var)) Text Method_Style (List (Type Value)) (Operation Method_Signature)) (do [! phase.monad] [class (phase.lifted (reflection!.load class_loader class_name)) .let [expected_class_tvars (class_type_variables class)] - candidates (|> class - java/lang/Class::getDeclaredMethods - (array.list {.#None}) + candidates (|> (if allow_inheritance? + (all_declared_methods class) + (array.list {.#None} (java/lang/Class::getDeclaredMethods class))) (list.only (|>> java/lang/reflect/Method::getName (text#= method_name))) (monad.each ! (is (-> java/lang/reflect/Method (Operation Evaluation)) (function (_ method) @@ -1399,8 +1433,10 @@ {.#End} (/////analysis.except ..no_candidates [actual_class_tvars class_name method_name actual_method_tvars inputsJT (list.all hint! candidates)]) - candidates - (/////analysis.except ..too_many_candidates [actual_class_tvars class_name method_name actual_method_tvars inputsJT candidates])))) + {.#Item method alternatives} + (if allow_inheritance? + (in method) + (/////analysis.except ..too_many_candidates [actual_class_tvars class_name method_name actual_method_tvars inputsJT (list& method alternatives)]))))) (def: constructor_method "<init>") @@ -1467,7 +1503,7 @@ (do phase.monad [_ (..ensure_fresh_class! class_loader class) .let [argsT (list#each product.left argsTC)] - [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class method_tvars method {#Static} argsT) + [methodT deprecated? exceptionsT] (..method_candidate false class_loader class_tvars class method_tvars method {#Static} argsT) _ (phase.assertion ..deprecated_method [class method methodT] (not deprecated?)) [outputT argsA] (inference.general archive analyse methodT (list#each product.right argsTC)) @@ -1485,7 +1521,7 @@ (do phase.monad [_ (..ensure_fresh_class! class_loader class) .let [argsT (list#each product.left argsTC)] - [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class method_tvars method {#Virtual} argsT) + [methodT deprecated? exceptionsT] (..method_candidate true class_loader class_tvars class method_tvars method {#Virtual} argsT) _ (phase.assertion ..deprecated_method [class method methodT] (not deprecated?)) [outputT allA] (inference.general archive analyse methodT (list& objectC (list#each product.right argsTC))) @@ -1510,7 +1546,7 @@ (do phase.monad [_ (..ensure_fresh_class! class_loader class) .let [argsT (list#each product.left argsTC)] - [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class method_tvars method {#Special} argsT) + [methodT deprecated? exceptionsT] (..method_candidate false class_loader class_tvars class method_tvars method {#Special} argsT) _ (phase.assertion ..deprecated_method [class method methodT] (not deprecated?)) [outputT allA] (inference.general archive analyse methodT (list& objectC (list#each product.right argsTC))) @@ -1538,7 +1574,7 @@ class (phase.lifted (reflection!.load class_loader class_name)) _ (phase.assertion non_interface class_name (java/lang/reflect/Modifier::isInterface (java/lang/Class::getModifiers class))) - [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class_name method_tvars method {#Interface} argsT) + [methodT deprecated? exceptionsT] (..method_candidate true class_loader class_tvars class_name method_tvars method {#Interface} argsT) _ (phase.assertion ..deprecated_method [class_name method methodT] (not deprecated?)) [outputT allA] (inference.general archive analyse methodT (list& objectC (list#each product.right argsTC))) @@ -1641,39 +1677,6 @@ (list (/////analysis.text argument) (value_analysis argumentJT)))) -(def: (family_tree' it) - (-> (java/lang/Class java/lang/Object) - (List (java/lang/Class java/lang/Object))) - (let [interfaces (array.list {.#None} (java/lang/Class::getInterfaces it)) - supers (case (java/lang/Class::getSuperclass it) - {.#Some class} - (list& class interfaces) - - {.#None} - interfaces)] - (|> supers - (list#each family_tree') - list#conjoint - (list& it)))) - -(def: family_tree - (-> (java/lang/Class java/lang/Object) - (List (java/lang/Class java/lang/Object))) - (|>> ..family_tree' - ... De-duplication - (list#mix (function (_ class all) - (dictionary.has (java/lang/Class::getName class) class all)) - (dictionary.empty text.hash)) - dictionary.values)) - -(def: (all_declared_methods it) - (-> (java/lang/Class java/lang/Object) - (List java/lang/reflect/Method)) - (|> it - ..family_tree - (list#each (|>> java/lang/Class::getDeclaredMethods (array.list {.#None}))) - list#conjoint)) - (template [<name> <only> <methods>] [(def: (<name> [type class]) (-> [(Type Class) (java/lang/Class java/lang/Object)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux index 081984baf..93435b43b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux @@ -364,7 +364,7 @@ (exception: .public (not_an_object_array [arrayJT (Type Array)]) (exception.report - ["JVM Type" (..signature arrayJT)])) + "JVM Type" (..signature arrayJT))) (def: .public object_array (Parser (Type Object)) @@ -377,7 +377,7 @@ (in elementJT) {.#None} - (<>.failure (exception.error ..not_an_object_array arrayJT))) + (<>.failure (exception.error ..not_an_object_array [arrayJT]))) {.#None} (undefined)))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/cli/compiler.lux b/stdlib/source/library/lux/tool/compiler/meta/cli/compiler.lux index 09eef4deb..898e4c5c3 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cli/compiler.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cli/compiler.lux @@ -1,6 +1,6 @@ (.using [library - [lux "*" + [lux {"-" parameter} [abstract [monad {"+" do}] [equivalence {"+" Equivalence}]] diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux index f55d026a3..ed65518e4 100644 --- a/stdlib/source/program/aedifex/command/build.lux +++ b/stdlib/source/program/aedifex/command/build.lux @@ -270,7 +270,8 @@ _ (revised ///runtime.#parameters (|>> (list& "-cp" (..jvm_class_path host_dependencies) - "--add-opens" "java.base/java.lang=ALL-UNNAMED")) + "--add-opens" "java.base/java.lang=ALL-UNNAMED" + "-Xss16m")) runtime))) (def: .public (do! console program fs shell resolution) |