File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
main/java/de/peeeq/wurstscript/translation/imtranslation
test/java/tests/wurstscript/tests Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -582,12 +582,12 @@ public void visit(ImTypeArgument ta) {
582582 @ Override
583583 public void visit (ImNull e ) {
584584 ImType newT = transformType (e .getType (), generics , typeVars );
585- newT = specializeType (newT );
586585 e .setType (newT );
587586
588587 ImExpr safe = specializeNullInitializer (e , newT );
589588 if (safe != e ) {
590589 e .replaceBy (safe );
590+ return ;
591591 }
592592 super .visit (e );
593593 }
Original file line number Diff line number Diff line change @@ -2023,5 +2023,35 @@ public void fullArrayListTest() throws IOException {
20232023 testAssertOkFileWithStdLib (new File (TEST_DIR + "arrayList.wurst" ), true );
20242024 }
20252025
2026+ @ Test
2027+ public void genericNullComparison () {
2028+ testAssertOkLinesWithStdLib (true ,
2029+ "package test" ,
2030+ "import NoWurst" ,
2031+ "import ClosureTimers" ,
2032+ "native testSuccess()" ,
2033+ "public class Reference<T:>" ,
2034+ " T val" ,
2035+ " construct(T val)" ,
2036+ " this.val = val" ,
2037+ " function into() returns T" ,
2038+ " let rval = val" ,
2039+ " destroy this" ,
2040+ " return rval" ,
2041+ "" ,
2042+ "var r = new Reference(0.0)" ,
2043+ "" ,
2044+ "init" ,
2045+ " // force member access on the global" ,
2046+ " doAfter(.1) ->" ,
2047+ " r.val = 1.0" ,
2048+ " if r != null and not r == null and r.into() == 1.0" ,
2049+ " testSuccess()" ,
2050+ " testSuccess() // to make compiler happy" ,
2051+ "endpackage"
2052+ );
2053+ }
2054+
2055+
20262056
20272057}
You can’t perform that action at this time.
0 commit comments