Revert "Make void a static warning to use almost everywhere."

This reverts commit 09eed74a8a.

Reason for revert: Too much SDK code is not yet compliant.

Original change's description:
> Make `void` a static warning to use almost everywhere.
> 
> Changed the hint to a StaticWarningCode, since that's the new spec'd
> error type and the hint is no longer needed.
> 
> Added a new set of methods to test the cases.
> 
> Didn't try to solve the problem generally ("all usages except ... are
> errors" means it easier, in theory, to make a ReportVoidExpressions
> style visitor that catches absolutely all types) because most of the
> work is actually about suppressing errors that are no longer needed.
> Ie, from NO_SUCH_METHOD to USAGE_OF_VOID_RESULT which means we have to
> put the void handling logic into each AST method specially anyway.
> 
> Some redundant tests removed.
> 
> Don't flag: ternaries, void -> void assignments, void returns in
> dynamic.
> 
> Change-Id: Ief8035dcfe582b36b6372180ddcf4e453d320d9c
> Reviewed-on: https://dart-review.googlesource.com/37441
> Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
> Reviewed-by: Leaf Petersen <leafp@google.com>

TBR=leafp@google.com,scheglov@google.com,mfairhurst@google.com

Change-Id: I13ee4c6939468d35506779ade637a040833632f4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/39848
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
This commit is contained in:
Mike Fairhurst 2018-02-07 22:32:51 +00:00 committed by commit-bot@chromium.org
parent 39448ff521
commit ec58f5646a
27 changed files with 443 additions and 1134 deletions

View file

