Skip to content

Commit

Permalink
[fasta][nnbd] Print NNBD type modifiers in Kernel's text representation
Browse files Browse the repository at this point in the history
Change-Id: I48c43858094e2b7264a15be05238bfc3dadd5ecb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/108264
Commit-Queue: Dmitry Stefantsov <[email protected]>
Reviewed-by: Johnni Winther <[email protected]>
  • Loading branch information
Dmitry Stefantsov authored and [email protected] committed Jul 31, 2019
1 parent 776f2d3 commit 20e4c74
Show file tree
Hide file tree
Showing 4,564 changed files with 40,157 additions and 39,858 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
17 changes: 9 additions & 8 deletions pkg/dev_compiler/test/nullable_inference_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ void main() {
});
test('List', () async {
await expectNotNull(
'main() { print([42, null]); }', '<dart.core::int>[42, null], 42');
'main() { print([42, null]); }', '<dart.core::int*>[42, null], 42');
});
test('Map', () async {
await expectNotNull('main() { print({"x": null}); }',
'<dart.core::String, dart.core::Null>{"x": null}, "x"');
'<dart.core::String*, dart.core::Null*>{"x": null}, "x"');
});

test('Symbol', () async {
await expectNotNull('main() { print(#hi); }', '#hi');
});

test('Type', () async {
await expectNotNull('main() { print(Object); }', 'dart.core::Object');
await expectNotNull('main() { print(Object); }', 'dart.core::Object*');
});
});

Expand All @@ -61,12 +61,12 @@ void main() {

test('is', () async {
await expectNotNull('main() { 42 is int; null is int; }',
'42 is dart.core::int, 42, null is dart.core::int');
'42 is dart.core::int*, 42, null is dart.core::int*');
});

test('as', () async {
await expectNotNull(
'main() { 42 as int; null as int; }', '42 as dart.core::int, 42');
'main() { 42 as int; null as int; }', '42 as dart.core::int*, 42');
});

test('constructor', () async {
Expand Down Expand Up @@ -248,8 +248,8 @@ void main() {
});

test('function expression', () async {
await expectNotNull(
'main() { () => null; f() {}; f; }', '() → dart.core::Null => null, f');
await expectNotNull('main() { () => null; f() {}; f; }',
'() → dart.core::Null* => null, f');
});

test('cascades (kernel let)', () async {
Expand Down Expand Up @@ -390,7 +390,8 @@ void main() {
await expectNotNull('''main() {
var x = () => 42;
var y = (() => x = null);
}''', '() → dart.core::int => 42, 42, () → dart.core::Null => x = null');
}''',
'() → dart.core::int* => 42, 42, () → dart.core::Null* => x = null');
});
test('do not depend on unrelated variables', () async {
await expectNotNull('''main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class TypeConstraintGathererTest {
InterfaceType get Q => classQ.rawType;

void test_any_subtype_parameter() {
_checkConstraints(Q, T1, ['lib::Q <: T1']);
_checkConstraints(Q, T1, ['lib::Q* <: T1']);
}

void test_any_subtype_top() {
Expand All @@ -87,7 +87,7 @@ class TypeConstraintGathererTest {
}

void test_different_classes() {
_checkConstraints(_list(T1), _iterable(Q), ['T1 <: lib::Q']);
_checkConstraints(_list(T1), _iterable(Q), ['T1 <: lib::Q*']);
_checkConstraints(_iterable(T1), _list(Q), null);
}

Expand Down Expand Up @@ -142,20 +142,20 @@ class TypeConstraintGathererTest {
void test_function_parameter_types() {
// (T1) -> dynamic <: (Q) -> dynamic, under constraint Q <: T1
_checkConstraints(new FunctionType([T1], dynamicType),
new FunctionType([Q], dynamicType), ['lib::Q <: T1']);
new FunctionType([Q], dynamicType), ['lib::Q* <: T1']);
// ({x: T1}) -> dynamic <: ({x: Q}) -> dynamic, under constraint Q <: T1
_checkConstraints(
new FunctionType([], dynamicType,
namedParameters: [new NamedType('x', T1)]),
new FunctionType([], dynamicType,
namedParameters: [new NamedType('x', Q)]),
['lib::Q <: T1']);
['lib::Q* <: T1']);
}

void test_function_return_type() {
// () -> T1 <: () -> Q, under constraint T1 <: Q
_checkConstraints(
new FunctionType([], T1), new FunctionType([], Q), ['T1 <: lib::Q']);
new FunctionType([], T1), new FunctionType([], Q), ['T1 <: lib::Q*']);
// () -> P <: () -> void, always
_checkConstraints(
new FunctionType([], P), new FunctionType([], voidType), []);
Expand All @@ -176,25 +176,25 @@ class TypeConstraintGathererTest {

void test_nonInferredParameter_subtype_any() {
var U = new TypeParameterType(new TypeParameter('U', _list(P)));
_checkConstraints(U, _list(T1), ['lib::P <: T1']);
_checkConstraints(U, _list(T1), ['lib::P* <: T1']);
}

void test_null_subtype_any() {
_checkConstraints(nullType, T1, ['dart.core::Null <: T1']);
_checkConstraints(nullType, T1, ['dart.core::Null* <: T1']);
_checkConstraints(nullType, Q, []);
}

void test_parameter_subtype_any() {
_checkConstraints(T1, Q, ['T1 <: lib::Q']);
_checkConstraints(T1, Q, ['T1 <: lib::Q*']);
}

void test_same_classes() {
_checkConstraints(_list(T1), _list(Q), ['T1 <: lib::Q']);
_checkConstraints(_list(T1), _list(Q), ['T1 <: lib::Q*']);
}

void test_typeParameters() {
_checkConstraints(
_map(T1, T2), _map(P, Q), ['T1 <: lib::P', 'T2 <: lib::Q']);
_map(T1, T2), _map(P, Q), ['T1 <: lib::P*', 'T2 <: lib::Q*']);
}

void test_unknown_subtype_any() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class TypeSchemaEliminationTest {
expect(
greatestClosure(new FunctionType([unknownType], dynamicType))
.toString(),
'(dart.core::Null) → dynamic');
'(dart.core::Null*) →* dynamic');
expect(
greatestClosure(new FunctionType([], dynamicType,
namedParameters: [new NamedType('foo', unknownType)])).toString(),
'({foo: dart.core::Null}) → dynamic');
'({foo: dart.core::Null*}) →* dynamic');
}

void test_greatestClosure_contravariant_contravariant() {
Expand All @@ -51,16 +51,16 @@ class TypeSchemaEliminationTest {
new FunctionType([unknownType], dynamicType)
], dynamicType))
.toString(),
'((dynamic) → dynamic) → dynamic');
'((dynamic) →* dynamic) →* dynamic');
}

