Fix and new/updated tests for Bug 331831 -  [compiler] better reporting for unresolvable tsuper call
(change in implementation strategy for tsuper calls).
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/AcquisitionAndInheritanceOfRoleClasses.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/AcquisitionAndInheritanceOfRoleClasses.java
index 44c2a55..415eaea 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/AcquisitionAndInheritanceOfRoleClasses.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/AcquisitionAndInheritanceOfRoleClasses.java
@@ -1677,7 +1677,7 @@
     // a role class accesses a method with the same name but different signature of its implicit super role via tsuper
     // 1.3.9-otjld-illegal-tsuper-access-4
     public void test139_illegalTsuperAccess4() {
-        runNegativeTestMatching(
+        runNegativeTest(
             new String[] {
 		"Team139ita4_1.java",
 			    "\n" +
@@ -1692,6 +1692,7 @@
 		"Team139ita4_2.java",
 			    "\n" +
 			    "public team class Team139ita4_2 extends Team139ita4_1 {\n" +
+			    "    @Override\n" +
 			    "    protected class Role139ita4 {\n" +
 			    "        public String getValue(String arg) {\n" +
 			    "            return tsuper.getValue();\n" +
@@ -1700,7 +1701,12 @@
 			    "}\n" +
 			    "    \n"
             },
-            "not applicable");
+            "----------\n" +
+            "1. ERROR in Team139ita4_2.java (at line 6)\n" +
+            "	return tsuper.getValue();\n" +
+			"	       ^^^^^^^^^^^^^^^^^\n" +
+    		"Illegal tsuper call: can only invoke the method being overridden by the current method (OTJLD 1.3.1(f)).\n" +
+            "----------\n");
     }
 
     // a role class accesses a method of its implicit super role via tsuper within an inner class - missing team keyword
@@ -1765,6 +1771,79 @@
             },
             "1.3.1(f)");
     }
+    
+    // a tsuper call is unresolved (requires specific error reporting, setting tsuperMethod to a ProblemMethodBinding)
+    public void test139_illegalTsuperAccess6() {
+        runNegativeTestMatching(
+            new String[] {
+		"Team139ita6_1.java",
+			    "\n" +
+			    "public team class Team139ita6_1 {\n" +
+			    "    protected class Role139ita6 {\n" +
+			    "    }\n" +
+			    "}\n" +
+			    "    \n",
+		"Team139ita6_2.java",
+			    "\n" +
+			    "public team class Team139ita6_2 extends Team139ita6_1 {\n" +
+			    "    @Override\n" +
+			    "    protected class Role139ita6 {\n" +
+			    "        callin String getValue(String arg) {\n" +
+			    "            return tsuper.getValue(arg);\n" +
+			    "        }\n" +
+			    "    }\n" +
+			    "}\n" +
+			    "    \n"
+            },
+            "----------\n" + 
+    		"1. ERROR in Team139ita6_2.java (at line 6)\n" + 
+    		"	return tsuper.getValue(arg);\n" + 
+    		"	              ^^^^^^^^\n" + 
+    		"The method getValue(String) is undefined for the type Team139ita6_1.Role139ita6\n" + 
+    		"----------\n");
+    }
+
+    // a tsuper call in a callin method with generic return type (requries copyInheritanceSrc to be reflected when creating a ParameterizedMethodBinding)
+    public void _test139_tsuperCallWithTypeParameter1() {
+        runConformTest(
+            new String[] {
+		"T139tcwtp1Main.java",
+    			"public class T139tcwtp1Main {\n" +
+			    "    public static void main(String[] args) {\n" +
+			    "        new Team139tcwtp1_2().activate();\n" +
+			    "        System.out.print(new T139tcwtp1().getValue(\"nv\"));\n" +
+			    "    }\n" +
+			    "}\n",
+		"T139tcwtp1.java",
+		    	"public class T139tcwtp1 {\n" +
+			    "    String getValue(String arg) {\n" +
+			    "        return \"NOTOK\";\n" +
+			    "    }\n" +
+			    "}\n",
+		"Team139tcwtp1_1.java",
+			    "\n" +
+			    "public team class Team139tcwtp1_1 {\n" +
+			    "    protected class Role139tcwtp1<E> {\n" +
+			    "        abstract E val();\n" +
+			    "        callin E getValue(String arg) {\n" +
+			    "            return this.val();\n" +
+			    "        }\n" +
+			    "    }\n" +
+			    "}\n",
+		"Team139tcwtp1_2.java",
+			    "\n" +
+			    "public team class Team139tcwtp1_2 extends Team139tcwtp1_1 {\n" +
+			    "    protected class Role139tcwtp1<String> playedBy T139tcwtp1 {\n" +
+			    "        String val() { return \"OK\"; }\n" +
+			    "        getValue <- replace getValue;\n" +
+			    "        callin String getValue(String arg) {\n" +
+			    "            return tsuper.getValue(arg);\n" +
+			    "        }\n" +
+			    "    }\n" +
+			    "}\n"
+            },
+            "OK");
+    }
 
     // a role class has stronger access rights than its implicit superrole
     // 1.3.10-otjld-stronger-access-than-superrole-1
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/TeamNesting.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/TeamNesting.java
index 33f18cb..4364d81 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/TeamNesting.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/rolesandteams/TeamNesting.java
@@ -679,6 +679,95 @@
 			    "}\n" +
 			    "    \n"
             },
