Files
sdk/pkg/front_end/testcases/general/invalid_cast.dart.weak.transformed.expect
T
Johnni Winther dd1c3a3233 [vm] Make async transform resilient in context of invalid type and never type of iterables
The CFE can invoke transformations despite having compile-time errors.
The async transform was crashing the compiler if it hits for-in
iterables that have an invalid type or never type.

In case of an invalid type, the program has a compile-time error and
won't be able to run propertly. So we'll replace the entire for-in with
an invalid expression statement if the iterable is an invalid
expression.

In case of a never type, the program should compile fine, which this CL
also fixes.

This makes the newly added tests no longer result in DartkCrash but
rather in a compile-time error (invalid expression) or runtime-error
(never type).

Closes https://github.com/dart-lang/sdk/issues/45014

Change-Id: Ic50f68400b67b57dd4a2c0a125b08f0f3e0d8dd6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188463
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-03-03 11:58:08 +00:00

175 lines
10 KiB
Plaintext

library;
//
// Problems in library:
//
// pkg/front_end/testcases/general/invalid_cast.dart:22:25: Error: The list literal type 'List<Object>' isn't of expected type 'List<int>'.
// - 'List' is from 'dart:core'.
// - 'Object' is from 'dart:core'.
// Change the type of the list literal or the context in which it is used.
// List<int> a = <Object>[];
// ^
//
// pkg/front_end/testcases/general/invalid_cast.dart:23:40: Error: The map literal type 'Map<Object, String>' isn't of expected type 'Map<int, String>'.
// - 'Map' is from 'dart:core'.
// - 'Object' is from 'dart:core'.
// Change the type of the map literal or the context in which it is used.
// Map<int, String> b = <Object, String>{};
// ^
//
// pkg/front_end/testcases/general/invalid_cast.dart:24:37: Error: The map literal type 'Map<int, Object>' isn't of expected type 'Map<int, String>'.
// - 'Map' is from 'dart:core'.
// - 'Object' is from 'dart:core'.
// Change the type of the map literal or the context in which it is used.
// Map<int, String> c = <int, Object>{};
// ^
//
// pkg/front_end/testcases/general/invalid_cast.dart:25:28: Error: The function expression type 'int Function(int)' isn't of expected type 'int Function(Object)'.
// - 'Object' is from 'dart:core'.
// Change the type of the function expression or the context in which it is used.
// int Function(Object) d = (int i) => i;
// ^
//
// pkg/front_end/testcases/general/invalid_cast.dart:28:13: Error: The constructor returns type 'C' that isn't of expected type 'D'.
// - 'C' is from 'pkg/front_end/testcases/general/invalid_cast.dart'.
// - 'D' is from 'pkg/front_end/testcases/general/invalid_cast.dart'.
// Change the type of the object being constructed or the context in which it is used.
// D g = new C.nonFact();
// ^
//
// pkg/front_end/testcases/general/invalid_cast.dart:29:13: Error: The constructor returns type 'C' that isn't of expected type 'D'.
// - 'C' is from 'pkg/front_end/testcases/general/invalid_cast.dart'.
// - 'D' is from 'pkg/front_end/testcases/general/invalid_cast.dart'.
// Change the type of the object being constructed or the context in which it is used.
// D h = new C.nonFact2();
// ^
//
// pkg/front_end/testcases/general/invalid_cast.dart:30:31: Error: The static method has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
// - 'Object' is from 'dart:core'.
// Change the type of the method or the context in which it is used.
// void Function(Object) i = C.staticFunction;
// ^
//
// pkg/front_end/testcases/general/invalid_cast.dart:31:29: Error: The top level function has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
// - 'Object' is from 'dart:core'.
// Change the type of the function or the context in which it is used.
// void Function(Object) j = topLevelFunction;
// ^
//
// pkg/front_end/testcases/general/invalid_cast.dart:32:29: Error: The local function has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
// - 'Object' is from 'dart:core'.
// Change the type of the function or the context in which it is used.
// void Function(Object) k = localFunction;
// ^
//
import self as self;
import "dart:core" as core;
class C extends core::Object {
static final field dynamic _redirecting# = <dynamic>[self::C::fact2];
constructor •() → self::C*
: super core::Object::•()
;
constructor nonFact() → self::C*
: super core::Object::•()
;
constructor nonFact2() → self::C*
: this self::C::nonFact()
;
static factory fact() → self::C*
return null;
static factory fact2() → self::C*
let Never #redirecting_factory = self::D::• in invalid-expression;
static method staticFunction(core::int* i) → void {}
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
abstract member-signature method toString() → core::String*; -> core::Object::toString
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
}
class D extends self::C {
synthetic constructor •() → self::D*
: super self::C::•()
;
}
static method topLevelFunction(core::int* i) → void {}
static method bad() → dynamic {
function localFunction(core::int* i) → void {}
core::List<core::int*>* a = let final Never* #t1 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:22:25: Error: The list literal type 'List<Object>' isn't of expected type 'List<int>'.
- 'List' is from 'dart:core'.
- 'Object' is from 'dart:core'.
Change the type of the list literal or the context in which it is used.
List<int> a = <Object>[];
^" in core::_GrowableList::•<core::Object*>(0);
core::Map<core::int*, core::String*>* b = let final Never* #t2 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:23:40: Error: The map literal type 'Map<Object, String>' isn't of expected type 'Map<int, String>'.
- 'Map' is from 'dart:core'.
- 'Object' is from 'dart:core'.
Change the type of the map literal or the context in which it is used.
Map<int, String> b = <Object, String>{};
^" in <core::Object*, core::String*>{};
core::Map<core::int*, core::String*>* c = let final Never* #t3 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:24:37: Error: The map literal type 'Map<int, Object>' isn't of expected type 'Map<int, String>'.
- 'Map' is from 'dart:core'.
- 'Object' is from 'dart:core'.
Change the type of the map literal or the context in which it is used.
Map<int, String> c = <int, Object>{};
^" in <core::int*, core::Object*>{};
(core::Object*) →* core::int* d = let final Never* #t4 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:25:28: Error: The function expression type 'int Function(int)' isn't of expected type 'int Function(Object)'.
- 'Object' is from 'dart:core'.
Change the type of the function expression or the context in which it is used.
int Function(Object) d = (int i) => i;
^" in (core::int* i) → core::int* => i;
self::D* e = self::C::fact() as{TypeError} self::D*;
self::D* f = new self::D::•();
self::D* g = let final Never* #t5 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:28:13: Error: The constructor returns type 'C' that isn't of expected type 'D'.
- 'C' is from 'pkg/front_end/testcases/general/invalid_cast.dart'.
- 'D' is from 'pkg/front_end/testcases/general/invalid_cast.dart'.
Change the type of the object being constructed or the context in which it is used.
D g = new C.nonFact();
^" in new self::C::nonFact();
self::D* h = let final Never* #t6 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:29:13: Error: The constructor returns type 'C' that isn't of expected type 'D'.
- 'C' is from 'pkg/front_end/testcases/general/invalid_cast.dart'.
- 'D' is from 'pkg/front_end/testcases/general/invalid_cast.dart'.
Change the type of the object being constructed or the context in which it is used.
D h = new C.nonFact2();
^" in new self::C::nonFact2();
(core::Object*) →* void i = let final Never* #t7 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:30:31: Error: The static method has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
- 'Object' is from 'dart:core'.
Change the type of the method or the context in which it is used.
void Function(Object) i = C.staticFunction;
^" in #C1;
(core::Object*) →* void j = let final Never* #t8 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:31:29: Error: The top level function has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
- 'Object' is from 'dart:core'.
Change the type of the function or the context in which it is used.
void Function(Object) j = topLevelFunction;
^" in #C2;
(core::Object*) →* void k = let final Never* #t9 = invalid-expression "pkg/front_end/testcases/general/invalid_cast.dart:32:29: Error: The local function has type 'void Function(int)' that isn't of expected type 'void Function(Object)'.
- 'Object' is from 'dart:core'.
Change the type of the function or the context in which it is used.
void Function(Object) k = localFunction;
^" in localFunction;
}
static method ok() → dynamic {
function localFunction(core::int* i) → void {}
core::List<core::int*>* a = core::_GrowableList::•<core::int*>(0);
core::Map<core::int*, core::String*>* b = <core::int*, core::String*>{};
core::Map<core::int*, core::String*>* c = <core::int*, core::String*>{};
(core::int*) →* core::int* d = (core::int* i) → core::int* => i;
self::D* e = self::C::fact() as{TypeError} self::D*;
self::D* f = new self::D::•();
self::C* g = new self::C::nonFact();
self::C* h = new self::C::nonFact2();
(core::int*) →* void i = #C1;
(core::int*) →* void j = #C2;
(core::int*) →* void k = localFunction;
}
static method main() → dynamic {}
constants {
#C1 = tearoff self::C::staticFunction
#C2 = tearoff self::topLevelFunction
}