more otredyn fixes for Bug 337413 - [otjld][compiler] consider changing LiftingFailedException to a checked exception
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lifting/Lifting.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lifting/Lifting.java
index d1c6280..fad1c86 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lifting/Lifting.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/lifting/Lifting.java
@@ -132,6 +132,13 @@
 		return    CharOperation.prefixEquals(IOTConstants._OT_LIFT_TO, method.selector)
 			   || CharOperation.prefixEquals(DeclaredLifting.OT_LIFT_DYNAMIC, method.selector);
 	}
+    public static boolean isLiftToMethodCall (Expression expr) {
+    	if (!(expr instanceof MessageSend))
+    		return false;
+    	char[] selector = ((MessageSend)expr).selector;
+		return    CharOperation.prefixEquals(IOTConstants._OT_LIFT_TO, selector)
+			   || CharOperation.prefixEquals(DeclaredLifting.OT_LIFT_DYNAMIC, selector);
+	}
 
 	public static char[] getLiftMethodName(TypeBinding roleType) {
 	    // TODO (SH) if roleType is not bound search for bound child role.
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementorDyn.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementorDyn.java
index c2df70e..e6be209 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementorDyn.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementorDyn.java
@@ -141,9 +141,7 @@
 									this._role.getBinding(),
 									IProblem.CallinDespiteBindingAmbiguity,
 									methodMappings[i]);
-				methodMappings[i].tagAsHavingErrors();
 			}
-			return;
 		}
         CallinMappingDeclaration[] callinMappings = new CallinMappingDeclaration[methodMappings.length];
         int num = 0;
@@ -411,14 +409,7 @@
 					if (!isStaticRoleMethod) {
 						if (needLiftedRoleVar) {
 
-							int iProblem = teamDecl.getTeamModel().canLiftingFail(roleType);
-							if (iProblem != 0) {
-								callinDecl.addRoleLiftingProblem(roleType, iProblem);
-								canLiftingFail = true;
-								// and report the problem(s)
-								for (Map.Entry<ReferenceBinding, Integer> entry : callinDecl.rolesWithLiftingProblem.entrySet())
-									callinDecl.scope.problemReporter().callinDespiteLiftingProblem(entry.getKey(), entry.getValue(), callinDecl);
-							}
+							canLiftingFail |= checkLiftingProblem(teamDecl, callinDecl, roleType);
 
 							roleVar = (LOCAL_ROLE+statements.size()).toCharArray();
 							blockStatements.add(gen.localVariable(roleVar, roleType.sourceName(),				//   RoleType local$n = this._OT$liftToRoleType((BaseType)base);
@@ -504,6 +495,7 @@
 														 CastExpression.DO_WRAP);
 								// lift?(MyBaseClass) 
 								arg = gen.potentialLift(gen.thisReference(), arg, roleParam, isReplace/*reversible*/);
+								canLiftingFail |= checkLiftingProblem(teamDecl, callinDecl, (ReferenceBinding)roleParam);
 							}
 						} else {
 							arg = getArgument(callinDecl, 														//    prepare:  <mappedArg<n>>
@@ -511,6 +503,8 @@
 											  callinDecl.getRoleMethod().parameters, 
 											  i+idx,
 											  baseSpec);
+							if (Lifting.isLiftToMethodCall(arg))
+								canLiftingFail |= checkLiftingProblem(teamDecl, callinDecl, roleType);
 							if (needLiftedRoleVar)
 								arg = new PotentialRoleReceiverExpression(arg, roleVar, gen.typeReference(roleType.getRealClass()));
 						}
@@ -578,14 +572,13 @@
 					}
 					blockStatements.add(gen.tryFinally(messageSendStatements, new Statement[]{resetFlag}));		//   try { roleMessageSend(); } finally { _OT$setExecutingCallin(_OT$oldIsExecutingCallin); } 
 					statements.add(gen.block(blockStatements.toArray(new Statement[blockStatements.size()])));
+					// collectively report the problem(s)
+					if (canLiftingFail)
+						for (Map.Entry<ReferenceBinding, Integer> entry : callinDecl.rolesWithLiftingProblem.entrySet())
+							callinDecl.scope.problemReporter().callinDespiteLiftingProblem(entry.getKey(), entry.getValue(), callinDecl);
 				}
 				
 				gen.retargetFrom(teamDecl);
-				if (canLiftingFail) {
-					TypeReference liftingFailed = gen.qualifiedTypeReference(IOTConstants.O_O_LIFTING_FAILED_EXCEPTION);
-					AstEdit.addException(methodDecl, liftingFailed, false/*resolve*/);
-				}
-
 				
 				boolean needSuperCall = false;
 				// callinIds handled by super call?
@@ -616,7 +609,6 @@
 						statements.add(superCall);																//    super._OT$callBefore/After(..);
 				}
 
-				// individual catch statements for LiftingVetoException and LiftingFailedException
 				Statement catchStatement1 = gen.emptyStatement();
 				Statement catchStatement2 = gen.emptyStatement();
 				if (isReplace) { 
@@ -812,4 +804,13 @@
 		decl.hasParsedStatements = true;
 		AstEdit.addMethod(teamDecl, decl);
 	}
+
+	boolean checkLiftingProblem(TypeDeclaration teamDecl, CallinMappingDeclaration callinDecl, ReferenceBinding roleType) {
+		int iProblem = teamDecl.getTeamModel().canLiftingFail(roleType);
+		if (iProblem != 0) {
+			callinDecl.addRoleLiftingProblem(roleType, iProblem);
+			return true;
+		}
+		return false;
+	}
 }