-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redo how Type objects are exposed from DDC.
- Instead of using the raw runtime type that DDC uses for its type checks, use a WrappedType that correctly implements Type's interface. - Compile class literals to wrap the type in a WrappedType. - Make Object.runtimeType() do the same thing. Fixes #488. Fixes #511. [email protected] Review URL: https://codereview.chromium.org/1944483002 .
- Loading branch information
1 parent
6485751
commit 44db042
Showing
16 changed files
with
299 additions
and
172 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
52 changes: 52 additions & 0 deletions
52
pkg/dev_compiler/test/codegen/language/type_literal_test.dart
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,52 @@ | ||
// Copyright (c) 2016, 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:expect/expect.dart"; | ||
|
||
// TODO(rnystrom): This test has a lot of overlap with some other language | ||
// tests, but those are sort of all over the place so I thought it useful to | ||
// test all of the relevant bits in one place here. | ||
|
||
class Foo {} | ||
|
||
class Box<T> { | ||
Type get typeArg => T; | ||
} | ||
|
||
typedef int Func(bool b); | ||
typedef int GenericFunc<T>(T t); | ||
|
||
main() { | ||
// Primitive types. | ||
testType(Object, "Object"); | ||
testType(Null, "Null"); | ||
testType(bool, "bool"); | ||
testType(double, "double"); | ||
testType(int, "int"); | ||
testType(num, "num"); | ||
testType(String, "String"); | ||
|
||
// Class types. | ||
testType(Foo, "Foo"); | ||
|
||
// Generic classes. | ||
testType(Box, "Box"); | ||
testType(new Box<Foo>().typeArg, "Foo"); | ||
testType(new Box<dynamic>().typeArg, "dynamic"); | ||
testType(new Box<Box<Foo>>().typeArg, "Box<Foo>"); | ||
|
||
// Typedef. | ||
testType(Func, "Func"); | ||
testType(GenericFunc, "GenericFunc"); | ||
|
||
// TODO(rnystrom): This should print "GenericFunc<int>", but that isn't | ||
// implemented yet. | ||
testType(new Box<GenericFunc<int>>().typeArg, "GenericFunc"); | ||
|
||
// Literals are canonicalized. | ||
Expect.identical(Foo, Foo); | ||
Expect.identical(Box, Box); | ||
Expect.identical(new Box<Foo>().typeArg, new Box<Foo>().typeArg); | ||
Expect.identical(Func, Func); | ||
} |
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.