bug 400833 - [compiler] resolve error re lifting constructor with
implicit playedBy refinement
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lookup/AnchorMapping.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lookup/AnchorMapping.java
index 6f99479..7b71c84 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lookup/AnchorMapping.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lookup/AnchorMapping.java
@@ -261,8 +261,9 @@
 	          		anchor = null; // cancel if incompatible.
 		   }
 	   }
-	return anchor;
-}
+	   return anchor;
+   }
+
    // if anchor is valid return it otherwise null 
    private ITeamAnchor validAnchor(ITeamAnchor anchor) {
 	   if (  (anchor != null)
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/RoleTypeCreator.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/RoleTypeCreator.java
index d59c199..9ccabcb 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/RoleTypeCreator.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/RoleTypeCreator.java
@@ -236,8 +236,8 @@
         if (typedNode instanceof Expression)
         	decapsulationAllowed = ((Expression)typedNode).getBaseclassDecapsulation().isAllowed();
         	
-        if (   (variableBinding instanceof VariableBinding) 
-			&& (((VariableBinding)variableBinding).tagBits & TagBits.IsFreshTeamInstance) != 0) 
+        if (   (variableBinding instanceof LocalVariableBinding) // not that for FieldBinding Bit63L has a different meaning!
+			&& (((LocalVariableBinding)variableBinding).tagBits & TagBits.IsFreshTeamInstance) != 0) 
         {
         	if (!RoleTypeBinding.isRoleType(refBinding))
         		return variableBinding.getDependentTypeBinding(refBinding, -1, null, dimensions);
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/roleplaying/LiftingAndLowering.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/roleplaying/LiftingAndLowering.java
index d323f10..4bbe522 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/roleplaying/LiftingAndLowering.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/roleplaying/LiftingAndLowering.java
@@ -5495,4 +5495,53 @@
     		"----------\n");
     }
 
+    // [compiler] resolve error re lifting constructor with implicit playedBy refinement
+    public void testBug400833() {
+    	runConformTest(
+    		new String[] {
+    			"to/TOuter.java",
+    			"package to;\n" + 
+    			"\n" + 
+    			"\n" + 
+    			"import base tb.TB1;\n" + 
+    			"import base tb.TB2;\n" + 
+    			"\n" + 
+    			"public team class TOuter {\n" + 
+    			"	public team class T1 playedBy TB1 {\n" + 
+    			"		protected class R playedBy B<@base> { }\n" + 
+    			"		/* added method */\n" + 
+    			"		public void test() {\n" + 
+    			"			new R(new B<@base>()); // works!\n" + 
+    			"		}\n" + 
+    			"	}\n" + 
+    			"	public team class T2 extends T1  playedBy TB2 {\n" + 
+    			"		@Override\n" +
+    			"		protected class R playedBy B<@base> { }\n" + 
+    			"		@Override\n" + 
+    			"		public void test() {\n" + 
+    			"			new R(new B<@base>());  // error!\n" + 
+    			"		}\n" + 
+    			"	}\n" +
+    			"	void test(TB2 as T2 t2) {\n" +
+    			"		t2.test();\n" +
+    			"	}\n" +
+    			"	public static void main(String... args) {\n" +
+    			"		new TOuter().test(new tb.TB2());\n" +
+    			"	}\n" + 
+    			"}\n",
+    			"tb/TB2.java",
+    			"package tb;\n" +
+    			"public team class TB2 extends TB1 {\n" +
+    			"	@Override public class B {\n" +
+    			"		public B() { System.out.print(\"OK\"); }\n" +
+    			"	}\n" +
+    			"}\n",
+    			"tb/TB1.java",
+    			"package tb;\n" +
+    			"public team class TB1 {\n" +
+    			"	public class B {}\n" +
+    			"}\n",
+    		},
+    		"OK");
+    }
 }