tests & fix for Bug 331828 -  DefaultBindingResoolver.resolveTypeBindingForName(Name name) for OT Elements
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/MethodMappingBindingTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/MethodMappingBindingTest.java
index eec21fa..ee3e500 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/MethodMappingBindingTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/MethodMappingBindingTest.java
@@ -34,6 +34,8 @@
 import org.eclipse.jdt.core.dom.IMethodMappingBinding;
 import org.eclipse.jdt.core.dom.ITypeBinding;
 import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.eclipse.jdt.core.dom.MethodMappingElement;
+import org.eclipse.jdt.core.dom.MethodSpec;
 import org.eclipse.jdt.core.dom.Modifier;
 import org.eclipse.jdt.core.dom.Name;
 import org.eclipse.jdt.core.dom.PrecedenceDeclaration;
@@ -149,6 +151,21 @@
         
         assertEquals(expected, actual);
     }
+
+    public void testMethodSpecType()
+    {
+        MethodMappingElement roleMappingElement = _callins[0].getRoleMappingElement();
+
+        // check we have the same method:
+        MethodDeclaration roleMethod = (MethodDeclaration)_methods[1];
+        assertEquals(roleMethod.resolveBinding(), ((MethodSpec)roleMappingElement).resolveBinding());
+        
+        // check the return types:
+        ITypeBinding actual = roleMappingElement.getName().resolveTypeBinding();
+        ITypeBinding expected = roleMethod.resolveBinding().getReturnType();
+        
+        assertEquals(expected, actual);
+    }
     
     public void testGetReferencedBaseClass()
     {
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/TypeBindingTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/TypeBindingTest.java
index 693732b..72c2d4c 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/TypeBindingTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/TypeBindingTest.java
@@ -28,8 +28,16 @@
 import org.eclipse.jdt.core.dom.ASTNode;
 import org.eclipse.jdt.core.dom.ASTParser;
 import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.eclipse.jdt.core.dom.Expression;
 import org.eclipse.jdt.core.dom.ITypeBinding;
+import org.eclipse.jdt.core.dom.LiftingType;
+import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.eclipse.jdt.core.dom.Name;
 import org.eclipse.jdt.core.dom.RoleTypeDeclaration;
+import org.eclipse.jdt.core.dom.SimpleType;
+import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
+import org.eclipse.jdt.core.dom.Type;
+import org.eclipse.jdt.core.dom.TypeDeclaration;
 import org.eclipse.objectteams.otdt.ui.tests.dom.FileBasedDOMTest;
 import org.eclipse.objectteams.otdt.ui.tests.dom.TypeDeclarationFinder;
 
@@ -45,10 +53,13 @@
 	private ASTParser _parser;
 	private ICompilationUnit _cuTA;
     private ICompilationUnit _cuTB;
+    private ICompilationUnit _cuMyT;
 
     private RoleTypeDeclaration _roleTAT2R1;
     private RoleTypeDeclaration _roleTBT1R1;
     private RoleTypeDeclaration _roleTBT2R1;
+    
+    private TypeDeclaration _teamMyTeam;
 
     private RoleTypeDeclaration _focus;
     
@@ -81,7 +92,12 @@
                 "src",
                 "roleTypeDeclaration.teampkg",
                 "TB.java");
-		
+        _cuMyT = getCompilationUnit(
+                getTestProjectDir(),
+                "src",
+                "roleTypeDeclaration.teampkg",
+                "MyTeam.java");
+        
 		_parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
 		_parser.setProject(super.getJavaProject(TEST_PROJECT));
         _parser.setResolveBindings(true);
@@ -108,6 +124,16 @@
         finder.setName("TB.T2.R1");
         compUnit.accept(finder);
         _roleTBT2R1 = (RoleTypeDeclaration)finder.getTypeDeclaration();        
+
+        _parser.setSource(_cuMyT);
+        _parser.setResolveBindings(true);
+        
+        root = _parser.createAST( new NullProgressMonitor() );
+        compUnit = (CompilationUnit) root;
+
+        finder.setName("MyTeam");
+        compUnit.accept(finder);
+        _teamMyTeam = finder.getTypeDeclaration();
 	}
 	
 	public void testInstanceTypes()
@@ -137,4 +163,15 @@
         assertEquals(expected[0].getOptimalName(), actual[0].getOptimalName());
         assertEquals(expected[1].getOptimalName(), actual[1].getOptimalName());
     }
+    
+    public void testDeclaredLiftingType() {
+    	MethodDeclaration method = (MethodDeclaration) _teamMyTeam.bodyDeclarations().get(3);
+    	SingleVariableDeclaration arg1 = (SingleVariableDeclaration) method.parameters().get(0);
+    	Type type = arg1.getType();
+		ITypeBinding typeBinding = type.resolveBinding();
+    	assertEquals("Wrong type binding for type", "MyClass", typeBinding.getName());
+    	Name typeName = ((LiftingType)type).getName();
+		typeBinding = typeName.resolveTypeBinding();
+    	assertEquals("Wrong type binding for name", "MyClass", typeBinding.getName());
+    }
 }
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/roleTypeDeclaration/teampkg/MyTeam.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/roleTypeDeclaration/teampkg/MyTeam.java
index 8d9063f..50515d8 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/roleTypeDeclaration/teampkg/MyTeam.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/workspace/DOM_AST/src/roleTypeDeclaration/teampkg/MyTeam.java
@@ -57,5 +57,9 @@
         }
         
         public void doSomething() {}
-    }   
+    }
+	
+	public void teamMethod(MyClass as Role1 arg1) { 
+		arg1.roleMethod1(0);
+	}
 }
\ No newline at end of file