diff --git a/tlatools/src/tlc2/overrides/Evaluation.java b/tlatools/src/tlc2/overrides/Evaluation.java index 9710713bcda98be7b5db71c5b9f31ad9d54b53cb..2422f496837c47d71a92c0ff080cc7cb24e193ea 100644 --- a/tlatools/src/tlc2/overrides/Evaluation.java +++ b/tlatools/src/tlc2/overrides/Evaluation.java @@ -61,4 +61,12 @@ public @interface Evaluation { * @see tlc2.tool.impl.SpecProcessor.processConstantDefns() */ int minLevel() default 0; + + /** + * @return true if a warning should be printed when a EV cannot be mapped to the + * given TLA+ definition in module. + * @see Evaluation#definition() + * @see Evaluation#module() + */ + boolean warn() default true; } diff --git a/tlatools/src/tlc2/overrides/TLAPlusOperator.java b/tlatools/src/tlc2/overrides/TLAPlusOperator.java index d00cb096262d250e7abce59e941de4c56d2bec88..780c0f8dfa50f1d9b6a4094415a2db02ff8a6565 100644 --- a/tlatools/src/tlc2/overrides/TLAPlusOperator.java +++ b/tlatools/src/tlc2/overrides/TLAPlusOperator.java @@ -52,4 +52,9 @@ public @interface TLAPlusOperator { * @see tlc2.overrides.Evaluation.minLevel() */ int minLevel() default 0; + + /** + * @return tlc2.overrides.Evaluation.warn() + */ + boolean warn() default true; } diff --git a/tlatools/src/tlc2/tool/impl/SpecProcessor.java b/tlatools/src/tlc2/tool/impl/SpecProcessor.java index 58a3b2cd046743777b747f72e5d6ed2d1a452ac5..71955b61de1b2d4e265abc39301ea9d2d5d445ca 100644 --- a/tlatools/src/tlc2/tool/impl/SpecProcessor.java +++ b/tlatools/src/tlc2/tool/impl/SpecProcessor.java @@ -589,15 +589,14 @@ public class SpecProcessor implements ValueConstants, ToolGlobals { final ModuleNode moduleNode = modSet.get(evaluation.module()); if (moduleNode == null) { - // If the module, for which the operator has been defined, isn't part of the spec, - // it is probably intentional and thus confusing to warn the user. This e.g. - // happen with CommunitModules which has a bunch of operators spread over a set - // modules and a user only uses a subset in her spec. + if (evaluation.warn()) MP.printMessage(EC.TLC_MODULE_VALUE_JAVA_METHOD_OVERRIDE_MODULE_MISMATCH, + evaluation.module() + "!" + evaluation.definition(), + c.getResource(c.getSimpleName() + ".class").toExternalForm(), val.toString()); continue LOOP; } final OpDefNode opDef = moduleNode.getOpDef(evaluation.definition()); if (opDef == null) { - MP.printMessage(EC.TLC_MODULE_VALUE_JAVA_METHOD_OVERRIDE_IDENTIFIER_MISMATCH, + if (evaluation.warn()) MP.printMessage(EC.TLC_MODULE_VALUE_JAVA_METHOD_OVERRIDE_IDENTIFIER_MISMATCH, evaluation.module() + "!" + evaluation.definition(), c.getResource(c.getSimpleName() + ".class").toExternalForm(), val.toString()); continue LOOP; @@ -619,24 +618,24 @@ public class SpecProcessor implements ValueConstants, ToolGlobals { if (opOverrideCandidate != null) { final ModuleNode moduleNode = modSet.get(opOverrideCandidate.module()); if (moduleNode == null) { - MP.printWarning(EC.TLC_MODULE_VALUE_JAVA_METHOD_OVERRIDE_MODULE_MISMATCH, + if (opOverrideCandidate.warn()) MP.printWarning(EC.TLC_MODULE_VALUE_JAVA_METHOD_OVERRIDE_MODULE_MISMATCH, opOverrideCandidate.identifier(), opOverrideCandidate.module(), m.toString()); continue LOOP; } final OpDefNode opDef = moduleNode.getOpDef(opOverrideCandidate.identifier()); if (opDef == null) { - MP.printWarning(EC.TLC_MODULE_VALUE_JAVA_METHOD_OVERRIDE_IDENTIFIER_MISMATCH, + if (opOverrideCandidate.warn()) MP.printWarning(EC.TLC_MODULE_VALUE_JAVA_METHOD_OVERRIDE_IDENTIFIER_MISMATCH, opOverrideCandidate.identifier(), opOverrideCandidate.module(), m.toString()); continue LOOP; } final Value val = MethodValue.get(m, opOverrideCandidate.minLevel()); if (opDef.getArity() != m.getParameterCount()) { - MP.printWarning(EC.TLC_MODULE_VALUE_JAVA_METHOD_OVERRIDE_MISMATCH, + if (opOverrideCandidate.warn()) MP.printWarning(EC.TLC_MODULE_VALUE_JAVA_METHOD_OVERRIDE_MISMATCH, opDef.getName().toString(), c.getName(), val.toString()); continue LOOP; } else { - MP.printMessage(EC.TLC_MODULE_VALUE_JAVA_METHOD_OVERRIDE_LOADED, + if (opOverrideCandidate.warn()) MP.printMessage(EC.TLC_MODULE_VALUE_JAVA_METHOD_OVERRIDE_LOADED, opDef.getName().toString(), c.getName(), val instanceof MethodValue ? val.toString() : val.getClass().getName()); // toString of non-MethodValue instances can be expensive. }