Commits

Tim Vernum  committed 43989d2

Add another func test

  • Participants
  • Parent commits 485568e

Comments (0)

Files changed (4)

File convert/source/java/main/org/adjective/syntactic/convert/j8to7/type/ASTMethodInfo.java

 
     public ASTMethodInfo(final ModifierSet modifiers, final ASTMethodDeclaration method, final TypeParameterLookup lookup)
     {
+        if (modifiers == null)
+        {
+            throw new IllegalArgumentException("[Internal Error] Modifiers cannot be null");
+        }
+        if (method == null)
+        {
+            throw new IllegalArgumentException("[Internal Error] Method cannot be null");
+        }
+        if (lookup == null)
+        {
+            throw new IllegalArgumentException("[Internal Error] Lookup cannot be null");
+        }
         _method = method;
         _parameterLookup = lookup;
         _modifiers = new ModifierSet(modifiers);
 
         for (int i = 0; i < vals.length; i++)
         {
-            final int lookup = _parameterLookup.findParameterIndex(types[i].getTypeName());
-            if (lookup != -1)
+            final JavaType type = types[i];
+            if (type == null)
+            {
+                throw new IllegalStateException("[Internal Error] AST Method " + _method.getDebugInfo()
+                                                        + " has no type for parameter " + i);
+            }
+            final Integer lookup = _parameterLookup.findParameterIndex(type.getTypeName());
+            if (lookup != null)
             {
                 vals[i] = lookup;
             }

File convert/source/resource/test/functional/004-InterfaceInCompUnit.java

+package net.example;
+
+public class Foo
+{
+    private interface Fwizzle<S> { public abstract int fwizzle(Foo foo, S s, boolean bool); }
+
+    public int foo(String str)
+    {
+        Fwizzle<CharSequence> fw = (foo, seq, bool) -> {
+           return seq.length() + foo.hc(bool);
+        };
+        return fw.fwizzle(this, str, true);
+    }
+
+    private int hc(boolean sys) { return sys ? System.identityHashCode(this) : this.hashCode(); }
+}

File convert/source/resource/test/functional/004-InterfaceInCompUnit.java.convert

+package net.example;
+public class Foo {
+  private interface Fwizzle<S> {
+    public abstract int fwizzle(Foo foo, S s, boolean bool) ;
+  }
+public int foo(String str) {
+    Fwizzle<CharSequence> fw = new Fwizzle<CharSequence>() {
+      public int fwizzle(Foo foo, CharSequence seq, boolean bool) {
+        return seq.length()+foo.hc(bool);
+      }
+    }
+;
+    return fw.fwizzle(this, str, true);
+  }
+private int hc(boolean sys) {
+    return sys?System.identityHashCode(this):this.hashCode();
+  }
+}

File parser/source/java/parser/org/adjective/syntactic/parser/node/BaseNode.java

         setChildren(nodes);
     }
 
+    public CharSequence getDebugInfo()
+    {
+        StringBuilder builder = new StringBuilder(toString());
+        builder.append("(@");
+        final Token token = jjtGetFirstToken();
+        if (token == null)
+        {
+            builder.append("?)");
+            return builder;
+        }
+        builder.append(token.beginLine).append(':').append(token.beginColumn).append(' ').append(token.image);
+        builder.append(")");
+        return builder;
+    }
+
     private class NodeIterator<T extends Node> implements Iterator<T>
     {
         private final Class<T> _type;