[577889] More oclAsType tests
diff --git a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/library/executor/ExecutorType.java b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/library/executor/ExecutorType.java
index d164c37..a48e1e2 100644
--- a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/library/executor/ExecutorType.java
+++ b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/library/executor/ExecutorType.java
@@ -23,6 +23,7 @@
 import org.eclipse.ocl.pivot.TemplateParameter;
 import org.eclipse.ocl.pivot.TemplateParameters;
 import org.eclipse.ocl.pivot.Type;
+import org.eclipse.ocl.pivot.ids.IdManager;
 import org.eclipse.ocl.pivot.ids.IdResolver;
 import org.eclipse.ocl.pivot.ids.OperationId;
 import org.eclipse.ocl.pivot.ids.TypeId;
@@ -43,7 +44,7 @@
 	 * Depth ordered inheritance fragments. OclAny at depth 0, OclSelf at depth size-1.
 	 */
 	private @NonNull ExecutorFragment @Nullable [] fragments = null;
-	
+
 	/**
 	 * The index in fragments at which inheritance fragments at a given depth start.
 	 * depthIndexes[0] is always zero since OclAny is always at depth 0.
@@ -51,11 +52,11 @@
 	 * depthIndexes[depthIndexes.length-1] is always depthIndexes.length to provide an easy end stop.
 	 */
 	private int[] indexes = null;
-	
+
 	protected final org.eclipse.ocl.pivot.@NonNull Package evaluationPackage;
 	private final @NonNull TemplateParameters typeParameters;
 	private /*@LazyNonNull*/ DomainProperties allProperties;
-	
+
 	public ExecutorType(@NonNull String name, @NonNull ExecutorPackage evaluationPackage, int flags, @NonNull ExecutorTypeParameter @NonNull ... typeParameters) {
 		super(name, flags);
 		this.evaluationPackage = evaluationPackage;
@@ -70,23 +71,23 @@
 		}
 		return thatInheritance.isSuperInheritanceOf(this);
 	}
-	
+
 	@Override
 	public org.eclipse.ocl.pivot.Class flattenedType() {
 		return this;
 	}
-	
+
 	@Override
 	public final @NonNull FragmentIterable getAllProperSuperFragments() {
 		@NonNull InheritanceFragment @NonNull [] fragments2 = ClassUtil.nonNullState(fragments);
 		return new FragmentIterable(fragments2, 0, fragments2.length-1);
 	}
-	
+
 	@Override
 	public @NonNull FragmentIterable getAllSuperFragments() {
 		return new FragmentIterable(ClassUtil.nonNullState(fragments));
 	}
