package polyglot.types;

import polyglot.util.Position;
import polyglot.main.Report;
import java.util.*;

/**
 * Thrown during any number of phases of the compiler during which a semantic
 * error may be detected.
 */
public class SemanticException extends Exception {
    protected Position position;
    
    public SemanticException() {
        super();
    }

    public SemanticException(Throwable cause) {
        super(cause);
    }

    public SemanticException(Position position) {
	super();
	this.position = position;
    }

    public SemanticException(String m) {
        super(m);
    }

    public SemanticException(String m, Throwable cause) {
        super(m, cause);
    }

    public SemanticException(String m, Position position) {
	super(m);
	this.position = position;
    }

    public Position position() {
	return position;
    }
    
    static boolean init = false;
    static boolean fill = true;
    
    public synchronized Throwable fillInStackTrace() {
        if (! fill) {
            // fast path: init==true, fill==false
            return this;
        }
        if (! init) {
            fill = Report.should_report("trace", 1);
            init = true;
        }
        return super.fillInStackTrace();
    }
}

@@ -851,24 +851,32 @@
  %7D%0A    %0A    
+private 
 static boole
@@ -896,16 +896,23 @@
 se;%0A    
+public 
 static b
@@ -922,16 +922,28 @@
 ean fill
+InStackTrace
  = true;
@@ -1021,16 +1021,28 @@
  (! fill
+InStackTrace
 ) %7B%0A    
@@ -1079,16 +1079,28 @@
 ue, fill
+InStackTrace
 ==false%0A
@@ -1172,16 +1172,28 @@
     fill
+InStackTrace
  = Repor

Made fillInStackTrace flag public to help with debugging. Example: