8034127: javac provide debug oriented toString() methods to InferenceContext and UndetVar
authorvromero
Thu, 13 Mar 2014 17:36:51 +0000
changeset 23395 e7e0973e6d2e
parent 23394 45a10f396552
child 23396 06e3726c6b3f
8034127: javac provide debug oriented toString() methods to InferenceContext and UndetVar Reviewed-by: jjg
langtools/src/share/classes/com/sun/tools/javac/code/Type.java
langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java	Tue Mar 11 17:52:45 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java	Thu Mar 13 17:36:51 2014 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1481,8 +1481,21 @@
         }
 
         public String toString() {
-            if (inst != null) return inst.toString();
-            else return qtype + "?";
+            return (inst == null) ? qtype + "?" : inst.toString();
+        }
+
+        public String debugString() {
+            String result = "inference var = " + qtype + "\n";
+            if (inst != null) {
+                result += "inst = " + inst + '\n';
+            }
+            for (InferenceBound bound: InferenceBound.values()) {
+                List<Type> aboundList = bounds.get(bound);
+                if (aboundList.size() > 0) {
+                    result += bound + " = " + aboundList + '\n';
+                }
+            }
+            return result;
         }
 
         @Override
@@ -1492,8 +1505,7 @@
 
         @Override
         public Type baseType() {
-            if (inst != null) return inst.baseType();
-            else return this;
+            return (inst == null) ? this : inst.baseType();
         }
 
         /** get all bounds of a given kind */
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java	Tue Mar 11 17:52:45 2014 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Mar 13 17:36:51 2014 +0000
@@ -2173,6 +2173,12 @@
             //back-door to infer
             return Infer.this;
         }
+
+        @Override
+        public String toString() {
+            return "Inference vars: " + inferencevars + '\n' +
+                   "Undet vars: " + undetvars;
+        }
     }
 
     final InferenceContext emptyContext = new InferenceContext(List.<Type>nil());