mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 10:48:25 +00:00
dart2js no longer warns that function type variables are not reified
Change-Id: I69746c92912fcbbc35e1f6c37e310352f92708f6 Reviewed-on: https://dart-review.googlesource.com/28641 Commit-Queue: Erik Ernst <eernst@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
This commit is contained in:
parent
e9d03b4120
commit
f95a3cc1e6
|
@ -270,8 +270,8 @@ abstract class ConstantCompilerBase implements ConstantCompiler {
|
|||
node, element.messageKind, element.messageArguments);
|
||||
} else {
|
||||
assert(elementType is MethodTypeVariableType);
|
||||
reporter.reportErrorMessage(
|
||||
node, MessageKind.TYPE_VARIABLE_FROM_METHOD_NOT_REIFIED);
|
||||
// Used to `reportErrorMessage` here, but with Dart 2 upcoming
|
||||
// very soon we do not emit this message any more.
|
||||
}
|
||||
} else {
|
||||
// We need to throw an exception at runtime.
|
||||
|
|
|
@ -404,8 +404,6 @@ enum MessageKind {
|
|||
TYPE_ARGUMENT_COUNT_MISMATCH,
|
||||
TYPE_VARIABLE_IN_CONSTANT,
|
||||
TYPE_VARIABLE_WITHIN_STATIC_MEMBER,
|
||||
TYPE_VARIABLE_FROM_METHOD_NOT_REIFIED,
|
||||
TYPE_VARIABLE_FROM_METHOD_CONSIDERED_DYNAMIC,
|
||||
TYPEDEF_FORMAL_WITH_DEFAULT,
|
||||
UNARY_OPERATOR_BAD_ARITY,
|
||||
UNBOUND_LABEL,
|
||||
|
@ -1197,43 +1195,6 @@ class C<T> {
|
|||
}
|
||||
|
||||
void main() => new C().m(null);
|
||||
"""
|
||||
]),
|
||||
|
||||
MessageKind.TYPE_VARIABLE_FROM_METHOD_NOT_REIFIED: const MessageTemplate(
|
||||
MessageKind.TYPE_VARIABLE_FROM_METHOD_NOT_REIFIED,
|
||||
"Method type variables do not have a runtime value.",
|
||||
howToFix: "Try using the upper bound of the type variable, "
|
||||
"or refactor the code to avoid needing this runtime value.",
|
||||
examples: const [
|
||||
"""
|
||||
// Method type variables are not reified, so they cannot be returned.
|
||||
Type f<T>() => T;
|
||||
|
||||
main() => f<int>();
|
||||
""",
|
||||
"""
|
||||
// Method type variables are not reified, so they cannot be tested dynamically.
|
||||
bool f<T>(Object o) => o is T;
|
||||
|
||||
main() => f<int>(42);
|
||||
"""
|
||||
]),
|
||||
|
||||
MessageKind.TYPE_VARIABLE_FROM_METHOD_CONSIDERED_DYNAMIC:
|
||||
const MessageTemplate(
|
||||
MessageKind.TYPE_VARIABLE_FROM_METHOD_CONSIDERED_DYNAMIC,
|
||||
"Method type variables are treated as `dynamic` in `as` "
|
||||
"expressions.",
|
||||
howToFix:
|
||||
"Try using the upper bound of the type variable, or check "
|
||||
"that the blind success of the test does not introduce bugs.",
|
||||
examples: const [
|
||||
"""
|
||||
// Method type variables are not reified, so they cannot be tested dynamically.
|
||||
bool f<T>(Object o) => o as T;
|
||||
|
||||
main() => f<int>(42);
|
||||
"""
|
||||
]),
|
||||
|
||||
|
|
|
@ -1131,13 +1131,6 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
|
|||
sendStructure = new IsStructure(type);
|
||||
}
|
||||
|
||||
// GENERIC_METHODS: Method type variables are not reified so we must warn
|
||||
// about the error which will occur at runtime.
|
||||
if (type is MethodTypeVariableType) {
|
||||
reporter.reportWarningMessage(
|
||||
node, MessageKind.TYPE_VARIABLE_FROM_METHOD_NOT_REIFIED);
|
||||
}
|
||||
|
||||
registry.registerTypeUse(new TypeUse.isCheck(type));
|
||||
registry.registerSendStructure(node, sendStructure);
|
||||
return const NoneResult();
|
||||
|
@ -1152,13 +1145,6 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
|
|||
ResolutionDartType type =
|
||||
resolveTypeAnnotation(typeNode, registerCheckedModeCheck: false);
|
||||
|
||||
// GENERIC_METHODS: Method type variables are not reified, so we must inform
|
||||
// the developer about the potentially bug-inducing semantics.
|
||||
if (type is MethodTypeVariableType) {
|
||||
reporter.reportHintMessage(
|
||||
node, MessageKind.TYPE_VARIABLE_FROM_METHOD_CONSIDERED_DYNAMIC);
|
||||
}
|
||||
|
||||
registry.registerTypeUse(new TypeUse.asCast(type));
|
||||
registry.registerSendStructure(node, new AsStructure(type));
|
||||
return const NoneResult();
|
||||
|
@ -1927,12 +1913,6 @@ class ResolverVisitor extends MappingVisitor<ResolutionResult> {
|
|||
// TODO(johnniwinther): Clean up registration of elements and selectors
|
||||
// for this case.
|
||||
} else {
|
||||
// GENERIC_METHODS: Method type variables are not reified so we must warn
|
||||
// about the error which will occur at runtime.
|
||||
if (element.type is MethodTypeVariableType) {
|
||||
reporter.reportWarningMessage(
|
||||
node, MessageKind.TYPE_VARIABLE_FROM_METHOD_NOT_REIFIED);
|
||||
}
|
||||
semantics = new StaticAccess.typeParameterTypeLiteral(element);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue