Chromium Code Reviews| Index: runtime/vm/parser.cc |
| =================================================================== |
| --- runtime/vm/parser.cc (revision 19079) |
| +++ runtime/vm/parser.cc (working copy) |
| @@ -3415,6 +3415,13 @@ |
| library_.AddClass(mixin_application); |
| set_current_class(mixin_application); |
| ParseTypeParameters(mixin_application); |
| + |
| + // TODO(hausner): Handle mixin application aliases with generics. |
| + if (mixin_application.NumTypeParameters() > 0) { |
| + ErrorMsg(classname_pos, |
| + "type parameters on mixin applications not yet supported"); |
| + } |
| + |
| ExpectToken(Token::kASSIGN); |
| if (CurrentToken() == Token::kABSTRACT) { |
| @@ -3439,7 +3446,13 @@ |
| } |
| Type& mixin_application_type = Type::Handle(ParseMixins(mixin_super_type)); |
|
regis
2013/02/26 22:49:54
const? (and break line)
hausner
2013/02/26 23:39:26
Done.
|
| - // The result of ParseMixins() is a chain of super classes that is the |
| + // TODO(hausner): Implement generic mixin support. |
| + if (mixin_application_type.arguments() != AbstractTypeArguments::null()) { |
| + ErrorMsg(mixin_application_type.token_pos(), |
| + "mixin class with type arguments not yet supported"); |
| + } |
| + |
| + // The result of ParseMixins() is a chain of super types that is the |
| // result of the mixin composition 'S with M1, M2, ...'. The mixin |
| // application classes are anonymous (i.e. not registered in the current |
| // library). We steal the super type and mixin type from the bottom of |
| @@ -3848,7 +3861,6 @@ |
| Type& mixin_application_type = Type::Handle(); |
| Type& mixin_super_type = Type::Handle(super_type.raw()); |
| Array& mixin_application_interfaces = Array::Handle(); |
| - const TypeArguments& no_type_arguments = TypeArguments::Handle(); |
| do { |
| ConsumeToken(); |
| const intptr_t mixin_pos = TokenPos(); |
| @@ -3858,14 +3870,6 @@ |
| "mixin type '%s' may not be a type parameter", |
| String::Handle(mixin_type.UserVisibleName()).ToCString()); |
| } |
| - // TODO(hausner): Remove this check once we handle mixins with type |
| - // arguments. |
| - mixin_type_arguments = mixin_type.arguments(); |
| - if (!mixin_type_arguments.IsNull()) { |
| - ErrorMsg(mixin_pos, |
| - "mixin type '%s' may not have type arguments", |
| - String::Handle(mixin_type.UserVisibleName()).ToCString()); |
| - } |
| // The name of the mixin application class is a combination of |
| // the superclass and mixin class. |
| @@ -3887,10 +3891,17 @@ |
| mixin_application_interfaces.SetAt(0, mixin_type); |
| mixin_application.set_interfaces(mixin_application_interfaces); |
| - // TODO(hausner): Need to support type arguments. |
| + // For the type arguments of the mixin application type, we need |
| + // a copy of the type arguments to the mixin type. The simplest way |
| + // to get the copy is to rewind the parser, parse the mixin type |
| + // again and steal its type arguments. |
| + SetPosition(mixin_pos); |
| + mixin_type = ParseType(ClassFinalizer::kTryResolve); |
|
regis
2013/02/26 22:49:54
spiffy :-)
|
| + mixin_type_arguments = mixin_type.arguments(); |
| + |
| mixin_application_type = Type::New(mixin_application, |
| - no_type_arguments, |
| - Scanner::kDummyTokenIndex); |
| + mixin_type_arguments, |
| + mixin_pos); |
| mixin_super_type = mixin_application_type.raw(); |
| } while (CurrentToken() == Token::kCOMMA); |
| return mixin_application_type.raw(); |