mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
[cfe] Account for InvalidType at nestedness level in UP and DOWN
Closes #46863. Bug: https://github.com/dart-lang/sdk/issues/46863 Change-Id: I0cc60251f80406baa955131978cd6cbd029b228e Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209700 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
This commit is contained in:
parent
c04a71e455
commit
6393841036
7 changed files with 128 additions and 0 deletions
13
pkg/front_end/testcases/general/issue46863.dart
Normal file
13
pkg/front_end/testcases/general/issue46863.dart
Normal file
|
@ -0,0 +1,13 @@
|
|||
// 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.
|
||||
|
||||
final foo = [() => const [], () => bar()];
|
||||
|
||||
final foo2 = [(dynamic x) => const [], (Bar x) => const []];
|
||||
|
||||
final foo3 = [(List<dynamic> x) => const [], (List<Bar> x) => const []];
|
||||
|
||||
final foo4 = [(Function(dynamic) x) => const [], (Function(Bar) x) => const []];
|
||||
|
||||
main() {}
|
|
@ -0,0 +1,5 @@
|
|||
final foo = [() => const [], () => bar()];
|
||||
final foo2 = [(dynamic x) => const [], (Bar x) => const []];
|
||||
final foo3 = [(List<dynamic> x) => const [], (List<Bar> x) => const []];
|
||||
final foo4 = [(Function(dynamic) x) => const [], (Function(Bar) x) => const []];
|
||||
main() {}
|
|
@ -0,0 +1,5 @@
|
|||
final foo = [() => const [], () => bar()];
|
||||
final foo2 = [(dynamic x) => const [], (Bar x) => const []];
|
||||
final foo3 = [(List<dynamic> x) => const [], (List<Bar> x) => const []];
|
||||
final foo4 = [(Function(dynamic) x) => const [], (Function(Bar) x) => const []];
|
||||
main() {}
|
34
pkg/front_end/testcases/general/issue46863.dart.weak.expect
Normal file
34
pkg/front_end/testcases/general/issue46863.dart.weak.expect
Normal file
|
@ -0,0 +1,34 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/general/issue46863.dart:5:36: Error: Method not found: 'bar'.
|
||||
// final foo = [() => const [], () => bar()];
|
||||
// ^^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/issue46863.dart:7:41: Error: 'Bar' isn't a type.
|
||||
// final foo2 = [(dynamic x) => const [], (Bar x) => const []];
|
||||
// ^^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/issue46863.dart:9:52: Error: 'Bar' isn't a type.
|
||||
// final foo3 = [(List<dynamic> x) => const [], (List<Bar> x) => const []];
|
||||
// ^^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/issue46863.dart:11:60: Error: 'Bar' isn't a type.
|
||||
// final foo4 = [(Function(dynamic) x) => const [], (Function(Bar) x) => const []];
|
||||
// ^^^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
static final field core::List<() → invalid-type> foo = <() → invalid-type>[() → core::List<dynamic> => #C1, () → invalid-type => invalid-expression "pkg/front_end/testcases/general/issue46863.dart:5:36: Error: Method not found: 'bar'.
|
||||
final foo = [() => const [], () => bar()];
|
||||
^^^"];
|
||||
static final field core::List<(invalid-type) → core::List<dynamic>> foo2 = <(invalid-type) → core::List<dynamic>>[(dynamic x) → core::List<dynamic> => #C1, (invalid-type x) → core::List<dynamic> => #C1];
|
||||
static final field core::List<(core::List<dynamic>) → core::List<dynamic>> foo3 = <(core::List<dynamic>) → core::List<dynamic>>[(core::List<dynamic> x) → core::List<dynamic> => #C1, (core::List<invalid-type> x) → core::List<dynamic> => #C1];
|
||||
static final field core::List<((invalid-type) → dynamic) → core::List<dynamic>> foo4 = <((invalid-type) → dynamic) → core::List<dynamic>>[((dynamic) → dynamic x) → core::List<dynamic> => #C1, ((invalid-type) → dynamic x) → core::List<dynamic> => #C1];
|
||||
static method main() → dynamic {}
|
||||
|
||||
constants {
|
||||
#C1 = <dynamic>[]
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/general/issue46863.dart:5:36: Error: Method not found: 'bar'.
|
||||
// final foo = [() => const [], () => bar()];
|
||||
// ^^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/issue46863.dart:7:41: Error: 'Bar' isn't a type.
|
||||
// final foo2 = [(dynamic x) => const [], (Bar x) => const []];
|
||||
// ^^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/issue46863.dart:9:52: Error: 'Bar' isn't a type.
|
||||
// final foo3 = [(List<dynamic> x) => const [], (List<Bar> x) => const []];
|
||||
// ^^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/issue46863.dart:11:60: Error: 'Bar' isn't a type.
|
||||
// final foo4 = [(Function(dynamic) x) => const [], (Function(Bar) x) => const []];
|
||||
// ^^^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
static final field core::List<() → invalid-type> foo;
|
||||
static final field core::List<(invalid-type) → core::List<dynamic>> foo2;
|
||||
static final field core::List<(core::List<dynamic>) → core::List<dynamic>> foo3;
|
||||
static final field core::List<((invalid-type) → dynamic) → core::List<dynamic>> foo4;
|
||||
static method main() → dynamic
|
||||
;
|
|
@ -0,0 +1,34 @@
|
|||
library /*isNonNullableByDefault*/;
|
||||
//
|
||||
// Problems in library:
|
||||
//
|
||||
// pkg/front_end/testcases/general/issue46863.dart:5:36: Error: Method not found: 'bar'.
|
||||
// final foo = [() => const [], () => bar()];
|
||||
// ^^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/issue46863.dart:7:41: Error: 'Bar' isn't a type.
|
||||
// final foo2 = [(dynamic x) => const [], (Bar x) => const []];
|
||||
// ^^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/issue46863.dart:9:52: Error: 'Bar' isn't a type.
|
||||
// final foo3 = [(List<dynamic> x) => const [], (List<Bar> x) => const []];
|
||||
// ^^^
|
||||
//
|
||||
// pkg/front_end/testcases/general/issue46863.dart:11:60: Error: 'Bar' isn't a type.
|
||||
// final foo4 = [(Function(dynamic) x) => const [], (Function(Bar) x) => const []];
|
||||
// ^^^
|
||||
//
|
||||
import self as self;
|
||||
import "dart:core" as core;
|
||||
|
||||
static final field core::List<() → invalid-type> foo = core::_GrowableList::_literal2<() → invalid-type>(() → core::List<dynamic> => #C1, () → invalid-type => invalid-expression "pkg/front_end/testcases/general/issue46863.dart:5:36: Error: Method not found: 'bar'.
|
||||
final foo = [() => const [], () => bar()];
|
||||
^^^");
|
||||
static final field core::List<(invalid-type) → core::List<dynamic>> foo2 = core::_GrowableList::_literal2<(invalid-type) → core::List<dynamic>>((dynamic x) → core::List<dynamic> => #C1, (invalid-type x) → core::List<dynamic> => #C1);
|
||||
static final field core::List<(core::List<dynamic>) → core::List<dynamic>> foo3 = core::_GrowableList::_literal2<(core::List<dynamic>) → core::List<dynamic>>((core::List<dynamic> x) → core::List<dynamic> => #C1, (core::List<invalid-type> x) → core::List<dynamic> => #C1);
|
||||
static final field core::List<((invalid-type) → dynamic) → core::List<dynamic>> foo4 = core::_GrowableList::_literal2<((invalid-type) → dynamic) → core::List<dynamic>>(((dynamic) → dynamic x) → core::List<dynamic> => #C1, ((invalid-type) → dynamic x) → core::List<dynamic> => #C1);
|
||||
static method main() → dynamic {}
|
||||
|
||||
constants {
|
||||
#C1 = <dynamic>[]
|
||||
}
|
|
@ -267,6 +267,10 @@ mixin StandardBounds {
|
|||
|
||||
DartType getNullabilityAwareStandardLowerBoundInternal(
|
||||
DartType type1, DartType type2, Library clientLibrary) {
|
||||
if (type1 is InvalidType || type2 is InvalidType) {
|
||||
return const InvalidType();
|
||||
}
|
||||
|
||||
// DOWN(T1, T2) where TOP(T1) and TOP(T2) =
|
||||
// T1 if MORETOP(T2, T1)
|
||||
// T2 otherwise
|
||||
|
@ -629,6 +633,10 @@ mixin StandardBounds {
|
|||
|
||||
DartType getNullabilityAwareStandardUpperBoundInternal(
|
||||
DartType type1, DartType type2, Library clientLibrary) {
|
||||
if (type1 is InvalidType || type2 is InvalidType) {
|
||||
return const InvalidType();
|
||||
}
|
||||
|
||||
// UP(T1, T2) where TOP(T1) and TOP(T2) =
|
||||
// T1 if MORETOP(T1, T2)
|
||||
// T2 otherwise
|
||||
|
|
Loading…
Reference in a new issue