@ -303,6 +303,7 @@ const List<ErrorCode> errorCodeValues = const [
HintCode.UNUSED_LABEL,
HintCode.UNUSED_LOCAL_VARIABLE,
HintCode.UNUSED_SHOWN_NAME,
HintCode.USE_OF_VOID_RESULT,
HintCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS_METHOD,
HtmlErrorCode.PARSE_ERROR,
HtmlWarningCode.INVALID_URI,
@ -626,7 +627,6 @@ const List<ErrorCode> errorCodeValues = const [
StaticWarningCode.UNDEFINED_STATIC_METHOD_OR_GETTER,
StaticWarningCode.UNDEFINED_SUPER_GETTER,
StaticWarningCode.UNDEFINED_SUPER_SETTER,
StaticWarningCode.USE_OF_VOID_RESULT,
StrongModeCode.ASSIGNMENT_CAST,
StrongModeCode.COULD_NOT_INFER,
StrongModeCode.DOWN_CAST_COMPOSITE,

View file

@ -662,6 +662,17 @@ class HintCode extends ErrorCode {
"The name {0} is shown, but not used.",
"Try removing the name from the list of shown members.");
/**
* Hint for cases where the source expects a method or function to return a
* non-void result, but the method or function signature returns void.
*
* Parameters:
* 0: the name of the method or function that returns void
*/
static const HintCode USE_OF_VOID_RESULT = const HintCode(
'USE_OF_VOID_RESULT',
"The result of '{0}' is being used, even though it is declared to be 'void'.");
/**
* It will be a static type warning if <i>m</i> is not a generic method with
* exactly <i>n</i> type parameters.

View file

@ -4760,20 +4760,6 @@ class StaticWarningCode extends ErrorCode {
"Try correcting the name to an existing setter, or "
"defining the setter in a superclass of '{1}'.");
/**
* It is a static warning to assign void to any non-void type in dart.
* compile-time error). Report that error specially for a better user
* experience.
*
* Parameters: none
*/
static const StaticWarningCode USE_OF_VOID_RESULT = const StaticWarningCode(
'USE_OF_VOID_RESULT',
"The expression here has a type of 'void', and therefore cannot be used.",
'Check if you are using the correct API; there may be a function or'
" call that returns void you didn't expect. Also check type parameters"
' and variables which, in rare cases, may be void as well.');
/**
* A flag indicating whether this warning is an error when running with strong
* mode enabled.

View file

@ -166,26 +166,15 @@ class ElementResolver extends SimpleAstVisitor<Object> {
Object visitAssignmentExpression(AssignmentExpression node) {
Token operator = node.operator;
TokenType operatorType = operator.type;
Expression leftHandSide = node.leftHandSide;
DartType staticType = _getStaticType(leftHandSide, read: true);
// For any compound assignments to a void variable, report bad void usage.
// Example: `y += voidFn()`, not allowed.
if (operatorType != TokenType.EQ &&
staticType != null &&
staticType.isVoid) {
_recordUndefinedToken(
null, StaticWarningCode.USE_OF_VOID_RESULT, operator, []);
return null;
}
if (operatorType != TokenType.AMPERSAND_AMPERSAND_EQ &&
operatorType != TokenType.BAR_BAR_EQ &&
operatorType != TokenType.EQ &&
operatorType != TokenType.QUESTION_QUESTION_EQ) {
operatorType = _operatorFromCompoundAssignment(operatorType);
Expression leftHandSide = node.leftHandSide;
if (leftHandSide != null) {
String methodName = operatorType.lexeme;
DartType staticType = _getStaticType(leftHandSide, read: true);
MethodElement staticMethod =
_lookUpMethod(leftHandSide, staticType, methodName);
node.staticElement = staticMethod;
@ -899,9 +888,6 @@ class ElementResolver extends SimpleAstVisitor<Object> {
StaticTypeWarningCode.UNDEFINED_SUPER_METHOD,
methodName,
[methodName.name, targetTypeName]);
} else if (identical(errorCode, StaticWarningCode.USE_OF_VOID_RESULT)) {
_resolver.errorReporter.reportErrorForNode(
StaticWarningCode.USE_OF_VOID_RESULT, target ?? methodName, []);
}
return null;
}
@ -1318,7 +1304,9 @@ class ElementResolver extends SimpleAstVisitor<Object> {
FunctionType getterType = element.type;
if (getterType != null) {
DartType returnType = getterType.returnType;
return _getErrorCodeForExecuting(returnType);
if (!_isExecutableType(returnType)) {
return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION;
}
}
} else if (element is ExecutableElement) {
return null;
@ -1340,11 +1328,15 @@ class ElementResolver extends SimpleAstVisitor<Object> {
FunctionType getterType = getter.type;
if (getterType != null) {
DartType returnType = getterType.returnType;
return _getErrorCodeForExecuting(returnType);
if (!_isExecutableType(returnType)) {
return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION;
}
}
} else if (element is VariableElement) {
DartType variableType = element.type;
return _getErrorCodeForExecuting(variableType);
if (!_isExecutableType(variableType)) {
return StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION;
}
} else {
if (target == null) {
ClassElement enclosingClass = _resolver.enclosingClass;
@ -1373,8 +1365,6 @@ class ElementResolver extends SimpleAstVisitor<Object> {
return null;
}
return StaticTypeWarningCode.UNDEFINED_FUNCTION;
} else if (targetType.isVoid) {
return StaticWarningCode.USE_OF_VOID_RESULT;
} else if (!targetType.isDynamic && target is! NullLiteral) {
// Proxy-conditional warning, based on state of
// targetType.getElement()
@ -1413,29 +1403,25 @@ class ElementResolver extends SimpleAstVisitor<Object> {
Token leftBracket = expression.leftBracket;
Token rightBracket = expression.rightBracket;
ErrorCode errorCode;
DartType type =
shouldReportMissingMember_static ? staticType : propagatedType;
var errorArguments = [methodName, type.displayName];
if (shouldReportMissingMember_static) {
if (target is SuperExpression) {
errorCode = StaticTypeWarningCode.UNDEFINED_SUPER_OPERATOR;
} else if (staticType != null && staticType.isVoid) {
errorCode = StaticWarningCode.USE_OF_VOID_RESULT;
errorArguments = [];
} else {
errorCode = StaticTypeWarningCode.UNDEFINED_OPERATOR;
}
} else {
errorCode = HintCode.UNDEFINED_OPERATOR;
}
DartType type =
shouldReportMissingMember_static ? staticType : propagatedType;
if (leftBracket == null || rightBracket == null) {
_recordUndefinedNode(
type.element, errorCode, expression, errorArguments);
_recordUndefinedNode(type.element, errorCode, expression,
[methodName, type.displayName]);
} else {
int offset = leftBracket.offset;
int length = rightBracket.offset - offset + 1;
_recordUndefinedOffset(
type.element, errorCode, offset, length, errorArguments);
_recordUndefinedOffset(type.element, errorCode, offset, length,
[methodName, type.displayName]);
}
return true;
}
@ -1886,21 +1872,6 @@ class ElementResolver extends SimpleAstVisitor<Object> {
return false;
}
/**
* Return an error if the [type], which is presumably being invoked, is not a
* function. The errors for non functions may be broken up by type; currently,
* it returns a special value for when the type is `void`.
*/
ErrorCode _getErrorCodeForExecuting(DartType type) {
if (_isExecutableType(type)) {
return null;
}
return type.isVoid
? StaticWarningCode.USE_OF_VOID_RESULT
: StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION;
}
/**
* Return `true` if the given [type] represents an object that could be
* invoked using the call operator '()'.
@ -2665,7 +2636,6 @@ class ElementResolver extends SimpleAstVisitor<Object> {
staticType.isVoid ? null : staticOrPropagatedEnclosingElt;
if (propertyName.inSetterContext()) {
ErrorCode errorCode;
var arguments = [propertyName.name, displayType.displayName];
if (shouldReportMissingMember_static) {
if (target is SuperExpression) {
if (isStaticProperty && !staticType.isVoid) {
@ -2674,10 +2644,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
errorCode = StaticTypeWarningCode.UNDEFINED_SUPER_SETTER;
}
} else {
if (staticType.isVoid) {
errorCode = StaticWarningCode.USE_OF_VOID_RESULT;
arguments = [];
} else if (isStaticProperty) {
if (isStaticProperty && !staticType.isVoid) {
errorCode = StaticWarningCode.UNDEFINED_SETTER;
} else {
errorCode = StaticTypeWarningCode.UNDEFINED_SETTER;
@ -2686,11 +2653,10 @@ class ElementResolver extends SimpleAstVisitor<Object> {
} else {
errorCode = HintCode.UNDEFINED_SETTER;
}
_recordUndefinedNode(
declaringElement, errorCode, propertyName, arguments);
_recordUndefinedNode(declaringElement, errorCode, propertyName,
[propertyName.name, displayType.displayName]);
} else if (propertyName.inGetterContext()) {
ErrorCode errorCode;
var arguments = [propertyName.name, displayType.displayName];
if (shouldReportMissingMember_static) {
if (target is SuperExpression) {
if (isStaticProperty && !staticType.isVoid) {
@ -2699,10 +2665,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
errorCode = StaticTypeWarningCode.UNDEFINED_SUPER_GETTER;
}
} else {
if (staticType.isVoid) {
errorCode = StaticWarningCode.USE_OF_VOID_RESULT;
arguments = [];
} else if (isStaticProperty) {
if (isStaticProperty && !staticType.isVoid) {
errorCode = StaticWarningCode.UNDEFINED_GETTER;
} else {
errorCode = StaticTypeWarningCode.UNDEFINED_GETTER;
@ -2711,8 +2674,8 @@ class ElementResolver extends SimpleAstVisitor<Object> {
} else {
errorCode = HintCode.UNDEFINED_GETTER;
}
_recordUndefinedNode(
declaringElement, errorCode, propertyName, arguments);
_recordUndefinedNode(declaringElement, errorCode, propertyName,
[propertyName.name, displayType.displayName]);
} else {
_recordUndefinedNode(
declaringElement,

View file

@ -390,7 +390,6 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
} else {
_checkForArgumentTypeNotAssignableForArgument(node.rightOperand);
}
_checkForUseOfVoidResult(node.leftOperand);
return super.visitBinaryExpression(node);
}
@ -548,9 +547,6 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
@override
Object visitConditionalExpression(ConditionalExpression node) {
_checkForNonBoolCondition(node.condition);
// TODO(mfairhurst) Enable this and get code compliant.
//_checkForUseOfVoidResult(node.thenExpression);
//_checkForUseOfVoidResult(node.elseExpression);
return super.visitConditionalExpression(node);
}
@ -793,8 +789,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
Object visitFunctionExpressionInvocation(FunctionExpressionInvocation node) {
Expression functionExpression = node.function;
DartType expressionType = functionExpression.staticType;
if (!_checkForUseOfVoidResult(functionExpression) &&
!_isFunctionType(expressionType)) {
if (!_isFunctionType(expressionType)) {
_errorReporter.reportErrorForNode(
StaticTypeWarningCode.INVOCATION_OF_NON_FUNCTION_EXPRESSION,
functionExpression);
@ -929,7 +924,6 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
@override
Object visitIsExpression(IsExpression node) {
_checkForTypeAnnotationDeferredClass(node.type);
_checkForUseOfVoidResult(node.expression);
return super.visitIsExpression(node);
}
@ -948,7 +942,6 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
}
_checkForImplicitDynamicTypedLiteral(node);
_checkForListElementTypeNotAssignable(node);
return super.visitListLiteral(node);
}
@ -1182,7 +1175,6 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
@override
Object visitThrowExpression(ThrowExpression node) {
_checkForConstEvalThrowsException(node);
_checkForUseOfVoidResult(node.expression);
return super.visitThrowExpression(node);
}
@ -2430,8 +2422,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
* [CompileTimeErrorCode.MAP_KEY_TYPE_NOT_ASSIGNABLE],
* [CompileTimeErrorCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE],
* [StaticWarningCode.MAP_KEY_TYPE_NOT_ASSIGNABLE], and
* [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE], and
* [StaticWarningCode.USE_OF_VOID_RESULT].
* [StaticWarningCode.MAP_VALUE_TYPE_NOT_ASSIGNABLE].
*/
void _checkForArgumentTypeNotAssignable(
Expression expression,
@ -2440,10 +2431,6 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
ErrorCode errorCode) {
// Warning case: test static type information
if (actualStaticType != null && expectedStaticType != null) {
if (!expectedStaticType.isVoid && _checkForUseOfVoidResult(expression)) {
return;
}
_checkForAssignableExpressionAtType(
expression, actualStaticType, expectedStaticType, errorCode);
}
@ -2462,7 +2449,6 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
if (argument == null) {
return;
}
ParameterElement staticParameterElement = argument.staticParameterElement;
DartType staticParameterType = staticParameterElement?.type;
_checkForArgumentTypeNotAssignableWithExpectedTypes(argument,
@ -4281,10 +4267,6 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
return;
}
if (_checkForUseOfVoidResult(node.iterable)) {
return;
}
DartType iterableType = getStaticType(node.iterable);
if (iterableType.isDynamic) {
return;
@ -4294,9 +4276,6 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
SimpleIdentifier variable = node.identifier ?? node.loopVariable.identifier;
DartType variableType = getStaticType(variable);
// TODO(mfairhurst) Check and guard against `for(void x in _)`?
//_checkForUseOfVoidResult(variable);
DartType loopType = node.awaitKeyword != null
? _typeProvider.streamType
: _typeProvider.iterableType;
@ -4413,11 +4392,6 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
DartType leftType = (leftVariableElement == null)
? getStaticType(lhs)
: leftVariableElement.type;
if (_checkForUseOfVoidResult(rhs)) {
return;
}
_checkForAssignableExpression(
rhs, leftType, StaticTypeWarningCode.INVALID_ASSIGNMENT,
isDeclarationCast: isDeclarationCast);
@ -5182,8 +5156,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
*/
void _checkForNonBoolCondition(Expression condition) {
DartType conditionType = getStaticType(condition);
if (!_checkForUseOfVoidResult(condition) &&
conditionType != null &&
if (conditionType != null &&
!_typeSystem.isAssignableTo(conditionType, _boolType)) {
_errorReporter.reportErrorForNode(
StaticTypeWarningCode.NON_BOOL_CONDITION, condition);
@ -5701,12 +5674,8 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
* See [StaticWarningCode.SWITCH_EXPRESSION_NOT_ASSIGNABLE].
*/
void _checkForSwitchExpressionNotAssignable(SwitchStatement statement) {
Expression expression = statement.expression;
if (_checkForUseOfVoidResult(expression)) {
return;
}
// prepare 'switch' expression type
Expression expression = statement.expression;
DartType expressionType = getStaticType(expression);
if (expressionType == null) {
return;
@ -6294,31 +6263,6 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
}
}
/**
* Check for situations where the result of a method or function is used, when
* it returns 'void'. Or, in rare cases, when other types of expressions are
* void, such as identifiers.
*
* See [StaticWarningCode.USE_OF_VOID_RESULT].
*/
bool _checkForUseOfVoidResult(Expression expression) {
if (expression == null ||
!identical(expression.staticType, VoidTypeImpl.instance)) {
return false;
}
if (expression is MethodInvocation) {
SimpleIdentifier methodName = expression.methodName;
_errorReporter.reportErrorForNode(
StaticWarningCode.USE_OF_VOID_RESULT, methodName, []);
} else {
_errorReporter.reportErrorForNode(
StaticWarningCode.USE_OF_VOID_RESULT, expression, []);
}
return true;
}
DartType _computeReturnTypeForMethod(Expression returnExpression) {
// This method should never be called for generators, since generators are
// never allowed to contain return statements with expressions.

View file

@ -166,6 +166,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
Object visitAssignmentExpression(AssignmentExpression node) {
TokenType operatorType = node.operator.type;
if (operatorType == TokenType.EQ) {
_checkForUseOfVoidResult(node.rightHandSide);
_checkForInvalidAssignment(node.leftHandSide, node.rightHandSide);
} else {
_checkForDeprecatedMemberUse(node.bestElement, node);
@ -369,6 +370,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
@override
Object visitVariableDeclaration(VariableDeclaration node) {
_checkForUseOfVoidResult(node.initializer);
_checkForInvalidAssignment(node.name, node.initializer);
return super.visitVariableDeclaration(node);
}
@ -1240,6 +1242,25 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
return false;
}
/**
* Check for situations where the result of a method or function is used, when
* it returns 'void'.
*
* See [HintCode.USE_OF_VOID_RESULT].
*/
void _checkForUseOfVoidResult(Expression expression) {
// TODO(jwren) Many other situations of use could be covered. We currently
// cover the cases var x = m() and x = m(), but we could also cover cases
// such as m().x, m()[k], a + m(), f(m()), return m().
if (expression is MethodInvocation) {
if (identical(expression.staticType, VoidTypeImpl.instance)) {
SimpleIdentifier methodName = expression.methodName;
_errorReporter.reportErrorForNode(
HintCode.USE_OF_VOID_RESULT, methodName, [methodName.name]);
}
}
}
void _checkRequiredParameter(FormalParameterList node) {
final requiredParameters =
node.parameters.where((p) => p.element?.isRequired == true);

View file

@ -1129,9 +1129,7 @@ class CodeChecker extends RecursiveAstVisitor {
/// Returns true if we need an implicit cast of [expr] from [from] type to
/// [to] type, returns false if no cast is needed, and returns null if the
/// types are statically incompatible, or the types are compatible but don't
/// allow implicit cast (ie, void, which is one form of Top which oill not
/// downcast implicitly).
/// types are statically incompatible.
///
/// If [from] is omitted, uses the static type of [expr]
bool _needsImplicitCast(Expression expr, DartType to,
@ -1140,8 +1138,8 @@ class CodeChecker extends RecursiveAstVisitor {
if (!_checkNonNullAssignment(expr, to, from)) return false;
// Void is considered Top, but may only be *explicitly* cast.
if (from.isVoid) return null;
// We can use anything as void.
if (to.isVoid) return false;
// fromT <: toT, no coercion needed.
if (rules.isSubtypeOf(from, to)) return false;

View file

@ -496,40 +496,4 @@ class HintCodeTest_Kernel extends HintCodeTest_Driver {
test_no_missingReturn_async_futureOrVoid() async {
await super.test_no_missingReturn_async_futureOrVoid();
}
@failingTest
@override
test_useOfVoidResult_assignmentExpression_function() async {
return super.test_useOfVoidResult_assignmentExpression_function();
}
@failingTest
@override
test_useOfVoidResult_assignmentExpression_method() async {
return super.test_useOfVoidResult_assignmentExpression_method();
}
@failingTest
@override
test_useOfVoidResult_inForLoop() async {
return super.test_useOfVoidResult_inForLoop();
}
@failingTest
@override
test_useOfVoidResult_variableDeclaration_function() async {
return super.test_useOfVoidResult_variableDeclaration_function();
}
@failingTest
@override
test_useOfVoidResult_variableDeclaration_method() async {
return super.test_useOfVoidResult_variableDeclaration_method();
}
@failingTest
@override
test_useOfVoidResult_variableDeclaration_method2() async {
return super.test_useOfVoidResult_variableDeclaration_method2();
}
}

View file

@ -5293,4 +5293,85 @@ const int var4 = 4;''');
assertNoErrors(source2);
verify([source, source2]);
}
test_useOfVoidResult_assignmentExpression_function() async {
Source source = addSource(r'''
void f() {}
class A {
n() {
var a;
a = f();
}
}''');
await computeAnalysisResult(source);
assertErrors(source, [HintCode.USE_OF_VOID_RESULT]);
verify([source]);
}
test_useOfVoidResult_assignmentExpression_method() async {
Source source = addSource(r'''
class A {
void m() {}
n() {
var a;
a = m();
}
}''');
await computeAnalysisResult(source);
assertErrors(source, [HintCode.USE_OF_VOID_RESULT]);
verify([source]);
}
test_useOfVoidResult_inForLoop() async {
Source source = addSource(r'''
class A {
void m() {}
n() {
for(var a = m();;) {}
}
}''');
await computeAnalysisResult(source);
assertErrors(source, [HintCode.USE_OF_VOID_RESULT]);
verify([source]);
}
test_useOfVoidResult_variableDeclaration_function() async {
Source source = addSource(r'''
void f() {}
class A {
n() {
var a = f();
}
}''');
await computeAnalysisResult(source);
assertErrors(source, [HintCode.USE_OF_VOID_RESULT]);
verify([source]);
}
test_useOfVoidResult_variableDeclaration_method() async {
Source source = addSource(r'''
class A {
void m() {}
n() {
var a = m();
}
}''');
await computeAnalysisResult(source);
assertErrors(source, [HintCode.USE_OF_VOID_RESULT]);
verify([source]);
}
test_useOfVoidResult_variableDeclaration_method2() async {
Source source = addSource(r'''
class A {
void m() {}
n() {
var a = m(), b = m();
}
}''');
await computeAnalysisResult(source);
assertErrors(
source, [HintCode.USE_OF_VOID_RESULT, HintCode.USE_OF_VOID_RESULT]);
verify([source]);
}
}

View file

@ -1546,6 +1546,14 @@ f() => A?.hashCode;
''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_undefinedGetter_void() async {
await assertErrorsInCode(r'''
class T {
void m() {}
}
f(T e) { return e.m().f; }''', [StaticTypeWarningCode.UNDEFINED_GETTER]);
}
test_undefinedGetter_wrongNumberOfTypeArguments_tooLittle() async {
await assertErrorsInCode(r'''
class A<K, V> {
@ -1779,6 +1787,14 @@ main() {
}''', [StaticTypeWarningCode.UNDEFINED_SETTER]);
}
test_undefinedSetter_void() async {
await assertErrorsInCode(r'''
class T {
void m() {}
}
f(T e) { e.m().f = 0; }''', [StaticTypeWarningCode.UNDEFINED_SETTER]);
}
test_undefinedSuperGetter() async {
await assertErrorsInCode(r'''
class A {}

View file

@ -1811,289 +1811,4 @@ class StaticWarningCodeTest_Kernel extends StaticWarningCodeTest_Driver {
test_undefinedStaticMethodOrGetter_setter_inSuperclass() async {
return super.test_undefinedStaticMethodOrGetter_setter_inSuperclass();
}
@override
@failingTest
test_generalizedVoid_assignToVoid_notStrong_error() async {
return super.test_generalizedVoid_assignToVoid_notStrong_error();
}
@override
@failingTest
test_generalizedVoid_useOfVoidInForPartsOk() async {
return super.test_generalizedVoid_useOfVoidInForPartsOk();
}
@override
@failingTest
test_generalizedVoid_useOfVoidInIsTestError() async {
return super.test_generalizedVoid_useOfVoidInIsTestError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidInConditionalConditionError() async {
return super.test_generalizedVoid_useOfVoidInConditionalConditionError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidInConditionalLhsError() async {
return super.test_generalizedVoid_useOfVoidInConditionalLhsError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidInConditionalRhsError() async {
return super.test_generalizedVoid_useOfVoidInConditionalRhsError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidWhenArgumentError() async {
return super.test_generalizedVoid_useOfVoidWhenArgumentError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidWithInitializerError() async {
return super.test_generalizedVoid_useOfVoidWithInitializerError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidAssignedToDynamicError() async {
return super.test_generalizedVoid_useOfVoidAssignedToDynamicError();
}
@override
@failingTest
test_generalizedVoid_throwVoidValueError() async {
return super.test_generalizedVoid_throwVoidValueError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidInListLiteralError() async {
return super.test_generalizedVoid_useOfVoidInListLiteralError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidInMapLiteralValueError() async {
return super.test_generalizedVoid_useOfVoidInMapLiteralValueError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidInMapLiteralKeyError() async {
return super.test_generalizedVoid_useOfVoidInMapLiteralKeyError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidInNullOperatorLhsError() async {
return super.test_generalizedVoid_useOfVoidInNullOperatorLhsError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidInNullOperatorRhsError() async {
return super.test_generalizedVoid_useOfVoidInNullOperatorRhsError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidReturnInNonVoidFunctionError() async {
return super.test_generalizedVoid_useOfVoidReturnInNonVoidFunctionError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidInWhileConditionError() async {
return super.test_generalizedVoid_useOfVoidInWhileConditionError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidInDoWhileConditionError() async {
return super.test_generalizedVoid_useOfVoidInDoWhileConditionError();
}
@override
@failingTest
test_generalizedVoid_useOfInForeachIterableError() async {
return super.test_generalizedVoid_useOfInForeachIterableError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidInForeachVariableError() async {
return super.test_generalizedVoid_useOfVoidInForeachVariableError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidInSpecialAssignmentError() async {
return super.test_generalizedVoid_useOfVoidInSpecialAssignmentError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidCallMethodError() async {
return super.test_generalizedVoid_useOfVoidCallMethodError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidCallMethodWithNullError() async {
return super.test_generalizedVoid_useOfVoidCallMethodWithNullError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidCascadeError() async {
return super.test_generalizedVoid_useOfVoidCascadeError();
}
@override
@failingTest
test_generalizedVoid_invocationOfVoidToplevelError() async {
return super.test_generalizedVoid_invocationOfVoidToplevelError();
}
@override
@failingTest
test_generalizedVoid_invocationOfVoidLocalError() async {
return super.test_generalizedVoid_invocationOfVoidLocalError();
}
@override
@failingTest
test_generalizedVoid_invocationOfVoidFieldError() async {
return super.test_generalizedVoid_invocationOfVoidFieldError();
}
@override
@failingTest
test_generalizedVoid_invocationOfVoidResultError() async {
return super.test_generalizedVoid_invocationOfVoidResultError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidByIndexingError() async {
return super.test_generalizedVoid_useOfVoidByIndexingError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidAsIndexError() async {
return super.test_generalizedVoid_useOfVoidAsIndexError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidAsIndexAssignError() async {
return super.test_generalizedVoid_useOfVoidAsIndexAssignError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidInSwitchExpressionError() async {
return super.test_generalizedVoid_useOfVoidInSwitchExpressionError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidPropertyAccessError() async {
return super.test_generalizedVoid_useOfVoidPropertyAccessError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidCallSetterError() async {
return super.test_generalizedVoid_useOfVoidCallSetterError();
}
@override
@failingTest
test_generalizedVoid_useOfVoidNullPropertyAccessError() async {
return super.test_generalizedVoid_useOfVoidNullPropertyAccessError();
}
@override
@failingTest
test_generalizedVoid_assignToVoidOk() async {
return super.test_generalizedVoid_assignToVoidOk();
}
@failingTest
@override
test_useOfVoidResult_assignmentExpression_function() async {
return super.test_useOfVoidResult_assignmentExpression_function();
}
@failingTest
@override
test_useOfVoidResult_assignmentExpression_method() async {
return super.test_useOfVoidResult_assignmentExpression_method();
}
@failingTest
@override
test_useOfVoidResult_inForLoop() async {
return super.test_useOfVoidResult_inForLoop();
}
@failingTest
@override
test_useOfVoidResult_variableDeclaration_function() async {
return super.test_useOfVoidResult_variableDeclaration_function();
}
@failingTest
@override
test_useOfVoidResult_variableDeclaration_method() async {
return super.test_useOfVoidResult_variableDeclaration_method();
}
@failingTest
@override
test_useOfVoidResult_variableDeclaration_method2() async {
return super.test_useOfVoidResult_variableDeclaration_method2();
}
@override
test_useOfVoidResult_inForLoop_ok() async {
return super.test_useOfVoidResult_inForLoop_ok();
}
@failingTest
@override
test_useOfVoidResult_inForLoop_error() async {
return super.test_useOfVoidResult_inForLoop_error();
}
@override
test_useOfVoidResult_variableDeclaration_function_ok() async {
return super.test_useOfVoidResult_variableDeclaration_function_ok();
}
@failingTest
@override
test_useOfVoidResult_variableDeclaration_function_error() async {
return super.test_useOfVoidResult_variableDeclaration_function_error();
}
@failingTest
@override
test_useOfVoidResult_variableDeclaration_method_error() async {
return super.test_useOfVoidResult_variableDeclaration_method_error();
}
@override
test_useOfVoidResult_variableDeclaration_method_ok() async {
return super.test_useOfVoidResult_variableDeclaration_method_ok();
}
}

View file

@ -3594,606 +3594,4 @@ class S {
await computeAnalysisResult(source);
assertNoErrors(source);
}
test_generalizedVoid_assignToVoid_notStrong_error() async {
// See StrongModeStaticTypeAnalyzer2Test.test_generalizedVoid_assignToVoidOk
// for testing that this does not have errors in strong mode.
Source source = addSource(r'''
void main() {
void x;
x = 42;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.INVALID_ASSIGNMENT]);
}
test_generalizedVoid_useOfVoidInExpStmtOk() async {
Source source = addSource(r'''
void main() {
void x;
x;
}
''');
await computeAnalysisResult(source);
assertNoErrors(source);
}
test_generalizedVoid_useOfVoidInForPartsOk() async {
Source source = addSource(r'''
void main() {
void x;
for (x; false; x) {}
}
''');
await computeAnalysisResult(source);
assertNoErrors(source);
}
test_generalizedVoid_useOfVoidCastsOk() async {
Source source = addSource(r'''
void use(dynamic x) { }
void main() {
void x;
use(x as int);
}
''');
await computeAnalysisResult(source);
assertNoErrors(source);
}
test_generalizedVoid_useOfVoidInIsTestError() async {
Source source = addSource(r'''
void main() {
void x;
x is int;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidInConditionalConditionError() async {
Source source = addSource(r'''
void main() {
void x;
x ? null : null;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
@failingTest
test_generalizedVoid_useOfVoidInConditionalLhsError() async {
// TODO(mfairhurst) Enable this.
Source source = addSource(r'''
void main(bool c) {
void x;
c ? x : null;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
@failingTest
test_generalizedVoid_useOfVoidInConditionalRhsError() async {
// TODO(mfairhurst) Enable this.
Source source = addSource(r'''
void main(bool c) {
void x;
c ? null : x;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidWhenArgumentError() async {
Source source = addSource(r'''
void use(dynamic x) { }
void main() {
void x;
use(x);
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidWithInitializerError() async {
Source source = addSource(r'''
void main() {
void x;
void y = x;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidAssignedToDynamicError() async {
Source source = addSource(r'''
void main() {
void x;
dynamic z = x;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_throwVoidValueError() async {
Source source = addSource(r'''
void main() {
void x;
throw x;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidInListLiteralOk() async {
Source source = addSource(r'''
void main() {
void x;
<void>[x]; // not strong mode; we have to specify <void>.
}
''');
await computeAnalysisResult(source);
assertNoErrors(source);
}
test_generalizedVoid_useOfVoidInListLiteralError() async {
Source source = addSource(r'''
void main() {
void x;
<dynamic>[x];
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidInMapLiteralValueOk() async {
Source source = addSource(r'''
void main() {
void x;
var m1 = <int, void>{4: x}; // not strong mode; we have to specify <void>.
}
''');
await computeAnalysisResult(source);
assertNoErrors(source);
}
test_generalizedVoid_useOfVoidInMapLiteralValueError() async {
Source source = addSource(r'''
void main() {
void x;
var m1 = <int, dynamic>{4: x};
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidInMapLiteralKeyOk() async {
Source source = addSource(r'''
void main() {
void x;
var m2 = <void, int>{x : 4}; // not strong mode; we have to specify <void>.
}
''');
await computeAnalysisResult(source);
assertNoErrors(source);
}
test_generalizedVoid_useOfVoidInMapLiteralKeyError() async {
Source source = addSource(r'''
void main() {
void x;
var m2 = <dynamic, int>{x : 4};
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidInNullOperatorLhsError() async {
Source source = addSource(r'''
void main() {
void x;
x ?? 499;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidInNullOperatorRhsOk() async {
Source source = addSource(r'''
void main() {
void x;
null ?? x;
}
''');
await computeAnalysisResult(source);
assertNoErrors(source);
}
@failingTest
test_generalizedVoid_useOfVoidReturnInNonVoidFunctionError() async {
// TODO(mfairhurst) Get this test to pass once codebase is compliant.
Source source = addSource(r'''
dynamic main() {
void x;
return x;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticTypeWarningCode.RETURN_OF_INVALID_TYPE]);
}
test_generalizedVoid_useOfVoidReturnInVoidFunctionOk() async {
Source source = addSource(r'''
void main() {
void x;
return x;
}
''');
await computeAnalysisResult(source);
assertNoErrors(source);
}
test_generalizedVoid_useOfVoidInWhileConditionError() async {
Source source = addSource(r'''
void main() {
void x;
while (x) {};
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidInDoWhileConditionError() async {
Source source = addSource(r'''
void main() {
void x;
do {} while (x);
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfInForeachIterableError() async {
Source source = addSource(r'''
void main() {
void x;
for (var v in x) {}
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
@failingTest // This test may be completely invalid.
test_generalizedVoid_useOfVoidInForeachVariableError() async {
Source source = addSource(r'''
void main() {
void x;
for (x in [1, 2]) {}
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidInSpecialAssignmentError() async {
Source source = addSource(r'''
void main() {
void x;
x += 1;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidCallMethodError() async {
Source source = addSource(r'''
void main() {
void x;
x.toString();
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidCallMethodWithNullError() async {
Source source = addSource(r'''
void main() {
void x;
x?.toString();
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidCascadeError() async {
Source source = addSource(r'''
void main() {
void x;
x..toString();
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_invocationOfVoidToplevelError() async {
Source source = addSource(r'''
void x;
void main() {
x();
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_invocationOfVoidLocalError() async {
Source source = addSource(r'''
void main() {
void x;
x();
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_invocationOfVoidFieldError() async {
Source source = addSource(r'''
class Container<T>{
T value;
}
void main(Container<void> voidContainer) {
voidContainer.value();
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_invocationOfVoidResultError() async {
Source source = addSource(r'''
void main() {
main()();
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidByIndexingError() async {
Source source = addSource(r'''
void main() {
void x;
x[0];
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidAsIndexError() async {
Source source = addSource(r'''
void main(List list) {
void x;
list[x];
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidAsIndexAssignError() async {
Source source = addSource(r'''
void main(List list) {
void x;
list[x] = null;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidInSwitchExpressionError() async {
Source source = addSource(r'''
void main() {
void x;
switch(x) {}
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidPropertyAccessError() async {
Source source = addSource(r'''
void main() {
void x;
x.foo;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidCallSetterError() async {
Source source = addSource(r'''
void main() {
void x;
x.foo = null;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_useOfVoidNullPropertyAccessError() async {
Source source = addSource(r'''
void main() {
void x;
x?.foo;
}
''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
}
test_generalizedVoid_assignmentToVoidParameterOk() async {
// Note: the spec may decide to disallow this, but at this point that seems
// highly unlikely.
Source source = addSource(r'''
void main() {
void x;
f(x);
}
void f(void x) {}
''');
await computeAnalysisResult(source);
assertNoErrors(source);
}
test_useOfVoidResult_assignmentExpression_function() async {
Source source = addSource(r'''
void f() {}
class A {
n() {
var a;
a = f();
}
}''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
verify([source]);
}
test_useOfVoidResult_assignmentExpression_method() async {
Source source = addSource(r'''
class A {
void m() {}
n() {
var a;
a = m();
}
}''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
verify([source]);
}
@failingTest
test_useOfVoidResult_inForLoop_ok() async {
Source source = addSource(r'''
class A {
void m() {}
n() {
for(var a = m();;) {}
}
}''');
await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
test_useOfVoidResult_inForLoop_error() async {
Source source = addSource(r'''
class A {
void m() {}
n() {
for(Object a = m();;) {}
}
}''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
verify([source]);
}
@failingTest
test_useOfVoidResult_variableDeclaration_function_ok() async {
Source source = addSource(r'''
void f() {}
class A {
n() {
var a = f();
}
}''');
await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
test_useOfVoidResult_variableDeclaration_function_error() async {
Source source = addSource(r'''
void f() {}
class A {
n() {
Object a = f();
}
}''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
verify([source]);
}
test_useOfVoidResult_variableDeclaration_method_error() async {
Source source = addSource(r'''
class A {
void m() {}
n() {
Object a = m();
}
}''');
await computeAnalysisResult(source);
assertErrors(source, [StaticWarningCode.USE_OF_VOID_RESULT]);
verify([source]);
}
@failingTest
test_useOfVoidResult_variableDeclaration_method_ok() async {
Source source = addSource(r'''
class A {
void m() {}
n() {
var a = m();
}
}''');
await computeAnalysisResult(source);
assertNoErrors(source);
verify([source]);
}
test_useOfVoidResult_variableDeclaration_method2() async {
Source source = addSource(r'''
class A {
void m() {}
n() {
Object a = m(), b = m();
}
}''');
await computeAnalysisResult(source);
assertErrors(source, [
StaticWarningCode.USE_OF_VOID_RESULT,
StaticWarningCode.USE_OF_VOID_RESULT
]);
verify([source]);
}
}

View file

@ -35,8 +35,8 @@ main() {
['x']
]);
AnalysisError use_of_void_result = new AnalysisError(
new TestSource(), 0, 1, StaticWarningCode.USE_OF_VOID_RESULT, [
AnalysisError use_of_void_result =
new AnalysisError(new TestSource(), 0, 1, HintCode.USE_OF_VOID_RESULT, [
['x']
]);

View file

@ -3751,7 +3751,7 @@ class A {
void set d(y) => voidFn();
/*warning:NON_VOID_RETURN_FOR_SETTER*/int set e(y) => 4;
/*warning:NON_VOID_RETURN_FOR_SETTER*/int set f(y) =>
/*error:RETURN_OF_INVALID_TYPE*/voidFn();
/*error:RETURN_OF_INVALID_TYPE, info:DOWN_CAST_IMPLICIT*/voidFn();
set g(y) {return /*error:RETURN_OF_INVALID_TYPE*/4;}
void set h(y) {return /*error:RETURN_OF_INVALID_TYPE*/4;}
/*warning:NON_VOID_RETURN_FOR_SETTER*/int set i(y) {return 4;}
@ -4437,7 +4437,7 @@ class B extends A {
typedef int Foo();
void foo() {}
void main () {
Foo x = /*error:USE_OF_VOID_RESULT*/foo();
Foo x = /*info:USE_OF_VOID_RESULT, info:DOWN_CAST_COMPOSITE*/foo();
}
''');
}

View file

@ -2429,7 +2429,7 @@ class B {
class C extends B {
f() {}
}
var x = /*error:TOP_LEVEL_INSTANCE_METHOD*/new C()./*error:USE_OF_VOID_RESULT*/f();
var x = /*error:TOP_LEVEL_INSTANCE_METHOD*/new C()./*info:USE_OF_VOID_RESULT*/f();
''');
}
@ -3516,7 +3516,7 @@ test() {
test_inferVariableVoid() async {
var mainUnit = await checkFileElement('''
void f() {}
var x = /*error:USE_OF_VOID_RESULT*/f();
var x = /*info:USE_OF_VOID_RESULT*/f();
''');
var x = mainUnit.topLevelVariables[0];
expect(x.name, 'x');
@ -4309,12 +4309,12 @@ T run<T>(T f()) {
void printRunning() { print("running"); }
var x = run<dynamic>(printRunning);
var y = /*error:USE_OF_VOID_RESULT*/run(printRunning);
var y = /*info:USE_OF_VOID_RESULT*/run(printRunning);
main() {
void printRunning() { print("running"); }
var x = run<dynamic>(printRunning);
var y = /*error:USE_OF_VOID_RESULT*/run(printRunning);
var y = /*info:USE_OF_VOID_RESULT*/run(printRunning);
x = 123;
x = 'hi';
y = 123;

View file

@ -25,7 +25,7 @@ import 'dart:async';
import 'package:expect/expect.dart';
typedef dynamic _Action();
typedef void _Action();
typedef void _ExpectationFunction(Object actual);
final List<_Group> _groups = [new _Group()];

View file

@ -23,6 +23,6 @@ main() {
for (var setToTest in sets) {
// Test that the set accepts a list that is not of the same type:
// Set<B>.removeAll(List<A>)
Expect.isNull(setToTest.removeAll(<A>[new A()]) as dynamic);
Expect.isNull(setToTest.removeAll(<A>[new A()]));
}
}

View file

@ -28,13 +28,11 @@ void m2(void x, {void y}) => null;
A<void> m3(A<void> x, [A<void> y]) => new A<void>(null);
A<void> m4(A<void> x, {A<void> y}) => new A<void>(null);
class B<S, T> implements A<void> {
void get t => null;
}
class B<S, T> implements A<void> { void get t => null; }
class C extends A<void> with B<void, A<void>> {
C() : super(null);
C(): super(null);
static final void x1 = null;
static final A<void> x2 = new A<void>(null);
@ -49,7 +47,7 @@ class C extends A<void> with B<void, A<void>> {
covariant void x11 = null, x12;
covariant A<void> x13 = new A<void>(null), x14;
static void get g1 => null;
static A<void> get g2 => new A<void>(null);
static void set s1(void x) => null;
@ -70,25 +68,11 @@ class C extends A<void> with B<void, A<void>> {
// Ensure that all members are used, and use `void` in expressions.
void run() {
x1;
x2;
x3;
x4;
x5;
x6;
x7;
x8;
x9;
x10;
x11;
x12;
x13;
x14;
g1;
g2;
g3;
g4;
List<dynamic> ignore = [
x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, //
g1, g2, g3, g4,
];
s1 = null;
s2 = new A<void>(null);
s3 = null;
@ -112,17 +96,7 @@ class C extends A<void> with B<void, A<void>> {
// Testing syntax, just enforce compilation.
main() {
// ignore
x1;
x2;
x3;
x4;
x5;
x6;
x7;
x8;
g1;
g2;
List<dynamic> ignore = [x1, x2, x3, x4, x5, x6, x7, x8, g1, g2];
s1 = null;
s2 = new A<void>(null);

View file

@ -10,7 +10,7 @@
import "package:expect/expect.dart";
bad() {
void bad() {
throw new Exception();
}

View file

@ -126,7 +126,7 @@ interpoleCallThrow() => "inter${callMeTrue()}...${kast('tada!')}pole";
call1() => ternary(0, kast("call1"), 1);
call2() => ternary(kast("call2"), 0, 1);
call3() => ternary(0, 1, kast("call3"));
call1c() => ternary(callMe() as dynamic, kast("call1"), 1);
call1c() => ternary(callMe(), kast("call1"), 1);
call3c() => ternary(callMeTrue(), 1, kast("call3"));
call4c() => ternary(0, callMeTrue(), kast("call3"));
@ -135,7 +135,7 @@ sendSet() {
}
sendSetCallThrow() {
var x = callMe() as dynamic, y = kast("sendSet");
var x = callMe(), y = kast("sendSet");
}
isSend() => kast("isSend") is int;

View file

@ -22,9 +22,6 @@ regress_29784_test/02: SkipByDesign # Requires checked mode.
stacktrace_demangle_ctors_test: SkipByDesign # Names are not scrubbed.
type_checks_in_factory_method_test: SkipByDesign # Requires checked mode.
[ $compiler != dart2analyzer && $compiler != spec_parser && !$strong ]
void_block_return_test/00: MissingCompileTimeError # Requires strong mode
[ $compiler == dart2js && $dart2js_with_kernel && $minified && $strong ]
first_class_types_literals_test/01: Crash
first_class_types_literals_test/02: Crash
@ -194,6 +191,7 @@ vm/type_vm_test/24: MissingCompileTimeError
vm/type_vm_test/25: MissingCompileTimeError
vm/type_vm_test/26: MissingCompileTimeError
vm/type_vm_test/27: MissingCompileTimeError
void_block_return_test/00: MissingCompileTimeError # Requires strong mode
void_type_callbacks_test: Skip # Requires strong mode
void_type_function_types_test: Skip # Requires strong mode
void_type_override_test: Skip # Requires strong mode

View file

@ -58,7 +58,6 @@ interface_static_non_final_fields_negative_test: Fail # Issue 11594
interface_test/00: MissingCompileTimeError
is_not_class1_negative_test: CompileTimeError
is_not_class4_negative_test: CompileTimeError
issue15606_test/none: CompileTimeError
issue1578_negative_test: CompileTimeError
label2_negative_test: CompileTimeError
label3_negative_test: CompileTimeError
@ -157,81 +156,201 @@ void_type_override_test/00b: MissingCompileTimeError
void_type_override_test/01: MissingCompileTimeError
void_type_override_test/02: MissingCompileTimeError
void_type_override_test/03: MissingCompileTimeError
void_type_usage_test/call_argument: MissingCompileTimeError
void_type_usage_test/call_conditional: MissingCompileTimeError
void_type_usage_test/call_do_while: MissingCompileTimeError
void_type_usage_test/call_dynamic_init: MissingCompileTimeError
void_type_usage_test/call_for_in: MissingCompileTimeError
void_type_usage_test/call_is: MissingCompileTimeError
void_type_usage_test/call_literal_list_init: MissingCompileTimeError
void_type_usage_test/call_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/call_literal_map_key_init2: MissingCompileTimeError
void_type_usage_test/call_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/call_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/call_null_equals2: MissingCompileTimeError
void_type_usage_test/call_return: MissingCompileTimeError
void_type_usage_test/call_throw: MissingCompileTimeError
void_type_usage_test/call_void_init: MissingCompileTimeError
void_type_usage_test/call_while: MissingCompileTimeError
void_type_usage_test/conditional2_argument: MissingCompileTimeError
void_type_usage_test/conditional2_conditional: MissingCompileTimeError
void_type_usage_test/conditional2_dynamic_init: MissingCompileTimeError
void_type_usage_test/conditional2_for: MissingCompileTimeError
void_type_usage_test/conditional2_literal_list_init: MissingCompileTimeError
void_type_usage_test/conditional2_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/conditional2_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/conditional2_null_equals2: MissingCompileTimeError
void_type_usage_test/conditional2_parens: MissingCompileTimeError
void_type_usage_test/conditional2_return: MissingCompileTimeError
void_type_usage_test/conditional2_return_to_void: MissingCompileTimeError
void_type_usage_test/conditional2_stmt: MissingCompileTimeError
void_type_usage_test/conditional2_throw: MissingCompileTimeError
void_type_usage_test/conditional2_void_init: MissingCompileTimeError
void_type_usage_test/conditional2do_while: MissingCompileTimeError
void_type_usage_test/conditional2for_in: MissingCompileTimeError
void_type_usage_test/conditional2while: MissingCompileTimeError
void_type_usage_test/conditional3_argument: MissingCompileTimeError
void_type_usage_test/conditional3_conditional: MissingCompileTimeError
void_type_usage_test/conditional3_dynamic_init: MissingCompileTimeError
void_type_usage_test/conditional3_for: MissingCompileTimeError
void_type_usage_test/conditional3_literal_list_init: MissingCompileTimeError
void_type_usage_test/conditional3_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/conditional3_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/conditional3_null_equals2: MissingCompileTimeError
void_type_usage_test/conditional3_parens: MissingCompileTimeError
void_type_usage_test/conditional3_return: MissingCompileTimeError
void_type_usage_test/conditional3_return_to_void: MissingCompileTimeError
void_type_usage_test/conditional3_stmt: MissingCompileTimeError
void_type_usage_test/conditional3_throw: MissingCompileTimeError
void_type_usage_test/conditional3_void_init: MissingCompileTimeError
void_type_usage_test/conditional_argument: MissingCompileTimeError
void_type_usage_test/conditional_conditional: MissingCompileTimeError
void_type_usage_test/conditional_do_while: MissingCompileTimeError
void_type_usage_test/conditional_dynamic_init: MissingCompileTimeError
void_type_usage_test/conditional_for: MissingCompileTimeError
void_type_usage_test/conditional_for_in: MissingCompileTimeError
void_type_usage_test/conditional_literal_list_init: MissingCompileTimeError
void_type_usage_test/conditional_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/conditional_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/conditional_null_equals2: MissingCompileTimeError
void_type_usage_test/conditional_parens: MissingCompileTimeError
void_type_usage_test/conditional_return: MissingCompileTimeError
void_type_usage_test/conditional_return_to_void: MissingCompileTimeError
void_type_usage_test/conditional_stmt: MissingCompileTimeError
void_type_usage_test/conditional_throw: MissingCompileTimeError
void_type_usage_test/conditional_void_init: MissingCompileTimeError
void_type_usage_test/conditional_while: MissingCompileTimeError
void_type_usage_test/final_local_argument: MissingCompileTimeError
void_type_usage_test/final_local_conditional: MissingCompileTimeError
void_type_usage_test/final_local_do_while: MissingCompileTimeError
void_type_usage_test/final_local_dynamic_init: MissingCompileTimeError
void_type_usage_test/final_local_for_in: MissingCompileTimeError
void_type_usage_test/final_local_for_in2: MissingCompileTimeError
void_type_usage_test/final_local_is: MissingCompileTimeError
void_type_usage_test/final_local_literal_list_init: MissingCompileTimeError
void_type_usage_test/final_local_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/final_local_literal_map_key_init2: MissingCompileTimeError
void_type_usage_test/final_local_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/final_local_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/final_local_null_equals2: MissingCompileTimeError
void_type_usage_test/final_local_return: MissingCompileTimeError
void_type_usage_test/final_local_throw: MissingCompileTimeError
void_type_usage_test/final_local_void_init: MissingCompileTimeError
void_type_usage_test/final_local_while: MissingCompileTimeError
void_type_usage_test/global_argument: MissingCompileTimeError
void_type_usage_test/global_conditional: MissingCompileTimeError
void_type_usage_test/global_do_while: MissingCompileTimeError
void_type_usage_test/global_dynamic_init: MissingCompileTimeError
void_type_usage_test/global_for_in: MissingCompileTimeError
void_type_usage_test/global_is: MissingCompileTimeError
void_type_usage_test/global_literal_list_init: MissingCompileTimeError
void_type_usage_test/global_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/global_literal_map_key_init2: MissingCompileTimeError
void_type_usage_test/global_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/global_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/global_null_equals2: MissingCompileTimeError
void_type_usage_test/global_return: MissingCompileTimeError
void_type_usage_test/global_throw: MissingCompileTimeError
void_type_usage_test/global_void_init: MissingCompileTimeError
void_type_usage_test/global_while: MissingCompileTimeError
void_type_usage_test/instance2_argument: MissingCompileTimeError
void_type_usage_test/instance2_conditional: MissingCompileTimeError
void_type_usage_test/instance2_do_while: MissingCompileTimeError
void_type_usage_test/instance2_dynamic_init: MissingCompileTimeError
void_type_usage_test/instance2_for_in: MissingCompileTimeError
void_type_usage_test/instance2_for_in2: MissingCompileTimeError
void_type_usage_test/instance2_is: MissingCompileTimeError
void_type_usage_test/instance2_literal_list_init: MissingCompileTimeError
void_type_usage_test/instance2_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/instance2_literal_map_key_init2: MissingCompileTimeError
void_type_usage_test/instance2_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/instance2_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/instance2_null_equals2: MissingCompileTimeError
void_type_usage_test/instance2_return: MissingCompileTimeError
void_type_usage_test/instance2_throw: MissingCompileTimeError
void_type_usage_test/instance2_void_init: MissingCompileTimeError
void_type_usage_test/instance2_while: MissingCompileTimeError
void_type_usage_test/instance3_argument: MissingCompileTimeError
void_type_usage_test/instance3_conditional: MissingCompileTimeError
void_type_usage_test/instance3_do_while: MissingCompileTimeError
void_type_usage_test/instance3_dynamic_init: MissingCompileTimeError
void_type_usage_test/instance3_for_in: MissingCompileTimeError
void_type_usage_test/instance3_for_in2: MissingCompileTimeError
void_type_usage_test/instance3_is: MissingCompileTimeError
void_type_usage_test/instance3_literal_list_init: MissingCompileTimeError
void_type_usage_test/instance3_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/instance3_literal_map_key_init2: MissingCompileTimeError
void_type_usage_test/instance3_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/instance3_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/instance3_null_equals2: MissingCompileTimeError
void_type_usage_test/instance3_return: MissingCompileTimeError
void_type_usage_test/instance3_throw: MissingCompileTimeError
void_type_usage_test/instance3_void_init: MissingCompileTimeError
void_type_usage_test/instance3_while: MissingCompileTimeError
void_type_usage_test/instance_argument: MissingCompileTimeError
void_type_usage_test/instance_conditional: MissingCompileTimeError
void_type_usage_test/instance_do_while: MissingCompileTimeError
void_type_usage_test/instance_dynamic_init: MissingCompileTimeError
void_type_usage_test/instance_for_in: MissingCompileTimeError
void_type_usage_test/instance_is: MissingCompileTimeError
void_type_usage_test/instance_literal_list_init: MissingCompileTimeError
void_type_usage_test/instance_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/instance_literal_map_key_init2: MissingCompileTimeError
void_type_usage_test/instance_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/instance_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/instance_null_equals2: MissingCompileTimeError
void_type_usage_test/instance_return: MissingCompileTimeError
void_type_usage_test/instance_throw: MissingCompileTimeError
void_type_usage_test/instance_void_init: MissingCompileTimeError
void_type_usage_test/instance_while: MissingCompileTimeError
void_type_usage_test/local_argument: MissingCompileTimeError
void_type_usage_test/local_conditional: MissingCompileTimeError
void_type_usage_test/local_do_while: MissingCompileTimeError
void_type_usage_test/local_dynamic_init: MissingCompileTimeError
void_type_usage_test/local_for_in: MissingCompileTimeError
void_type_usage_test/local_is: MissingCompileTimeError
void_type_usage_test/local_literal_list_init: MissingCompileTimeError
void_type_usage_test/local_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/local_literal_map_key_init2: MissingCompileTimeError
void_type_usage_test/local_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/local_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/local_null_equals2: MissingCompileTimeError
void_type_usage_test/local_return: MissingCompileTimeError
void_type_usage_test/local_throw: MissingCompileTimeError
void_type_usage_test/local_void_init: MissingCompileTimeError
void_type_usage_test/local_while: MissingCompileTimeError
void_type_usage_test/param_argument: MissingCompileTimeError
void_type_usage_test/param_conditional: MissingCompileTimeError
void_type_usage_test/param_do_while: MissingCompileTimeError
void_type_usage_test/param_dynamic_init: MissingCompileTimeError
void_type_usage_test/param_for_in: MissingCompileTimeError
void_type_usage_test/param_is: MissingCompileTimeError
void_type_usage_test/param_literal_list_init: MissingCompileTimeError
void_type_usage_test/param_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/param_literal_map_key_init2: MissingCompileTimeError
void_type_usage_test/param_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/param_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/param_null_equals2: MissingCompileTimeError
void_type_usage_test/param_return: MissingCompileTimeError
void_type_usage_test/param_throw: MissingCompileTimeError
void_type_usage_test/param_void_init: MissingCompileTimeError
void_type_usage_test/param_while: MissingCompileTimeError
void_type_usage_test/paren_argument: MissingCompileTimeError
void_type_usage_test/paren_conditional: MissingCompileTimeError
void_type_usage_test/paren_do_while: MissingCompileTimeError
void_type_usage_test/paren_dynamic_init: MissingCompileTimeError
void_type_usage_test/paren_for_in: MissingCompileTimeError
void_type_usage_test/paren_is: MissingCompileTimeError
void_type_usage_test/paren_literal_list_init: MissingCompileTimeError
void_type_usage_test/paren_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/paren_literal_map_key_init2: MissingCompileTimeError
void_type_usage_test/paren_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/paren_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/paren_null_equals2: MissingCompileTimeError
void_type_usage_test/paren_return: MissingCompileTimeError
void_type_usage_test/paren_throw: MissingCompileTimeError
void_type_usage_test/paren_void_init: MissingCompileTimeError
void_type_usage_test/paren_while: MissingCompileTimeError
[ $compiler == dart2analyzer && $runtime == none ]
error_stacktrace_test/00: MissingCompileTimeError
@ -1214,6 +1333,7 @@ type_promotion_functions_test/08: Pass
type_promotion_functions_test/10: Pass
vm/lazy_deopt_with_exception_test: CompileTimeError
void_type_callbacks_test/00: MissingCompileTimeError # Issue 30177
void_type_callbacks_test/01: MissingCompileTimeError # Issue 30177
void_type_function_types_test/none: CompileTimeError # Issue 30177
[ $compiler == dart2analyzer && !$strong ]

View file

@ -54,7 +54,6 @@ instantiate_tearoff_after_contravariance_check_test: RuntimeError
instantiate_tearoff_of_call_test: RuntimeError
interface_test/00: MissingCompileTimeError
internal_library_test/01: MissingCompileTimeError # Issue 29920
issue15606_test/none: CompileTimeError
issue31596_implement_covariant_test: CompileTimeError
issue31596_override_test/01: CompileTimeError
issue31596_override_test/02: CompileTimeError
@ -136,87 +135,208 @@ type_promotion_functions_test/14: CompileTimeError # Issue 30895
type_promotion_functions_test/none: CompileTimeError # Issue 30895
type_variable_scope_test/none: CompileTimeError
void_type_callbacks_test/00: MissingCompileTimeError # Issue 30514
void_type_callbacks_test/01: MissingCompileTimeError # Issue 30514
void_type_function_types_test/none: CompileTimeError # Issue 30514
void_type_override_test/00: MissingCompileTimeError
void_type_override_test/00b: MissingCompileTimeError
void_type_override_test/01: MissingCompileTimeError
void_type_override_test/02: MissingCompileTimeError
void_type_override_test/03: MissingCompileTimeError
void_type_usage_test/call_argument: MissingCompileTimeError
void_type_usage_test/call_conditional: MissingCompileTimeError
void_type_usage_test/call_do_while: MissingCompileTimeError
void_type_usage_test/call_dynamic_init: MissingCompileTimeError
void_type_usage_test/call_for_in: MissingCompileTimeError
void_type_usage_test/call_is: MissingCompileTimeError
void_type_usage_test/call_literal_list_init: MissingCompileTimeError
void_type_usage_test/call_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/call_literal_map_key_init2: MissingCompileTimeError
void_type_usage_test/call_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/call_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/call_null_equals2: MissingCompileTimeError
void_type_usage_test/call_return: MissingCompileTimeError
void_type_usage_test/call_throw: MissingCompileTimeError
void_type_usage_test/call_void_init: MissingCompileTimeError
void_type_usage_test/call_while: MissingCompileTimeError
void_type_usage_test/conditional2_argument: MissingCompileTimeError
void_type_usage_test/conditional2_conditional: MissingCompileTimeError
void_type_usage_test/conditional2_dynamic_init: MissingCompileTimeError
void_type_usage_test/conditional2_for: MissingCompileTimeError
void_type_usage_test/conditional2_literal_list_init: MissingCompileTimeError
void_type_usage_test/conditional2_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/conditional2_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/conditional2_null_equals2: MissingCompileTimeError
void_type_usage_test/conditional2_parens: MissingCompileTimeError
void_type_usage_test/conditional2_return: MissingCompileTimeError
void_type_usage_test/conditional2_return_to_void: MissingCompileTimeError
void_type_usage_test/conditional2_stmt: MissingCompileTimeError
void_type_usage_test/conditional2_throw: MissingCompileTimeError
void_type_usage_test/conditional2_void_init: MissingCompileTimeError
void_type_usage_test/conditional2do_while: MissingCompileTimeError
void_type_usage_test/conditional2for_in: MissingCompileTimeError
void_type_usage_test/conditional2while: MissingCompileTimeError
void_type_usage_test/conditional3_argument: MissingCompileTimeError
void_type_usage_test/conditional3_conditional: MissingCompileTimeError
void_type_usage_test/conditional3_dynamic_init: MissingCompileTimeError
void_type_usage_test/conditional3_for: MissingCompileTimeError
void_type_usage_test/conditional3_literal_list_init: MissingCompileTimeError
void_type_usage_test/conditional3_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/conditional3_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/conditional3_null_equals2: MissingCompileTimeError
void_type_usage_test/conditional3_parens: MissingCompileTimeError
void_type_usage_test/conditional3_return: MissingCompileTimeError
void_type_usage_test/conditional3_return_to_void: MissingCompileTimeError
void_type_usage_test/conditional3_stmt: MissingCompileTimeError
void_type_usage_test/conditional3_throw: MissingCompileTimeError
void_type_usage_test/conditional3_void_init: MissingCompileTimeError
void_type_usage_test/conditional_argument: MissingCompileTimeError
void_type_usage_test/conditional_conditional: MissingCompileTimeError
void_type_usage_test/conditional_do_while: MissingCompileTimeError
void_type_usage_test/conditional_dynamic_init: MissingCompileTimeError
void_type_usage_test/conditional_for: MissingCompileTimeError
void_type_usage_test/conditional_for_in: MissingCompileTimeError
void_type_usage_test/conditional_literal_list_init: MissingCompileTimeError
void_type_usage_test/conditional_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/conditional_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/conditional_null_equals2: MissingCompileTimeError
void_type_usage_test/conditional_parens: MissingCompileTimeError
void_type_usage_test/conditional_return: MissingCompileTimeError
void_type_usage_test/conditional_return_to_void: MissingCompileTimeError
void_type_usage_test/conditional_stmt: MissingCompileTimeError
void_type_usage_test/conditional_throw: MissingCompileTimeError
void_type_usage_test/conditional_void_init: MissingCompileTimeError
void_type_usage_test/conditional_while: MissingCompileTimeError
void_type_usage_test/final_local_argument: MissingCompileTimeError
void_type_usage_test/final_local_conditional: MissingCompileTimeError
void_type_usage_test/final_local_do_while: MissingCompileTimeError
void_type_usage_test/final_local_dynamic_init: MissingCompileTimeError
void_type_usage_test/final_local_for_in: MissingCompileTimeError
void_type_usage_test/final_local_for_in2: MissingCompileTimeError
void_type_usage_test/final_local_is: MissingCompileTimeError
void_type_usage_test/final_local_literal_list_init: MissingCompileTimeError
void_type_usage_test/final_local_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/final_local_literal_map_key_init2: MissingCompileTimeError
void_type_usage_test/final_local_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/final_local_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/final_local_null_equals2: MissingCompileTimeError
void_type_usage_test/final_local_return: MissingCompileTimeError
void_type_usage_test/final_local_throw: MissingCompileTimeError
void_type_usage_test/final_local_void_init: MissingCompileTimeError
void_type_usage_test/final_local_while: MissingCompileTimeError
void_type_usage_test/global_argument: MissingCompileTimeError
void_type_usage_test/global_conditional: MissingCompileTimeError
void_type_usage_test/global_do_while: MissingCompileTimeError
void_type_usage_test/global_dynamic_init: MissingCompileTimeError
void_type_usage_test/global_for_in: MissingCompileTimeError
void_type_usage_test/global_is: MissingCompileTimeError
void_type_usage_test/global_literal_list_init: MissingCompileTimeError
void_type_usage_test/global_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/global_literal_map_key_init2: MissingCompileTimeError
void_type_usage_test/global_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/global_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/global_null_equals2: MissingCompileTimeError
void_type_usage_test/global_return: MissingCompileTimeError
void_type_usage_test/global_throw: MissingCompileTimeError
void_type_usage_test/global_void_init: MissingCompileTimeError
void_type_usage_test/global_while: MissingCompileTimeError
void_type_usage_test/instance2_argument: MissingCompileTimeError
void_type_usage_test/instance2_conditional: MissingCompileTimeError
void_type_usage_test/instance2_do_while: MissingCompileTimeError
void_type_usage_test/instance2_dynamic_init: MissingCompileTimeError
void_type_usage_test/instance2_for_in: MissingCompileTimeError
void_type_usage_test/instance2_for_in2: MissingCompileTimeError
void_type_usage_test/instance2_is: MissingCompileTimeError
void_type_usage_test/instance2_literal_list_init: MissingCompileTimeError
void_type_usage_test/instance2_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/instance2_literal_map_key_init2: MissingCompileTimeError
void_type_usage_test/instance2_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/instance2_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/instance2_null_equals2: MissingCompileTimeError
void_type_usage_test/instance2_return: MissingCompileTimeError
void_type_usage_test/instance2_throw: MissingCompileTimeError
void_type_usage_test/instance2_void_init: MissingCompileTimeError
void_type_usage_test/instance2_while: MissingCompileTimeError
void_type_usage_test/instance3_argument: MissingCompileTimeError
void_type_usage_test/instance3_conditional: MissingCompileTimeError
void_type_usage_test/instance3_do_while: MissingCompileTimeError
void_type_usage_test/instance3_dynamic_init: MissingCompileTimeError
void_type_usage_test/instance3_for_in: MissingCompileTimeError
void_type_usage_test/instance3_for_in2: MissingCompileTimeError
void_type_usage_test/instance3_is: MissingCompileTimeError
void_type_usage_test/instance3_literal_list_init: MissingCompileTimeError
void_type_usage_test/instance3_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/instance3_literal_map_key_init2: MissingCompileTimeError
void_type_usage_test/instance3_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/instance3_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/instance3_null_equals2: MissingCompileTimeError
void_type_usage_test/instance3_return: MissingCompileTimeError
void_type_usage_test/instance3_throw: MissingCompileTimeError
void_type_usage_test/instance3_void_init: MissingCompileTimeError
void_type_usage_test/instance3_while: MissingCompileTimeError
void_type_usage_test/instance_argument: MissingCompileTimeError
void_type_usage_test/instance_conditional: MissingCompileTimeError
void_type_usage_test/instance_do_while: MissingCompileTimeError
void_type_usage_test/instance_dynamic_init: MissingCompileTimeError
void_type_usage_test/instance_for_in: MissingCompileTimeError
void_type_usage_test/instance_is: MissingCompileTimeError
void_type_usage_test/instance_literal_list_init: MissingCompileTimeError
void_type_usage_test/instance_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/instance_literal_map_key_init2: MissingCompileTimeError
void_type_usage_test/instance_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/instance_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/instance_null_equals2: MissingCompileTimeError
void_type_usage_test/instance_return: MissingCompileTimeError
void_type_usage_test/instance_throw: MissingCompileTimeError
void_type_usage_test/instance_void_init: MissingCompileTimeError
void_type_usage_test/instance_while: MissingCompileTimeError
void_type_usage_test/local_argument: MissingCompileTimeError
void_type_usage_test/local_conditional: MissingCompileTimeError
void_type_usage_test/local_do_while: MissingCompileTimeError
void_type_usage_test/local_dynamic_init: MissingCompileTimeError
void_type_usage_test/local_for_in: MissingCompileTimeError
void_type_usage_test/local_is: MissingCompileTimeError
void_type_usage_test/local_literal_list_init: MissingCompileTimeError
void_type_usage_test/local_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/local_literal_map_key_init2: MissingCompileTimeError
void_type_usage_test/local_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/local_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/local_null_equals2: MissingCompileTimeError
void_type_usage_test/local_return: MissingCompileTimeError
void_type_usage_test/local_throw: MissingCompileTimeError
void_type_usage_test/local_void_init: MissingCompileTimeError
void_type_usage_test/local_while: MissingCompileTimeError
void_type_usage_test/param_argument: MissingCompileTimeError
void_type_usage_test/param_conditional: MissingCompileTimeError
void_type_usage_test/param_do_while: MissingCompileTimeError
void_type_usage_test/param_dynamic_init: MissingCompileTimeError
void_type_usage_test/param_for_in: MissingCompileTimeError
void_type_usage_test/param_is: MissingCompileTimeError
void_type_usage_test/param_literal_list_init: MissingCompileTimeError
void_type_usage_test/param_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/param_literal_map_key_init2: MissingCompileTimeError
void_type_usage_test/param_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/param_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/param_null_equals2: MissingCompileTimeError
void_type_usage_test/param_return: MissingCompileTimeError
void_type_usage_test/param_throw: MissingCompileTimeError
void_type_usage_test/param_void_init: MissingCompileTimeError
void_type_usage_test/param_while: MissingCompileTimeError
void_type_usage_test/paren_argument: MissingCompileTimeError
void_type_usage_test/paren_conditional: MissingCompileTimeError
void_type_usage_test/paren_do_while: MissingCompileTimeError
void_type_usage_test/paren_dynamic_init: MissingCompileTimeError
void_type_usage_test/paren_for_in: MissingCompileTimeError
void_type_usage_test/paren_is: MissingCompileTimeError
void_type_usage_test/paren_literal_list_init: MissingCompileTimeError
void_type_usage_test/paren_literal_map_key_init: MissingCompileTimeError
void_type_usage_test/paren_literal_map_key_init2: MissingCompileTimeError
void_type_usage_test/paren_literal_map_value_init: MissingCompileTimeError
void_type_usage_test/paren_literal_map_value_init2: MissingCompileTimeError
void_type_usage_test/paren_null_equals2: MissingCompileTimeError
void_type_usage_test/paren_return: MissingCompileTimeError
void_type_usage_test/paren_throw: MissingCompileTimeError
void_type_usage_test/paren_void_init: MissingCompileTimeError
void_type_usage_test/paren_while: MissingCompileTimeError
[ $compiler == dartdevk ]
abstract_factory_constructor_test/00: MissingCompileTimeError

View file

@ -30,7 +30,7 @@ main() {
var t1 = f(trace);
var t2 = b(trace);
var t3 = identical(t2, "foo");
trace.add(t1);
var t4 = trace.add(t1);
trace.add(t3);
trace.add(t3);
Expect.listEquals(["foo", "bar", "foo", false, false], trace);

View file

@ -7,7 +7,7 @@ import "package:expect/expect.dart";
var _str = new StringBuffer();
T run<T>(T f()) {
/*=T*/ run/*<T>*/(/*=T*/ f()) {
_str.write("+");
var t = f();
_str.write("-");
@ -20,12 +20,12 @@ void writeV() {
main() {
{
var x = run<dynamic>(writeV);
var x = run/*<dynamic>*/(writeV);
Expect.equals('+V-', _str.toString());
Expect.equals(null, x);
_str.clear();
var y = run(writeV) as dynamic;
var y = run(writeV);
Expect.equals('+V-', _str.toString());
Expect.equals(null, y);
_str.clear();
@ -34,7 +34,7 @@ main() {
// implicit cast
{
dynamic d = writeV;
var x = run<dynamic>(d);
var x = run/*<dynamic>*/(d);
Expect.equals('+V-', _str.toString());
Expect.equals(null, x);
_str.clear();
@ -48,7 +48,7 @@ main() {
// dynamic dispatch
{
dynamic d = run;
var x = d<dynamic>(writeV);
var x = d/*<dynamic>*/(writeV);
Expect.equals('+V-', _str.toString());
Expect.equals(null, x);
_str.clear();

View file

@ -21,12 +21,12 @@ void f_f() {
return f();
}
void test(int n, void func()) {
void test(int n, void func(), bool must_get_error) {
// Test as closure call.
{
bool got_type_error = false;
try {
func();
var x = func();
} on TypeError catch (error) {
got_type_error = true;
}
@ -39,16 +39,16 @@ void test(int n, void func()) {
var x;
switch (n) {
case 0:
x = f() as dynamic;
x = f();
break;
case 1:
x = f_null() as dynamic;
x = f_null();
break;
case 2:
x = f_dyn_null() as dynamic;
x = f_dyn_null();
break;
case 3:
x = f_f() as dynamic;
x = f_f();
break;
}
} on TypeError catch (error) {
@ -59,8 +59,8 @@ void test(int n, void func()) {
}
main() {
test(0, f);
test(1, f_null);
test(2, f_dyn_null);
test(3, f_f);
test(0, f, false);
test(1, f_null, false);
test(2, f_dyn_null, false);
test(3, f_f, false);
}

View file

@ -873,7 +873,7 @@ class FileTest {
;
write([start, end]) {
openedFile.writeFromSync(buffer, start, end);
var returnValue = openedFile.writeFromSync(buffer, start, end);
result.addAll(buffer.sublist(start, end));
}