haxetink / tink_core

Core utilities
https://haxetink.github.io/tink_core
MIT License
116 stars 33 forks source link

tink.core.Lazy does not compile when targeting C# and Java #148

Closed sebthom closed 3 years ago

sebthom commented 3 years ago

I am using tink_testrunner in haxe-doctest and lately the java and c# target fail to compile because of this error:

Java: https://travis-ci.com/github/vegardit/haxe-doctest/jobs/423567360

haxelib run hxjava hxjava_build.txt --haxe-version 4005 --feature-level 1
javac "-sourcepath" "src" "-d" "obj" "-g" "@cmd"
src/tink/core/_Lazy/LazyFunc.java:7: error: LazyFunc is not abstract and does not override abstract method get() in LazyObject
public class LazyFunc<T> extends haxe.lang.HxObject implements tink.core._Lazy.LazyObject<T>
       ^
  where T is a type-variable:
    T extends Object declared in class LazyFunc
src/tink/core/_Lazy/LazyFunc.java:60: error: get() in LazyFunc cannot implement get() in LazyObject
    public java.lang.Object get()
                            ^
  return type Object is not compatible with T#2
  where T#1,T#2 are type-variables:
    T#1 extends Object declared in interface LazyObject
    T#2 extends Object declared in class LazyFunc
Note: src/haxe/root/Type.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
Compilation error
Native compilation failed

\ C#: https://travis-ci.com/github/vegardit/haxe-doctest/jobs/423567357

haxelib run hxcs hxcs_build.txt --haxe-version 4005 --feature-level 1
/home/travis/haxe/lib/tink_core/2,0,0-rc,1/src/tink/core/Future.hx(373,69): error CS0121: The call is ambiguous between the following methods or properties: `tink.core._Lazy.LazyObject.isComputed()' and `tink.core._Lazy.Computable.isComputed()'
src/tink/core/Lazy.cs(44,8): (Location of the symbol related to previous error)
src/tink/core/Lazy.cs(7,8): (Location of the symbol related to previous error)
Compilation failed: 1 error(s), 0 warnings
Compilation error
Native compilation failed

I tested with Haxe 4.1.4 and 4.0.4

Any ideas how to fix this?

kevinresol commented 3 years ago

do you have a minimal reproducible snippet?

sebthom commented 3 years ago

Here is a small sample project.

tink_test.zip

kevinresol commented 3 years ago

d1610609727244ab57fa03ddf362d5b57a0094c7 seems to fix c#.

As for java I am not sure if it is fixable. It is a long standing issue about type parameters in generated java. I suggest using jvm instead.

p.s. the generated java interface has T get();, but the generated implementation is java.lang.Object get();

sebthom commented 3 years ago

I wonder what changed in tink_core or tinkrunner lately as it used to work fine with Java target.

kevinresol commented 3 years ago

I think Lazy is overhauled in 2.0

back2dos commented 3 years ago

Works now. But as Kevin suggested, it's best to transition to the jvm target. The java target is not really maintained anymore, so it's only a matter of time until we run into an issue that requires a major workaround and we probably won't be able to afford maintaining that.

sebthom commented 3 years ago

Maybe we should get the java target deprecated officially.

sebthom commented 3 years ago

@back2dos @kevinresol Would you mind publishing another release (2.0.0-rc.2?) with this fix in place?

back2dos commented 3 years ago

Done.