Skip to content

Commit

Permalink
Skip abstract forwarding stubs
Browse files Browse the repository at this point in the history
Change-Id: If0c0967e55038d330fef48d97bc96a92b0f4b506
Reviewed-on: https://dart-review.googlesource.com/49860
Commit-Queue: Johnni Winther <[email protected]>
Reviewed-by: Sigmund Cherem <[email protected]>
  • Loading branch information
johnniwinther authored and [email protected] committed Apr 10, 2018
1 parent 7689dc9 commit 91bbc79
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 8 deletions.
15 changes: 15 additions & 0 deletions pkg/compiler/lib/src/kernel/env.dart
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,21 @@ class ClassEnvImpl implements ClassEnv {

void addProcedures(ir.Class c, {bool includeStatic}) {
for (ir.Procedure member in c.procedures) {
if (member.isForwardingStub && member.isAbstract) {
// Skip abstract forwarding stubs. These are never emitted but they
// might shadow the inclusion of a mixed in method in code like:
//
// class Super {}
// class Mixin<T> {
// void method(T t) {}
// }
// class Class extends Super with Mixin<int> {}
// main() => new Class().method();
//
// Here a stub is created for `Super&Mixin.method` hiding that
// `Mixin.method` is inherited by `Class`.
continue;
}
if (!includeStatic && member.isStatic) continue;
var name = member.name.name;
assert(!name.contains('#'));
Expand Down
17 changes: 17 additions & 0 deletions pkg/compiler/lib/src/universe/function_set.dart
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,19 @@ class FunctionSetNode {
: const EmptyFunctionSetQuery();
return result;
}

String toString() {
StringBuffer sb = new StringBuffer();
sb.write('FunctionSetNode(');
String comma = '';
cache.forEach((mask, query) {
sb.write(comma);
sb.write('$mask=$query');
comma = ',';
});
sb.write(')');
return sb.toString();
}
}

/// A set of functions that are the potential targets of all call sites sharing
Expand All @@ -265,6 +278,8 @@ class EmptyFunctionSetQuery implements FunctionSetQuery {

@override
Iterable<MemberEntity> get functions => const <MemberEntity>[];

String toString() => '<empty>';
}

class FullFunctionSetQuery implements FunctionSetQuery {
Expand Down Expand Up @@ -296,4 +311,6 @@ class FullFunctionSetQuery implements FunctionSetQuery {
}),
closedWorld);
}

String toString() => '$_mask:$functions';
}
44 changes: 44 additions & 0 deletions tests/compiler/dart2js/model/forwarding_stub_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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 'package:async_helper/async_helper.dart';
import 'package:compiler/src/commandline_options.dart';
import 'package:compiler/src/common_elements.dart';
import 'package:compiler/src/compiler.dart';
import 'package:compiler/src/elements/entities.dart';
import 'package:compiler/src/world.dart';
import 'package:expect/expect.dart';
import '../memory_compiler.dart';

const String source = '''
class Mixin<T> {
void method(T t) {}
}
class Super {}
class Class extends Super with Mixin<int> {}
main() {
new Class().method(0);
}
''';

main() {
asyncTest(() async {
CompilationResult result = await (runCompiler(
memorySourceFiles: {'main.dart': source}, options: [Flags.strongMode]));
Expect.isTrue(result.isSuccess);
Compiler compiler = result.compiler;
ClosedWorld closedWorld = compiler.backendClosedWorldForTesting;
ElementEnvironment elementEnvironment = closedWorld.elementEnvironment;
ClassEntity cls =
elementEnvironment.lookupClass(elementEnvironment.mainLibrary, 'Class');
ClassEntity mixin =
elementEnvironment.lookupClass(elementEnvironment.mainLibrary, 'Mixin');
FunctionEntity method = elementEnvironment.lookupClassMember(cls, 'method');
Expect.isNotNull(method);
Expect.equals(mixin, method.enclosingClass);
Expect.isFalse(method.isAbstract);
});
}
5 changes: 0 additions & 5 deletions tests/corelib_2/corelib_2.status
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ list_unmodifiable_test: RuntimeError
main_test: RuntimeError
nan_infinity_test/01: RuntimeError
regexp/pcre_test: RuntimeError
string_fromcharcodes_test: RuntimeError
string_split_test/checkedstore: RuntimeError # Issue 30548: does not check stores into List<String>
symbol_reserved_word_test/03: RuntimeError # Issue 19972, new Symbol('void') should be allowed.
uri_base_test: RuntimeError
Expand Down Expand Up @@ -266,7 +265,6 @@ main_test: RuntimeError
nan_infinity_test/01: RuntimeError
nsm_invocation_test: RuntimeError # Symbols don't match due to minifiaction.
regexp/pcre_test: RuntimeError
string_fromcharcodes_test: RuntimeError
string_split_test/checkedstore: RuntimeError # Issue 30548: does not check stores into List<String>
symbol_operator_test/03: RuntimeError
symbol_operator_test/none: RuntimeError
Expand All @@ -275,9 +273,6 @@ uri_base_test: RuntimeError
uri_parameters_all_test: RuntimeError
uri_test: RuntimeError

[ $compiler == dart2js && $fasta && $strong ]
shuffle_test: RuntimeError

[ $compiler == dart2js && $fasta && !$strong ]
*: SkipByDesign

Expand Down
3 changes: 0 additions & 3 deletions tests/language_2/language_2_dart2js.status
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ covariance_field_test/02: RuntimeError
covariance_field_test/03: RuntimeError
covariance_field_test/04: RuntimeError
covariance_field_test/05: RuntimeError
recursive_mixin_test: RuntimeError # no check without --checked

[ $compiler == dart2js && !$checked && !$enable_asserts ]
assertion_test: RuntimeError, OK
Expand Down Expand Up @@ -2324,8 +2323,6 @@ wrong_number_type_arguments_test/none: Pass
[ $compiler == dart2js && $fasta && $strong ]
const_constructor3_test/04: MissingCompileTimeError # OK - Subtype check uses JS number semantics.
ct_const_test: RuntimeError
mixin_type_parameter5_test: RuntimeError
mixin_type_parameter6_test: RuntimeError

[ $compiler == dart2js && $fasta && !$strong ]
*: SkipByDesign
Expand Down

0 comments on commit 91bbc79

Please sign in to comment.