Merge fixes:
 - Re-applied parts from ea2c66d41813ffe0a73e9227d41cf335eedf7fb6 (orig)
   that got lost during merging.
 - Repair InvocationSite as of Bug 384380 (one method lost).
 - Import fixes in tests
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
index 871bfed..c334792 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java
@@ -32589,16 +32589,7 @@
 				"}", // =================
 			},
 			"----------\n" + 
-<<<<<<< HEAD
 			"1. ERROR in X.java (at line 11)\n" + 
-=======
-			"1. ERROR in X.java (at line 7)\n" + 
-			"	abstract class GLinkElementView<M,CM> extends AbstractLinkView<M> {}\n" + 
-			"	               ^^^^^^^^^^^^^^^^\n" + 
-			"The return types are incompatible for the inherited methods ILinkViewElement.getViewer(), EditPart.getViewer(), AbstractLinkView<M>.getViewer()\n" + 
-			"----------\n" + 
-			"2. ERROR in X.java (at line 11)\n" + 
->>>>>>> ec20a16682652a850d7194f0a8e92d958de83c2b
 			"	public SheetViewer getViewer() { return null; }	\n" + 
 			"	       ^^^^^^^^^^^\n" + 
 			"The return type is incompatible with AbstractEditPart.getViewer()\n" + 
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTestJLS4.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTestJLS4.java
index d2a13fd..bb01a70 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTestJLS4.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterBugsTestJLS4.java
@@ -15,6 +15,9 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.JavaModelException;
+
 
 /**
  * Test suite to verify that DOM/AST bugs are fixed.
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingExpressionsTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingExpressionsTest.java
index 5de11c4..ff39a64 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingExpressionsTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/rewrite/describing/ASTRewritingExpressionsTest.java
@@ -19,6 +19,7 @@
 
 import org.eclipse.jdt.core.ICompilationUnit;
 import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.JavaCore;
 import org.eclipse.jdt.core.dom.*;
 import org.eclipse.jdt.core.dom.rewrite.ASTRewrite;
 import org.eclipse.jdt.core.dom.rewrite.ListRewrite;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
index 80ba5de..0d46bb3 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java
@@ -139,7 +139,7 @@
 	if (this.binding.declaringClass.isMemberType() && !this.binding.declaringClass.isStatic()) {
 		// allocating a non-static member type without an enclosing instance of parent type
 		// https://bugs.eclipse.org/bugs/show_bug.cgi?id=335845
-		currentScope.resetDeclaringClassMethodStaticFlag(this.binding.declaringClass.enclosingType());
+		currentScope.tagAsAccessingEnclosingInstanceStateOf(this.binding.declaringClass.enclosingType(), false /* type variable access */);
 		// Reviewed for https://bugs.eclipse.org/bugs/show_bug.cgi?id=378674 :
 		// The corresponding problem (when called from static) is not produced until during code generation
 	}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
index ebb4308..9cfc6b9 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java
@@ -150,7 +150,7 @@
 				ReferenceBinding superclass = this.binding.declaringClass.superclass();
 				if (superclass != null && superclass.isMemberType() && !superclass.isStatic()) {
 					// creating an anonymous type of a non-static member type without an enclosing instance of parent type
-					currentScope.resetDeclaringClassMethodStaticFlag(superclass.enclosingType());
+					currentScope.tagAsAccessingEnclosingInstanceStateOf(superclass.enclosingType(), false /* type variable access */);
 					// Reviewed for https://bugs.eclipse.org/bugs/show_bug.cgi?id=378674 :
 					// The corresponding problem (when called from static) is not produced until during code generation
 				}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java
index 59a28b5..07a6d45 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedThisReference.java
@@ -144,8 +144,7 @@
 			// otherwise problem will be reported by the caller
 			return this.resolvedType;
 		} else {
-			// Mark all methods between here and the declared type as not static
-			scope.resetDeclaringClassMethodStaticFlag(this.currentCompatibleType);
+			scope.tagAsAccessingEnclosingInstanceStateOf(this.currentCompatibleType, false /* type variable access */);
 		}
 
 		// Ensure one cannot write code like: B() { super(B.this); }
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java
index 6f63c16..65897fc 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InvocationSite.java
@@ -49,5 +49,6 @@
 		public int sourceEnd() {return this.node.sourceEnd; }
 		public int sourceStart() {return this.node.sourceStart; }
 		public TypeBinding expectedType() { return null; }
+		public boolean receiverIsImplicitThis() { return false; }
 	}
 }
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/describing/TypeDeclarationTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/describing/TypeDeclarationTest.java
index 3df6304..1461514 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/describing/TypeDeclarationTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/describing/TypeDeclarationTest.java
@@ -195,7 +195,7 @@
 		buf.append("}\n");
 		ICompilationUnit cu= pack1.createCompilationUnit("R1.java", buf.toString(), false, null);			
 
-		CompilationUnit astRoot= createAST3(cu);
+		CompilationUnit astRoot= createAST(cu);
 		ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
 		AST ast= astRoot.getAST();
 		
@@ -222,7 +222,7 @@
 		// re-get to also challenge ASTConverter and NaiveASTFlattener:
 		IPackageFragment pack2 = this.sourceFolder.createPackageFragment("test2.MyTeam", false, null);
 		cu= pack2.createCompilationUnit("R1.java", buf.toString(), false, null);		
-		astRoot= createAST3(cu);
+		astRoot= createAST(cu);
 		assertEqualString(astRoot.toString(), buf.toString());
 	}
 }