+            "222.122.");
+    }
+
+    // a role inherits features from all possible super roles within nested teams - super and tsuper tree (note, that some of these are re-bound, so full tree is not possible.
+    // use qualified tsuper to achieve order of old tsuper-precedence (pre 0.8M3)
+    // 1.1.10-otjld-full-inheritance-structure-5
+    public void test1110_fullInheritanceStructure5a() {
+       
+       runConformTest(
+            new String[] {
+		"T1110fis5a.java",
+			    "\n" +
+			    "public class T1110fis5a {\n" +
+			    "    public static void main(String[] args) {\n" +
+			    "        Team1110fis5a_2 t = new Team1110fis5a_2();\n" +
+			    "        t.test();\n" +
+			    "    }\n" +
+			    "}\n" +
+			    "    \n",
+		"Team1110fis5a_1.java",
+			    "\n" +
+			    "public team class Team1110fis5a_1 {\n" +
+			    "    public team class Mid1 {\n" +
+			    "        public class R1 {\n" +
+			    "            public void m() {\n" +
+			    "                System.out.print(\"111.\");\n" +
+			    "            }\n" +
+			    "        }\n" +
+			    "        public class R2 extends R1 {\n" +
+			    "            public void m() {\n" +
+			    "                System.out.print(\"112.\");\n" +
+			    "                super.m();\n" +
+			    "            }\n" +
+			    "        }\n" +
+			    "    }\n" +
+			    "    public team class Mid2 extends Mid1 {\n" +
+			    "        public class R1 {\n" +
+			    "            public void m() {\n" +
+			    "                System.out.print(\"121.\");\n" +
+			    "            }\n" +
+			    "        }\n" +
+			    "        public class R2 extends R1 {\n" +
+			    "            public void m() {\n" +
+			    "                System.out.print(\"122.\");\n" +
+			    "            }\n" +
+			    "        }\n" +
+			    "    }\n" +
+			    "}\n" +
+			    "    \n",
+		"Team1110fis5a_2.java",
+			    "\n" +
+			    "public team class Team1110fis5a_2 extends Team1110fis5a_1 {\n" +
+			    "    public team class Mid1 {\n" +
+			    "        public class R1 {\n" +
+			    "            public void m() {\n" +
+			    "                System.out.print(\"211.\");\n" +
+			    "            }\n" +
+			    "        }\n" +
+			    "        public class R2 {\n" +
+			    "            public void m() {\n" +
+			    "                System.out.print(\"212.\");\n" +
+			    "                tsuper.m();\n" +
+			    "            }\n" +
+			    "        }\n" +
+			    "    }\n" +
+			    "    public team class Mid2 {\n" +
+			    "        public class R1 {\n" +
+			    "            public void m() {\n" +
+			    "                System.out.print(\"221.\");\n" +
+			    "            }\n" +
+			    "        }\n" +
+			    "        public class R2 extends R1 {\n" +
+			    "            public void m() {\n" +
+			    "                System.out.print(\"222.\");\n" +
+			    "                Mid2.tsuper.m();\n" +
+			    "            }\n" +
+			    "        }\n" +
+			    "        protected void test() {\n" +
+			    "            R2 r = new R2();\n" +
+			    "            r.m();\n" +
+			    "        }\n" +
+			    "    }\n" +
+			    "    public void test () {\n" +
+			    "        Mid2 m = new Mid2();\n" +
+			    "        m.test();\n" +
+			    "    }\n" +
+			    "}\n" +
+			    "    \n"
+            },
             "222.212.112.221.");
     }
 
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/selection/org/eclipse/objectteams/otdt/tests/selection/codeselect/CodeSelectionTests.java b/testplugins/org.eclipse.objectteams.otdt.tests/selection/org/eclipse/objectteams/otdt/tests/selection/codeselect/CodeSelectionTests.java
index 316fcb1..3eec3c1 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/selection/org/eclipse/objectteams/otdt/tests/selection/codeselect/CodeSelectionTests.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/selection/org/eclipse/objectteams/otdt/tests/selection/codeselect/CodeSelectionTests.java
@@ -476,4 +476,21 @@
 					"RProtected(String) [in RProtected [in RoleCreation [in RoleCreation.java [in statements [in src [in CodeSelection]]]]]]",
 					elements);
 	}
