mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
Report noSuchMethod forwarders as synthetic in the mirror api
Fixes http://dartbug.com/34982 Bug: http://dartbug.com/34982 Change-Id: I0302586c5f0e58dd66e238bd32088ebe1c150c0e Reviewed-on: https://dart-review.googlesource.com/c/93124 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Liam Appelbe <liama@google.com>
This commit is contained in:
parent
5d6bab4ed2
commit
223eaa6fbb
|
@ -274,6 +274,8 @@ static RawInstance* CreateMethodMirror(const Function& func,
|
|||
((is_ctor && func.is_redirecting()) << Mirrors::kRedirectingCtor);
|
||||
kind_flags |= ((is_ctor && func.IsFactory()) << Mirrors::kFactoryCtor);
|
||||
kind_flags |= (func.is_external() << Mirrors::kExternal);
|
||||
bool is_synthetic = func.is_no_such_method_forwarder();
|
||||
kind_flags |= (is_synthetic << Mirrors::kSynthetic);
|
||||
args.SetAt(5, Smi::Handle(Smi::New(kind_flags)));
|
||||
|
||||
return CreateMirror(Symbols::_LocalMethodMirror(), args);
|
||||
|
|
|
@ -20,7 +20,8 @@ class Mirrors : public AllStatic {
|
|||
V(kGenerativeCtor) \
|
||||
V(kRedirectingCtor) \
|
||||
V(kFactoryCtor) \
|
||||
V(kExternal)
|
||||
V(kExternal) \
|
||||
V(kSynthetic)
|
||||
|
||||
// These offsets much be kept in sync with those in mirrors_impl.dart.
|
||||
enum KindShifts {
|
||||
|
|
|
@ -1181,6 +1181,7 @@ class _LocalMethodMirror extends _LocalDeclarationMirror
|
|||
static const kRedirectingCtor = 6;
|
||||
static const kFactoryCtor = 7;
|
||||
static const kExternal = 8;
|
||||
static const kSynthetic = 9;
|
||||
|
||||
// These offsets much be kept in sync with those in mirrors.h.
|
||||
bool get isAbstract => 0 != (_kindFlags & (1 << kAbstract));
|
||||
|
@ -1194,6 +1195,7 @@ class _LocalMethodMirror extends _LocalDeclarationMirror
|
|||
0 != (_kindFlags & (1 << kRedirectingCtor));
|
||||
bool get isFactoryConstructor => 0 != (_kindFlags & (1 << kFactoryCtor));
|
||||
bool get isExternal => 0 != (_kindFlags & (1 << kExternal));
|
||||
bool get isSynthetic => 0 != (_kindFlags & (1 << kSynthetic));
|
||||
|
||||
static const _operators = const [
|
||||
"%", "&", "*", "+", "-", "/", "<", "<<", //
|
||||
|
@ -1216,7 +1218,6 @@ class _LocalMethodMirror extends _LocalDeclarationMirror
|
|||
_n(simpleName).startsWith('_') || _n(constructorName).startsWith('_');
|
||||
|
||||
bool get isTopLevel => owner is LibraryMirror;
|
||||
bool get isSynthetic => false;
|
||||
|
||||
TypeMirror _returnType;
|
||||
TypeMirror get returnType {
|
||||
|
|
26
tests/lib_2/mirrors/regress_34982_test.dart
Normal file
26
tests/lib_2/mirrors/regress_34982_test.dart
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Copyright (c) 2019, 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.
|
||||
|
||||
// Regression test for http://dartbug.com/34982
|
||||
import 'dart:mirrors';
|
||||
import 'package:expect/expect.dart';
|
||||
|
||||
abstract class A {
|
||||
int c();
|
||||
}
|
||||
|
||||
class B implements A {
|
||||
dynamic noSuchMethod(Invocation invocation) {}
|
||||
}
|
||||
|
||||
void main() {
|
||||
MethodMirror method1 = reflectClass(B).declarations[#c];
|
||||
Expect.isTrue(method1.isSynthetic);
|
||||
|
||||
MethodMirror method2 = reflectClass(B).declarations[#noSuchMethod];
|
||||
Expect.isFalse(method2.isSynthetic);
|
||||
|
||||
MethodMirror method3 = reflectClass(A).declarations[#c];
|
||||
Expect.isFalse(method3.isSynthetic);
|
||||
}
|
Loading…
Reference in a new issue