| Index: pkg/compiler/lib/src/js_emitter/program_builder.dart
|
| diff --git a/pkg/compiler/lib/src/js_emitter/program_builder.dart b/pkg/compiler/lib/src/js_emitter/program_builder.dart
|
| index 9f517342b513efb7ccabbbe7257a53eb0316ae5e..6f89f66b2e82423d057dff0fe247598a05d22861 100644
|
| --- a/pkg/compiler/lib/src/js_emitter/program_builder.dart
|
| +++ b/pkg/compiler/lib/src/js_emitter/program_builder.dart
|
| @@ -389,6 +389,13 @@ class ProgramBuilder {
|
| return !method.functionSignature.optionalParameters.isEmpty;
|
| }
|
|
|
| + bool _methodCanBeReflected(FunctionElement method) {
|
| + return backend.isAccessibleByReflection(method) ||
|
| + // During incremental compilation, we have to assume that reflection
|
| + // *might* get enabled.
|
| + _compiler.hasIncrementalSupport;
|
| + }
|
| +
|
| bool _methodCanBeApplied(FunctionElement method) {
|
| return _compiler.enabledFunctionApply &&
|
| _compiler.world.getMightBePassedToApply(method);
|
| @@ -417,6 +424,7 @@ class ProgramBuilder {
|
| bool isNotApplyTarget = !element.isFunction || element.isAccessor;
|
|
|
| final bool needsStubs = _methodNeedsStubs(element);
|
| + final bool canBeReflected = _methodCanBeReflected(element);
|
| final bool canBeApplied = _methodCanBeApplied(element);
|
| final bool hasSuperAlias = backend.isAliasedSuperMember(element);
|
|
|
| @@ -428,7 +436,8 @@ class ProgramBuilder {
|
| isClosure = true;
|
| } else {
|
| // Careful with operators.
|
| - canTearOff = universe.hasInvokedGetter(element, _compiler.world);
|
| + canTearOff = universe.hasInvokedGetter(element, _compiler.world) ||
|
| + (canBeReflected && !element.isOperator);
|
| assert(canTearOff ||
|
| !universe.methodsNeedingSuperGetter.contains(element));
|
| tearOffName = namer.getterName(element);
|
| @@ -444,7 +453,7 @@ class ProgramBuilder {
|
| return new InstanceMethod(element, name, code, needsTearOff: canTearOff,
|
| tearOffName: tearOffName, isClosure: isClosure,
|
| hasSuperAlias: hasSuperAlias, canBeApplied: canBeApplied,
|
| - needsStubs: needsStubs);
|
| + canBeReflected: canBeReflected, needsStubs: needsStubs);
|
| }
|
|
|
| /// Builds a stub method.
|
| @@ -552,12 +561,13 @@ class ProgramBuilder {
|
| String holder = namer.globalObjectFor(element);
|
| js.Expression code = backend.generatedCode[element];
|
|
|
| + final bool isNotApplyTarget = !element.isConstructor && !element.isAccessor;
|
| final bool needsStubs = _methodNeedsStubs(element);
|
| final bool canBeApplied = _methodCanBeApplied(element);
|
| + final bool canBeReflected = _methodCanBeReflected(element);
|
|
|
| - final bool isApplyTarget = !element.isConstructor && !element.isAccessor;
|
| - final bool needsTearOff = isApplyTarget &&
|
| - universe.staticFunctionsNeedingGetter.contains(element);
|
| + final bool needsTearOff = isNotApplyTarget && (canBeReflected ||
|
| + universe.staticFunctionsNeedingGetter.contains(element));
|
|
|
| final String tearOffName =
|
| needsTearOff ? namer.getStaticClosureName(element) : null;
|
| @@ -567,6 +577,7 @@ class ProgramBuilder {
|
| needsTearOff: needsTearOff,
|
| tearOffName: tearOffName,
|
| canBeApplied: canBeApplied,
|
| + canBeReflected: canBeReflected,
|
| needsStubs: needsStubs);
|
| }
|
|
|
|
|