Bug 550408 - [compiler] Bogus compile error observed on team
CheckUniqueCallinCapture
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
index 91c7ffc..d2f57f1 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractRegressionTest.java
@@ -544,6 +544,9 @@
 }
 protected static class JavacTestOptions {
 	static final JavacTestOptions DEFAULT = new JavacTestOptions();
+//{ObjectTeams:
+	public
+// SH}
 	static final JavacTestOptions SKIP = new JavacTestOptions() {
 		boolean skip(JavacCompiler compiler) {
 			return true;
@@ -3090,7 +3093,12 @@
 // - check the callees statistics for wrapper methods and tune them accordingly
 //   (aka, suppress low profile ones).
 // WORK log test files in all failure cases (ez cut and paste)
+//{ObjectTeams: make available for our copy of Runner:
+/* orig:
 	private void runTest(
+  :giro */
+	public void runTest(
+// SH}
 			// test directory preparation
 			boolean shouldFlushOutputDirectory,
 			String[] testFiles,
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java
index 5291bd6..d1569bd 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/classfmt/MethodInfo.java
@@ -547,10 +547,8 @@
 		readOffset += (6 + u4At(readOffset + 2));
 	}
 //{ObjectTeams: combine sets of modifiers
-	if (otFlags != 0) {
-		if ((otFlags & HAVE_OT_MODIFIERS) != 0) {
-			flags &= ~ExtraCompilerModifiers.AccVisibilityMASK; // replace those bits
-		}
+	if ((otFlags & HAVE_OT_MODIFIERS) != 0) {
+		flags &= ~ExtraCompilerModifiers.AccVisibilityMASK; // replace those bits
 		flags |= (otFlags & 0xffffffff);
 	}
 // SH}
@@ -565,6 +563,7 @@
      * @param readOffset
      * @param aStructOffset (subtract when indexing via constantPoolOffsets)
      * @param someConstantPoolOffsets
+     * @return (visibility modifiers | HAVE_OT_MODIFIERS) or 0 
      */
     long readOTAttribute(
             char[]     attributeName,
@@ -593,7 +592,6 @@
         else if (CharOperation.equals(attributeName, CALLIN_FLAGS))
         {
             this.methodAttributes.add(WordValueAttribute.readCallinFlags(info, readOffset));
-            return ExtraCompilerModifiers.AccCallin;
         }
         else if (CharOperation.equals(attributeName, TYPE_ANCHOR_LIST))
         {
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/AbstractOTJLDTest.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/AbstractOTJLDTest.java
index a65fc82..6203a05 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/AbstractOTJLDTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/AbstractOTJLDTest.java
@@ -32,7 +32,9 @@
 import org.eclipse.jdt.core.tests.util.CompilerTestSetup;
 import org.eclipse.jdt.core.tests.util.TestVerifier;
 import org.eclipse.jdt.core.tests.util.Util;
+import org.eclipse.jdt.internal.compiler.ASTVisitor;
 import org.eclipse.jdt.internal.compiler.Compiler;
+import org.eclipse.jdt.internal.compiler.ICompilerRequestor;
 import org.eclipse.jdt.internal.compiler.batch.FileSystem;
 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
 import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
@@ -133,6 +135,115 @@
 	protected String spliteratorCallout() {
 		return (IS_JRE_8 && this.complianceLevel < ClassFileConstants.JDK1_8) ? "spliterator -> spliterator;\n" : "";
 	}
+	
+// copy from JDT-orig for visibility's sake
+	protected class Runner {
+		public boolean shouldFlushOutputDirectory = true;
+		// input:
+		public String[] testFiles;
+		public String[] dependantFiles;
+		public String[] classLibraries;
+		public boolean  libsOnModulePath;
+		// control compilation:
+		public Map<String,String> customOptions;
+		public boolean performStatementsRecovery;
+		public boolean generateOutput;
+		public ICompilerRequestor customRequestor;
+		// compiler result:
+		public String expectedCompilerLog;
+		public String[] alternateCompilerLogs;
+		public boolean showCategory;
+		public boolean showWarningToken;
+		// javac:
+		public boolean skipJavac;
+		public String expectedJavacOutputString;
+		public JavacTestOptions javacTestOptions;
+		// execution:
+		public boolean forceExecution;
+		public String[] vmArguments;
+		public String expectedOutputString;
+		public String expectedErrorString;
+
+		public ASTVisitor visitor;
+
+		public Runner() {}
+
+		public void runConformTest() {
+			runTest(this.shouldFlushOutputDirectory,
+					this.testFiles,
+					this.dependantFiles != null ? this.dependantFiles : new String[] {},
+					this.classLibraries,
+					this.libsOnModulePath,
+					this.customOptions,
+					this.performStatementsRecovery,
+					new Requestor(
+							this.generateOutput,
+							this.customRequestor,
+							this.showCategory,
+							this.showWarningToken),
+					false,
+					this.expectedCompilerLog,
+					this.alternateCompilerLogs,
+					this.forceExecution,
+					this.vmArguments,
+					this.expectedOutputString,
+					this.expectedErrorString,
+					this.visitor,
+					this.expectedJavacOutputString != null ? this.expectedJavacOutputString : this.expectedOutputString,
+					this.skipJavac ? JavacTestOptions.SKIP : this.javacTestOptions);
+		}
+
+		public void runNegativeTest() {
+			runTest(this.shouldFlushOutputDirectory,
+					this.testFiles,
+					this.dependantFiles != null ? this.dependantFiles : new String[] {},
+					this.classLibraries,
+					this.libsOnModulePath,
+					this.customOptions,
+					this.performStatementsRecovery,
+					new Requestor(
+							this.generateOutput,
+							this.customRequestor,
+							this.showCategory,
+							this.showWarningToken),
+					true,
+					this.expectedCompilerLog,
+					this.alternateCompilerLogs,
+					this.forceExecution,
+					this.vmArguments,
+					this.expectedOutputString,
+					this.expectedErrorString,
+					this.visitor,
+					this.expectedJavacOutputString != null ? this.expectedJavacOutputString : this.expectedOutputString,
+					this.skipJavac ? JavacTestOptions.SKIP : this.javacTestOptions);
+		}
+
+		public void runWarningTest() {
+			runTest(this.shouldFlushOutputDirectory,
+					this.testFiles,
+					this.dependantFiles != null ? this.dependantFiles : new String[] {},
+					this.classLibraries,
+					this.libsOnModulePath,
+					this.customOptions,
+					this.performStatementsRecovery,
+					new Requestor(
+							this.generateOutput,
+							this.customRequestor,
+							this.showCategory,
+							this.showWarningToken),
+					false,
+					this.expectedCompilerLog,
+					this.alternateCompilerLogs,
+					this.forceExecution,
+					this.vmArguments,
+					this.expectedOutputString,
+					this.expectedErrorString,
+					this.visitor,
+					this.expectedJavacOutputString != null ? this.expectedJavacOutputString : this.expectedOutputString,
+					this.skipJavac ? JavacTestOptions.SKIP : this.javacTestOptions);
+		}
+	}
+
 	// ===
 	
 	protected static final JavacTestOptions DEFAULT_TEST_OPTIONS = new JavacTestOptions();
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/CompilationOrder.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/CompilationOrder.java
index 5cc0272..f4dc8f4 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/CompilationOrder.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/CompilationOrder.java
@@ -182,4 +182,41 @@
     		},
     		"OK");
     }
+    public void testBug550408() {
+    	runConformTest(
+    		new String[] {
+		"Base550408.java",
+				"public class Base550408 {\n" +
+				"	public void bm() {}\n" +
+				"}\n",
+    	"Team550408_1.java",
+    			"public team class Team550408_1 {\n" +
+    			"	protected class R playedBy Base550408 {\n" +
+    			"		protected void test() {\n" +
+    			"			System.out.print(\"OK\");\n" +
+    			"		}\n" +
+    			"		test <- after bm;\n" +
+    			"	}\n" +
+    			"}\n",
+    		},
+    		"");
+    	Runner runner = new Runner();
+    	runner.shouldFlushOutputDirectory = false;
+    	runner.testFiles = new String[] {
+    		"Base550408_2.java",
+    			"public class Base550408_2 {\n" +
+    			"	public void bm2() {}\n" +
+    			"}\n",
+			"Team550408_2.java",
+    			"team class Team550408_2 {\n" +
+				"	protected team class Mid extends Team550408_1 playedBy Base550408_2 {\n" +
+    			"		protected void test2() {\n" +
+    			"			System.out.print(\"OK\");\n" +
+    			"		}\n" +
+    			"		test2 <- after bm2;\n" +
+				"	}\n" +
+				"}\n"    			
+    		};
+    	runner.runConformTest();
+    }
 }