-	
+
 	@Override
 	public @NonNull Type getCommonType(@NonNull IdResolver idResolver, @NonNull Type type) {
 		if (this == type) {
@@ -102,7 +103,7 @@
 	public int getDepth() {
 		return indexes.length-2;
 	}
-	
+
 	@Override
 	public @NonNull Iterable<@NonNull InheritanceFragment> getFragments() {
 		return new ArrayIterable<@NonNull InheritanceFragment>(fragments);
@@ -112,7 +113,7 @@
 	public @NonNull ExecutorFragment getFragment(int fragmentNumber) {
 		return ClassUtil.nonNullState(fragments)[fragmentNumber];
 	}
-	
+
 	@Override
 	public int getIndex(int fragmentNumber) {
 		return indexes[fragmentNumber];
@@ -166,7 +167,7 @@
 	public @NonNull List<Operation> getOwnedOperations() {
 		return getSelfFragment().getLocalOperations();
 	}
-	
+
 	@Override
 	public org.eclipse.ocl.pivot.@NonNull Package getOwningPackage() {
 		return evaluationPackage;
@@ -195,7 +196,7 @@
 	public @NonNull List<org.eclipse.ocl.pivot.Class> getSuperClasses() {
 		return getSelfFragment().getSuperClasses();
 	}
-	
+
 	@Override
 	public final @NonNull FragmentIterable getSuperFragments(int depth) {
 		return new FragmentIterable(ClassUtil.nonNullState(fragments), indexes[depth], indexes[depth+1]);
@@ -264,9 +265,14 @@
 	public int oclHashCode() {
 		return getTypeId().hashCode();
 	}
-	
+
 	@Override
 	public String toString() {
-		return String.valueOf(evaluationPackage) + "::" + String.valueOf(name); //$NON-NLS-1$
+		if (evaluationPackage.getPackageId() != IdManager.METAMODEL) {
+			return String.valueOf(evaluationPackage) + "::" + String.valueOf(name); //$NON-NLS-1$
+		}
+		else {
+			return String.valueOf(name);
+		}
 	}
 }
\ No newline at end of file
diff --git a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/prettyprint/EssentialOCLPrettyPrintVisitor.java b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/prettyprint/EssentialOCLPrettyPrintVisitor.java
index 07da532..cd35151 100644
--- a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/prettyprint/EssentialOCLPrettyPrintVisitor.java
+++ b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/internal/prettyprint/EssentialOCLPrettyPrintVisitor.java
@@ -26,6 +26,7 @@
 import org.eclipse.ocl.pivot.IfExp;
 import org.eclipse.ocl.pivot.IntegerLiteralExp;
 import org.eclipse.ocl.pivot.InvalidLiteralExp;
+import org.eclipse.ocl.pivot.IterableType;
 import org.eclipse.ocl.pivot.IterateExp;
 import org.eclipse.ocl.pivot.Iteration;
 import org.eclipse.ocl.pivot.IteratorExp;
@@ -88,7 +89,7 @@
 				else {
 					safeVisit(source);
 				}
-				if (source.getType() instanceof CollectionType) {
+				if (source.getType() instanceof IterableType) {
 					context.append(PivotUtil.getNavigationOperator(object.isIsSafe(), !object.isIsImplicit()));				// "." for implicit collect
 				}
 				else {
diff --git a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/utilities/ToStringVisitor.java b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/utilities/ToStringVisitor.java
index a111d26..8c05c50 100644
--- a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/utilities/ToStringVisitor.java
+++ b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/utilities/ToStringVisitor.java
@@ -985,7 +985,7 @@
 					if (((index == 0) && !object.isKeysAreNullFree()) || ((index == 1) && !object.isValuesAreNullFree())) {
 						append("[?]");
 					}
-					else /*if (SHOW_ALL_MULTIPLICITIES)*/ {
+					else if (SHOW_ALL_MULTIPLICITIES) {
 						append("[1]");
 					}
 					prefix = ",";
diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateClassifierOperationsTest4.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateClassifierOperationsTest4.java
index eb7b857..3596c63 100644
--- a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateClassifierOperationsTest4.java
+++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateClassifierOperationsTest4.java
@@ -155,7 +155,7 @@
 			ocl.assertQueryResults(null, "Set{}", "Map(Integer,String).allInstances()");
 			ocl.assertQueryResults(null, "Set{}", "Map{1 with '1'}->oclType().allInstances()");
 			ocl.assertQueryResults(null, "Bag{}", "Map{1 with '1'}.oclType().allInstances()");
-			ocl.assertSemanticErrorQuery(classType, "Map{1 with '1'}->allInstances()", PivotMessagesInternal.UnresolvedOperationCall_ERROR_, "Map(Integer[1],String[1])", "allInstances", "");
+			ocl.assertSemanticErrorQuery(classType, "Map{1 with '1'}->allInstances()", PivotMessagesInternal.UnresolvedOperationCall_ERROR_, "Map(Integer,String)", "allInstances", "");
 			ocl.assertSemanticErrorQuery(classType, "Map{1 with '1'}.allInstances()", PivotMessagesInternal.UnresolvedOperationCall_ERROR_, "Integer", "allInstances", "");
 			//
 			ocl.assertQueryResults(null, "Set{}", "Tuple(a:Integer).allInstances()");
diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateCollectionOperationsTest4.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateCollectionOperationsTest4.java
index dd1044f..90f29de 100644
--- a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateCollectionOperationsTest4.java
+++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateCollectionOperationsTest4.java
@@ -17,8 +17,11 @@
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.ocl.pivot.StandardLibrary;
 import org.eclipse.ocl.pivot.internal.messages.PivotMessagesInternal;
+import org.eclipse.ocl.pivot.messages.PivotMessages;
 import org.eclipse.ocl.pivot.utilities.OCL;
+import org.eclipse.ocl.pivot.utilities.StringUtil;
 import org.eclipse.ocl.pivot.values.InvalidValueException;
+import org.eclipse.ocl.xtext.essentialocl.cs2as.EssentialOCLCS2ASMessages;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -355,14 +358,34 @@
 	@Test public void testCollectionElementType() {
 		TestOCL ocl = createOCL();
 		StandardLibrary standardLibrary = ocl.getStandardLibrary();
-		ocl.assertQueryEquals(null, standardLibrary.getStringType(), "Sequence{'1', '2', '3'}->oclType().elementType");
-		ocl.assertQueryEquals(null, standardLibrary.getOclAnyType(), "Sequence{1, 2.0, '3'}->oclType().elementType");
-		ocl.assertQueryEquals(null, standardLibrary.getIntegerType(), "Sequence{1, 2, 3}->oclType().elementType");
-		ocl.assertQueryEquals(null, standardLibrary.getIntegerType(), "Sequence{1, 2, 3}->oclAsType(Collection(Real))->oclType().elementType");
-		// FIXME fails because common type is Set(T) and then because T is not type-servable and has no OclAny inheritance
-		//		ocl.assertQueryEquals(null, metamodelManager.getSetType(), "Sequence{Set{1}, Set{2.0}, Set{'3'}}->elementType");
-		// FIXME fails because common type is inadequate for implicit collect
-		//				ocl.assertQueryEquals(null, metamodelManager.getOclAnyType(), "Sequence{Set{1}, Set{2.0}, Set{'3'}}.elementType");
+		org.eclipse.ocl.pivot.Class integerType = standardLibrary.getIntegerType();
+		org.eclipse.ocl.pivot.Class oclAnyType = standardLibrary.getOclAnyType();
+		org.eclipse.ocl.pivot.Class stringType = standardLibrary.getStringType();
+//
+		ocl.assertSemanticErrorQuery(null, "Set{'1'}->elementType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "Set(String)", "elementType");
+		ocl.assertSemanticErrorQuery(null, "Set{'1'}->_'Collection'::elementType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "Set(String)", "elementType");
+		ocl.assertSemanticErrorQuery(null, "Set{'1'}->SetType::elementType", EssentialOCLCS2ASMessages.PropertyCallExp_IncompatibleProperty, "CollectionType::elementType");
+//
+		ocl.assertSemanticErrorQuery(null, "Set{'1'}.elementType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "String", "elementType");
+		ocl.assertSemanticErrorQuery(null, "Set{'1'}.SetType::elementType", EssentialOCLCS2ASMessages.PropertyCallExp_IncompatibleProperty, "CollectionType::elementType");
+		ocl.assertSemanticErrorQuery(null, "Set{'1'}._'Collection'::elementType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "String", "elementType");
+//
+		ocl.assertQueryEquals(null, stringType, "Set{'1'}->oclType().elementType");
+		ocl.assertQueryEquals(null, stringType, "Set{'1'}->oclType().SetType::elementType");
+		ocl.assertSemanticErrorQuery(null, "Set{'1'}->oclType()._'Collection'::elementType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "Set(String)", "elementType");
+//
+		ocl.assertSemanticErrorQuery(null, "Set{'1'}.oclType()->elementType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "Bag(PrimitiveType)", "elementType");
+		ocl.assertSemanticErrorQuery(null, "Set{'1'}.oclType()->SetType::elementType", EssentialOCLCS2ASMessages.PropertyCallExp_IncompatibleProperty, "CollectionType::elementType");
+		ocl.assertSemanticErrorQuery(null, "Set{'1'}.oclType()->_'Collection'::elementType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "Bag(PrimitiveType)", "elementType");
+//
+		ocl.assertSemanticErrorQuery(null, "Set{'1'}.oclType().elementType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "PrimitiveType", "elementType");
+		ocl.assertSemanticErrorQuery(null, "Set{'1'}.oclType().SetType::elementType", EssentialOCLCS2ASMessages.PropertyCallExp_IncompatibleProperty, "CollectionType::elementType");
+		ocl.assertSemanticErrorQuery(null, "Set{'1'}.oclType()._'Collection'::elementType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "PrimitiveType", "elementType");
+//
+		ocl.assertQueryEquals(null, oclAnyType, "Set{1, 2.0, '3'}->oclType().elementType");
+		ocl.assertQueryEquals(null, integerType, "Set{1, 2, 3}->oclType().elementType");
+		ocl.assertQueryEquals(null, integerType, "Set{1, 2, 3}->oclAsType(Collection(Real))->oclType().elementType");
+		ocl.assertSemanticErrorQuery(null, "Set{'1'}->SetType::size()", PivotMessagesInternal.UnresolvedOperation_ERROR_, "Set(String)", "size");
 	}
 
 	@Test public void testCollectionEqual() {
@@ -1248,15 +1271,18 @@
 
 	@Test public void testCollectionLower() {
 		TestOCL ocl = createOCL();
-/*		ocl.assertQueryEquals(null, 3, "Sequence{1, 2.0, '3'}->oclAsType(Collection(OclAny))->oclType().lower");
-		ocl.assertQueryEquals(null, 3, "Sequence{1, 2.0, '3'}->oclAsType(Sequence(OclAny))->oclType().lower");
-		ocl.assertQueryEquals(null, 3, "Sequence{1, 2.0, '3'}->oclAsType(Set(OclAny))->oclType().lower");
-		ocl.assertQueryEquals(null, 3, "Sequence{1, 2.0, '3'}->oclAsType(OclVoid).oclType().lower");
-		ocl.assertQueryEquals(null, 3, "Sequence{1, 2.0, '3'}->oclAsType(OclAny).oclType().lower");
-// XXX */
 		ocl.assertQueryEquals(null, 3, "Sequence{1, 2.0, '3'}->oclType().lower");
 		ocl.assertQueryEquals(null, 3, "Sequence{1, 2.0, 3}->oclAsType(Collection(Real))->oclType().lower");
 		ocl.assertQueryEquals(null, 3, "Set{1, 2.0, 3}->oclAsType(Collection(Real[2..4]))->oclType().lower"); // no change to dynamic bound
+		ocl.assertQueryEquals(null, 3, "Sequence{1, 2.0, '3'}->oclAsType(Collection(OclAny))->oclType().lower");
+		ocl.assertQueryEquals(null, 3, "Sequence{1, 2.0, '3'}->oclAsType(Sequence(OclAny))->oclType().lower");
+		String string = useCodeGen ? "Set(OclAny[*|?])" : "Set(OclAny)"; 		// FIXME See Bug 578117
+		ocl.assertQueryInvalid(null, "Sequence{1, 2.0, '3'}->oclAsType(Set(OclAny))->oclType().lower",
+			StringUtil.bind(PivotMessages.IncompatibleOclAsTypeSourceType, "Sequence(OclAny[3|?])", string), InvalidValueException.class);
+		ocl.assertSemanticErrorQuery(null, "Sequence{1, 2.0, '3'}->oclAsType(OclVoid).oclType().lower",
+			PivotMessagesInternal.UnresolvedProperty_ERROR_, "OclVoid", "lower");
+		ocl.assertSemanticErrorQuery(null, "Sequence{1, 2.0, '3'}->oclAsType(OclAny).oclType().lower",
+			PivotMessagesInternal.UnresolvedProperty_ERROR_, "OclAny", "lower");
 		ocl.dispose();
 	}
 
diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateMapOperationsTest4.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateMapOperationsTest4.java
index 3836a04..904ec6f 100644
--- a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateMapOperationsTest4.java
+++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateMapOperationsTest4.java
@@ -131,7 +131,7 @@
 
 	@Test public void testMapErrors() {
 		TestOCL ocl = createOCL();
-		ocl.assertValidationErrorQuery(null, "Map{}?->keyType", PivotMessages.ValidationConstraintIsNotSatisfied_ERROR_, "CallExp::SafeSourceCannotBeMap", ocl);
+	//	ocl.assertValidationErrorQuery(null, "Map{}?->keyType", PivotMessages.ValidationConstraintIsNotSatisfied_ERROR_, "CallExp::SafeSourceCannotBeMap", ocl);
 		ocl.assertValidationErrorQuery(null, "Map{}?->size()", PivotMessages.ValidationConstraintIsNotSatisfied_ERROR_, "CallExp::SafeSourceCannotBeMap", ocl);
 		ocl.assertValidationErrorQuery(null, "Map{}?->collect(c | '')", PivotMessages.ValidationConstraintIsNotSatisfied_ERROR_, "CallExp::SafeSourceCannotBeMap", "Map{}?->collect(c : OclVoid[1] | '')");
 		ocl.assertValidationErrorQuery(null, "Map{}?->iterate(c; acc:String = '' | '')", PivotMessages.ValidationConstraintIsNotSatisfied_ERROR_, "CallExp::SafeSourceCannotBeMap", "Map{}?->iterate(c : OclVoid[1]; acc : String[1] = '' | '')");
@@ -593,30 +593,30 @@
 		org.eclipse.ocl.pivot.Class oclAnyType = standardLibrary.getOclAnyType();
 		org.eclipse.ocl.pivot.Class stringType = standardLibrary.getStringType();
 //
-		ocl.assertQueryEquals(null, stringType, "Map{'1' with true}->keyType");
-		ocl.assertQueryEquals(null, stringType, "Map{'1' with true}->_'Map'::keyType");
-		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}->MapType::keyType", EssentialOCLCS2ASMessages.PropertyCallExp_IncompatibleProperty, "pivot::MapType::keyType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}->keyType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "Map(String,Boolean)", "keyType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}->_'Map'::keyType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "Map(String,Boolean)", "keyType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}->MapType::keyType", EssentialOCLCS2ASMessages.PropertyCallExp_IncompatibleProperty, "MapType::keyType");
 //
 		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}.keyType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "String", "keyType");
-		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}.MapType::keyType", EssentialOCLCS2ASMessages.PropertyCallExp_IncompatibleProperty, "pivot::MapType::keyType");
-		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}._'Map'::keyType", EssentialOCLCS2ASMessages.PropertyCallExp_IncompatibleProperty, "Map(K,V)::keyType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}.MapType::keyType", EssentialOCLCS2ASMessages.PropertyCallExp_IncompatibleProperty, "MapType::keyType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}._'Map'::keyType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "String", "keyType");
 //
 		ocl.assertQueryEquals(null, stringType, "Map{'1' with true}->oclType().keyType");
 		ocl.assertQueryEquals(null, stringType, "Map{'1' with true}->oclType().MapType::keyType");
-		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}->oclType()._'Map'::keyType", EssentialOCLCS2ASMessages.PropertyCallExp_IncompatibleProperty, "Map(K,V)::keyType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}->oclType()._'Map'::keyType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "Map(String,Boolean)", "keyType");
 //
-		ocl.assertQueryEquals(null, stringType, "Map{'1' with true}->oclType().keyType");
-		ocl.assertQueryEquals(null, stringType, "Map{'1' with true}->oclType().MapType::keyType");
-		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}->oclType()._'Map'::keyType", EssentialOCLCS2ASMessages.PropertyCallExp_IncompatibleProperty, "Map(K,V)::keyType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}.oclType()->keyType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "Bag(PrimitiveType)", "keyType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}.oclType()->MapType::keyType", EssentialOCLCS2ASMessages.PropertyCallExp_IncompatibleProperty, "MapType::keyType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}.oclType()->_'Map'::keyType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "Bag(PrimitiveType)", "keyType");
 //
 		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}.oclType().keyType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "PrimitiveType", "keyType");
-		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}.oclType().MapType::keyType", EssentialOCLCS2ASMessages.PropertyCallExp_IncompatibleProperty, "pivot::MapType::keyType");
-		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}.oclType()._'Map'::keyType", EssentialOCLCS2ASMessages.PropertyCallExp_IncompatibleProperty, "Map(K,V)::keyType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}.oclType().MapType::keyType", EssentialOCLCS2ASMessages.PropertyCallExp_IncompatibleProperty, "MapType::keyType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}.oclType()._'Map'::keyType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "PrimitiveType", "keyType");
 //
 		ocl.assertQueryEquals(null, oclAnyType, "Map{1 with true, 2.0 with true, '3' with true}->oclType().keyType");
 		ocl.assertQueryEquals(null, integerType, "Map{1 with true, 2 with true, 3 with true}->oclType().keyType");
 		ocl.assertQueryEquals(null, integerType, "Map{1 with true, 2 with true, 3 with true}->oclAsType(Map(Real, Boolean))->oclType().keyType");
