mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 08:20:31 +00:00
Remove all the contravariance bits
Change-Id: Ib43b32d12749ddac0a93795cb5e8543eb5131dd9 Reviewed-on: https://dart-review.googlesource.com/52867 Commit-Queue: Kevin Millikin <kmillikin@google.com> Reviewed-by: Dmitry Stefantsov <dmitryas@google.com> Reviewed-by: Samir Jindel <sjindel@google.com>
This commit is contained in:
parent
c544a9fcd1
commit
9371ca061c
64 changed files with 140 additions and 220 deletions
|
@ -65,9 +65,6 @@ class InstrumentationValueForForwardingStub extends InstrumentationValue {
|
|||
buffer.write('abstract ');
|
||||
}
|
||||
var function = procedure.function;
|
||||
if (procedure.isGenericContravariant) {
|
||||
buffer.write('genericContravariant ');
|
||||
}
|
||||
buffer.write(function.returnType);
|
||||
buffer.write(' ');
|
||||
switch (procedure.kind) {
|
||||
|
|
|
@ -230,15 +230,6 @@ class ForwardingNode extends Procedure {
|
|||
bool needsCheck(DartType type) => needsCheckVisitor == null
|
||||
? false
|
||||
: substitution.substituteType(type).accept(needsCheckVisitor);
|
||||
needsCheckVisitor?.inCovariantContext = false;
|
||||
var isGenericContravariant = needsCheck(interfaceFunction.returnType);
|
||||
needsCheckVisitor?.inCovariantContext = true;
|
||||
if (isGenericContravariant != interfaceMember.isGenericContravariant) {
|
||||
fixes.add((FunctionNode function) {
|
||||
Procedure procedure = function.parent;
|
||||
procedure.isGenericContravariant = isGenericContravariant;
|
||||
});
|
||||
}
|
||||
for (int i = 0; i < interfacePositionalParameters.length; i++) {
|
||||
var parameter = interfacePositionalParameters[i];
|
||||
var isGenericCovariantInterface = needsCheck(parameter.type);
|
||||
|
@ -491,8 +482,7 @@ class ForwardingNode extends Procedure {
|
|||
fileUri: enclosingClass.fileUri,
|
||||
forwardingStubInterfaceTarget: finalTarget)
|
||||
..fileOffset = enclosingClass.fileOffset
|
||||
..parent = enclosingClass
|
||||
..isGenericContravariant = target.isGenericContravariant;
|
||||
..parent = enclosingClass;
|
||||
}
|
||||
|
||||
/// Creates a forwarding stub for this node if necessary, and propagates
|
||||
|
@ -1103,13 +1093,6 @@ class InterfaceResolver {
|
|||
}
|
||||
}
|
||||
|
||||
void recordContravariance(int fileOffset, bool isGenericContravariant) {
|
||||
if (isGenericContravariant) {
|
||||
_instrumentation.record(uri, fileOffset, 'genericContravariant',
|
||||
new InstrumentationValueLiteral('true'));
|
||||
}
|
||||
}
|
||||
|
||||
for (var procedure in class_.procedures) {
|
||||
if (procedure.isStatic) continue;
|
||||
// Forwarding stubs are annotated separately
|
||||
|
@ -1132,14 +1115,11 @@ class InterfaceResolver {
|
|||
procedure.function.positionalParameters.forEach(recordFormalAnnotations);
|
||||
procedure.function.namedParameters.forEach(recordFormalAnnotations);
|
||||
procedure.function.typeParameters.forEach(recordTypeParameterAnnotations);
|
||||
recordContravariance(
|
||||
procedure.fileOffset, procedure.isGenericContravariant);
|
||||
}
|
||||
for (var field in class_.fields) {
|
||||
if (field.isStatic) continue;
|
||||
recordCovariance(field.fileOffset, field.isCovariant,
|
||||
field.isGenericCovariantInterface, field.isGenericCovariantImpl);
|
||||
recordContravariance(field.fileOffset, field.isGenericContravariant);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1250,16 +1230,6 @@ class SyntheticAccessor extends Procedure {
|
|||
@override
|
||||
DartType get getterType => _field.type;
|
||||
|
||||
@override
|
||||
bool get isGenericContravariant =>
|
||||
kind == ProcedureKind.Getter && _field.isGenericContravariant;
|
||||
|
||||
@override
|
||||
void set isGenericContravariant(bool value) {
|
||||
assert(kind == ProcedureKind.Getter);
|
||||
_field.isGenericContravariant = value;
|
||||
}
|
||||
|
||||
static getField(SyntheticAccessor accessor) => accessor._field;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,8 @@ import 'interface_resolver.dart' show ForwardingNode, SyntheticAccessor;
|
|||
|
||||
import 'type_constraint_gatherer.dart' show TypeConstraintGatherer;
|
||||
|
||||
import 'type_inference_engine.dart' show TypeInferenceEngineImpl;
|
||||
import 'type_inference_engine.dart'
|
||||
show IncludesTypeParametersCovariantly, TypeInferenceEngineImpl;
|
||||
|
||||
import 'type_promotion.dart' show TypePromoter, TypePromoterDisabled;
|
||||
|
||||
|
@ -867,9 +868,12 @@ abstract class TypeInferrerImpl extends TypeInferrer {
|
|||
interfaceMember != null &&
|
||||
receiver is! ThisExpression) {
|
||||
if (interfaceMember is Procedure) {
|
||||
checkReturn = interfaceMember.isGenericContravariant;
|
||||
checkReturn = typeParametersOccurNegatively(
|
||||
interfaceMember.enclosingClass,
|
||||
interfaceMember.function.returnType);
|
||||
} else if (interfaceMember is Field) {
|
||||
checkReturn = interfaceMember.isGenericContravariant;
|
||||
checkReturn = typeParametersOccurNegatively(
|
||||
interfaceMember.enclosingClass, interfaceMember.type);
|
||||
}
|
||||
}
|
||||
var replacedExpression = desugaredGet ?? expression;
|
||||
|
@ -1397,6 +1401,19 @@ abstract class TypeInferrerImpl extends TypeInferrer {
|
|||
return tearoffType;
|
||||
}
|
||||
|
||||
/// True if [type] has negative occurrences of any of [class_]'s type
|
||||
/// parameters.
|
||||
///
|
||||
/// A negative occurrence of a type parameter is one that is to the left of
|
||||
/// an odd number of arrows. For example, T occurs negatively in T -> T0,
|
||||
/// T0 -> (T -> T1), (T0 -> T) -> T1 but not in (T -> T0) -> T1.
|
||||
static bool typeParametersOccurNegatively(Class class_, DartType type) {
|
||||
if (class_.typeParameters.isEmpty) return false;
|
||||
var checker = new IncludesTypeParametersCovariantly(class_.typeParameters)
|
||||
..inCovariantContext = false;
|
||||
return type.accept(checker);
|
||||
}
|
||||
|
||||
/// Determines the dispatch category of a [MethodInvocation] and returns a
|
||||
/// boolean indicating whether an "as" check will need to be added due to
|
||||
/// contravariance.
|
||||
|
@ -1416,16 +1433,19 @@ abstract class TypeInferrerImpl extends TypeInferrer {
|
|||
}
|
||||
if (receiver != null && receiver is! ThisExpression) {
|
||||
if ((interfaceMember is Field &&
|
||||
interfaceMember.isGenericContravariant) ||
|
||||
typeParametersOccurNegatively(
|
||||
interfaceMember.enclosingClass, interfaceMember.type)) ||
|
||||
(interfaceMember is Procedure &&
|
||||
interfaceMember.isGenericContravariant)) {
|
||||
typeParametersOccurNegatively(interfaceMember.enclosingClass,
|
||||
interfaceMember.function.returnType))) {
|
||||
return MethodContravarianceCheckKind.checkGetterReturn;
|
||||
}
|
||||
}
|
||||
} else if (receiver != null &&
|
||||
receiver is! ThisExpression &&
|
||||
interfaceMember is Procedure &&
|
||||
interfaceMember.isGenericContravariant) {
|
||||
typeParametersOccurNegatively(interfaceMember.enclosingClass,
|
||||
interfaceMember.function.returnType)) {
|
||||
return MethodContravarianceCheckKind.checkMethodReturn;
|
||||
}
|
||||
return MethodContravarianceCheckKind.none;
|
||||
|
|
|
@ -4,7 +4,7 @@ import "dart:core" as core;
|
|||
|
||||
typedef Function2<S extends core::Object, T extends core::Object> = (S) → T;
|
||||
class A<T extends core::Object> extends core::Object {
|
||||
generic-covariant-impl generic-covariant-interface generic-contravariant field (self::A::T) → self::A::T x;
|
||||
generic-covariant-impl generic-covariant-interface field (self::A::T) → self::A::T x;
|
||||
constructor •((self::A::T) → self::A::T x) → void
|
||||
: self::A::x = x, super core::Object::•()
|
||||
;
|
||||
|
|
|
@ -4,7 +4,7 @@ import "dart:core" as core;
|
|||
|
||||
typedef Function2<S extends core::Object, T extends core::Object> = (S) → T;
|
||||
class A<T extends core::Object> extends core::Object {
|
||||
generic-covariant-impl generic-covariant-interface generic-contravariant field (self::A::T) → self::A::T x;
|
||||
generic-covariant-impl generic-covariant-interface field (self::A::T) → self::A::T x;
|
||||
constructor •((self::A::T) → self::A::T x) → void
|
||||
: self::A::x = x, super core::Object::•()
|
||||
;
|
||||
|
|
|
@ -6,7 +6,7 @@ class C<T extends core::Object> extends core::Object {
|
|||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
generic-contravariant method f<U extends core::Object>(self::C::f::U x) → (self::C::T) → void
|
||||
method f<U extends core::Object>(self::C::f::U x) → (self::C::T) → void
|
||||
return (self::C::T y) → core::Null {};
|
||||
}
|
||||
static method test(self::C<core::String> c) → void {
|
||||
|
|
|
@ -6,7 +6,7 @@ class C<T extends core::Object> extends core::Object {
|
|||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
generic-contravariant method f<U extends core::Object>(self::C::f::U x) → (self::C::T) → void
|
||||
method f<U extends core::Object>(self::C::f::U x) → (self::C::T) → void
|
||||
return (self::C::T y) → core::Null {};
|
||||
}
|
||||
static method test(self::C<core::String> c) → void {
|
||||
|
|
|
@ -11,19 +11,19 @@ class Foo<T extends core::Object> extends core::Object {
|
|||
return new self::Bar::•<self::Foo::T>();
|
||||
get v2() → self::Bar<core::List<self::Foo::T>>
|
||||
return new self::Bar::•<core::List<self::Foo::T>>();
|
||||
generic-contravariant get v3() → self::Bar<(self::Foo::T) → self::Foo::T>
|
||||
get v3() → self::Bar<(self::Foo::T) → self::Foo::T>
|
||||
return new self::Bar::•<(self::Foo::T) → self::Foo::T>();
|
||||
generic-contravariant get v4() → self::Bar<((self::Foo::T) → self::Foo::T) → self::Foo::T>
|
||||
get v4() → self::Bar<((self::Foo::T) → self::Foo::T) → self::Foo::T>
|
||||
return new self::Bar::•<((self::Foo::T) → self::Foo::T) → self::Foo::T>();
|
||||
get v5() → core::List<self::Foo::T>
|
||||
return <self::Foo::T>[];
|
||||
generic-contravariant get v6() → core::List<(self::Foo::T) → self::Foo::T>
|
||||
get v6() → core::List<(self::Foo::T) → self::Foo::T>
|
||||
return <(self::Foo::T) → self::Foo::T>[];
|
||||
get v7() → core::Map<self::Foo::T, self::Foo::T>
|
||||
return <self::Foo::T, self::Foo::T>{};
|
||||
generic-contravariant get v8() → core::Map<(self::Foo::T) → self::Foo::T, self::Foo::T>
|
||||
get v8() → core::Map<(self::Foo::T) → self::Foo::T, self::Foo::T>
|
||||
return <(self::Foo::T) → self::Foo::T, self::Foo::T>{};
|
||||
generic-contravariant get v9() → core::Map<self::Foo::T, (self::Foo::T) → self::Foo::T>
|
||||
get v9() → core::Map<self::Foo::T, (self::Foo::T) → self::Foo::T>
|
||||
return <self::Foo::T, (self::Foo::T) → self::Foo::T>{};
|
||||
}
|
||||
class Bar<T extends core::Object> extends core::Object {
|
||||
|
|
|
@ -11,19 +11,19 @@ class Foo<T extends core::Object> extends core::Object {
|
|||
return new self::Bar::•<self::Foo::T>();
|
||||
get v2() → self::Bar<core::List<self::Foo::T>>
|
||||
return new self::Bar::•<core::List<self::Foo::T>>();
|
||||
generic-contravariant get v3() → self::Bar<(self::Foo::T) → self::Foo::T>
|
||||
get v3() → self::Bar<(self::Foo::T) → self::Foo::T>
|
||||
return new self::Bar::•<(self::Foo::T) → self::Foo::T>();
|
||||
generic-contravariant get v4() → self::Bar<((self::Foo::T) → self::Foo::T) → self::Foo::T>
|
||||
get v4() → self::Bar<((self::Foo::T) → self::Foo::T) → self::Foo::T>
|
||||
return new self::Bar::•<((self::Foo::T) → self::Foo::T) → self::Foo::T>();
|
||||
get v5() → core::List<self::Foo::T>
|
||||
return <self::Foo::T>[];
|
||||
generic-contravariant get v6() → core::List<(self::Foo::T) → self::Foo::T>
|
||||
get v6() → core::List<(self::Foo::T) → self::Foo::T>
|
||||
return <(self::Foo::T) → self::Foo::T>[];
|
||||
get v7() → core::Map<self::Foo::T, self::Foo::T>
|
||||
return <self::Foo::T, self::Foo::T>{};
|
||||
generic-contravariant get v8() → core::Map<(self::Foo::T) → self::Foo::T, self::Foo::T>
|
||||
get v8() → core::Map<(self::Foo::T) → self::Foo::T, self::Foo::T>
|
||||
return <(self::Foo::T) → self::Foo::T, self::Foo::T>{};
|
||||
generic-contravariant get v9() → core::Map<self::Foo::T, (self::Foo::T) → self::Foo::T>
|
||||
get v9() → core::Map<self::Foo::T, (self::Foo::T) → self::Foo::T>
|
||||
return <self::Foo::T, (self::Foo::T) → self::Foo::T>{};
|
||||
}
|
||||
class Bar<T extends core::Object> extends core::Object {
|
||||
|
|
|
@ -11,19 +11,19 @@ class Foo<T extends core::Object> extends core::Object {
|
|||
return const self::Bar::•<core::Null>();
|
||||
get v2() → self::Bar<core::List<self::Foo::T>>
|
||||
return const self::Bar::•<core::List<core::Null>>();
|
||||
generic-contravariant get v3() → self::Bar<(self::Foo::T) → self::Foo::T>
|
||||
get v3() → self::Bar<(self::Foo::T) → self::Foo::T>
|
||||
return const self::Bar::•<(core::Object) → core::Null>();
|
||||
generic-contravariant get v4() → self::Bar<((self::Foo::T) → self::Foo::T) → self::Foo::T>
|
||||
get v4() → self::Bar<((self::Foo::T) → self::Foo::T) → self::Foo::T>
|
||||
return const self::Bar::•<((core::Null) → core::Object) → core::Null>();
|
||||
get v5() → core::List<self::Foo::T>
|
||||
return const <core::Null>[];
|
||||
generic-contravariant get v6() → core::List<(self::Foo::T) → self::Foo::T>
|
||||
get v6() → core::List<(self::Foo::T) → self::Foo::T>
|
||||
return const <(core::Object) → core::Null>[];
|
||||
get v7() → core::Map<self::Foo::T, self::Foo::T>
|
||||
return const <core::Null, core::Null>{};
|
||||
generic-contravariant get v8() → core::Map<(self::Foo::T) → self::Foo::T, self::Foo::T>
|
||||
get v8() → core::Map<(self::Foo::T) → self::Foo::T, self::Foo::T>
|
||||
return const <(core::Object) → core::Null, core::Null>{};
|
||||
generic-contravariant get v9() → core::Map<self::Foo::T, (self::Foo::T) → self::Foo::T>
|
||||
get v9() → core::Map<self::Foo::T, (self::Foo::T) → self::Foo::T>
|
||||
return const <core::Null, (core::Object) → core::Null>{};
|
||||
}
|
||||
class Bar<T extends core::Object> extends core::Object {
|
||||
|
|
|
@ -11,19 +11,19 @@ class Foo<T extends core::Object> extends core::Object {
|
|||
return const self::Bar::•<core::Null>();
|
||||
get v2() → self::Bar<core::List<self::Foo::T>>
|
||||
return const self::Bar::•<core::List<core::Null>>();
|
||||
generic-contravariant get v3() → self::Bar<(self::Foo::T) → self::Foo::T>
|
||||
get v3() → self::Bar<(self::Foo::T) → self::Foo::T>
|
||||
return const self::Bar::•<(core::Object) → core::Null>();
|
||||
generic-contravariant get v4() → self::Bar<((self::Foo::T) → self::Foo::T) → self::Foo::T>
|
||||
get v4() → self::Bar<((self::Foo::T) → self::Foo::T) → self::Foo::T>
|
||||
return const self::Bar::•<((core::Null) → core::Object) → core::Null>();
|
||||
get v5() → core::List<self::Foo::T>
|
||||
return const <core::Null>[];
|
||||
generic-contravariant get v6() → core::List<(self::Foo::T) → self::Foo::T>
|
||||
get v6() → core::List<(self::Foo::T) → self::Foo::T>
|
||||
return const <(core::Object) → core::Null>[];
|
||||
get v7() → core::Map<self::Foo::T, self::Foo::T>
|
||||
return const <core::Null, core::Null>{};
|
||||
generic-contravariant get v8() → core::Map<(self::Foo::T) → self::Foo::T, self::Foo::T>
|
||||
get v8() → core::Map<(self::Foo::T) → self::Foo::T, self::Foo::T>
|
||||
return const <(core::Object) → core::Null, core::Null>{};
|
||||
generic-contravariant get v9() → core::Map<self::Foo::T, (self::Foo::T) → self::Foo::T>
|
||||
get v9() → core::Map<self::Foo::T, (self::Foo::T) → self::Foo::T>
|
||||
return const <core::Null, (core::Object) → core::Null>{};
|
||||
}
|
||||
class Bar<T extends core::Object> extends core::Object {
|
||||
|
|
|
@ -4,7 +4,7 @@ import "dart:core" as core;
|
|||
|
||||
typedef A<T extends core::Object> = (T) → dynamic;
|
||||
class B<S extends core::Object> extends core::Object {
|
||||
generic-contravariant final field core::List<(self::B::S) → dynamic> foo = <(self::B::S) → dynamic>[];
|
||||
final field core::List<(self::B::S) → dynamic> foo = <(self::B::S) → dynamic>[];
|
||||
final field core::List<(core::num) → dynamic> bar = <(core::num) → dynamic>[];
|
||||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
|
|
|
@ -4,7 +4,7 @@ import "dart:core" as core;
|
|||
|
||||
typedef A<T extends core::Object> = (T) → dynamic;
|
||||
class B<S extends core::Object> extends core::Object {
|
||||
generic-contravariant final field core::List<(self::B::S) → dynamic> foo = <(self::B::S) → dynamic>[];
|
||||
final field core::List<(self::B::S) → dynamic> foo = <(self::B::S) → dynamic>[];
|
||||
final field core::List<(core::num) → dynamic> bar = <(core::num) → dynamic>[];
|
||||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
|
|
|
@ -8,7 +8,7 @@ library test;
|
|||
typedef void F<T>(T x);
|
||||
|
||||
class C<T> {
|
||||
F<T> /*@genericContravariant=true*/ y;
|
||||
F<T> y;
|
||||
void f() {
|
||||
var x = this.y;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import "dart:core" as core;
|
|||
|
||||
typedef F<T extends core::Object> = (T) → void;
|
||||
class C<T extends core::Object> extends core::Object {
|
||||
generic-contravariant field (self::C::T) → void y = null;
|
||||
field (self::C::T) → void y = null;
|
||||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
|
|
|
@ -4,7 +4,7 @@ import "dart:core" as core;
|
|||
|
||||
typedef F<T extends core::Object> = (T) → void;
|
||||
class C<T extends core::Object> extends core::Object {
|
||||
generic-contravariant field (self::C::T) → void y = null;
|
||||
field (self::C::T) → void y = null;
|
||||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
|
|
|
@ -8,8 +8,8 @@ library test;
|
|||
typedef void F<T>(T x);
|
||||
|
||||
class C<T> {
|
||||
F<T> /*@genericContravariant=true*/ f1() {}
|
||||
List<F<T>> /*@genericContravariant=true*/ f2() {
|
||||
F<T> f1() {}
|
||||
List<F<T>> f2() {
|
||||
return [this.f1()];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ class C<T extends core::Object> extends core::Object {
|
|||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
generic-contravariant method f1() → (self::C::T) → void {}
|
||||
generic-contravariant method f2() → core::List<(self::C::T) → void> {
|
||||
method f1() → (self::C::T) → void {}
|
||||
method f2() → core::List<(self::C::T) → void> {
|
||||
return <(self::C::T) → void>[this.{self::C::f1}()];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ class C<T extends core::Object> extends core::Object {
|
|||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
generic-contravariant method f1() → (self::C::T) → void {}
|
||||
generic-contravariant method f2() → core::List<(self::C::T) → void> {
|
||||
method f1() → (self::C::T) → void {}
|
||||
method f2() → core::List<(self::C::T) → void> {
|
||||
return <(self::C::T) → void>[this.{self::C::f1}()];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ library test;
|
|||
typedef void F<T>(T x);
|
||||
|
||||
class C<T> {
|
||||
F<T> /*@genericContravariant=true*/ f1() {}
|
||||
List<F<T>> /*@genericContravariant=true*/ f2() {
|
||||
F<T> f1() {}
|
||||
List<F<T>> f2() {
|
||||
return [this?.f1()];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ class C<T extends core::Object> extends core::Object {
|
|||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
generic-contravariant method f1() → (self::C::T) → void {}
|
||||
generic-contravariant method f2() → core::List<(self::C::T) → void> {
|
||||
method f1() → (self::C::T) → void {}
|
||||
method f2() → core::List<(self::C::T) → void> {
|
||||
return <(self::C::T) → void>[this.{self::C::f1}()];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ class C<T extends core::Object> extends core::Object {
|
|||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
generic-contravariant method f1() → (self::C::T) → void {}
|
||||
generic-contravariant method f2() → core::List<(self::C::T) → void> {
|
||||
method f1() → (self::C::T) → void {}
|
||||
method f2() → core::List<(self::C::T) → void> {
|
||||
return <(self::C::T) → void>[this.{self::C::f1}()];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ typedef void F<T>(T x);
|
|||
typedef F<T> G<T>();
|
||||
|
||||
class C<T> {
|
||||
F<T> /*@genericContravariant=true*/ _x;
|
||||
F<T> _x;
|
||||
C(this._x);
|
||||
F<T> /*@genericContravariant=true*/ f() => _x;
|
||||
F<T> f() => _x;
|
||||
}
|
||||
|
||||
G<num> g(C<num> c) {
|
||||
|
|
|
@ -5,11 +5,11 @@ import "dart:core" as core;
|
|||
typedef F<T extends core::Object> = (T) → void;
|
||||
typedef G<T extends core::Object> = () → (T) → void;
|
||||
class C<T extends core::Object> extends core::Object {
|
||||
generic-contravariant field (self::C::T) → void _x;
|
||||
field (self::C::T) → void _x;
|
||||
constructor •((self::C::T) → void _x) → void
|
||||
: self::C::_x = _x, super core::Object::•()
|
||||
;
|
||||
generic-contravariant method f() → (self::C::T) → void
|
||||
method f() → (self::C::T) → void
|
||||
return this.{self::C::_x};
|
||||
}
|
||||
static method g(self::C<core::num> c) → () → (core::num) → void {
|
||||
|
|
|
@ -5,11 +5,11 @@ import "dart:core" as core;
|
|||
typedef F<T extends core::Object> = (T) → void;
|
||||
typedef G<T extends core::Object> = () → (T) → void;
|
||||
class C<T extends core::Object> extends core::Object {
|
||||
generic-contravariant field (self::C::T) → void _x;
|
||||
field (self::C::T) → void _x;
|
||||
constructor •((self::C::T) → void _x) → void
|
||||
: self::C::_x = _x, super core::Object::•()
|
||||
;
|
||||
generic-contravariant method f() → (self::C::T) → void
|
||||
method f() → (self::C::T) → void
|
||||
return this.{self::C::_x};
|
||||
}
|
||||
static method g(self::C<core::num> c) → () → (core::num) → void {
|
||||
|
|
|
@ -8,7 +8,7 @@ library test;
|
|||
typedef void F<T>(T x);
|
||||
|
||||
class C<T> {
|
||||
F<T> /*@genericContravariant=true*/ y;
|
||||
F<T> y;
|
||||
void f(T /*@covariance=genericInterface, genericImpl*/ value) {
|
||||
this.y(value);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import "dart:core" as core;
|
|||
|
||||
typedef F<T extends core::Object> = (T) → void;
|
||||
class C<T extends core::Object> extends core::Object {
|
||||
generic-contravariant field (self::C::T) → void y = null;
|
||||
field (self::C::T) → void y = null;
|
||||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
|
|
|
@ -4,7 +4,7 @@ import "dart:core" as core;
|
|||
|
||||
typedef F<T extends core::Object> = (T) → void;
|
||||
class C<T extends core::Object> extends core::Object {
|
||||
generic-contravariant field (self::C::T) → void y = null;
|
||||
field (self::C::T) → void y = null;
|
||||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
|
|
|
@ -8,8 +8,8 @@ library test;
|
|||
typedef void F<T>(T x);
|
||||
|
||||
class C<T> {
|
||||
F<T> get /*@genericContravariant=true*/ f1 => null;
|
||||
List<F<T>> get /*@genericContravariant=true*/ f2 {
|
||||
F<T> get f1 => null;
|
||||
List<F<T>> get f2 {
|
||||
return [this.f1];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@ class C<T extends core::Object> extends core::Object {
|
|||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
generic-contravariant get f1() → (self::C::T) → void
|
||||
get f1() → (self::C::T) → void
|
||||
return null;
|
||||
generic-contravariant get f2() → core::List<(self::C::T) → void> {
|
||||
get f2() → core::List<(self::C::T) → void> {
|
||||
return <(self::C::T) → void>[this.{self::C::f1}];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@ class C<T extends core::Object> extends core::Object {
|
|||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
generic-contravariant get f1() → (self::C::T) → void
|
||||
get f1() → (self::C::T) → void
|
||||
return null;
|
||||
generic-contravariant get f2() → core::List<(self::C::T) → void> {
|
||||
get f2() → core::List<(self::C::T) → void> {
|
||||
return <(self::C::T) → void>[this.{self::C::f1}];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ library test;
|
|||
typedef void F<T>(T x);
|
||||
|
||||
class C<T> {
|
||||
F<T> get /*@genericContravariant=true*/ f1 => null;
|
||||
List<F<T>> get /*@genericContravariant=true*/ f2 {
|
||||
F<T> get f1 => null;
|
||||
List<F<T>> get f2 {
|
||||
return [this?.f1];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@ class C<T extends core::Object> extends core::Object {
|
|||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
generic-contravariant get f1() → (self::C::T) → void
|
||||
get f1() → (self::C::T) → void
|
||||
return null;
|
||||
generic-contravariant get f2() → core::List<(self::C::T) → void> {
|
||||
get f2() → core::List<(self::C::T) → void> {
|
||||
return <(self::C::T) → void>[this.{self::C::f1}];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@ class C<T extends core::Object> extends core::Object {
|
|||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
generic-contravariant get f1() → (self::C::T) → void
|
||||
get f1() → (self::C::T) → void
|
||||
return null;
|
||||
generic-contravariant get f2() → core::List<(self::C::T) → void> {
|
||||
get f2() → core::List<(self::C::T) → void> {
|
||||
return <(self::C::T) → void>[this.{self::C::f1}];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,27 +22,27 @@ class C<T> {
|
|||
c.f(x);
|
||||
}
|
||||
|
||||
F<T> /*@genericContravariant=true*/ g4() => this.f;
|
||||
F<T> g4() => this.f;
|
||||
}
|
||||
|
||||
class
|
||||
/*@forwardingStub=abstract void f(covariance=(genericImpl) int x)*/
|
||||
/*@forwardingStub=abstract void g1(covariance=(genericImpl) int x)*/
|
||||
/*@forwardingStub=abstract void g2(covariance=(genericImpl) int x)*/
|
||||
/*@forwardingStub=abstract (int) -> dynamic g4()*/
|
||||
/*@forwardingStub=abstract void g3(covariance=(genericImpl) C<int> c, covariance=(genericImpl) int x)*/
|
||||
|
||||
D extends C<int> {}
|
||||
|
||||
class /*@forwardingStub=abstract void g1(covariance=(genericImpl) num x)*/
|
||||
/*@forwardingStub=abstract void g2(covariance=(genericImpl) num x)*/
|
||||
/*@forwardingStub=abstract (num) -> dynamic g4()*/
|
||||
/*@forwardingStub=abstract void g3(covariance=(genericImpl) C<num> c, covariance=(genericImpl) num x)*/
|
||||
|
||||
E extends C<num> {
|
||||
void f(covariant int /*@covariance=explicit*/ x) {}
|
||||
}
|
||||
|
||||
test() {
|
||||
var x = new D().g4() as F<Object>;
|
||||
var x = new D().g4 /*@checkReturn=(int) -> dynamic*/ () as F<Object>;
|
||||
x('hi');
|
||||
new E().g1(1.5);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class C<T extends core::Object> extends core::Object {
|
|||
method g3(generic-covariant-impl generic-covariant-interface self::C<self::C::T> c, generic-covariant-impl generic-covariant-interface self::C::T x) → void {
|
||||
c.{self::C::f}(x);
|
||||
}
|
||||
generic-contravariant method g4() → (self::C::T) → dynamic
|
||||
method g4() → (self::C::T) → dynamic
|
||||
return this.{self::C::f};
|
||||
}
|
||||
class D extends self::C<core::int> {
|
||||
|
@ -27,7 +27,6 @@ class D extends self::C<core::int> {
|
|||
abstract forwarding-stub method f(generic-covariant-impl core::int x) → void;
|
||||
abstract forwarding-stub method g1(generic-covariant-impl core::int x) → void;
|
||||
abstract forwarding-stub method g2(generic-covariant-impl core::int x) → void;
|
||||
abstract forwarding-stub method g4() → (core::int) → dynamic;
|
||||
abstract forwarding-stub method g3(generic-covariant-impl self::C<core::int> c, generic-covariant-impl core::int x) → void;
|
||||
}
|
||||
class E extends self::C<core::num> {
|
||||
|
@ -37,11 +36,10 @@ class E extends self::C<core::num> {
|
|||
method f(covariant generic-covariant-impl core::int x) → void {}
|
||||
abstract forwarding-stub method g1(generic-covariant-impl core::num x) → void;
|
||||
abstract forwarding-stub method g2(generic-covariant-impl core::num x) → void;
|
||||
abstract forwarding-stub method g4() → (core::num) → dynamic;
|
||||
abstract forwarding-stub method g3(generic-covariant-impl self::C<core::num> c, generic-covariant-impl core::num x) → void;
|
||||
}
|
||||
static method test() → dynamic {
|
||||
(core::Object) → dynamic x = new self::D::•().{self::D::g4}() as (core::Object) → dynamic;
|
||||
(core::Object) → dynamic x = (new self::D::•().{self::C::g4}() as{TypeError} (core::int) → dynamic) as (core::Object) → dynamic;
|
||||
x.call("hi");
|
||||
new self::E::•().{self::E::g1}(1.5);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class C<T extends core::Object> extends core::Object {
|
|||
method g3(generic-covariant-impl generic-covariant-interface self::C<self::C::T> c, generic-covariant-impl generic-covariant-interface self::C::T x) → void {
|
||||
c.{self::C::f}(x);
|
||||
}
|
||||
generic-contravariant method g4() → (self::C::T) → dynamic
|
||||
method g4() → (self::C::T) → dynamic
|
||||
return this.{self::C::f};
|
||||
}
|
||||
class D extends self::C<core::int> {
|
||||
|
@ -27,7 +27,6 @@ class D extends self::C<core::int> {
|
|||
abstract forwarding-stub method f(generic-covariant-impl core::int x) → void;
|
||||
abstract forwarding-stub method g1(generic-covariant-impl core::int x) → void;
|
||||
abstract forwarding-stub method g2(generic-covariant-impl core::int x) → void;
|
||||
abstract forwarding-stub method g4() → (core::int) → dynamic;
|
||||
abstract forwarding-stub method g3(generic-covariant-impl self::C<core::int> c, generic-covariant-impl core::int x) → void;
|
||||
}
|
||||
class E extends self::C<core::num> {
|
||||
|
@ -37,11 +36,10 @@ class E extends self::C<core::num> {
|
|||
method f(covariant generic-covariant-impl core::int x) → void {}
|
||||
abstract forwarding-stub method g1(generic-covariant-impl core::num x) → void;
|
||||
abstract forwarding-stub method g2(generic-covariant-impl core::num x) → void;
|
||||
abstract forwarding-stub method g4() → (core::num) → dynamic;
|
||||
abstract forwarding-stub method g3(generic-covariant-impl self::C<core::num> c, generic-covariant-impl core::num x) → void;
|
||||
}
|
||||
static method test() → dynamic {
|
||||
(core::Object) → dynamic x = new self::D::•().{self::D::g4}() as (core::Object) → dynamic;
|
||||
(core::Object) → dynamic x = (new self::D::•().{self::C::g4}() as{TypeError} (core::int) → dynamic) as (core::Object) → dynamic;
|
||||
x.call("hi");
|
||||
new self::E::•().{self::E::g1}(1.5);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ library test;
|
|||
typedef void F<T>(T x);
|
||||
|
||||
class B<T, U extends F<T>> {
|
||||
B<T, F<T>> operator /*@genericContravariant=true*/ +(other) => null;
|
||||
B<T, F<T>> operator +(other) => null;
|
||||
}
|
||||
|
||||
class C {
|
||||
|
|
|
@ -7,7 +7,7 @@ class B<T extends core::Object, U extends (self::B::T) → void> extends core::O
|
|||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
generic-contravariant operator +(dynamic other) → self::B<self::B::T, (self::B::T) → void>
|
||||
operator +(dynamic other) → self::B<self::B::T, (self::B::T) → void>
|
||||
return null;
|
||||
}
|
||||
class C extends core::Object {
|
||||
|
|
|
@ -7,7 +7,7 @@ class B<T extends core::Object, U extends (self::B::T) → void> extends core::O
|
|||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
generic-contravariant operator +(dynamic other) → self::B<self::B::T, (self::B::T) → void>
|
||||
operator +(dynamic other) → self::B<self::B::T, (self::B::T) → void>
|
||||
return null;
|
||||
}
|
||||
class C extends core::Object {
|
||||
|
|
|
@ -20,9 +20,8 @@ void expect(Object value, Object expected) {
|
|||
|
||||
class C<T> {
|
||||
C(this.plusResult);
|
||||
final num Function(T) /*@genericContravariant=true*/ plusResult;
|
||||
num Function(T) operator /*@genericContravariant=true*/ +(int i) =>
|
||||
plusResult;
|
||||
final num Function(T) plusResult;
|
||||
num Function(T) operator +(int i) => plusResult;
|
||||
}
|
||||
|
||||
class D {
|
||||
|
|
|
@ -3,11 +3,11 @@ import self as self;
|
|||
import "dart:core" as core;
|
||||
|
||||
class C<T extends core::Object> extends core::Object {
|
||||
generic-contravariant final field (self::C::T) → core::num plusResult;
|
||||
final field (self::C::T) → core::num plusResult;
|
||||
constructor •((self::C::T) → core::num plusResult) → void
|
||||
: self::C::plusResult = plusResult, super core::Object::•()
|
||||
;
|
||||
generic-contravariant operator +(core::int i) → (self::C::T) → core::num
|
||||
operator +(core::int i) → (self::C::T) → core::num
|
||||
return this.{self::C::plusResult};
|
||||
}
|
||||
class D extends core::Object {
|
||||
|
@ -41,14 +41,14 @@ static method numToNum(core::num n) → core::num
|
|||
return 2;
|
||||
static method main() → void {
|
||||
self::D d = new self::D::•(new self::C::•<core::num>(self::numToInt));
|
||||
let final self::D #t1 = d in #t1.{self::D::value} = let final dynamic #t2 = let dynamic _ = null in invalid-expression "pkg/front_end/testcases/runtime_checks_new/contravariant_generic_return_with_compound_assign_implicit_downcast.dart:50:41: Error: A value of type '(dart.core::num) \u8594 dart.core::num' can't be assigned to a variable of type '(dart.core::int) \u8594 dart.core::int'.
|
||||
let final self::D #t1 = d in #t1.{self::D::value} = let final dynamic #t2 = let dynamic _ = null in invalid-expression "pkg/front_end/testcases/runtime_checks_new/contravariant_generic_return_with_compound_assign_implicit_downcast.dart:49:41: Error: A value of type '(dart.core::num) \u8594 dart.core::num' can't be assigned to a variable of type '(dart.core::int) \u8594 dart.core::int'.
|
||||
Try changing the type of the left hand side, or casting the right hand side to '(dart.core::int) \u8594 dart.core::int'.
|
||||
d.value /*@checkReturn=(num) -> num*/ += 1;
|
||||
^" in let final dynamic #t3 = #t1.{self::D::value}.{self::C::+}(1) as{TypeError} (core::num) → core::num in null;
|
||||
self::expect(d.{self::D::setValue}(0), 1);
|
||||
d = new self::D::•(new self::C::•<core::num>(self::numToNum));
|
||||
self::expectTypeError(() → core::Null {
|
||||
let final self::D #t4 = d in #t4.{self::D::value} = let final dynamic #t5 = let dynamic _ = null in invalid-expression "pkg/front_end/testcases/runtime_checks_new/contravariant_generic_return_with_compound_assign_implicit_downcast.dart:54:43: Error: A value of type '(dart.core::num) \u8594 dart.core::num' can't be assigned to a variable of type '(dart.core::int) \u8594 dart.core::int'.
|
||||
let final self::D #t4 = d in #t4.{self::D::value} = let final dynamic #t5 = let dynamic _ = null in invalid-expression "pkg/front_end/testcases/runtime_checks_new/contravariant_generic_return_with_compound_assign_implicit_downcast.dart:53:43: Error: A value of type '(dart.core::num) \u8594 dart.core::num' can't be assigned to a variable of type '(dart.core::int) \u8594 dart.core::int'.
|
||||
Try changing the type of the left hand side, or casting the right hand side to '(dart.core::int) \u8594 dart.core::int'.
|
||||
d.value /*@checkReturn=(num) -> num*/ += 1;
|
||||
^" in let final dynamic #t6 = #t4.{self::D::value}.{self::C::+}(1) as{TypeError} (core::num) → core::num in null;
|
||||
|
|
|
@ -3,11 +3,11 @@ import self as self;
|
|||
import "dart:core" as core;
|
||||
|
||||
class C<T extends core::Object> extends core::Object {
|
||||
generic-contravariant final field (self::C::T) → core::num plusResult;
|
||||
final field (self::C::T) → core::num plusResult;
|
||||
constructor •((self::C::T) → core::num plusResult) → void
|
||||
: self::C::plusResult = plusResult, super core::Object::•()
|
||||
;
|
||||
generic-contravariant operator +(core::int i) → (self::C::T) → core::num
|
||||
operator +(core::int i) → (self::C::T) → core::num
|
||||
return this.{self::C::plusResult};
|
||||
}
|
||||
class D extends core::Object {
|
||||
|
@ -41,14 +41,14 @@ static method numToNum(core::num n) → core::num
|
|||
return 2;
|
||||
static method main() → void {
|
||||
self::D d = new self::D::•(new self::C::•<core::num>(self::numToInt));
|
||||
let final self::D #t1 = d in #t1.{self::D::value} = let final dynamic #t2 = let<BottomType> _ = null in invalid-expression "pkg/front_end/testcases/runtime_checks_new/contravariant_generic_return_with_compound_assign_implicit_downcast.dart:50:41: Error: A value of type '(dart.core::num) \u8594 dart.core::num' can't be assigned to a variable of type '(dart.core::int) \u8594 dart.core::int'.
|
||||
let final self::D #t1 = d in #t1.{self::D::value} = let final dynamic #t2 = let<BottomType> _ = null in invalid-expression "pkg/front_end/testcases/runtime_checks_new/contravariant_generic_return_with_compound_assign_implicit_downcast.dart:49:41: Error: A value of type '(dart.core::num) \u8594 dart.core::num' can't be assigned to a variable of type '(dart.core::int) \u8594 dart.core::int'.
|
||||
Try changing the type of the left hand side, or casting the right hand side to '(dart.core::int) \u8594 dart.core::int'.
|
||||
d.value /*@checkReturn=(num) -> num*/ += 1;
|
||||
^" in let final (core::num) → core::num #t3 = #t1.{self::D::value}.{self::C::+}(1) as{TypeError} (core::num) → core::num in null;
|
||||
self::expect(d.{self::D::setValue}(0), 1);
|
||||
d = new self::D::•(new self::C::•<core::num>(self::numToNum));
|
||||
self::expectTypeError(() → core::Null {
|
||||
let final self::D #t4 = d in #t4.{self::D::value} = let final dynamic #t5 = let<BottomType> _ = null in invalid-expression "pkg/front_end/testcases/runtime_checks_new/contravariant_generic_return_with_compound_assign_implicit_downcast.dart:54:43: Error: A value of type '(dart.core::num) \u8594 dart.core::num' can't be assigned to a variable of type '(dart.core::int) \u8594 dart.core::int'.
|
||||
let final self::D #t4 = d in #t4.{self::D::value} = let final dynamic #t5 = let<BottomType> _ = null in invalid-expression "pkg/front_end/testcases/runtime_checks_new/contravariant_generic_return_with_compound_assign_implicit_downcast.dart:53:43: Error: A value of type '(dart.core::num) \u8594 dart.core::num' can't be assigned to a variable of type '(dart.core::int) \u8594 dart.core::int'.
|
||||
Try changing the type of the left hand side, or casting the right hand side to '(dart.core::int) \u8594 dart.core::int'.
|
||||
d.value /*@checkReturn=(num) -> num*/ += 1;
|
||||
^" in let final (core::num) → core::num #t6 = #t4.{self::D::value}.{self::C::+}(1) as{TypeError} (core::num) → core::num in null;
|
||||
|
|
|
@ -13,7 +13,7 @@ class B<T> {
|
|||
}
|
||||
|
||||
class C<T> {
|
||||
B<F<T>> get /*@genericContravariant=true*/ x => null;
|
||||
B<F<T>> get x => null;
|
||||
void set x(B<F<T>> value) {}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ class C<T extends core::Object> extends core::Object {
|
|||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
generic-contravariant get x() → self::B<(self::C::T) → void>
|
||||
get x() → self::B<(self::C::T) → void>
|
||||
return null;
|
||||
set x(self::B<(self::C::T) → void> value) → void {}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class C<T extends core::Object> extends core::Object {
|
|||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
generic-contravariant get x() → self::B<(self::C::T) → void>
|
||||
get x() → self::B<(self::C::T) → void>
|
||||
return null;
|
||||
set x(self::B<(self::C::T) → void> value) → void {}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class B<T> {
|
|||
}
|
||||
|
||||
class C<T> {
|
||||
B<F<T>> operator /*@genericContravariant=true*/ [](int i) => null;
|
||||
B<F<T>> operator [](int i) => null;
|
||||
void operator []=(int i, B<F<T>> x) {}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ class C<T extends core::Object> extends core::Object {
|
|||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
generic-contravariant operator [](core::int i) → self::B<(self::C::T) → void>
|
||||
operator [](core::int i) → self::B<(self::C::T) → void>
|
||||
return null;
|
||||
operator []=(core::int i, self::B<(self::C::T) → void> x) → void {}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ class C<T extends core::Object> extends core::Object {
|
|||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
generic-contravariant operator [](core::int i) → self::B<(self::C::T) → void>
|
||||
operator [](core::int i) → self::B<(self::C::T) → void>
|
||||
return null;
|
||||
operator []=(core::int i, self::B<(self::C::T) → void> x) → void {}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ library test;
|
|||
typedef void F<T>(T x);
|
||||
|
||||
class C<T> {
|
||||
F<T> operator /*@genericContravariant=true*/ [](int i) => null;
|
||||
F<T> operator [](int i) => null;
|
||||
}
|
||||
|
||||
F<num> test(C<num> c) {
|
||||
|
|
|
@ -7,7 +7,7 @@ class C<T extends core::Object> extends core::Object {
|
|||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
generic-contravariant operator [](core::int i) → (self::C::T) → void
|
||||
operator [](core::int i) → (self::C::T) → void
|
||||
return null;
|
||||
}
|
||||
static method test(self::C<core::num> c) → (core::num) → void {
|
||||
|
|
|
@ -7,7 +7,7 @@ class C<T extends core::Object> extends core::Object {
|
|||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
generic-contravariant operator [](core::int i) → (self::C::T) → void
|
||||
operator [](core::int i) → (self::C::T) → void
|
||||
return null;
|
||||
}
|
||||
static method test(self::C<core::num> c) → (core::num) → void {
|
||||
|
|
|
@ -31,7 +31,7 @@ class B {
|
|||
}
|
||||
|
||||
abstract class I<T> {
|
||||
F<T> get /*@genericContravariant=true*/ x;
|
||||
F<T> get x;
|
||||
void set x(Object value);
|
||||
}
|
||||
|
||||
|
@ -44,10 +44,7 @@ abstract class M<T> {
|
|||
T f();
|
||||
}
|
||||
|
||||
abstract class
|
||||
/*@forwardingStub=abstract genericContravariant (C::T) -> void f()*/
|
||||
/*@forwardingStub=abstract genericContravariant (C::T) -> void get x()*/
|
||||
C<T> = B with M<F<T>> implements I<T>;
|
||||
abstract class C<T> = B with M<F<T>> implements I<T>;
|
||||
|
||||
class D extends C<int> {
|
||||
F<int> f() => (int i) {
|
||||
|
|
|
@ -18,7 +18,7 @@ abstract class I<T extends core::Object> extends core::Object {
|
|||
synthetic constructor •() → void
|
||||
: super core::Object::•()
|
||||
;
|
||||
abstract generic-contravariant get x() → (self::I::T) → void;
|
||||
abstract get x() → (self::I::T) → void;
|
||||
abstract set x(core::Object value) → void;
|
||||
}
|
||||
abstract class M<T extends core::Object> extends core::Object {
|
||||
|
@ -36,8 +36,6 @@ abstract class C<T extends core::Object> = self::B with self::M<(self::C::T) →
|
|||
synthetic constructor •() → void
|
||||
: super self::B::•()
|
||||
;
|
||||
abstract forwarding-stub generic-contravariant method f() → (self::C::T) → void;
|
||||
abstract forwarding-stub generic-contravariant get x() → (self::C::T) → void;
|
||||
}
|
||||
class D extends self::C<core::int> {
|
||||
synthetic constructor •() → void
|
||||
|
|
|
@ -16,7 +16,7 @@ abstract class I<T> {
|
|||
}
|
||||
|
||||
class
|
||||
/*@forwardingStub=abstract genericContravariant (C::T) -> void f(covariance=() Object x)*/
|
||||
/*@forwardingStub=abstract (C::T) -> void f(covariance=() Object x)*/
|
||||
C<T> extends B<F<T>> implements I<F<T>> {}
|
||||
|
||||
void main() {}
|
||||
|
|
|
@ -19,6 +19,6 @@ class C<T extends core::Object> extends self::B<(self::C::T) → void> implement
|
|||
synthetic constructor •() → void
|
||||
: super self::B::•()
|
||||
;
|
||||
abstract forwarding-stub generic-contravariant method f(core::Object x) → (self::C::T) → void;
|
||||
abstract forwarding-stub method f(core::Object x) → (self::C::T) → void;
|
||||
}
|
||||
static method main() → void {}
|
||||
|
|
|
@ -314,7 +314,6 @@ type Field extends Member {
|
|||
FileOffset fileEndOffset;
|
||||
Byte flags (isFinal, isConst, isStatic, hasImplicitGetter, hasImplicitSetter,
|
||||
isCovariant, isGenericCovariantImpl, isGenericCovariantInterface);
|
||||
Byte flags2 (isGenericContravariant);
|
||||
Name name;
|
||||
List<Expression> annotations;
|
||||
DartType type;
|
||||
|
@ -353,9 +352,9 @@ type Procedure extends Member {
|
|||
FileOffset fileEndOffset;
|
||||
Byte kind; // Index into the ProcedureKind enum above.
|
||||
Byte flags (isStatic, isAbstract, isExternal, isConst, isForwardingStub,
|
||||
isGenericContravariant, isForwardingSemiStub,
|
||||
isRedirectingFactoryConstructor);
|
||||
Byte flags2 (isNoSuchMethodForwarder);
|
||||
isForwardingSemiStub,
|
||||
isRedirectingFactoryConstructor,
|
||||
isNoSuchMethodForwarder);
|
||||
Name name;
|
||||
List<Expression> annotations;
|
||||
// Only present if the 'isForwardingStub' flag is set.
|
||||
|
|
|
@ -1039,7 +1039,6 @@ abstract class Member extends NamedNode implements FileUriNode {
|
|||
class Field extends Member {
|
||||
DartType type; // Not null. Defaults to DynamicType.
|
||||
int flags = 0;
|
||||
int flags2 = 0;
|
||||
Expression initializer; // May be null.
|
||||
|
||||
Field(Name name,
|
||||
|
@ -1075,9 +1074,6 @@ class Field extends Member {
|
|||
static const int FlagGenericCovariantImpl = 1 << 6;
|
||||
static const int FlagGenericCovariantInterface = 1 << 7;
|
||||
|
||||
// Must match serialized bit positions
|
||||
static const int Flag2GenericContravariant = 1 << 0;
|
||||
|
||||
/// Whether the field is declared with the `covariant` keyword.
|
||||
bool get isCovariant => flags & FlagCovariant != 0;
|
||||
|
||||
|
@ -1120,14 +1116,6 @@ class Field extends Member {
|
|||
bool get isGenericCovariantInterface =>
|
||||
flags & FlagGenericCovariantInterface != 0;
|
||||
|
||||
/// Indicates whether getter invocations using this interface target may need
|
||||
/// to perform a runtime type check to deal with generic covariance.
|
||||
///
|
||||
/// Note that the appropriate runtime checks are inserted by the front end, so
|
||||
/// back ends need not consult this flag; this flag exists merely to reduce
|
||||
/// front end computational overhead.
|
||||
bool get isGenericContravariant => flags2 & Flag2GenericContravariant != 0;
|
||||
|
||||
void set isCovariant(bool value) {
|
||||
flags = value ? (flags | FlagCovariant) : (flags & ~FlagCovariant);
|
||||
}
|
||||
|
@ -1168,12 +1156,6 @@ class Field extends Member {
|
|||
: (flags & ~FlagGenericCovariantInterface);
|
||||
}
|
||||
|
||||
void set isGenericContravariant(bool value) {
|
||||
flags2 = value
|
||||
? (flags2 | Flag2GenericContravariant)
|
||||
: (flags2 & ~Flag2GenericContravariant);
|
||||
}
|
||||
|
||||
/// True if the field is neither final nor const.
|
||||
bool get isMutable => flags & (FlagFinal | FlagConst) == 0;
|
||||
bool get isInstanceMember => !isStatic;
|
||||
|
@ -1450,7 +1432,6 @@ class RedirectingFactoryConstructor extends Member {
|
|||
class Procedure extends Member {
|
||||
ProcedureKind kind;
|
||||
int flags = 0;
|
||||
int flags2 = 0;
|
||||
// function is null if and only if abstract, external.
|
||||
FunctionNode function;
|
||||
|
||||
|
@ -1535,11 +1516,10 @@ class Procedure extends Member {
|
|||
static const int FlagExternal = 1 << 2;
|
||||
static const int FlagConst = 1 << 3; // Only for external const factories.
|
||||
static const int FlagForwardingStub = 1 << 4;
|
||||
static const int FlagGenericContravariant = 1 << 5;
|
||||
static const int FlagForwardingSemiStub = 1 << 6;
|
||||
static const int FlagForwardingSemiStub = 1 << 5;
|
||||
// TODO(29841): Remove this flag after the issue is resolved.
|
||||
static const int FlagRedirectingFactoryConstructor = 1 << 7;
|
||||
static const int Flag2NoSuchMethodForwarder = 1 << 0;
|
||||
static const int FlagRedirectingFactoryConstructor = 1 << 6;
|
||||
static const int FlagNoSuchMethodForwarder = 1 << 7;
|
||||
|
||||
bool get isStatic => flags & FlagStatic != 0;
|
||||
bool get isAbstract => flags & FlagAbstract != 0;
|
||||
|
@ -1559,14 +1539,6 @@ class Procedure extends Member {
|
|||
/// was present in the source, consult [isSyntheticForwarder].
|
||||
bool get isForwardingStub => flags & FlagForwardingStub != 0;
|
||||
|
||||
/// Indicates whether invocations using this interface target may need to
|
||||
/// perform a runtime type check to deal with generic covariance.
|
||||
///
|
||||
/// Note that the appropriate runtime checks are inserted by the front end, so
|
||||
/// back ends need not consult this flag; this flag exists merely to reduce
|
||||
/// front end computational overhead.
|
||||
bool get isGenericContravariant => flags & FlagGenericContravariant != 0;
|
||||
|
||||
/// If set, this flag indicates that although this function is a forwarding
|
||||
/// stub, it was present in the original source as an abstract method.
|
||||
bool get isForwardingSemiStub => flags & FlagForwardingSemiStub != 0;
|
||||
|
@ -1582,7 +1554,7 @@ class Procedure extends Member {
|
|||
/// and forwarding to [forwardingStubSuperTarget].
|
||||
bool get isSyntheticForwarder => isForwardingStub && !isForwardingSemiStub;
|
||||
|
||||
bool get isNoSuchMethodForwarder => flags2 & Flag2NoSuchMethodForwarder != 0;
|
||||
bool get isNoSuchMethodForwarder => flags & FlagNoSuchMethodForwarder != 0;
|
||||
|
||||
void set isStatic(bool value) {
|
||||
flags = value ? (flags | FlagStatic) : (flags & ~FlagStatic);
|
||||
|
@ -1605,12 +1577,6 @@ class Procedure extends Member {
|
|||
value ? (flags | FlagForwardingStub) : (flags & ~FlagForwardingStub);
|
||||
}
|
||||
|
||||
void set isGenericContravariant(bool value) {
|
||||
flags = value
|
||||
? (flags | FlagGenericContravariant)
|
||||
: (flags & ~FlagGenericContravariant);
|
||||
}
|
||||
|
||||
void set isForwardingSemiStub(bool value) {
|
||||
flags = value
|
||||
? (flags | FlagForwardingSemiStub)
|
||||
|
@ -1625,9 +1591,9 @@ class Procedure extends Member {
|
|||
|
||||
void set isNoSuchMethodForwarder(bool value) {
|
||||
assert(isAbstract);
|
||||
flags2 = value
|
||||
? (flags2 | Flag2NoSuchMethodForwarder)
|
||||
: (flags2 & ~Flag2NoSuchMethodForwarder);
|
||||
flags = value
|
||||
? (flags | FlagNoSuchMethodForwarder)
|
||||
: (flags & ~FlagNoSuchMethodForwarder);
|
||||
}
|
||||
|
||||
bool get isInstanceMember => !isStatic;
|
||||
|
|
|
@ -873,7 +873,6 @@ class BinaryBuilder {
|
|||
int fileOffset = readOffset();
|
||||
int fileEndOffset = readOffset();
|
||||
int flags = readByte();
|
||||
int flags2 = readByte();
|
||||
var name = readName();
|
||||
var annotations = readAnnotationList(node);
|
||||
assert(() {
|
||||
|
@ -888,7 +887,6 @@ class BinaryBuilder {
|
|||
node.fileOffset = fileOffset;
|
||||
node.fileEndOffset = fileEndOffset;
|
||||
node.flags = flags;
|
||||
node.flags2 = flags2;
|
||||
node.name = name;
|
||||
node.fileUri = fileUri;
|
||||
node.annotations = annotations;
|
||||
|
@ -960,7 +958,6 @@ class BinaryBuilder {
|
|||
int kindIndex = readByte();
|
||||
var kind = ProcedureKind.values[kindIndex];
|
||||
var flags = readByte();
|
||||
var flags2 = readByte();
|
||||
var name = readName();
|
||||
var annotations = readAnnotationList(node);
|
||||
assert(() {
|
||||
|
@ -984,7 +981,6 @@ class BinaryBuilder {
|
|||
node.fileEndOffset = fileEndOffset;
|
||||
node.kind = kind;
|
||||
node.flags = flags;
|
||||
node.flags2 = flags2;
|
||||
node.name = name;
|
||||
node.fileUri = fileUri;
|
||||
node.annotations = annotations;
|
||||
|
|
|
@ -830,7 +830,6 @@ class BinaryPrinter implements Visitor<void>, BinarySink {
|
|||
writeOffset(node.fileEndOffset);
|
||||
writeByte(node.kind.index);
|
||||
writeByte(node.flags);
|
||||
writeByte(node.flags2);
|
||||
writeName(node.name ?? '');
|
||||
writeAnnotationList(node.annotations);
|
||||
writeOptionalReference(node.forwardingStubSuperTargetReference);
|
||||
|
@ -860,7 +859,6 @@ class BinaryPrinter implements Visitor<void>, BinarySink {
|
|||
writeOffset(node.fileOffset);
|
||||
writeOffset(node.fileEndOffset);
|
||||
writeByte(node.flags);
|
||||
writeByte(node.flags2);
|
||||
writeName(node.name);
|
||||
writeAnnotationList(node.annotations);
|
||||
writeNode(node.type);
|
||||
|
|
|
@ -424,9 +424,7 @@ class CloneVisitor implements TreeVisitor {
|
|||
forwardingStubInterfaceTarget: node.forwardingStubInterfaceTarget)
|
||||
..fileOffset = _cloneFileOffset(node.fileOffset)
|
||||
..fileEndOffset = _cloneFileOffset(node.fileEndOffset)
|
||||
..isGenericContravariant = node.isGenericContravariant
|
||||
..flags = node.flags
|
||||
..flags2 = node.flags2;
|
||||
..flags = node.flags;
|
||||
}
|
||||
|
||||
visitField(Field node) {
|
||||
|
@ -443,8 +441,7 @@ class CloneVisitor implements TreeVisitor {
|
|||
fileUri: _activeFileUri)
|
||||
..fileOffset = _cloneFileOffset(node.fileOffset)
|
||||
..fileEndOffset = _cloneFileOffset(node.fileEndOffset)
|
||||
..flags = node.flags
|
||||
..flags2 = node.flags2;
|
||||
..flags = node.flags;
|
||||
}
|
||||
|
||||
visitRedirectingFactoryConstructor(RedirectingFactoryConstructor node) {
|
||||
|
|
|
@ -887,7 +887,6 @@ class Printer extends Visitor<Null> {
|
|||
writeModifier(node.isGenericCovariantImpl, 'generic-covariant-impl');
|
||||
writeModifier(
|
||||
node.isGenericCovariantInterface, 'generic-covariant-interface');
|
||||
writeModifier(node.isGenericContravariant, 'generic-contravariant');
|
||||
writeModifier(node.isFinal, 'final');
|
||||
writeModifier(node.isConst, 'const');
|
||||
// Only show implicit getter/setter modifiers in cases where they are
|
||||
|
@ -928,7 +927,6 @@ class Printer extends Visitor<Null> {
|
|||
writeModifier(node.isAbstract, 'abstract');
|
||||
writeModifier(node.isForwardingStub, 'forwarding-stub');
|
||||
writeModifier(node.isForwardingSemiStub, 'forwarding-semi-stub');
|
||||
writeModifier(node.isGenericContravariant, 'generic-contravariant');
|
||||
writeModifier(node.isNoSuchMethodForwarder, 'no-such-method-forwarder');
|
||||
writeWord(procedureKindToString(node.kind));
|
||||
if ((node.enclosingClass == null &&
|
||||
|
|
|
@ -175,9 +175,6 @@ void FieldHelper::ReadUntilExcluding(Field field,
|
|||
case kFlags:
|
||||
flags_ = helper_->ReadFlags();
|
||||
if (++next_read_ == field) return;
|
||||
case kFlags2:
|
||||
secondary_flags_ = helper_->ReadFlags();
|
||||
if (++next_read_ == field) return;
|
||||
case kName:
|
||||
helper_->SkipName(); // read name.
|
||||
if (++next_read_ == field) return;
|
||||
|
@ -246,7 +243,6 @@ void ProcedureHelper::ReadUntilExcluding(Field field) {
|
|||
if (++next_read_ == field) return;
|
||||
case kFlags:
|
||||
flags_ = helper_->ReadFlags();
|
||||
flags2_ = helper_->ReadFlags();
|
||||
if (++next_read_ == field) return;
|
||||
case kName:
|
||||
helper_->SkipName(); // read name.
|
||||
|
@ -4422,7 +4418,7 @@ uint32_t KernelFingerprintHelper::CalculateFieldFingerprint() {
|
|||
}
|
||||
|
||||
BuildHash(name.Hash());
|
||||
BuildHash((field_helper.flags_ << 8) | field_helper.secondary_flags_);
|
||||
BuildHash(field_helper.flags_);
|
||||
BuildHash(field_helper.annotation_count_);
|
||||
return hash_;
|
||||
}
|
||||
|
@ -4468,7 +4464,6 @@ uint32_t KernelFingerprintHelper::CalculateFunctionFingerprint() {
|
|||
|
||||
BuildHash(procedure_helper.kind_);
|
||||
BuildHash(procedure_helper.flags_);
|
||||
BuildHash(procedure_helper.flags2_);
|
||||
BuildHash(procedure_helper.annotation_count_);
|
||||
BuildHash(name.Hash());
|
||||
return hash_;
|
||||
|
|
|
@ -202,7 +202,6 @@ class FieldHelper {
|
|||
kPosition,
|
||||
kEndPosition,
|
||||
kFlags,
|
||||
kFlags2,
|
||||
kName,
|
||||
kAnnotations,
|
||||
kType,
|
||||
|
@ -260,7 +259,6 @@ class FieldHelper {
|
|||
TokenPosition position_;
|
||||
TokenPosition end_position_;
|
||||
uint8_t flags_;
|
||||
uint8_t secondary_flags_;
|
||||
intptr_t source_uri_index_;
|
||||
intptr_t annotation_count_;
|
||||
|
||||
|
@ -314,11 +312,8 @@ class ProcedureHelper {
|
|||
kForwardingStub = 1 << 4,
|
||||
|
||||
// TODO(29841): Remove this line after the issue is resolved.
|
||||
kRedirectingFactoryConstructor = 1 << 7,
|
||||
};
|
||||
|
||||
enum Flag2 {
|
||||
kNoSuchMethodForwarder = 1 << 0,
|
||||
kRedirectingFactoryConstructor = 1 << 6,
|
||||
kNoSuchMethodForwarder = 1 << 7,
|
||||
};
|
||||
|
||||
explicit ProcedureHelper(KernelReaderHelper* helper)
|
||||
|
@ -342,7 +337,7 @@ class ProcedureHelper {
|
|||
return (flags_ & kRedirectingFactoryConstructor) != 0;
|
||||
}
|
||||
bool IsNoSuchMethodForwarder() {
|
||||
return (flags2_ & kNoSuchMethodForwarder) != 0;
|
||||
return (flags_ & kNoSuchMethodForwarder) != 0;
|
||||
}
|
||||
|
||||
NameIndex canonical_name_;
|
||||
|
@ -350,7 +345,6 @@ class ProcedureHelper {
|
|||
TokenPosition end_position_;
|
||||
Kind kind_;
|
||||
uint8_t flags_;
|
||||
uint8_t flags2_;
|
||||
intptr_t source_uri_index_;
|
||||
intptr_t annotation_count_;
|
||||
|
||||
|
|
Loading…
Reference in a new issue