+	
+	public void testTSuperCall1() throws JavaModelException {
+		ICompilationUnit cu = getCompilationUnit("CodeSelection", "src", "statements", "TSuper.java");
+		IJavaElement[] elements = codeSelect(cu, "m(1);", "m");
+		assertElementsEqual(
+					"Unexpected elements",
+					"m(int) [in R1 [in Inner2 [in Mid1 [in TSuper [in TSuper.java [in statements [in src [in CodeSelection]]]]]]]]",
+					elements);
+	}
+	public void testTSuperCall2() throws JavaModelException {
+		ICompilationUnit cu = getCompilationUnit("CodeSelection", "src", "statements", "TSuper.java");
+		IJavaElement[] elements = codeSelect(cu, "m(2);", "m");
+		assertElementsEqual(
+					"Unexpected elements",
+					"m(int) [in R1 [in Inner1 [in Mid2 [in TSuper [in TSuper.java [in statements [in src [in CodeSelection]]]]]]]]",
+					elements);
+	}
 }
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/workspace/CodeSelection/src/statements/TSuper.java b/testplugins/org.eclipse.objectteams.otdt.tests/workspace/CodeSelection/src/statements/TSuper.java
new file mode 100644
index 0000000..d61367d
--- /dev/null
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/workspace/CodeSelection/src/statements/TSuper.java
@@ -0,0 +1,31 @@
+package statements;
+
+public team class TSuper {
+	protected team class Mid1 {
+		protected team class Inner1 {
+			protected class R1 {
+				void m(int a) { }
+			}
+		}
+		protected team class Inner2 {
+			protected class R1 {
+				void m(int a) { }
+			}
+		}
+	}
+	protected team class Mid2 extends Mid1 {
+		protected team class Inner1 {
+			protected class R1 {
+				void m(int a) { }
+			}
+		}
+		protected team class Inner2 extends Inner1 {
+			protected class R1 {
+				void m(int a) {
+					tsuper.m(1);
+					Inner2.tsuper.m(2);
+				}
+			}
+		}
+	}
+}
\ No newline at end of file