Skip to content

Commit

Permalink
Treat generic method parameters as dynamic in all contexts in the VM (f…
Browse files Browse the repository at this point in the history
  • Loading branch information
mhausner committed Oct 3, 2016
1 parent 70803e7 commit 43e338d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 35 deletions.
35 changes: 8 additions & 27 deletions runtime/vm/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11914,15 +11914,9 @@ AstNode* Parser::LoadTypeParameter(PrimaryNode* primary) {
// TODO(regis): Verify that CaptureFunctionInstantiator() was already
// called if necessary.
// TODO(regis): Finalize type parameter and return as type node.
// For now, throw a type error.
Type& malformed_type = Type::ZoneHandle(Z);
malformed_type = ClassFinalizer::NewFinalizedMalformedType(
Error::Handle(Z), // No previous error.
script_,
primary_pos,
"function type parameter '%s' not yet supported",
String::Handle(Z, type_parameter.name()).ToCString());
return ThrowTypeError(primary_pos, malformed_type);
// For now, map to dynamic type.
Type& type = Type::ZoneHandle(Z, Type::DynamicType());
return new(Z) TypeNode(primary_pos, type);
}
}

Expand Down Expand Up @@ -12383,15 +12377,8 @@ void Parser::ResolveType(ClassFinalizer::FinalizationKind finalization,
NULL));
if (!type_parameter.IsNull()) {
// TODO(regis): Check for absence of type arguments.
// For now, return as malformed type.
Type& malformed_type = Type::ZoneHandle(Z);
malformed_type = ClassFinalizer::NewFinalizedMalformedType(
Error::Handle(Z), // No previous error.
script_,
type->token_pos(),
"function type parameter '%s' not yet supported",
String::Handle(Z, type_parameter.name()).ToCString());
*type = malformed_type.raw();
// For now, resolve the function type parameter to dynamic.
*type = Type::DynamicType();
return;
}
}
Expand Down Expand Up @@ -13001,15 +12988,9 @@ AstNode* Parser::ResolveIdent(TokenPosition ident_pos,
CaptureFunctionInstantiator();
}
// TODO(regis): Finalize type parameter and return as type node.
// For now, return as malformed type.
Type& malformed_type = Type::ZoneHandle(Z);
malformed_type = ClassFinalizer::NewFinalizedMalformedType(
Error::Handle(Z), // No previous error.
script_,
ident_pos,
"function type parameter '%s' not yet supported",
ident.ToCString());
return new(Z) TypeNode(ident_pos, malformed_type);
// For now, map to dynamic type.
Type& type = Type::ZoneHandle(Z, Type::DynamicType());
return new(Z) TypeNode(ident_pos, type);
}
}
}
Expand Down
17 changes: 9 additions & 8 deletions tests/language/language.status
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ string_literals_test: Skip # Issue 27433

[ ($compiler == none || $compiler == precompiler || $compiler == dart2app || $compiler == dart2appjit) ]
tearoff_constructor_basic_test: Skip # Crashes in checked mode -- hausner investigating
generic_methods_type_expression_test: RuntimeError # Issue 25869

# This is OK for now, but we may want to change the semantics to match the test.
async_star_pause_test: Fail, OK
Expand Down Expand Up @@ -51,14 +52,14 @@ async_star_regression_2238_test: CompileTimeError, RuntimeError # drt only runti
async_star_cancel_while_paused_test: RuntimeError

[ ($compiler == none || $compiler == precompiler || $compiler == dart2app || $compiler == dart2appjit) && $checked ]
# The generic functions tests fail in checked mode because the parsed type parameters
# are ignored.
generic_methods_function_type_test: RuntimeError # Issue 25869
generic_methods_test: RuntimeError # Issue 25869
generic_methods_new_test: RuntimeError # Issue 25869
generic_local_functions_test: RuntimeError # Issue 25869
generic_functions_test: RuntimeError # Issue 25869
generic_methods_generic_function_parameter_test: RuntimeError # Issue 25869
# These generic functions tests pass for the wrong reason in checked mode,
# because the parsed type parameters are mapped to dynamic type.
generic_methods_function_type_test: Pass # Issue 25869
generic_methods_test: Pass # Issue 25869
generic_methods_new_test: Pass # Issue 25869
generic_local_functions_test: Pass # Issue 25869
generic_functions_test: Pass # Issue 25869
generic_methods_generic_function_parameter_test: Pass # Issue 25869

[ ($compiler == none || $compiler == precompiler || $compiler == dart2app || $compiler == dart2appjit) && ($runtime == vm || $runtime == dart_precompiled || $runtime == dart_app) ]

Expand Down

0 comments on commit 43e338d

Please sign in to comment.