-		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}->MapType::size()", PivotMessagesInternal.UnresolvedOperation_ERROR_, "Map(String[1],Boolean[1])", "size");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}->MapType::size()", PivotMessagesInternal.UnresolvedOperation_ERROR_, "Map(String,Boolean)", "size");
 	}
 
 	@Test public void testMapKeys() {
@@ -739,17 +739,42 @@
 		ocl.assertQueryEquals(null, 1, "Map{'a' with 'b'}->size()");
 		ocl.assertQueryEquals(null, 1, "Map{'1' with true}->size()");
 		ocl.assertQueryEquals(null, 1, "Map{'1' with true}->_'Map'::size()");
-		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}->MapType::size()", PivotMessagesInternal.UnresolvedOperation_ERROR_, "Map(String[1],Boolean[1])", "size");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}->MapType::size()", PivotMessagesInternal.UnresolvedOperation_ERROR_, "Map(String,Boolean)", "size");
 		ocl.dispose();
 	}
 
 	@Test public void testMapValueType() {
 		TestOCL ocl = createOCL();
 		StandardLibrary standardLibrary = ocl.getStandardLibrary();
-		ocl.assertQueryEquals(null, standardLibrary.getStringType(), "Map{true with '1'}->oclType().valueType");
-		ocl.assertQueryEquals(null, standardLibrary.getOclAnyType(), "Map{'1' with 1, '2' with 2.0, '3' with '3'}->oclType().valueType");
-		ocl.assertQueryEquals(null, standardLibrary.getIntegerType(), "Map{'1' with 1, '2' with 2, '3' with 3}->oclType().valueType");
-		ocl.assertQueryEquals(null, standardLibrary.getIntegerType(), "Map{'1' with 1, '2' with 2, '3' with 3}->oclAsType(Map(String, Real))->oclType().valueType");
+		org.eclipse.ocl.pivot.Class integerType = standardLibrary.getIntegerType();
+		org.eclipse.ocl.pivot.Class oclAnyType = standardLibrary.getOclAnyType();
+		org.eclipse.ocl.pivot.Class booleanType = standardLibrary.getBooleanType();
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}->valueType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "Map(String,Boolean)", "valueType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}->_'Map'::valueType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "Map(String,Boolean)", "valueType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}->MapType::valueType", EssentialOCLCS2ASMessages.PropertyCallExp_IncompatibleProperty, "MapType::valueType");
+//
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}.valueType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "String", "valueType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}.MapType::valueType", EssentialOCLCS2ASMessages.PropertyCallExp_IncompatibleProperty, "MapType::valueType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}._'Map'::valueType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "String", "valueType");
+//
+		ocl.assertQueryEquals(null, booleanType, "Map{'1' with true}->oclType().valueType");
+		ocl.assertQueryEquals(null, booleanType, "Map{'1' with true}->oclType().MapType::valueType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}->oclType()._'Map'::valueType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "Map(String,Boolean)", "valueType");
+//
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}.oclType()->valueType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "Bag(PrimitiveType)", "valueType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}.oclType()->MapType::valueType", EssentialOCLCS2ASMessages.PropertyCallExp_IncompatibleProperty, "MapType::valueType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}.oclType()->_'Map'::valueType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "Bag(PrimitiveType)", "valueType");
+//
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}.oclType().valueType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "PrimitiveType", "valueType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}.oclType().MapType::valueType", EssentialOCLCS2ASMessages.PropertyCallExp_IncompatibleProperty, "MapType::valueType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}.oclType()._'Map'::valueType", PivotMessagesInternal.UnresolvedProperty_ERROR_, "PrimitiveType", "valueType");
+//
+		ocl.assertQueryEquals(null, oclAnyType, "Map{1 with 1, 2.0 with '2', '3' with true}->oclType().valueType");
+		ocl.assertQueryEquals(null, integerType, "Map{1 with 1, 2 with 2, 3 with 3}->oclType().valueType");
+		ocl.assertQueryInvalid(null, "Map{1 with 1, 2 with 2, 3 with 3}->oclAsType(Map(Real, Boolean))->oclType().valueType",
+			StringUtil.bind(PivotMessages.IncompatibleOclAsTypeSourceType, "Map(Integer,Integer)", "Map(Real,Boolean)"), InvalidValueException.class);
+		ocl.assertQueryEquals(null, integerType, "Map{1 with 1, 2 with 2, 3 with 3}->oclAsType(Map(Real, Real))->oclType().valueType");
+		ocl.assertSemanticErrorQuery(null, "Map{'1' with true}->MapType::size()", PivotMessagesInternal.UnresolvedOperation_ERROR_, "Map(String,Boolean)", "size");
 	}
 
 	@Test public void testMapValues() {
diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateNameVisibilityTest4.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateNameVisibilityTest4.java
index 81f70a4..25de97a 100644
--- a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateNameVisibilityTest4.java
+++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateNameVisibilityTest4.java
@@ -133,8 +133,8 @@
 		ocl.assertSemanticErrorQuery(null, "let a : Set(Type) = null in a->Package()", PivotMessagesInternal.UnresolvedOperation_ERROR_, "Set(Type)", "Package");
 		ocl.assertSemanticErrorQuery(null, "Type->Package", PivotMessagesInternal.UnresolvedProperty_ERROR_, "Set(Class)", "Package");
 		ocl.assertSemanticErrorQuery(null, "Type->Package()", PivotMessagesInternal.UnresolvedOperation_ERROR_, "Set(Class)", "Package");
-		ocl.assertSemanticErrorQuery(null, "Set(Type)->Package", PivotMessagesInternal.UnresolvedProperty_ERROR_, "Set(Class)", "Package");
-		ocl.assertSemanticErrorQuery(null, "Set(Type)->Package()", PivotMessagesInternal.UnresolvedOperation_ERROR_, "Set(Class)", "Package");
+		ocl.assertSemanticErrorQuery(null, "Set(Type)->Package", PivotMessagesInternal.UnresolvedProperty_ERROR_, "Set(SetType)", "Package");
+		ocl.assertSemanticErrorQuery(null, "Set(Type)->Package()", PivotMessagesInternal.UnresolvedOperation_ERROR_, "Set(SetType)", "Package");
 		ocl.assertSemanticErrorQuery(null, "let a : Type = null in a.if", "no viable alternative following input ''if''");
 		ocl.assertSemanticErrorQuery(null, "let a : Type = null in a->if", "no viable alternative following input ''if''");
 		// oclAsSet()
diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateOclAnyOperationsTest4.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateOclAnyOperationsTest4.java
index b23d1c4..06da243 100644
--- a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateOclAnyOperationsTest4.java
+++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateOclAnyOperationsTest4.java
@@ -842,8 +842,6 @@
 		StandardLibrary standardLibrary = environmentFactory.getStandardLibrary();
 		org.eclipse.ocl.pivot.Class anyType = standardLibrary.getOclAnyType();
 		org.eclipse.ocl.pivot.Class anyTypeClass = useCodeGen ? standardLibrary.getClassType() : environmentFactory.getASClass("AnyType");
-		ocl.assertQueryResults(null, "Set{null}", "null.oclAsType(OclAny).oclType().allInstances()");
-// XXX
 		ocl.assertQueryEquals(null, standardLibrary.getOclVoidType(), "null.oclType()");
 		//    	ocl.assertQueryEquals(null, standardLibrary.getOclVoidType(), "null.oclAsType(OclAny).oclType()");		// Cast does not change the dynamic type
 		//    	ocl.assertQueryEquals(null, "OclAny", "null.oclAsType(OclAny).name");