Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reland "[vm] Hide internal implementation List types and expose them …
…as List" This is a reland of 824bec5 Original change's description: > [vm] Hide internal implementation List types and expose them as List > > When taking a type of an instance with x.runtimeType we can map > internal classes _List, _ImmutableList and _GrowableList to a > user-visible List class. This is similar to what we do for > implementation classes of int, String and Type. > After that, result of x.runtimeType for built-in lists would be > compatible with List<T> type literals. > > Also, both intrinsic and native implementations of _haveSameRuntimeType > are updated to agree with new semantic of runtimeType. > > TEST=co19/LanguageFeatures/Constructor-tear-offs/type_literal_A01_t01 > TEST=runtime/tests/vm/dart/have_same_runtime_type_test > > Fixes #46893 > Issue #46231 > > Change-Id: Ie24a9f527f66a06118427b7a09e49c03dff93d8e > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210066 > Commit-Queue: Alexander Markov <alexmarkov@google.com> > Reviewed-by: Tess Strickland <sstrickl@google.com> TEST=co19/LanguageFeatures/Constructor-tear-offs/type_literal_A01_t01 TEST=runtime/tests/vm/dart/have_same_runtime_type_test TEST=lib/mirrors/regress_b196606044_test Fixes #46893 Issue #46231 Change-Id: I79b587540338808bd73a6554f00a5eed042f4c26 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210201 Commit-Queue: Alexander Markov <alexmarkov@google.com> Reviewed-by: Tess Strickland <sstrickl@google.com>
- Loading branch information
1 parent
6fdf8f1
commit cfb057d
Showing
14 changed files
with
261 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) 2021, 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. | ||
|
||
// Test for corner cases of 'a.runtimeType == b.runtimeType' pattern | ||
// which is recognized and optimized in AOT mode. | ||
|
||
import "package:expect/expect.dart"; | ||
|
||
@pragma('vm:never-inline') | ||
Object getType(Object obj) => obj.runtimeType; | ||
|
||
@pragma('vm:never-inline') | ||
void test(bool expected, Object a, Object b) { | ||
bool result1 = getType(a) == getType(b); | ||
bool result2 = a.runtimeType == b.runtimeType; | ||
Expect.equals(expected, result1); | ||
Expect.equals(expected, result2); | ||
} | ||
|
||
typedef Func = void Function(); | ||
|
||
void main() { | ||
test(true, 0x7fffffffffffffff, int.parse('42')); | ||
test(true, 'hi', String.fromCharCode(1114111)); | ||
test(false, 'hi', 1); | ||
test(true, List, Func); | ||
test(true, <int>[1], const <int>[2]); | ||
test(true, const <String>[], List<String>.filled(1, '')); | ||
test(true, <String>[]..add('hi'), List<String>.filled(2, '')); | ||
test(false, <int>[], <String>[]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) 2021, 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. | ||
|
||
// Test for corner cases of 'a.runtimeType == b.runtimeType' pattern | ||
// which is recognized and optimized in AOT mode. | ||
|
||
// @dart = 2.9 | ||
|
||
import "package:expect/expect.dart"; | ||
|
||
@pragma('vm:never-inline') | ||
Object getType(Object obj) => obj.runtimeType; | ||
|
||
@pragma('vm:never-inline') | ||
void test(bool expected, Object a, Object b) { | ||
bool result1 = getType(a) == getType(b); | ||
bool result2 = a.runtimeType == b.runtimeType; | ||
Expect.equals(expected, result1); | ||
Expect.equals(expected, result2); | ||
} | ||
|
||
typedef Func = void Function(); | ||
|
||
void main() { | ||
test(true, 0x7fffffffffffffff, int.parse('42')); | ||
test(true, 'hi', String.fromCharCode(1114111)); | ||
test(false, 'hi', 1); | ||
test(true, List, Func); | ||
test(true, <int>[1], const <int>[2]); | ||
test(true, const <String>[], List<String>.filled(1, '')); | ||
test(true, <String>[]..add('hi'), List<String>.filled(2, '')); | ||
test(false, <int>[], <String>[]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.