Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 91bbc79

Browse files
johnniwinthercommit-bot@chromium.org
authored andcommitted
Skip abstract forwarding stubs
Change-Id: If0c0967e55038d330fef48d97bc96a92b0f4b506 Reviewed-on: https://dart-review.googlesource.com/49860 Commit-Queue: Johnni Winther <[email protected]> Reviewed-by: Sigmund Cherem <[email protected]>
1 parent 7689dc9 commit 91bbc79

File tree

5 files changed

+76
-8
lines changed

5 files changed

+76
-8
lines changed

pkg/compiler/lib/src/kernel/env.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,21 @@ class ClassEnvImpl implements ClassEnv {
317317

318318
void addProcedures(ir.Class c, {bool includeStatic}) {
319319
for (ir.Procedure member in c.procedures) {
320+
if (member.isForwardingStub && member.isAbstract) {
321+
// Skip abstract forwarding stubs. These are never emitted but they
322+
// might shadow the inclusion of a mixed in method in code like:
323+
//
324+
// class Super {}
325+
// class Mixin<T> {
326+
// void method(T t) {}
327+
// }
328+
// class Class extends Super with Mixin<int> {}
329+
// main() => new Class().method();
330+
//
331+
// Here a stub is created for `Super&Mixin.method` hiding that
332+
// `Mixin.method` is inherited by `Class`.
333+
continue;
334+
}
320335
if (!includeStatic && member.isStatic) continue;
321336
var name = member.name.name;
322337
assert(!name.contains('#'));

pkg/compiler/lib/src/universe/function_set.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,19 @@ class FunctionSetNode {
242242
: const EmptyFunctionSetQuery();
243243
return result;
244244
}
245+
246+
String toString() {
247+
StringBuffer sb = new StringBuffer();
248+
sb.write('FunctionSetNode(');
249+
String comma = '';
250+
cache.forEach((mask, query) {
251+
sb.write(comma);
252+
sb.write('$mask=$query');
253+
comma = ',';
254+
});
255+
sb.write(')');
256+
return sb.toString();
257+
}
245258
}
246259

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

266279
@override
267280
Iterable<MemberEntity> get functions => const <MemberEntity>[];
281+
282+
String toString() => '<empty>';
268283
}
269284

270285
class FullFunctionSetQuery implements FunctionSetQuery {
@@ -296,4 +311,6 @@ class FullFunctionSetQuery implements FunctionSetQuery {
296311
}),
297312
closedWorld);
298313
}
314+
315+
String toString() => '$_mask:$functions';
299316
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'package:async_helper/async_helper.dart';
6+
import 'package:compiler/src/commandline_options.dart';
7+
import 'package:compiler/src/common_elements.dart';
8+
import 'package:compiler/src/compiler.dart';
9+
import 'package:compiler/src/elements/entities.dart';
10+
import 'package:compiler/src/world.dart';
11+
import 'package:expect/expect.dart';
12+
import '../memory_compiler.dart';
13+
14+
const String source = '''
15+
16+
class Mixin<T> {
17+
void method(T t) {}
18+
}
19+
class Super {}
20+
class Class extends Super with Mixin<int> {}
21+
22+
main() {
23+
new Class().method(0);
24+
}
25+
''';
26+
27+
main() {
28+
asyncTest(() async {
29+
CompilationResult result = await (runCompiler(
30+
memorySourceFiles: {'main.dart': source}, options: [Flags.strongMode]));
31+
Expect.isTrue(result.isSuccess);
32+
Compiler compiler = result.compiler;
33+
ClosedWorld closedWorld = compiler.backendClosedWorldForTesting;
34+
ElementEnvironment elementEnvironment = closedWorld.elementEnvironment;
35+
ClassEntity cls =
36+
elementEnvironment.lookupClass(elementEnvironment.mainLibrary, 'Class');
37+
ClassEntity mixin =
38+
elementEnvironment.lookupClass(elementEnvironment.mainLibrary, 'Mixin');
39+
FunctionEntity method = elementEnvironment.lookupClassMember(cls, 'method');
40+
Expect.isNotNull(method);
41+
Expect.equals(mixin, method.enclosingClass);
42+
Expect.isFalse(method.isAbstract);
43+
});
44+
}

tests/corelib_2/corelib_2.status

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ list_unmodifiable_test: RuntimeError
234234
main_test: RuntimeError
235235
nan_infinity_test/01: RuntimeError
236236
regexp/pcre_test: RuntimeError
237-
string_fromcharcodes_test: RuntimeError
238237
string_split_test/checkedstore: RuntimeError # Issue 30548: does not check stores into List<String>
239238
symbol_reserved_word_test/03: RuntimeError # Issue 19972, new Symbol('void') should be allowed.
240239
uri_base_test: RuntimeError
@@ -266,7 +265,6 @@ main_test: RuntimeError
266265
nan_infinity_test/01: RuntimeError
267266
nsm_invocation_test: RuntimeError # Symbols don't match due to minifiaction.
268267
regexp/pcre_test: RuntimeError
269-
string_fromcharcodes_test: RuntimeError
270268
string_split_test/checkedstore: RuntimeError # Issue 30548: does not check stores into List<String>
271269
symbol_operator_test/03: RuntimeError
272270
symbol_operator_test/none: RuntimeError
@@ -275,9 +273,6 @@ uri_base_test: RuntimeError
275273
uri_parameters_all_test: RuntimeError
276274
uri_test: RuntimeError
277275

278-
[ $compiler == dart2js && $fasta && $strong ]
279-
shuffle_test: RuntimeError
280-
281276
[ $compiler == dart2js && $fasta && !$strong ]
282277
*: SkipByDesign
283278

tests/language_2/language_2_dart2js.status

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,6 @@ covariance_field_test/02: RuntimeError
546546
covariance_field_test/03: RuntimeError
547547
covariance_field_test/04: RuntimeError
548548
covariance_field_test/05: RuntimeError
549-
recursive_mixin_test: RuntimeError # no check without --checked
550549

551550
[ $compiler == dart2js && !$checked && !$enable_asserts ]
552551
assertion_test: RuntimeError, OK
@@ -2324,8 +2323,6 @@ wrong_number_type_arguments_test/none: Pass
23242323
[ $compiler == dart2js && $fasta && $strong ]
23252324
const_constructor3_test/04: MissingCompileTimeError # OK - Subtype check uses JS number semantics.
23262325
ct_const_test: RuntimeError
2327-
mixin_type_parameter5_test: RuntimeError
2328-
mixin_type_parameter6_test: RuntimeError
23292326

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

0 commit comments

Comments
 (0)