[vm/kernel] Fix crash when reading symbol literal from Dart annotation

Fixes https://github.com/dart-lang/sdk/issues/33513

Change-Id: I1595409dd3faa363922d595c1c33e6acce92af74
Reviewed-on: https://dart-review.googlesource.com/61800
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
Alexander Markov 2018-06-22 00:22:13 +00:00 committed by commit-bot@chromium.org
parent 16c0c0ff07
commit f885a0c8f3
2 changed files with 22 additions and 2 deletions

View file

@ -4109,8 +4109,7 @@ void StreamingConstantEvaluator::EvaluateStringConcatenation() {
}
void StreamingConstantEvaluator::EvaluateSymbolLiteral() {
const Class& owner =
Class::Handle(Z, builder_->parsed_function()->function().Owner());
const Class& owner = *builder_->active_class()->klass;
const Library& lib = Library::Handle(Z, owner.library());
String& symbol_value = H.DartIdentifier(lib, builder_->ReadStringReference());
const Class& symbol_class =

View file

@ -0,0 +1,21 @@
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:mirrors';
import 'package:expect/expect.dart';
class T {
const T(this.symbol);
final Symbol symbol;
}
class U {
@T(#x)
int field;
}
main() {
final metadata = reflectClass(U).declarations[#field].metadata;
Expect.identical((metadata.first.reflectee as T).symbol, const Symbol('x'));
}