void test_greatestClosure_covariant() {
expect(greatestClosure(new FunctionType([], unknownType)).toString(),
'() → dynamic');
'() →* dynamic');
expect(
greatestClosure(new InterfaceType(coreTypes.listClass, [unknownType]))
.toString(),
'dart.core::List<dynamic>');
'dart.core::List<dynamic>*');
}

void test_greatestClosure_function_multipleUnknown() {
Expand All @@ -71,8 +71,8 @@ class TypeSchemaEliminationTest {
new NamedType('a', unknownType),
new NamedType('b', unknownType)
])).toString(),
'(dart.core::Null, dart.core::Null, {a: dart.core::Null, '
'b: dart.core::Null}) → dynamic');
'(dart.core::Null*, dart.core::Null*, {a: dart.core::Null*, '
'b: dart.core::Null*}) →* dynamic');
}

void test_greatestClosure_simple() {
Expand All @@ -82,11 +82,11 @@ class TypeSchemaEliminationTest {
void test_leastClosure_contravariant() {
expect(
leastClosure(new FunctionType([unknownType], dynamicType)).toString(),
'(dynamic) → dynamic');
'(dynamic) →* dynamic');
expect(
leastClosure(new FunctionType([], dynamicType,
namedParameters: [new NamedType('foo', unknownType)])).toString(),
'({foo: dynamic}) → dynamic');
'({foo: dynamic}) →* dynamic');
}

void test_leastClosure_contravariant_contravariant() {
Expand All @@ -95,16 +95,16 @@ class TypeSchemaEliminationTest {
new FunctionType([unknownType], dynamicType)
], dynamicType))
.toString(),
'((dart.core::Null) → dynamic) → dynamic');
'((dart.core::Null*) →* dynamic) →* dynamic');
}

void test_leastClosure_covariant() {
expect(leastClosure(new FunctionType([], unknownType)).toString(),
'() → dart.core::Null');
'() →* dart.core::Null*');
expect(
leastClosure(new InterfaceType(coreTypes.listClass, [unknownType]))
.toString(),
'dart.core::List<dart.core::Null>');
'dart.core::List<dart.core::Null*>*');
}

