Fix bogus errors reported by the reconciler:
 + fix analysis of method overriding:
   + change parameter of restoreRole from Class to Class<?>
   + detect overriding during resolveGeneratedMethod if we're past verify.
 + avoid reporting of missing IBoundBase._OT$addRole
   + support detection of non-OT types as generated
     - IBoundBase is a regular ifc
     - The method is missing because it has an invalid OT identifier
   + tag referenceContext as having errors after silencing an error to avoid
     generating code from broken AST
 + reconstruct valid AST from o.o.Team.__OT__Confined by reverting role splitting
   + remove __OT__ prefix (was already happening)
   + remove super interface Confined to avoid cyclic definition
   + don't convert the interface Confined
 + Connect two old patches with newly reported bug
   Bug 320841 -  TypeConverters don't set enclosingType
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
index 639c0f8..23d5e2c 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java
@@ -2274,7 +2274,15 @@
 //	    scope.connectTypeVariables(methodDeclaration.typeParameters(), true);
 	    if (   StateMemento.hasMethodResolveStarted(this)
 	    	&& methodDeclaration.binding.isValidBinding())
+	    {
+	    	// manually detect overriding, if we're past the MethodVerifier:
+	    	if (StateHelper.hasState(this, ITranslationStates.STATE_METHODS_VERIFIED))
+	    		if (methodBinding != null && methodBinding.isValidBinding() && methodBinding.declaringClass != this)
+	    			methodDeclaration.binding.modifiers |= methodBinding.declaringClass.isInterface() 
+									    					? ExtraCompilerModifiers.AccImplementing 
+									    					: ExtraCompilerModifiers.AccOverriding;
 	        methodDeclaration.resolve(this.scope);
+	    }
     } finally {
     	if (cp != null)
     		// type already had errors, roll back errors in generated methods
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index a0ea077..f5204da 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -4034,7 +4034,10 @@
 	}
 	if (   typeIsBogus
 		&& CharOperation.prefixEquals(IOTConstants.OT_DOLLAR_NAME, method.selector))