void test_leastClosure_function_multipleUnknown() {
Expand All @@ -114,11 +114,11 @@ class TypeSchemaEliminationTest {
new NamedType('a', unknownType),
new NamedType('b', unknownType)
])).toString(),
'(dynamic, dynamic, {a: dynamic, b: dynamic}) → dart.core::Null');
'(dynamic, dynamic, {a: dynamic, b: dynamic}) →* dart.core::Null*');
}

void test_leastClosure_simple() {
expect(leastClosure(unknownType).toString(), 'dart.core::Null');
expect(leastClosure(unknownType).toString(), 'dart.core::Null*');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class UnknownTypeTest {
expect(
typeSchemaToString(
new FunctionType([unknownType, unknownType], unknownType)),
'(?, ?) → ?');
'(?, ?) →* ?');
}

void test_visitChildren() {
Expand Down
24 changes: 12 additions & 12 deletions pkg/front_end/test/fasta/types/kernel_type_parser_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,28 @@ const String expectedSdk = """
library core;
import self as self;
typedef Typedef<T extends self::Object = dynamic> = <S extends self::Object = dynamic>(T) → S;
typedef VoidFunction = () → void;
typedef TestDefaultTypes = () → self::DefaultTypes<dynamic, self::Object, self::List<dynamic>, self::List<self::Object>, self::Comparable<dynamic>, (<BottomType>) → void, () → self::Comparable<dynamic>>;
typedef Id<T extends self::Object = dynamic> = T;
typedef TestSorting = ({a: self::int, b: self::int, c: self::int}) → void;
typedef Typedef<T extends self::Object* = dynamic> = <S extends self::Object* = dynamic>(T*) →* S*;
typedef VoidFunction = () →* void;
typedef TestDefaultTypes = () →* self::DefaultTypes<dynamic, self::Object, self::List<dynamic>*, self::List<self::Object>*, self::Comparable<dynamic>*, (<BottomType>) →* void, () →* self::Comparable<dynamic>*>;
typedef Id<T extends self::Object* = dynamic> = T*;
typedef TestSorting = ({a: self::int, b: self::int, c: self::int}) →* void;
class Object {
}
class Comparable<T extends self::Object = dynamic> extends self::Object {
class Comparable<T extends self::Object* = dynamic> extends self::Object {
}
class num extends self::Object implements self::Comparable<self::num> {
}
class int extends self::num {
}
class double extends self::num {
}
class Iterable<T extends self::Object = dynamic> extends self::Object {
class Iterable<T extends self::Object* = dynamic> extends self::Object {
}
class List<T extends self::Object = dynamic> extends self::Iterable<self::List::T> {
class List<T extends self::Object* = dynamic> extends self::Iterable<self::List::T*> {
}
class Future<T extends self::Object = dynamic> extends self::Object {
class Future<T extends self::Object* = dynamic> extends self::Object {
}
class FutureOr<T extends self::Object = dynamic> extends self::Object {
class FutureOr<T extends self::Object* = dynamic> extends self::Object {
}
class Null extends self::Object {
}
Expand All @@ -71,13 +71,13 @@ class String extends self::Object {
}
class bool extends self::Object {
}
class DefaultTypes<S extends self::Object = dynamic, T extends self::Object = self::Object, U extends self::List<self::DefaultTypes::S> = self::List<dynamic>, V extends self::List<self::DefaultTypes::T> = self::List<self::Object>, W extends self::Comparable<self::DefaultTypes::W> = self::Comparable<dynamic>, X extends (self::DefaultTypes::W) → void = (<BottomType>) → void, Y extends () → self::DefaultTypes::W = () → self::Comparable<dynamic>> extends self::Object {
class DefaultTypes<S extends self::Object* = dynamic, T extends self::Object = self::Object, U extends self::List<self::DefaultTypes::S*> = self::List<dynamic>*, V extends self::List<self::DefaultTypes::T> = self::List<self::Object>*, W extends self::Comparable<self::DefaultTypes::W> = self::Comparable<dynamic>*, X extends (self::DefaultTypes::W) → void = (<BottomType>) →* void, Y extends () → self::DefaultTypes::W = () →* self::Comparable<dynamic>*> extends self::Object {
}
class Super extends self::Object implements self::Comparable<self::Sub> {
}
class Sub extends self::Super {
}
class FBound<T extends self::FBound<self::FBound::T> = self::FBound<dynamic>> extends self::Object {
class FBound<T extends self::FBound<self::FBound::T> = self::FBound<dynamic>*> extends self::Object {
}
class MixinApplication = self::Object with self::FBound<self::MixinApplication> {
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Errors: {
}
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr() → dynamic
return () → dart.core::int {
return () → dart.core::int* {
return this.{main::B::x}.{dart.core::num::+}(this.{main::B::y});
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Errors: {
^^^^^^^^^
}
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr() → dynamic
return #lib1::globalVar.{dart.core::num::+}(invalid-expression "org-dartlang-debug:synthetic_debug_expression:1:13: Error: Getter not found: 'staticVar'.\nglobalVar + staticVar + 5\n ^^^^^^^^^" as{TypeError} dart.core::num).{dart.core::num::+}(5);
return #lib1::globalVar.{dart.core::num::+}(invalid-expression "org-dartlang-debug:synthetic_debug_expression:1:13: Error: Getter not found: 'staticVar'.\nglobalVar + staticVar + 5\n ^^^^^^^^^" as{TypeError} dart.core::num*).{dart.core::num::+}(5);
Errors: {
}
static method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr() → dynamic
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Errors: {
}
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(dynamic x) → dynamic
return main::hasBound<main::C::T>();
return main::hasBound<main::C::T*>();
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Errors: {
}
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(dynamic x) → dynamic
return main::hasBound<main::C::T>();
return main::hasBound<main::C::T*>();
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Errors: {
^
}
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(dynamic x) → dynamic
return main::hasBound<main::A::T>();
return main::hasBound<main::A::T*>();
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Errors: {
^
}
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(dynamic x) → dynamic
return main::hasBound<main::A::T>();
return main::hasBound<main::A::T*>();
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Errors: {
}
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(dynamic x) → dynamic
return x is main::A::T;
return x is main::A::T*;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Errors: {
}
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(dynamic x) → dynamic
return main::id<main::A::T>(x as{TypeError} main::A::T);
return main::id<main::A::T*>(x as{TypeError} main::A::T*);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Errors: {
}
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(dynamic x) → dynamic
return () → dart.core::Null {
return () → dart.core::Null* {
x = main::id<dynamic>(x);
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Errors: {
}
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(dynamic x) → dynamic
return new main::A::•<main::A::T>();
return new main::A::•<main::A::T*>();
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Errors: {
}
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(dynamic x) → dynamic
return () → dart.core::Null {
return () → dart.core::Null* {
x = new main::A::•<dynamic>();
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Errors: {
}
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr() → dynamic
return () → main::A::T {
main::A::T k = null;
return () → main::A::T* {
main::A::T* k = null;
return k;
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Errors: {
}
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr() → dynamic
return null is dart.collection::Queue<dynamic>;
return null is dart.collection::Queue<dynamic>*;
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Errors: {
}
method /* from org-dartlang-debug:synthetic_debug_expression */ debugExpr(dynamic a, dynamic b) → dynamic
return ((dynamic a, dynamic b) → dart.core::bool {
return ((dynamic a, dynamic b) → dart.core::bool* {
if(!a._usedData.{dart.core::Object::==}(b._usedData) || !a._deletedKeys.{dart.core::Object::==}(b._deletedKeys) || !a._hashMask.{dart.core::Object::==}(b._hashMask) || !a._index.length.{dart.core::Object::==}(b._index.length) || !a._data.length.{dart.core::Object::==}(b._data.length)) {
return false;
}
for (dart.core::int i = 0; i.{dart.core::num::<}(a._index.length as{TypeError} dart.core::num); i = i.{dart.core::num::+}(1)) {
for (dart.core::int* i = 0; i.{dart.core::num::<}(a._index.length as{TypeError} dart.core::num*); i = i.{dart.core::num::+}(1)) {
if(!a._index.[](i).{dart.core::Object::==}(b._index.[](i))) {
return false;
}
}
for (dart.core::int i = 0; i.{dart.core::num::<}(a._data.length as{TypeError} dart.core::num); i = i.{dart.core::num::+}(1)) {
for (dart.core::int* i = 0; i.{dart.core::num::<}(a._data.length as{TypeError} dart.core::num*); i = i.{dart.core::num::+}(1)) {
dynamic ad = a._data.[](i);
dynamic bd = b._data.[](i);
if(!dart.core::identical(ad, bd) && !(ad.{dart.core::Object::==}(a) && bd.{dart.core::Object::==}(b))) {
Expand Down
Loading

0 comments on commit 20e4c74

Please sign in to comment.