+	{
+		this.referenceContext.tagAsHavingErrors(); // avoid generating bogus code
 		return; // silently
+	}
 //SH}
 
 	this.handle(
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/model/TypeModel.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/model/TypeModel.java
index e559369..cf53c38 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/model/TypeModel.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/model/TypeModel.java
@@ -39,6 +39,7 @@
 import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
 import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
 import org.eclipse.jdt.internal.compiler.lookup.Scope;
+import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
 import org.eclipse.jdt.internal.compiler.lookup.UnresolvedReferenceBinding;
 import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
 import org.eclipse.objectteams.otdt.core.compiler.IOTConstants;
@@ -523,6 +524,12 @@
 
 	public static boolean isConverted(ReferenceBinding declaringClass) {
 		TypeDeclaration result;
+		if (declaringClass instanceof SourceTypeBinding) {
+			Scope scope = ((SourceTypeBinding) declaringClass).scope;
+			if (scope != null && scope.referenceType() != null)
+				return scope.referenceType().isConverted;
+		}
+		// TODO(SH): the rest of this method is probably obsoleted the above
 		if (declaringClass.isRole()) {
 			RoleModel roleModel = declaringClass.roleModel;
 			if (roleModel != null) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/statemachine/transformer/SerializationGenerator.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/statemachine/transformer/SerializationGenerator.java
index 4ed6d27..a3fec68 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/statemachine/transformer/SerializationGenerator.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/statemachine/transformer/SerializationGenerator.java
@@ -27,6 +27,7 @@
 import org.eclipse.jdt.internal.compiler.ast.Statement;
 import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
 import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.eclipse.jdt.internal.compiler.ast.Wildcard;
 import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
 import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
 import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
@@ -83,7 +84,7 @@
 				TypeBinding.VOID, 
 				RESTORE_ROLE, 
 				new Argument[] {
-					gen.argument(CLASS_ARG_NAME, gen.qualifiedTypeReference(TypeConstants.JAVA_LANG_CLASS)),
+					gen.argument(CLASS_ARG_NAME, gen.parameterizedQualifiedTypeReference(TypeConstants.JAVA_LANG_CLASS, new TypeReference[]{gen.wildcard(Wildcard.UNBOUND)})),
 					gen.argument(ROLE_ARG_NAME, gen.qualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT))
 				});
 		if (superIsTeam)
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java
index 2a40910..55206f8 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/SourceElementNotifier.java
@@ -885,8 +885,16 @@
   :giro */
 			typeInfo.modifiers = deprecated ? (currentModifiers & ExtraCompilerModifiers.AccOTTypeJustFlag) | ClassFileConstants.AccDeprecated : currentModifiers & ExtraCompilerModifiers.AccOTTypeJustFlag;
 			typeInfo.name = typeDeclaration.name;
-			if (CharOperation.prefixEquals(IOTConstants.OT_DELIM_NAME, typeInfo.name))
+			// existing __OT__ prefix and special treatment for o.o.Team.Confined:
+			if (CharOperation.prefixEquals(IOTConstants.OT_DELIM_NAME, typeInfo.name)) {
 				typeInfo.name = CharOperation.subarray(typeInfo.name, IOTConstants.OT_DELIM_LEN, -1);
+				if (CharOperation.equals(IOTConstants.CONFINED, typeInfo.name) && CharOperation.equals(new char[][]{IOTConstants.CONFINED}, interfaceNames)) {
+					// avoid Confined implements Confined (revert manual role splitting)
+					superclassName = null;
+					interfaceNames = null;
+				}
+				// filtering interface o.o.T.Confined is already done at the call site.
+			}
 // SH}
 			typeInfo.nameSourceStart = isEnumInit ? typeDeclaration.allocation.enumConstant.sourceStart : typeDeclaration.sourceStart;
 			typeInfo.nameSourceEnd = sourceEnd(typeDeclaration);
@@ -997,6 +1005,11 @@
 				break;
 			case 2 :
 				memberTypeIndex++;
+//{ObjectTeams: don't convert interface o.o.T.Confined:
+				if (   currentPackage != null && CharOperation.equals(IOTConstants.ORG_OBJECTTEAMS, currentPackage.tokens)
+					&& CharOperation.equals(IOTConstants.TEAM, typeDeclaration.name)
+					&& CharOperation.equals(IOTConstants.CONFINED, nextMemberDeclaration.name))
+					break;
 				notifySourceElementRequestor(nextMemberDeclaration, true, null, currentPackage);
 //{ObjectTeams:
 				break;
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java
index 2ddc135..f3c2506 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/compiler/parser/SourceTypeConverter.java
@@ -593,8 +593,7 @@
 			type.memberTypes = new TypeDeclaration[sourceMemberTypeCount];
 			for (int i = 0; i < sourceMemberTypeCount; i++) {
 				type.memberTypes[i] = convert(sourceMemberTypes[i], compilationResult);
-//{ObjectTeams: bugfix!
-//TODO (carp,SH): who needs this?
+//{ObjectTeams: fix for  Bug 320841 -  TypeConverters don't set enclosingType
                 type.memberTypes[i].enclosingType = type;
 // SH}
 			}
diff --git a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryTypeConverter.java b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryTypeConverter.java
index 4afa526..6883c29 100644
--- a/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryTypeConverter.java
+++ b/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryTypeConverter.java
@@ -338,7 +338,7 @@
 				typeDeclaration.memberTypes[i] = alreadyComputedMemberDeclaration;
 			} else {
 				typeDeclaration.memberTypes[i] = convert(memberTypes[i], null, null);
-//{ObjectTeams: bugfix:
+//{ObjectTeams: fix for  Bug 320841 -  TypeConverters don't set enclosingType
                 typeDeclaration.memberTypes[i].enclosingType = typeDeclaration;
 // SH}
 			}