Remove unused reify transformation

Change-Id: I4d29e3372b9aaf6bc7f1849e9fc0fb27f63e5c5f
Reviewed-on: https://dart-review.googlesource.com/54223
Commit-Queue: Peter von der Ahé <ahe@google.com>
Reviewed-by: Karl Klose <karlklose@google.com>
This commit is contained in:
Peter von der Ahé 2018-05-14 14:48:57 +00:00 committed by commit-bot@chromium.org
parent 184e2a8b4c
commit bc86dc1dd6
88 changed files with 0 additions and 6724 deletions

View file

@ -10,7 +10,6 @@ import '../transformations/treeshaker.dart' show ProgramRoot;
import 'flutter.dart' show FlutterTarget;
import 'vm.dart' show VmTarget;
import 'vmcc.dart' show VmClosureConvertedTarget;
import 'vmreify.dart' show VmGenericTypesReifiedTarget;
final List<String> targetNames = targets.keys.toList();
@ -37,7 +36,6 @@ final Map<String, _TargetBuilder> targets = <String, _TargetBuilder>{
'none': (TargetFlags flags) => new NoneTarget(flags),
'vm': (TargetFlags flags) => new VmTarget(flags),
'vmcc': (TargetFlags flags) => new VmClosureConvertedTarget(flags),
'vmreify': (TargetFlags flags) => new VmGenericTypesReifiedTarget(flags),
'flutter': (TargetFlags flags) => new FlutterTarget(flags),
};

View file

@ -1,44 +0,0 @@
// Copyright (c) 2017, 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.
library kernel.target.vmreify;
import '../ast.dart' show Component;
import '../core_types.dart' show CoreTypes;
import '../transformations/generic_types_reification.dart' as reify
show transformComponent;
import 'targets.dart' show TargetFlags;
import 'vmcc.dart' as vmcc_target;
/// Specializes the kernel IR to the Dart VM with reified generic types.
class VmGenericTypesReifiedTarget extends vmcc_target.VmClosureConvertedTarget {
VmGenericTypesReifiedTarget(TargetFlags flags) : super(flags);
@override
String get name => "vmreify";
// This is the order that bootstrap libraries are loaded according to
// `runtime/vm/object_store.h`.
List<String> get extraRequiredLibraries {
return new List<String>.from(super.extraRequiredLibraries)
..add("${flags.kernelRuntime.resolve('reify/types.dart')}")
..add("${flags.kernelRuntime.resolve('reify/declarations.dart')}")
..add("${flags.kernelRuntime.resolve('reify/interceptors.dart')}");
}
@override
void performGlobalTransformations(CoreTypes coreTypes, Component component,
{void logger(String msg)}) {
super.performGlobalTransformations(coreTypes, component);
// TODO(dmitryas) this transformation should be made modular
reify.transformComponent(coreTypes, component);
}
// Disable tree shaking for Generic Types Reification. There are some runtime
// libraries that are required for the transformation and are shaken off,
// because they aren't invoked from the component being transformed prior to
// the transformation.
// TODO(dmitryas): remove this when the libraries are in dart:_internal
@override
void performTreeShaking(CoreTypes coreTypes, Component component) {}
}

View file

@ -1,14 +0,0 @@
// Copyright (c) 2017, 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.
library kernel.transformation.generic_types_reification;
import '../ast.dart' show Component;
import '../core_types.dart' show CoreTypes;
import '../transformations/reify/reify_transformer.dart' as reify
show transformComponent;
Component transformComponent(CoreTypes coreTypes, Component component) {
return reify.transformComponent(coreTypes, component);
}

View file

@ -1,106 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library kernel.transformation.reify.analysis.program_analysis;
import '../asts.dart';
import '../../../ast.dart';
// TODO(karlklose): keep all predicates and derived information here and move
// the actual data to a builder class.
class ProgramKnowledge {
Map<Member, Set<TypeParameter>> _usedTypeVariables =
<Member, Set<TypeParameter>>{};
Map<Member, Set<DartType>> isTests = <Member, Set<DartType>>{};
Set<Class> _classTests;
/// Contains all classes that are used as the declaration of a type expression
/// in a type test.
Set<Class> get classTests {
if (_classTests == null) {
_classTests = isTests.values
.expand((set) => set)
.where((DartType type) => type is InterfaceType)
.map((DartType type) => (type as InterfaceType).classNode)
.toSet();
}
return _classTests;
}
recordTypeVariableUse(Expression expression, TypeParameter parameter) {
// TODO(karlklose): also record expression.
add(_usedTypeVariables, getEnclosingMember(expression), parameter);
}
Set<TypeParameter> usedParameters(Member member) {
return _usedTypeVariables[member] ?? new Set<TypeParameter>();
}
void recordIsTest(IsExpression node, DartType type) {
add(isTests, getEnclosingMember(node), type);
}
add(Map<dynamic, Set> map, key, value) {
map.putIfAbsent(key, () => new Set()).add(value);
}
}
typedef bool LibraryFilter(Library library);
class ProgramAnalysis extends Visitor {
final ProgramKnowledge knowledge;
final LibraryFilter analyzeLibrary;
ProgramAnalysis(this.knowledge, this.analyzeLibrary);
defaultTreeNode(TreeNode node) => node.visitChildren(this);
visitLibrary(Library library) {
if (!analyzeLibrary(library)) {
return;
}
super.visitLibrary(library);
}
handleTypeReference(TreeNode node, DartType type) {
typeVariables(type).forEach((TypeParameter parameter) {
knowledge.recordTypeVariableUse(node, parameter);
});
}
handleInstantiation(InvocationExpression node) {
node.arguments.types.forEach((DartType type) {
handleTypeReference(node, type);
});
}
visitIsExpression(IsExpression node) {
knowledge.recordIsTest(node, node.type);
handleTypeReference(node, node.type);
node.visitChildren(this);
}
visitConstructorInvocation(ConstructorInvocation node) {
handleInstantiation(node);
node.visitChildren(this);
}
visitStaticInvocation(StaticInvocation node) {
if (node.target.kind == ProcedureKind.Factory) {
handleInstantiation(node);
}
node.visitChildren(this);
}
}
bool _analyzeAll(Library library) => true;
ProgramKnowledge analyze(Component component,
{LibraryFilter analyzeLibrary: _analyzeAll}) {
ProgramKnowledge knowledge = new ProgramKnowledge();
component.accept(new ProgramAnalysis(knowledge, analyzeLibrary));
return knowledge;
}

View file

@ -1,54 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library kernel.transformations.reify.ast_helpers;
import '../../ast.dart';
Class getEnclosingClass(TreeNode node) {
TreeNode original = node;
while (node != null && node is! Class) {
node = node.parent;
}
if (node == null) {
throw 'internal error: enclosing class not found for $original';
}
return node;
}
Library getEnclosingLibrary(TreeNode node) {
TreeNode original = node;
while (node != null && node is! Library) {
node = node.parent;
}
if (node == null) {
throw 'internal error: enclosing library not found for $original';
}
return node;
}
Member getEnclosingMember(TreeNode node) {
TreeNode original = node;
while (node != null && node is! Member) {
node = node.parent;
}
if (node == null) {
throw 'internal error: enclosing member not found for $original';
}
return node;
}
List<TypeParameter> typeVariables(DartType type) {
List<TypeParameter> parameters = <TypeParameter>[];
collect(DartType type) {
if (type is InterfaceType) {
type.typeArguments.map(collect);
} else if (type is TypeParameterType) {
parameters.add(type.parameter);
}
}
collect(type);
return parameters;
}

View file

@ -1,112 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library kernel.transformations.reify.standalone_runner;
import 'analysis/program_analysis.dart';
import 'dart:io' show File, IOSink;
import '../../binary/ast_to_binary.dart' show BinaryPrinter;
import '../../ast.dart';
import '../../kernel.dart';
import '../../verifier.dart';
import '../../text/ast_to_text.dart' show Printer;
import 'transformation/remove_generics.dart';
import 'transformation/transformer.dart'
show ReifyVisitor, RuntimeLibrary, RuntimeTypeSupportBuilder;
import '../../core_types.dart' show CoreTypes;
RuntimeLibrary findRuntimeTypeLibrary(Component p) {
Library findLibraryEndingWith(String postfix) {
Iterable<Library> candidates = p.libraries.where((Library l) {
return l.importUri.toString().endsWith(postfix);
});
if (candidates.length != 1) {
String howMany = candidates.isEmpty ? "No" : "Multiple";
throw new Exception(
"$howMany candidates for runtime support library found.");
}
return candidates.single;
}
Library types = findLibraryEndingWith("reify/types.dart");
Library declarations = findLibraryEndingWith("reify/declarations.dart");
Library interceptors = findLibraryEndingWith("reify/interceptors.dart");
return new RuntimeLibrary(types, declarations, interceptors);
}
Component transformComponentUsingLibraries(
CoreTypes coreTypes, Component component, RuntimeLibrary runtimeLibrary,
[Library libraryToTransform]) {
LibraryFilter filter = libraryToTransform != null
? (Library library) => library == libraryToTransform
: (_) => true;
ProgramKnowledge knowledge = analyze(component, analyzeLibrary: filter);
Library mainLibrary = component.mainMethod.parent;
RuntimeTypeSupportBuilder builder =
new RuntimeTypeSupportBuilder(runtimeLibrary, coreTypes, mainLibrary);
ReifyVisitor transformer =
new ReifyVisitor(runtimeLibrary, builder, knowledge, libraryToTransform);
// Transform the main component.
component = component.accept(transformer);
if (!filter(runtimeLibrary.interceptorsLibrary)) {
// We need to transform the interceptor function in any case to make sure
// that the type literals in the interceptor function are rewritten.
runtimeLibrary.interceptorFunction.accept(transformer);
}
builder.createDeclarations();
component = component.accept(new Erasure(transformer));
// TODO(karlklose): skip checks in debug mode
verifyComponent(component);
return component;
}
Component transformComponent(CoreTypes coreTypes, Component component) {
RuntimeLibrary runtimeLibrary = findRuntimeTypeLibrary(component);
Library mainLibrary = component.mainMethod.enclosingLibrary;
return transformComponentUsingLibraries(
coreTypes, component, runtimeLibrary, mainLibrary);
}
main(List<String> arguments) async {
String path = arguments.first;
Uri output;
if (arguments.length > 1) {
output = Uri.base.resolve(arguments[1]);
}
Uri uri = Uri.base.resolve(path);
Component component = loadComponentFromBinary(uri.toFilePath());
CoreTypes coreTypes = new CoreTypes(component);
RuntimeLibrary runtimeLibrary = findRuntimeTypeLibrary(component);
Library mainLibrary = component.mainMethod.enclosingLibrary;
component = transformComponentUsingLibraries(
coreTypes, component, runtimeLibrary, mainLibrary);
if (output == null) {
// Print result
StringBuffer sb = new StringBuffer();
Printer printer = new Printer(sb);
printer.writeLibraryFile(mainLibrary);
print("$sb");
} else {
IOSink sink = new File.fromUri(output).openWrite();
try {
new BinaryPrinter(sink).writeComponentFile(component);
} finally {
await sink.close();
}
try {
// Check that we can read the binary file.
loadComponentFromBinary(output.toFilePath());
} catch (e) {
print("Error when attempting to read $output.");
rethrow;
}
}
}

View file

@ -1,180 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library kernel.transformations.reify.transformation.binding;
import '../../../ast.dart';
class RuntimeLibrary {
final Library typesLibrary;
final Library declarationsLibrary;
final Library interceptorsLibrary;
final Constructor dynamicTypeConstructor;
final Constructor interfaceTypeConstructor;
final Constructor declarationClassConstructor;
final Constructor functionTypeConstructor;
final Constructor voidTypeConstructor;
// The class used to mark instances that implement `$type`.
final Class markerClass;
final Class declarationClass;
final Class reifiedTypeClass;
DartType get typeType => reifiedTypeClass.rawType;
final Name variablesFieldName = new Name("variables");
/// The name of the field to create for the type information. This name is
/// extracted from the class `HasRuntimeTypeGetter`.
final Name runtimeTypeName;
final Procedure asInstanceOfFunction;
final Procedure isSubtypeOfFunction;
final Procedure typeArgumentsFunction;
final Procedure allocateDeclarationsFunction;
final Procedure initFunction;
final Procedure interceptorFunction;
final Procedure reifyFunction;
final Procedure attachTypeFunction;
factory RuntimeLibrary(Library typesLibrary, Library declarationsLibrary,
Library interceptorsLibrary) {
Class dynamicTypeClass;
Class interfaceTypeClass;
Class declarationClass;
Class functionTypeClass;
Class voidTypeClass;
Class markerClass;
Class reifiedTypeClass;
Procedure allocateDeclarationsFunction;
Procedure initFunction;
Procedure interceptorFunction;
Procedure reifyFunction;
Procedure attachTypeFunction;
Procedure asInstanceOfFunction;
Procedure isSubtypeOfFunction;
Procedure typeArgumentsFunction;
for (Procedure p in interceptorsLibrary.procedures) {
if (p.name.name == "type") {
interceptorFunction = p;
} else if (p.name.name == "reify") {
reifyFunction = p;
} else if (p.name.name == "attachType") {
attachTypeFunction = p;
}
}
for (Class c in interceptorsLibrary.classes) {
if (c.name == "HasRuntimeTypeGetter") {
markerClass = c;
}
}
for (Class c in typesLibrary.classes) {
if (c.name == 'Dynamic') {
dynamicTypeClass = c;
} else if (c.name == 'Interface') {
interfaceTypeClass = c;
} else if (c.name == 'FunctionType') {
functionTypeClass = c;
} else if (c.name == 'Void') {
voidTypeClass = c;
} else if (c.name == 'ReifiedType') {
reifiedTypeClass = c;
}
}
for (Procedure p in typesLibrary.procedures) {
if (p.name.name == "asInstanceOf") {
asInstanceOfFunction = p;
} else if (p.name.name == "isSubtypeOf") {
isSubtypeOfFunction = p;
} else if (p.name.name == "getTypeArguments") {
typeArgumentsFunction = p;
}
}
for (Procedure p in declarationsLibrary.procedures) {
if (p.name.name == "allocateDeclarations") {
allocateDeclarationsFunction = p;
} else if (p.name.name == "init") {
initFunction = p;
}
}
for (Class c in declarationsLibrary.classes) {
if (c.name == 'Class') {
declarationClass = c;
}
}
assert(dynamicTypeClass != null);
assert(declarationClass != null);
assert(interfaceTypeClass != null);
assert(functionTypeClass != null);
assert(voidTypeClass != null);
assert(markerClass != null);
assert(declarationClass != null);
assert(reifiedTypeClass != null);
assert(allocateDeclarationsFunction != null);
assert(initFunction != null);
assert(interceptorFunction != null);
assert(reifyFunction != null);
assert(attachTypeFunction != null);
assert(asInstanceOfFunction != null);
assert(isSubtypeOfFunction != null);
assert(typeArgumentsFunction != null);
return new RuntimeLibrary._(
markerClass.procedures.single.name,
typesLibrary,
declarationsLibrary,
interceptorsLibrary,
markerClass,
declarationClass,
reifiedTypeClass,
dynamicTypeClass.constructors.single,
interfaceTypeClass.constructors.single,
declarationClass.constructors.single,
functionTypeClass.constructors.single,
voidTypeClass.constructors.single,
allocateDeclarationsFunction,
initFunction,
interceptorFunction,
reifyFunction,
attachTypeFunction,
asInstanceOfFunction,
isSubtypeOfFunction,
typeArgumentsFunction);
}
RuntimeLibrary._(
this.runtimeTypeName,
this.typesLibrary,
this.declarationsLibrary,
this.interceptorsLibrary,
this.markerClass,
this.declarationClass,
this.reifiedTypeClass,
this.dynamicTypeConstructor,
this.interfaceTypeConstructor,
this.declarationClassConstructor,
this.functionTypeConstructor,
this.voidTypeConstructor,
this.allocateDeclarationsFunction,
this.initFunction,
this.interceptorFunction,
this.reifyFunction,
this.attachTypeFunction,
this.asInstanceOfFunction,
this.isSubtypeOfFunction,
this.typeArgumentsFunction);
/// Returns `true` if [node] is defined in the runtime library.
bool contains(TreeNode node) {
while (node is! Library) {
node = node.parent;
if (node == null) return false;
}
return node == typesLibrary || node == declarationsLibrary;
}
}

View file

@ -1,509 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library kernel.transformations.reify.transformation.builder;
import '../asts.dart';
import '../../../ast.dart';
import 'dart:collection' show LinkedHashMap;
import 'binding.dart' show RuntimeLibrary;
import '../../../core_types.dart' show CoreTypes;
class Scope {
final Map<String, TreeNode> names = <String, TreeNode>{};
bool nameAlreadyTaken(String name, TreeNode node) {
TreeNode existing = names[name];
return existing != null && existing == node;
}
void add(String name, TreeNode node) {
assert(!nameAlreadyTaken(name, node));
names[name] = node;
}
}
class Namer {
final Scope scope;
Namer([Scope scope]) : this.scope = scope ?? new Scope();
String _getProposal(TreeNode node) {
if (node is Class) {
return node.name;
}
throw 'unsupported node: $node';
}
String getNameFor(TreeNode node) {
String base = _getProposal(node);
int id = 0;
String proposal = base;
while (scope.nameAlreadyTaken(proposal, node)) {
proposal = "$base${++id}";
}
scope.add(proposal, node);
return proposal;
}
}
class RuntimeTypeSupportBuilder {
// TODO(karlklose): group this together with other information about what
// needs to be built.
final LinkedHashMap<Class, int> reifiedClassIds =
new LinkedHashMap<Class, int>();
int currentDeclarationId = 0;
final Field declarations;
final RuntimeLibrary rtiLibrary;
final CoreTypes coreTypes;
final DartType declarationType;
RuntimeTypeSupportBuilder(
RuntimeLibrary rtiLibrary, CoreTypes coreTypes, Library mainLibrary)
: declarations = new Field(new Name(r"$declarations"),
isFinal: true, isStatic: true, fileUri: mainLibrary.fileUri),
declarationType = new InterfaceType(coreTypes.listClass,
<DartType>[rtiLibrary.declarationClass.rawType]),
rtiLibrary = rtiLibrary,
coreTypes = coreTypes {
mainLibrary.addMember(declarations);
}
int addDeclaration(Class cls) {
return reifiedClassIds.putIfAbsent(cls, () {
return currentDeclarationId++;
});
}
final Name indexOperatorName = new Name("[]");
MethodInvocation createArrayAccess(Expression target, int index) {
return new MethodInvocation(target, indexOperatorName,
new Arguments(<Expression>[new IntLiteral(index)]));
}
Expression createAccessDeclaration(Class cls) {
return createArrayAccess(new StaticGet(declarations), addDeclaration(cls));
}
Name getTypeTestTagName(Class cls) {
return new Name('\$is\$${cls.name}');
}
Name typeVariableGetterName(TypeParameter parameter) {
Class cls = getEnclosingClass(parameter);
return new Name("\$${cls.name}\$${parameter.name}");
}
// A call to a constructor or factory of a class that we have not transformed
// is wrapped in a call to `attachType`.
Expression attachTypeToConstructorInvocation(
InvocationExpression invocation, Member member) {
assert(member is Procedure && member.kind == ProcedureKind.Factory ||
member is Constructor);
Class targetClass = member.parent;
assert(targetClass != null);
DartType type = new InterfaceType(targetClass, invocation.arguments.types);
return callAttachType(invocation, type);
}
Expression callAttachType(Expression expression, DartType type) {
return new StaticInvocation(rtiLibrary.attachTypeFunction,
new Arguments(<Expression>[expression, createRuntimeType(type)]));
}
Expression createGetType(Expression receiver, {needsInterceptor: true}) {
if (receiver is ThisExpression || !needsInterceptor) {
return new PropertyGet(receiver, rtiLibrary.runtimeTypeName);
}
return new StaticInvocation(
rtiLibrary.interceptorFunction, new Arguments(<Expression>[receiver]));
}
Expression createGetTypeArguments(Expression typeObject) {
return new StaticInvocation(rtiLibrary.typeArgumentsFunction,
new Arguments(<Expression>[typeObject]));
}
// TODO(karlklose): consider adding a unique identifier for each test site.
/// `receiver.[subtypeTestName]([type])`
StaticInvocation createIsSubtypeOf(
Expression receiver, Expression typeExpression,
{targetHasTypeProperty: false}) {
Expression receiverType =
createGetType(receiver, needsInterceptor: !targetHasTypeProperty);
return new StaticInvocation(rtiLibrary.isSubtypeOfFunction,
new Arguments(<Expression>[receiverType, typeExpression]));
}
int getTypeVariableIndex(TypeParameter variable) {
Class c = getEnclosingClass(variable);
List<TypeParameter> variables = c.typeParameters;
for (int i = 0; i < variables.length; ++i) {
if (variables[i].name == variable.name) {
return i;
}
}
throw new Exception(
"Type variable $variable not found in enclosing class $c");
}
Expression createNewInterface(
Expression declaration, Expression typeArgumentList) {
List<Expression> arguments = <Expression>[declaration];
if (typeArgumentList != null) {
arguments.add(typeArgumentList);
}
return new ConstructorInvocation(
rtiLibrary.interfaceTypeConstructor, new Arguments(arguments));
}
/// Returns `true` if [types] is a list of [TypeParameterType]s that exactly
/// match the [TypeParameters] of the class they are defined in, i.e.,
/// for all 0 <= i < cls.typeParameters.length.
/// types[i].parameter == cls.typeParameters[i].
bool matchesTypeParameters(List<DartType> types) {
List<TypeParameter> parameters;
for (int i = 0; i < types.length; ++i) {
var type = types[i];
if (type is TypeParameterType) {
if (parameters == null) {
Class cls = getEnclosingClass(type.parameter);
parameters = cls.typeParameters;
if (parameters.length != types.length) return false;
}
if (type.parameter != parameters[i]) {
return false;
}
} else {
return false;
}
}
return true;
}
// TODO(karlklose): Refactor into visitor.
// TODO(karlklose): split this method in different strategies.
/// Creates an expression to represent a runtime type instance of type [type].
Expression createRuntimeType(DartType type,
{reifyTypeVariable: false,
Expression createReference(Class cls),
VariableDeclaration typeContext}) {
Expression buildReifiedTypeVariable(TypeParameterType type) {
Expression typeVariables = new PropertyGet(
createReference(type.parameter.parent),
rtiLibrary.variablesFieldName);
return createArrayAccess(
typeVariables, getTypeVariableIndex(type.parameter));
}
Expression buildDirectTypeVariableAccess(TypeParameterType variable) {
Class cls = getEnclosingClass(variable.parameter);
return extractTypeVariable(
cls,
variable.parameter,
getTypeVariableIndex(variable.parameter),
new VariableGet(typeContext));
}
Expression buildGetterTypeVariableAccess(TypeParameterType type) {
return new PropertyGet(
new ThisExpression(), typeVariableGetterName(type.parameter));
}
Expression buildTypeVariable(TypeParameterType type) {
if (reifyTypeVariable) {
assert(typeContext == null);
return buildReifiedTypeVariable(type);
} else if (typeContext != null) {
return buildDirectTypeVariableAccess(type);
} else {
return buildGetterTypeVariableAccess(type);
}
}
createReference ??= createAccessDeclaration;
/// Helper to make recursive invocation more readable.
Expression createPart(DartType type) {
return createRuntimeType(type,
reifyTypeVariable: reifyTypeVariable,
createReference: createReference,
typeContext: typeContext);
}
if (type is InterfaceType || type is Supertype) {
InterfaceType interfaceType =
(type is InterfaceType) ? type : (type as Supertype).asInterfaceType;
Class cls = interfaceType.classNode;
Expression declaration = createReference(cls);
List<DartType> typeArguments = interfaceType.typeArguments;
Expression typeArgumentList;
if (typeArguments.isNotEmpty) {
if (!reifyTypeVariable && matchesTypeParameters(typeArguments)) {
// The type argument list corresponds to the list of type parameters
// and we are not in "declaration emitter" mode, we can reuse the
// type argument vector.
TypeParameterType parameterType = typeArguments[0];
Class cls = parameterType.parameter.parent;
Expression typeObject = typeContext != null
? new VariableGet(typeContext)
: createGetType(new ThisExpression());
typeArgumentList =
createGetTypeArguments(createCallAsInstanceOf(typeObject, cls));
} else {
typeArgumentList =
new ListLiteral(typeArguments.map(createPart).toList());
}
}
return createNewInterface(declaration, typeArgumentList);
} else if (type is DynamicType) {
return new ConstructorInvocation(
rtiLibrary.dynamicTypeConstructor, new Arguments([]),
isConst: true);
} else if (type is TypeParameterType) {
return buildTypeVariable(type);
} else if (type is FunctionType) {
FunctionType functionType = type;
Expression returnType = createPart(functionType.returnType);
List<Expression> encodedParameterTypes =
functionType.positionalParameters.map(createPart).toList();
List<NamedType> namedParameters = functionType.namedParameters;
int data;
if (namedParameters.isNotEmpty) {
for (NamedType param in namedParameters) {
encodedParameterTypes.add(new StringLiteral(param.name));
encodedParameterTypes.add(createPart(param.type));
}
data = functionType.namedParameters.length << 1 | 1;
} else {
data = (functionType.positionalParameters.length -
functionType.requiredParameterCount) <<
1;
}
Expression functionTypeExpression = new ConstructorInvocation(
rtiLibrary.interfaceTypeConstructor,
new Arguments(
<Expression>[createReference(coreTypes.functionClass)]));
Arguments arguments = new Arguments(<Expression>[
functionTypeExpression,
returnType,
new IntLiteral(data),
new ListLiteral(encodedParameterTypes)
]);
return new ConstructorInvocation(
rtiLibrary.functionTypeConstructor, arguments);
} else if (type is VoidType) {
return new ConstructorInvocation(
rtiLibrary.voidTypeConstructor, new Arguments(<Expression>[]));
}
return new InvalidExpression(null);
}
Expression createCallAsInstanceOf(Expression receiver, Class cls) {
return new StaticInvocation(rtiLibrary.asInstanceOfFunction,
new Arguments(<Expression>[receiver, createAccessDeclaration(cls)]));
}
/// `get get$<variable-name> => <get-type>.arguments[<variable-index>]`
Member createTypeVariableGetter(
Class cls, TypeParameter variable, int index) {
Expression type = createGetType(new ThisExpression());
Expression argument = extractTypeVariable(cls, variable, index, type);
return new Procedure(
typeVariableGetterName(variable),
ProcedureKind.Getter,
new FunctionNode(new ReturnStatement(argument),
returnType: rtiLibrary.typeType),
fileUri: cls.fileUri);
}
Expression extractTypeVariable(
Class cls, TypeParameter variable, int index, Expression typeObject) {
Expression type = createCallAsInstanceOf(typeObject, cls);
Expression arguments = new StaticInvocation(
rtiLibrary.typeArgumentsFunction, new Arguments(<Expression>[type]));
// TODO(karlklose): use the global index instead of the local one.
return createArrayAccess(arguments, index);
}
void insertAsFirstArgument(Arguments arguments, Expression expression) {
expression.parent = arguments;
arguments.positional.insert(0, expression);
}
/// Creates a call to the `init` function that completes the definition of a
/// class by setting its (direct) supertypes.
Expression createCallInit(
VariableDeclaration declarations,
int index,
InterfaceType supertype,
List<InterfaceType> interfaces,
FunctionType callableType) {
/// Helper to create a reference to the declaration in the declaration
/// list instead of the field to avoid cycles if that field's
/// initialization depends on the class we are currently initializing.
Expression createReference(Class declaration) {
int id = reifiedClassIds[declaration];
return createArrayAccess(new VariableGet(declarations), id);
}
bool isNotMarkerInterface(InterfaceType interface) {
return interface.classNode != rtiLibrary.markerClass;
}
Expression createLocalType(DartType type) {
if (type == null) return null;
return createRuntimeType(type,
reifyTypeVariable: true, createReference: createReference);
}
Expression supertypeExpression =
supertype == null ? new NullLiteral() : createLocalType(supertype);
List<Expression> interfaceTypes = interfaces
.where(isNotMarkerInterface)
.map(createLocalType)
.toList(growable: false);
Expression callableTypeExpression = createLocalType(callableType);
List<Expression> arguments = <Expression>[
new VariableGet(declarations),
new IntLiteral(index),
supertypeExpression,
];
if (interfaceTypes.isNotEmpty || callableTypeExpression != null) {
arguments.add(new ListLiteral(interfaceTypes));
if (callableTypeExpression != null) {
arguments.add(callableTypeExpression);
}
}
return new StaticInvocation(
rtiLibrary.initFunction, new Arguments(arguments));
}
Expression createDeclarationsInitializer() {
List<Statement> statements = <Statement>[];
// Call function to allocate the class declarations given the names and
// number of type variables of the classes.
Namer classNamer = new Namer();
List<Expression> names = <Expression>[];
List<Expression> parameterCount = <Expression>[];
reifiedClassIds.keys.forEach((Class c) {
names.add(new StringLiteral(classNamer.getNameFor(c)));
parameterCount.add(new IntLiteral(c.typeParameters.length));
});
Expression namesList = new ListLiteral(names);
Expression parameterCountList = new ListLiteral(parameterCount);
StaticInvocation callAllocate = new StaticInvocation(
rtiLibrary.allocateDeclarationsFunction,
new Arguments(<Expression>[namesList, parameterCountList]));
VariableDeclaration parameter =
new VariableDeclaration("d", type: declarationType);
reifiedClassIds.forEach((Class cls, int id) {
if (cls == rtiLibrary.markerClass) return;
// If the class declares a `call` method, translate the signature to a
// reified type.
FunctionType callableType;
Procedure call = cls.procedures.firstWhere(
(Procedure p) => p.name.name == "call",
orElse: () => null);
if (call != null) {
FunctionNode function = call.function;
final namedParameters = new List<NamedType>();
for (VariableDeclaration v in function.namedParameters) {
namedParameters.add(new NamedType(v.name, v.type));
}
List<DartType> positionalArguments = function.positionalParameters
.map((VariableDeclaration v) => v.type)
.toList();
callableType = new FunctionType(
positionalArguments, function.returnType,
namedParameters: namedParameters,
requiredParameterCount: function.requiredParameterCount);
}
statements.add(new ExpressionStatement(createCallInit(
parameter,
id,
cls.supertype?.asInterfaceType,
cls.implementedTypes
.map((Supertype type) => type?.asInterfaceType)
.toList(),
callableType)));
});
statements.add(new ReturnStatement(new VariableGet(parameter)));
Expression function = new FunctionExpression(new FunctionNode(
new Block(statements),
positionalParameters: <VariableDeclaration>[parameter],
returnType: declarationType));
return new MethodInvocation(
function, new Name("call"), new Arguments(<Expression>[callAllocate]));
}
void createDeclarations() {
/// Recursively find all referenced classes in [type].
void collectNewReferencedClasses(DartType type, Set<Class> newClasses) {
if (type is InterfaceType || type is Supertype) {
InterfaceType interfaceType = null;
if (type is InterfaceType) {
interfaceType = type;
} else {
interfaceType = (type as Supertype).asInterfaceType;
}
Class cls = interfaceType.classNode;
if (!reifiedClassIds.containsKey(cls) && !newClasses.contains(cls)) {
newClasses.add(cls);
}
interfaceType.typeArguments.forEach((DartType argument) {
collectNewReferencedClasses(argument, newClasses);
});
}
// TODO(karlklose): function types
}
Iterable<Class> classes = reifiedClassIds.keys;
while (classes.isNotEmpty) {
Set<Class> newClasses = new Set<Class>();
for (Class c in classes) {
collectNewReferencedClasses(c.supertype?.asInterfaceType, newClasses);
c.implementedTypes.forEach((Supertype supertype) {
collectNewReferencedClasses(supertype?.asInterfaceType, newClasses);
});
}
for (Class newClass in newClasses) {
// Make sure that there is a declaration field for the class and its
// library's declaration list is setup.
addDeclaration(newClass);
}
classes = newClasses;
}
Expression initializer = createDeclarationsInitializer();
initializer.parent = declarations;
declarations.initializer = initializer;
declarations.type = declarationType;
}
Procedure createGetter(
Name name, Expression expression, Class cls, DartType type) {
return new Procedure(name, ProcedureKind.Getter,
new FunctionNode(new ReturnStatement(expression), returnType: type),
fileUri: cls.fileUri);
}
}

View file

@ -1,143 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library kernel.transformations.reify.transformation.remove_generics;
import '../../../ast.dart';
import 'transformer.dart';
class Erasure extends Transformer with DartTypeVisitor<DartType> {
final ReifyVisitor reifyVisitor;
Erasure(this.reifyVisitor);
bool removeTypeParameters(Class cls) {
return reifyVisitor.needsTypeInformation(cls);
}
TreeNode removeTypeArgumentsOfConstructorCall(ConstructorInvocation node) {
Class cls = node.target.parent;
if (removeTypeParameters(cls)) {
node.arguments.types.clear();
Constructor target = node.target;
target.enclosingClass.typeParameters.clear();
}
return node;
}
TreeNode removeTypeArgumentsOfStaticCall(StaticInvocation node) {
if (node.target.parent is Class) {
Class cls = node.target.parent;
if (!removeTypeParameters(cls)) {
return node;
}
} else {
// If parent is a Library, then a global procedure is invoked, and it may
// be a generic function, so we need to remove type arguments anyway.
assert(node.target.parent is Library);
}
node.arguments.types.clear();
Procedure target = node.target;
target.function.typeParameters.clear();
return node;
}
TreeNode removeTypeArgumentOfMethodInvocation(MethodInvocation node) {
node.arguments.types.clear();
return node;
}
@override
defaultDartType(DartType type) => type;
@override
InterfaceType visitInterfaceType(InterfaceType type) {
if (removeTypeParameters(type.classNode)) {
return new InterfaceType(type.classNode, const <DartType>[]);
}
return type;
}
@override
TypedefType visitTypedefType(TypedefType type) {
throw 'Typedef types not implemented in erasure';
}
@override
Supertype visitSupertype(Supertype type) {
if (removeTypeParameters(type.classNode)) {
return new Supertype(type.classNode, const <DartType>[]);
}
return type;
}
@override
FunctionType visitFunctionType(FunctionType type) {
bool partHasChanged = false;
DartType translate(DartType type) {
DartType newType = type.accept(this);
if (newType != type) {
partHasChanged = true;
return newType;
} else {
return type;
}
}
DartType returnType = translate(type.returnType);
List<DartType> positionalTypes =
type.positionalParameters.map(translate).toList();
List<NamedType> namedParameters = new List<NamedType>();
for (NamedType param in type.namedParameters) {
namedParameters.add(new NamedType(param.name, translate(param.type)));
}
if (partHasChanged) {
return new FunctionType(positionalTypes, returnType,
namedParameters: namedParameters,
requiredParameterCount: type.requiredParameterCount);
} else {
return type;
}
}
@override
DynamicType visitTypeParameterType(_) => const DynamicType();
@override
DartType visitDartType(DartType type) {
return type.accept(this);
}
@override
StaticInvocation visitStaticInvocation(StaticInvocation node) {
node.transformChildren(this);
if (node.target.kind == ProcedureKind.Factory ||
node.target.kind == ProcedureKind.Method) {
node = removeTypeArgumentsOfStaticCall(node);
}
return node;
}
@override
ConstructorInvocation visitConstructorInvocation(ConstructorInvocation node) {
node.transformChildren(this);
return removeTypeArgumentsOfConstructorCall(node);
}
@override
Class visitClass(Class node) {
node.transformChildren(this);
if (removeTypeParameters(node)) {
node.typeParameters.clear();
}
return node;
}
@override
Expression visitMethodInvocation(MethodInvocation node) {
node.transformChildren(this);
return removeTypeArgumentOfMethodInvocation(node);
}
}

View file

@ -1,624 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library kernel.transformations.reify.transformation.transformer;
import '../analysis/program_analysis.dart';
import '../../../ast.dart';
import 'binding.dart' show RuntimeLibrary;
import 'builder.dart' show RuntimeTypeSupportBuilder;
import 'dart:collection' show LinkedHashMap;
import '../asts.dart';
export 'binding.dart' show RuntimeLibrary;
export 'builder.dart' show RuntimeTypeSupportBuilder;
enum RuntimeTypeStorage {
none,
inheritedField,
field,
getter,
}
class TransformationContext {
/// Describes how the runtime type is stored on the object.
RuntimeTypeStorage runtimeTypeStorage;
/// Field added to store the runtime type if [runtimeType] is
/// [RuntimeTypeStorage.field].
Field runtimeTypeField;
/// The parameter for the type information introduced to the constructor or
/// to static initializers.
VariableDeclaration parameter;
/// A ordered collection of fields together with their initializers rewritten
/// to static initializer functions that can be used in the constructor's
/// initializer list.
/// The order is important because of possible side-effects in the
/// initializers.
LinkedHashMap<Field, Procedure> initializers;
// `true` if the visitor currently is in a field initializer, a initializer
// list of a constructor, or the body of a factory method. In these cases,
// type argument access is different than in an instance context, since `this`
// is not available.
bool inInitializer = false;
String toString() => "s: ${runtimeTypeStorage} f: $runtimeTypeField,"
" p: $parameter, i: $inInitializer";
}
abstract class DebugTrace {
static const bool debugTrace = false;
static const int lineLength = 80;
TransformationContext get context;
String getNodeLevel(TreeNode node) {
String level = "";
while (node != null && node is! Library) {
level = " $level";
node = node.parent;
}
return level;
}
String shorten(String s) {
return s.length > lineLength ? s.substring(0, lineLength) : s;
}
void trace(TreeNode node) {
if (debugTrace) {
String nodeText = node.toString().replaceAll("\n", " ");
print(shorten("trace:${getNodeLevel(node)}$context"
" [${node.runtimeType}] $nodeText"));
}
}
}
/// Rewrites a tree to remove generic types and runtime type checks and replace
/// them with Dart objects.
///
/// Runtime types are stored in a field/getter called [runtimeTypeName] on the
/// object, which for parameterized classes is initialized in the constructor.
// TODO(karlklose):
// - add a scoped namer
// - rewrite types (supertypes, implemented types)
// - rewrite as
class ReifyVisitor extends Transformer with DebugTrace {
final RuntimeLibrary rtiLibrary;
final RuntimeTypeSupportBuilder builder;
final ProgramKnowledge knowledge;
ReifyVisitor(this.rtiLibrary, this.builder, this.knowledge,
[this.libraryToTransform]);
/// If not null, the transformation will only be applied to classes declared
/// in this library.
final Library libraryToTransform;
// TODO(karlklose): find a way to get rid of this state in the visitor.
TransformationContext context;
static const String genericMethodTypeParametersName = r"$typeParameters";
bool libraryShouldBeTransformed(Library library) {
return libraryToTransform == null || libraryToTransform == library;
}
bool needsTypeInformation(Class cls) {
return !isObject(cls) &&
!rtiLibrary.contains(cls) &&
libraryShouldBeTransformed(cls.enclosingLibrary);
}
bool usesTypeGetter(Class cls) {
return cls.typeParameters.isEmpty;
}
bool isObject(Class cls) {
// TODO(karlklose): use [CoreTypes].
return "$cls" == 'dart.core::Object';
}
Initializer addTypeAsArgument(initializer) {
assert(initializer is SuperInitializer ||
initializer is RedirectingInitializer);
Class cls = getEnclosingClass(initializer.target);
if (needsTypeInformation(cls) && !usesTypeGetter(cls)) {
// If the current class uses a getter for type information, we did not add
// a parameter to the constructor, but we can pass `null` as the value to
// initialize the type field, since it will be shadowed by the getter.
Expression type = (context.parameter != null)
? new VariableGet(context.parameter)
: new NullLiteral();
builder.insertAsFirstArgument(initializer.arguments, type);
}
return initializer;
}
Expression interceptInstantiation(
InvocationExpression invocation, Member target) {
Class targetClass = target.parent;
Library targetLibrary = targetClass.parent;
Library currentLibrary = getEnclosingLibrary(invocation);
if (libraryShouldBeTransformed(currentLibrary) &&
!libraryShouldBeTransformed(targetLibrary) &&
!rtiLibrary.contains(target)) {
return builder.attachTypeToConstructorInvocation(invocation, target);
}
return invocation;
}
Expression createRuntimeType(DartType type) {
if (context?.inInitializer == true) {
// In initializer context, the instance type is provided in
// `context.parameter` as there is no `this`.
return builder.createRuntimeType(type, typeContext: context.parameter);
} else {
return builder.createRuntimeType(type);
}
}
TreeNode defaultTreeNode(TreeNode node) {
trace(node);
return super.defaultTreeNode(node);
}
Expression visitStaticInvocation(StaticInvocation invocation) {
trace(invocation);
invocation.transformChildren(this);
Procedure target = invocation.target;
if (target == rtiLibrary.reifyFunction) {
/// Rewrite calls to reify(TypeLiteral) to a reified type.
TypeLiteral literal = invocation.arguments.positional.single;
return createRuntimeType(literal.type);
} else if (target.kind == ProcedureKind.Factory) {
// Intercept calls to factories of classes we do not transform
return interceptInstantiation(invocation, target);
}
addTypeArgumentToGenericInvocation(invocation);
return invocation;
}
Library visitLibrary(Library library) {
trace(library);
if (libraryShouldBeTransformed(library)) {
library.transformChildren(this);
}
return library;
}
Expression visitConstructorInvocation(ConstructorInvocation invocation) {
invocation.transformChildren(this);
return interceptInstantiation(invocation, invocation.target);
}
Member getStaticInvocationTarget(InvocationExpression invocation) {
if (invocation is ConstructorInvocation) {
return invocation.target;
} else if (invocation is StaticInvocation) {
return invocation.target;
} else {
throw "Unexpected InvocationExpression $invocation.";
}
}
bool isInstantiation(TreeNode invocation) {
return invocation is ConstructorInvocation ||
invocation is StaticInvocation &&
invocation.target.kind == ProcedureKind.Factory;
}
bool isTypeVariable(DartType type) => type is TypeParameterType;
/// Add the runtime type as an extra argument to constructor invocations.
Arguments visitArguments(Arguments arguments) {
trace(arguments);
arguments.transformChildren(this);
TreeNode parent = arguments.parent;
if (isInstantiation(parent)) {
Class targetClass = getEnclosingClass(getStaticInvocationTarget(parent));
// Do not add the extra argument if the class does not need a type member
// or if it can be implemented as a getter.
if (!needsTypeInformation(targetClass) || usesTypeGetter(targetClass)) {
return arguments;
}
List<DartType> typeArguments = arguments.types;
Expression type =
createRuntimeType(new InterfaceType(targetClass, typeArguments));
builder.insertAsFirstArgument(arguments, type);
}
return arguments;
}
Field visitField(Field field) {
trace(field);
visitDartType(field.type);
for (Expression annotation in field.annotations) {
annotation.accept(this);
}
// Do not visit initializers, they have already been transformed when the
// class was handled.
return field;
}
/// Go through all initializers of fields and record a static initializer
/// function, if necessary.
void rewriteFieldInitializers(Class cls) {
assert(context != null);
context.initializers = new LinkedHashMap<Field, Procedure>();
List<Field> fields = cls.fields;
bool initializerRewritten = false;
for (Field field in fields) {
if (!initializerRewritten && knowledge.usedParameters(field).isEmpty) {
// This field needs no static initializer.
continue;
}
Expression initializer = field.initializer;
if (initializer == null || field.isStatic) continue;
// Declare a new variable that holds the type information and can be
// used to access type variables in initializer context.
// TODO(karlklose): some fields do not need the parameter.
VariableDeclaration typeObject = new VariableDeclaration(r"$type");
context.parameter = typeObject;
context.inInitializer = true;
// Translate the initializer while keeping track of whether there was
// already an initializers that required type information in
// [typeVariableUsedInInitializer].
initializer = initializer.accept(this);
context.parameter = null;
context.inInitializer = false;
// Create a static initializer function from the translated initializer
// expression and record it.
Name name = new Name("\$init\$${field.name.name}");
Statement body = new ReturnStatement(initializer);
Procedure staticInitializer = new Procedure(
name,
ProcedureKind.Method,
new FunctionNode(body,
positionalParameters: <VariableDeclaration>[typeObject]),
isStatic: true,
fileUri: cls.fileUri);
context.initializers[field] = staticInitializer;
// Finally, remove the initializer from the field.
field.initializer = null;
}
}
bool inheritsTypeProperty(Class cls) {
assert(needsTypeInformation(cls));
Class superclass = cls.superclass;
return needsTypeInformation(superclass);
}
Class visitClass(Class cls) {
trace(cls);
if (needsTypeInformation(cls)) {
context = new TransformationContext();
List<TypeParameter> typeParameters = cls.typeParameters;
if (usesTypeGetter(cls)) {
assert(typeParameters.isEmpty);
context.runtimeTypeStorage = RuntimeTypeStorage.getter;
Member getter = builder.createGetter(rtiLibrary.runtimeTypeName,
createRuntimeType(cls.rawType), cls, rtiLibrary.typeType);
cls.addMember(getter);
} else if (!inheritsTypeProperty(cls)) {
context.runtimeTypeStorage = RuntimeTypeStorage.field;
// TODO(karlklose): should we add the field to [Object]?
context.runtimeTypeField = new Field(rtiLibrary.runtimeTypeName,
fileUri: cls.fileUri, isFinal: true, type: rtiLibrary.typeType);
cls.addMember(context.runtimeTypeField);
} else {
context.runtimeTypeStorage = RuntimeTypeStorage.inheritedField;
}
for (int i = 0; i < typeParameters.length; ++i) {
TypeParameter variable = typeParameters[i];
cls.addMember(builder.createTypeVariableGetter(cls, variable, i));
}
// Tag the class as supporting the runtime type getter.
InterfaceType interfaceTypeForSupertype =
new InterfaceType(rtiLibrary.markerClass);
cls.implementedTypes.add(new Supertype(
interfaceTypeForSupertype.classNode,
interfaceTypeForSupertype.typeArguments));
// Before transforming the parts of the class declaration, rewrite field
// initializers that use type variables (or that would be called after one
// that does) to static functions that can be used from constructors.
rewriteFieldInitializers(cls);
// Add properties for declaration tests.
for (Class test in knowledge.classTests) {
if (test == rtiLibrary.markerClass) continue;
Procedure tag = builder.createGetter(
builder.getTypeTestTagName(test),
new BoolLiteral(isSuperClass(test, cls)),
cls,
builder.coreTypes.boolClass.rawType);
cls.addMember(tag);
}
// Add a runtimeType getter.
if (!usesTypeGetter(cls) && !inheritsTypeProperty(cls)) {
cls.addMember(new Procedure(
new Name("runtimeType"),
ProcedureKind.Getter,
new FunctionNode(
new ReturnStatement(new DirectPropertyGet(
new ThisExpression(), context.runtimeTypeField)),
returnType: builder.coreTypes.typeClass.rawType),
fileUri: cls.fileUri));
}
}
cls.transformChildren(this);
// Add the static initializer functions. They have already been transformed.
if (context?.initializers != null) {
context.initializers.forEach((_, Procedure initializer) {
cls.addMember(initializer);
});
}
// TODO(karlklose): clear type arguments later, the order of class
// transformations otherwise influences the result.
// cls.typeParameters.clear();
context = null;
return cls;
}
// TODO(karlklose): replace with a structure that can answer also the question
// which tags must be overriden due to different values.
/// Returns `true` if [a] is a declaration used in a supertype of [b].
bool isSuperClass(Class a, Class b) {
if (b == null) return false;
if (a == b) return true;
if (isSuperClass(a, b.superclass)) {
return true;
}
Iterable<Class> interfaceClasses = b.implementedTypes
.map((Supertype type) => type.classNode)
.where((Class cls) => cls != rtiLibrary.markerClass);
return interfaceClasses
.any((Class declaration) => isSuperClass(a, declaration));
}
bool isConstructorOrFactory(TreeNode node) {
return isFactory(node) || node is Constructor;
}
bool isFactory(TreeNode node) {
return node is Procedure && node.kind == ProcedureKind.Factory;
}
bool needsParameterForRuntimeType(TreeNode node) {
if (!isConstructorOrFactory(node)) return false;
RuntimeTypeStorage access = context.runtimeTypeStorage;
assert(access != RuntimeTypeStorage.none);
return access == RuntimeTypeStorage.field ||
access == RuntimeTypeStorage.inheritedField;
}
FunctionNode visitFunctionNode(FunctionNode node) {
trace(node);
addTypeArgumentToGenericDeclaration(node);
// If we have a [TransformationContext] with a runtime type field and we
// translate a constructor or factory, we need a parameter that the code of
// initializers or the factory body can use to access type arguments.
// The parameter field in the context will be reset in the visit-method of
// the parent.
if (context != null && needsParameterForRuntimeType(node.parent)) {
assert(context.parameter == null);
// Create the parameter and insert it as the function's first parameter.
context.parameter = new VariableDeclaration(
rtiLibrary.runtimeTypeName.name,
type: rtiLibrary.typeType);
context.parameter.parent = node;
node.positionalParameters.insert(0, context.parameter);
node.requiredParameterCount++;
}
node.transformChildren(this);
return node;
}
SuperInitializer visitSuperInitializer(SuperInitializer initializer) {
initializer.transformChildren(this);
return addTypeAsArgument(initializer);
}
RedirectingInitializer visitRedirectingInitializer(
RedirectingInitializer initializer) {
initializer.transformChildren(this);
return addTypeAsArgument(initializer);
}
Procedure visitProcedure(Procedure procedure) {
trace(procedure);
transformList(procedure.annotations, this, procedure.parent);
// Visit the function body in a initializing context, if it is a factory.
context?.inInitializer = isFactory(procedure);
procedure.function?.accept(this);
context?.inInitializer = false;
context?.parameter = null;
return procedure;
}
Constructor visitConstructor(Constructor constructor) {
trace(constructor);
transformList(constructor.annotations, this, constructor);
if (constructor.function != null) {
constructor.function = constructor.function.accept(this);
constructor.function?.parent = constructor;
}
context?.inInitializer = true;
transformList(constructor.initializers, this, constructor);
context?.inInitializer = false;
if (context != null) {
if (context.runtimeTypeStorage == RuntimeTypeStorage.field) {
// Initialize the runtime type field with value given in the additional
// constructor parameter.
assert(context.parameter != null);
Initializer initializer = new FieldInitializer(
context.runtimeTypeField, new VariableGet(context.parameter));
initializer.parent = constructor;
constructor.initializers.insert(0, initializer);
}
if (context.initializers != null) {
// For each field that needed a static initializer function, initialize
// the field by calling the function.
List<Initializer> fieldInitializers = <Initializer>[];
context.initializers.forEach((Field field, Procedure initializer) {
assert(context.parameter != null);
Arguments argument =
new Arguments(<Expression>[new VariableGet(context.parameter)]);
fieldInitializers.add(new FieldInitializer(
field, new StaticInvocation(initializer, argument)));
});
constructor.initializers.insertAll(0, fieldInitializers);
}
context.parameter = null;
}
return constructor;
}
/// Returns `true` if the given type can be tested using type test tags.
///
/// This implies that there are no subtypes of the [type] that are not
/// transformed.
bool typeSupportsTagTest(InterfaceType type) {
return needsTypeInformation(type.classNode);
}
Expression visitIsExpression(IsExpression expression) {
trace(expression);
expression.transformChildren(this);
if (getEnclosingLibrary(expression) == rtiLibrary.interceptorsLibrary) {
// In the interceptor library we need actual is-checks at the moment.
return expression;
}
Expression target = expression.operand;
DartType type = expression.type;
if (type is InterfaceType && typeSupportsTagTest(type)) {
assert(knowledge.classTests.contains(type.classNode));
bool checkArguments =
type.typeArguments.any((DartType type) => type is! DynamicType);
Class declaration = type.classNode;
VariableDeclaration typeExpression =
new VariableDeclaration(null, initializer: createRuntimeType(type));
VariableDeclaration targetValue =
new VariableDeclaration(null, initializer: target);
Expression markerClassTest = new IsExpression(
new VariableGet(targetValue), rtiLibrary.markerClass.rawType);
Expression tagCheck = new PropertyGet(new VariableGet(targetValue),
builder.getTypeTestTagName(declaration));
Expression check = new LogicalExpression(markerClassTest, "&&", tagCheck);
if (checkArguments) {
// TODO(karlklose): support a direct argument check, we already checked
// the declaration.
Expression uninterceptedCheck = new Let(
typeExpression,
builder.createIsSubtypeOf(
new VariableGet(targetValue), new VariableGet(typeExpression),
targetHasTypeProperty: true));
check = new LogicalExpression(check, "&&", uninterceptedCheck);
}
return new Let(targetValue, check);
} else {
return builder.createIsSubtypeOf(target, createRuntimeType(type));
}
}
Expression visitListLiteral(ListLiteral node) {
trace(node);
node.transformChildren(this);
return builder.callAttachType(
node,
new InterfaceType(
builder.coreTypes.listClass, <DartType>[node.typeArgument]));
}
Expression visitMapLiteral(MapLiteral node) {
trace(node);
node.transformChildren(this);
return builder.callAttachType(
node,
new InterfaceType(builder.coreTypes.mapClass,
<DartType>[node.keyType, node.valueType]));
}
Expression visitMethodInvocation(MethodInvocation node) {
node.transformChildren(this);
addTypeArgumentToGenericInvocation(node);
return node;
}
bool isGenericMethod(FunctionNode node) {
if (node.parent is Member) {
Member member = node.parent;
if (member is Constructor ||
member is Procedure && member.kind == ProcedureKind.Factory) {
return member.enclosingClass.typeParameters.length <
node.typeParameters.length;
}
}
return node.typeParameters.isNotEmpty;
}
void addTypeArgumentToGenericInvocation(InvocationExpression expression) {
if (expression.arguments.types.length > 0) {
ListLiteral genericMethodTypeParameters = new ListLiteral(
expression.arguments.types
.map(createRuntimeType)
.toList(growable: false),
typeArgument: rtiLibrary.typeType);
expression.arguments.named.add(new NamedExpression(
genericMethodTypeParametersName, genericMethodTypeParameters)
..parent = expression.arguments);
}
}
void addTypeArgumentToGenericDeclaration(FunctionNode node) {
if (isGenericMethod(node)) {
VariableDeclaration genericMethodTypeParameters = new VariableDeclaration(
genericMethodTypeParametersName,
type: new InterfaceType(
builder.coreTypes.listClass, <DartType>[rtiLibrary.typeType]));
genericMethodTypeParameters.parent = node;
node.namedParameters.insert(0, genericMethodTypeParameters);
}
}
}

View file

@ -1,21 +0,0 @@
# Copyright (c) 2017, 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.md file.
/generic_methods_unused_parameter_test: Crash
/generic_methods_closure_test: Crash
/generic_methods_generic_class_tearoff_test: Crash
/generic_methods_local_variable_declaration_test: Crash
/generic_methods_named_parameters_test: Crash
/generic_methods_optional_parameters_test: Crash
/generic_methods_recursive_bound_error_test: Crash
/generic_methods_recursive_bound_test: Crash
/generic_methods_reuse_type_variables_test: Crash
/generic_methods_shadowing_test: Crash
/generic_methods_simple_is_expression_test: Crash
/generic_methods_tearoff_specialization_test: Crash
/generic_methods_bounds_test: Fail
/generic_methods_dynamic_dependent_type_error_test: Fail
/generic_methods_dynamic_simple_error_test: Fail
/generic_methods_dynamic_test: Fail
/generic_methods_simple_as_expression_error_test: Fail

View file

@ -1,155 +0,0 @@
// Copyright (c) 2017, 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.md file.
library test.kernel.reify.suite;
import 'dart:async' show Future;
import 'dart:io' show Platform, File;
import 'package:kernel/core_types.dart' show CoreTypes;
import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget;
import 'package:kernel/target/vmcc.dart' show VmClosureConvertedTarget;
import 'package:front_end/src/compute_platform_binaries_location.dart'
show computePlatformBinariesLocation;
import 'package:front_end/src/fasta/testing/kernel_chain.dart'
show
Compile,
CompileContext,
MatchExpectation,
Print,
ReadDill,
Verify,
WriteDill;
import 'package:testing/testing.dart'
show Chain, ChainContext, Result, StdioProcess, Step, runMe;
import 'package:kernel/ast.dart' show Component;
import 'package:kernel/transformations/generic_types_reification.dart'
as generic_types_reification;
class TestContext extends ChainContext implements CompileContext {
final Uri vm;
final Uri platformUri;
final Uri platformBinaries;
@override
final Target target = new NotReifiedTarget(new TargetFlags(
strongMode: true,
kernelRuntime: Platform.script.resolve("../../runtime/")));
// Strong mode is required to keep the type arguments in invocations of
// generic methods.
@override
bool get strongMode => true;
final List<Step> steps;
TestContext(
this.vm, this.platformUri, this.platformBinaries, bool updateExpectations)
: steps = <Step>[
const Compile(),
const Print(),
const Verify(true),
const GenericTypesReification(),
const Print(),
const Verify(true),
new MatchExpectation(".expect",
updateExpectations: updateExpectations),
const WriteDill(),
const ReadDill(),
const Run(),
];
}
enum Environment {
directory,
file,
}
Future<TestContext> createContext(
Chain suite, Map<String, String> environment) async {
Uri vm = Uri.base.resolveUri(new Uri.file(Platform.resolvedExecutable));
Uri platformBinaries = computePlatformBinariesLocation();
Uri platform = platformBinaries.resolve("vm_platform.dill");
bool updateExpectations = environment["updateExpectations"] == "true";
return new TestContext(vm, platform, platformBinaries, updateExpectations);
}
// [NotReifiedTarget] is intended to work as the [Target] class that
// [VmGenericTypesReifiedTarget] inherits from, but with some transformations
// disabled. Those include tree shaking and generic types information erasure
// passes.
// [NotReifiedTarget] also adds the necessary runtime libraries.
class NotReifiedTarget extends VmClosureConvertedTarget {
NotReifiedTarget(TargetFlags flags) : super(flags);
@override
String get name => "not reified target";
// Tree shaking needs to be disabled, because Generic Types Reification
// transformation relies on certain runtime libraries to be present in
// the component that is being transformed. If the tree shaker is enabled,
// it just deletes everything from those libraries, because they aren't
// used in the component being transformed prior to the transformation.
@override
void performTreeShaking(CoreTypes coreTypes, Component component) {}
// Adds the necessary runtime libraries.
@override
List<String> get extraRequiredLibraries {
Target reifyTarget = getTarget("vmreify", this.flags);
var x = reifyTarget.extraRequiredLibraries;
return x;
}
}
class GenericTypesReification extends Step<Component, Component, TestContext> {
const GenericTypesReification();
String get name => "generic types reification";
Future<Result<Component>> run(
Component component, TestContext testContext) async {
try {
CoreTypes coreTypes = new CoreTypes(component);
component =
generic_types_reification.transformComponent(coreTypes, component);
return pass(component);
} catch (e, s) {
return crash(e, s);
}
}
}
class Run extends Step<Uri, int, TestContext> {
const Run();
String get name => "run";
bool get isAsync => true;
bool get isRuntime => true;
Future<Result<int>> run(Uri uri, TestContext context) async {
File generated = new File.fromUri(uri);
StdioProcess process;
try {
var args = [generated.path];
process = await StdioProcess.run(context.vm.toFilePath(), args);
print(process.output);
} finally {
generated.parent.delete(recursive: true);
}
return process.toResult();
}
}
main(List<String> arguments) => runMe(arguments, createContext, "testing.json");

View file

@ -1,29 +0,0 @@
{
"":"Copyright (c) 2017, 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.md file.",
"packages": "../../../../.packages",
"suites": [
{
"name": "reify",
"kind": "Chain",
"source": "suite.dart",
"path": "../../testcases/reify",
"status": "reify.status",
"pattern": [
"\\.dart$"
],
"exclude": [
"/test/reify/suite\\.dart$",
"/testcases/reify/test_base\\.dart$"
]
}
],
"analyze": {
"uris": [
"suite.dart"
],
"exclude": [
]
}
}

View file

@ -1,22 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library closure2_test;
import 'test_base.dart';
class A<T> {
fun() => (o) => o is T;
}
class X {}
class Y {}
main() {
var tester = new A<X>().fun();
expectTrue(tester(new X()));
expectFalse(tester(new Y()));
}

View file

@ -1,85 +0,0 @@
library closure2_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "dart:mock" as mock;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class A extends core::Object implements int::HasRuntimeTypeGetter {
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type) → void
: self::A::$type = $type, super core::Object::•()
;
method fun() → dynamic {
return new self::Closure#A#fun#function::•(new typ::Interface::•(self::$declarations.[](1), typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](0)))), null);
}
get $A$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](0))).[](0);
get runtimeType() → core::Type
return this.{=self::A::$type};
}
class X extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](2));
}
class Y extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](3));
}
class Closure#A#fun#function extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field mock::Context context;
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type, final mock::Context context) → dynamic
: self::Closure#A#fun#function::$type = $type, self::Closure#A#fun#function::context = context
;
method call(dynamic o) → core::bool {
"This is a temporary solution. In the VM, this will become an additional parameter.";
final mock::Context #contextParameter = this.{self::Closure#A#fun#function::context};
return typ::isSubtypeOf(int::type(o), this.$Closure#A#fun#function$T);
}
get $Closure#A#fun#function$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](1))).[](0);
get runtimeType() → core::Type
return this.{=self::Closure#A#fun#function::$type};
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](17)));
dec::init(d, 1, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](19))], new typ::FunctionType::•(new typ::Interface::•(d.[](19)), new typ::Interface::•(d.[](5)), 0, <dynamic>[const typ::Dynamic::•()]));
dec::init(d, 2, new typ::Interface::•(d.[](17)));
dec::init(d, 3, new typ::Interface::•(d.[](17)));
dec::init(d, 4, new typ::Interface::•(d.[](17)));
dec::init(d, 5, new typ::Interface::•(d.[](17)));
dec::init(d, 6, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](20), <dynamic>[new typ::Interface::•(d.[](6))]), new typ::Interface::•(d.[](21))]);
dec::init(d, 7, new typ::Interface::•(d.[](22)));
dec::init(d, 8, new typ::Interface::•(d.[](22)));
dec::init(d, 9, new typ::Interface::•(d.[](17)));
dec::init(d, 10, new typ::Interface::•(d.[](23)));
dec::init(d, 11, new typ::Interface::•(d.[](23)));
dec::init(d, 12, new typ::Interface::•(d.[](23)));
dec::init(d, 13, new typ::Interface::•(d.[](23)));
dec::init(d, 14, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](24))]);
dec::init(d, 15, new typ::Interface::•(d.[](16)));
dec::init(d, 16, new typ::Interface::•(d.[](23)));
dec::init(d, 17, null);
dec::init(d, 19, new typ::Interface::•(d.[](17)));
dec::init(d, 20, new typ::Interface::•(d.[](17)));
dec::init(d, 21, new typ::Interface::•(d.[](17)));
dec::init(d, 22, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](20), <dynamic>[new typ::Interface::•(d.[](22))])]);
dec::init(d, 23, new typ::Interface::•(d.[](17)));
dec::init(d, 24, new typ::Interface::•(d.[](17)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["A", "Closure#A#fun#function", "X", "Y", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Function", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method main() → dynamic {
dynamic tester = new self::A::•(new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](2))])).{self::A::fun}();
tes::expectTrue(tester.call(new self::X::•()));
tes::expectFalse(tester.call(new self::Y::•()));
}

View file

@ -1,49 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library closure_test;
import 'test_base.dart';
class A {}
class B {}
typedef B A2B(A a);
typedef A B2A(B b);
bar(A a) {
return null;
}
B baz(a) {
return null;
}
main() {
B foo(A a) {
return null;
}
A qux(B b) {
return null;
}
expectTrue(foo is A2B);
expectTrue(qux is! A2B);
expectTrue(foo is! B2A);
expectTrue(qux is B2A);
expectTrue(bar is A2B);
expectTrue(bar is! B2A);
expectTrue(baz is A2B);
expectTrue(baz is! B2A);
var rab = bar;
var zab = baz;
expectTrue(rab is A2B);
expectTrue(rab is! B2A);
expectTrue(zab is A2B);
expectTrue(zab is! B2A);
}

View file

@ -1,122 +0,0 @@
library closure_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "dart:mock" as mock;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class A extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](0));
}
class B extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](1));
}
class Closure#main#foo extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field mock::Context context;
constructor •(final mock::Context context) → dynamic
: self::Closure#main#foo::context = context
;
method call(self::A a) → self::B {
"This is a temporary solution. In the VM, this will become an additional parameter.";
final mock::Context #contextParameter = this.{self::Closure#main#foo::context};
return null;
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](2));
}
class Closure#main#qux extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field mock::Context context;
constructor •(final mock::Context context) → dynamic
: self::Closure#main#qux::context = context
;
method call(self::B b) → self::A {
"This is a temporary solution. In the VM, this will become an additional parameter.";
final mock::Context #contextParameter = this.{self::Closure#main#qux::context};
return null;
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](3));
}
class Closure#bar extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
constructor •() → dynamic
;
method call(self::A a) → dynamic
return self::bar(a);
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](4));
}
class Closure#baz extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
constructor •() → dynamic
;
method call(dynamic a) → self::B
return self::baz(a);
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](5));
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](20)));
dec::init(d, 1, new typ::Interface::•(d.[](20)));
dec::init(d, 2, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](6))], new typ::FunctionType::•(new typ::Interface::•(d.[](6)), new typ::Interface::•(d.[](1)), 0, <dynamic>[new typ::Interface::•(d.[](0))]));
dec::init(d, 3, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](6))], new typ::FunctionType::•(new typ::Interface::•(d.[](6)), new typ::Interface::•(d.[](0)), 0, <dynamic>[new typ::Interface::•(d.[](1))]));
dec::init(d, 4, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](6))], new typ::FunctionType::•(new typ::Interface::•(d.[](6)), const typ::Dynamic::•(), 0, <dynamic>[new typ::Interface::•(d.[](0))]));
dec::init(d, 5, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](6))], new typ::FunctionType::•(new typ::Interface::•(d.[](6)), new typ::Interface::•(d.[](1)), 0, <dynamic>[const typ::Dynamic::•()]));
dec::init(d, 6, new typ::Interface::•(d.[](20)));
dec::init(d, 7, new typ::Interface::•(d.[](20)));
dec::init(d, 8, new typ::Interface::•(d.[](20)));
dec::init(d, 9, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](22), <dynamic>[new typ::Interface::•(d.[](9))]), new typ::Interface::•(d.[](23))]);
dec::init(d, 10, new typ::Interface::•(d.[](24)));
dec::init(d, 11, new typ::Interface::•(d.[](24)));
dec::init(d, 12, new typ::Interface::•(d.[](20)));
dec::init(d, 13, new typ::Interface::•(d.[](25)));
dec::init(d, 14, new typ::Interface::•(d.[](25)));
dec::init(d, 15, new typ::Interface::•(d.[](25)));
dec::init(d, 16, new typ::Interface::•(d.[](25)));
dec::init(d, 17, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](26))]);
dec::init(d, 18, new typ::Interface::•(d.[](19)));
dec::init(d, 19, new typ::Interface::•(d.[](25)));
dec::init(d, 20, null);
dec::init(d, 22, new typ::Interface::•(d.[](20)));
dec::init(d, 23, new typ::Interface::•(d.[](20)));
dec::init(d, 24, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](22), <dynamic>[new typ::Interface::•(d.[](24))])]);
dec::init(d, 25, new typ::Interface::•(d.[](20)));
dec::init(d, 26, new typ::Interface::•(d.[](20)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["A", "B", "Closure#main#foo", "Closure#main#qux", "Closure#bar", "Closure#baz", "Function", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method bar(self::A a) → dynamic {
return null;
}
static method baz(dynamic a) → self::B {
return null;
}
static method main() → dynamic {
final (self::A) → self::B foo = new self::Closure#main#foo::•(null);
final (self::B) → self::A qux = new self::Closure#main#qux::•(null);
tes::expectTrue(typ::isSubtypeOf(int::type(foo), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](1)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))])));
tes::expectTrue(!typ::isSubtypeOf(int::type(qux), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](1)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))])));
tes::expectTrue(!typ::isSubtypeOf(int::type(foo), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](0)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](1))])));
tes::expectTrue(typ::isSubtypeOf(int::type(qux), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](0)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](1))])));
tes::expectTrue(typ::isSubtypeOf(int::type(new self::Closure#bar::•()), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](1)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))])));
tes::expectTrue(!typ::isSubtypeOf(int::type(new self::Closure#bar::•()), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](0)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](1))])));
tes::expectTrue(typ::isSubtypeOf(int::type(new self::Closure#baz::•()), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](1)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))])));
tes::expectTrue(!typ::isSubtypeOf(int::type(new self::Closure#baz::•()), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](0)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](1))])));
(self::A) → dynamic rab = new self::Closure#bar::•();
(dynamic) → self::B zab = new self::Closure#baz::•();
tes::expectTrue(typ::isSubtypeOf(int::type(rab), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](1)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))])));
tes::expectTrue(!typ::isSubtypeOf(int::type(rab), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](0)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](1))])));
tes::expectTrue(typ::isSubtypeOf(int::type(zab), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](1)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))])));
tes::expectTrue(!typ::isSubtypeOf(int::type(zab), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](6)), new typ::Interface::•(self::$declarations.[](0)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](1))])));
}

View file

@ -1,40 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library factories_test;
import 'test_base.dart';
class A<T> {
factory A() {
return new B<T>();
}
factory A.named() {
return new A<T>.internal();
}
factory A.forward() = A<T>.internal;
A.internal();
}
class B<T> extends A<T> {
B() : super.internal();
}
class X {}
class Y {}
main() {
expectTrue(new A<X>.named() is A<X>);
expectTrue(new A<X>.named() is! A<Y>);
expectTrue(new A<X>.forward() is A<X>);
expectTrue(new A<X>.forward() is! A<Y>);
expectTrue(new A<X>() is B<X>);
expectTrue(new A<X>() is! B<Y>);
expectTrue(new A<X>.named() is! B<X>);
expectTrue(new A<X>.forward() is! B<X>);
}

View file

@ -1,97 +0,0 @@
library factories_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class A extends core::Object implements int::HasRuntimeTypeGetter {
final field typ::ReifiedType $type;
constructor internal(typ::ReifiedType $type) → void
: self::A::$type = $type, super core::Object::•()
;
static factory •(typ::ReifiedType $type) → self::A {
return new self::B::•(new typ::Interface::•(self::$declarations.[](1), <dynamic>[typ::getTypeArguments(typ::asInstanceOf($type, self::$declarations.[](0))).[](0)]));
}
static factory named(typ::ReifiedType $type) → self::A {
return new self::A::internal(new typ::Interface::•(self::$declarations.[](0), <dynamic>[typ::getTypeArguments(typ::asInstanceOf($type, self::$declarations.[](0))).[](0)]));
}
get $A$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](0))).[](0);
get $is$A() → core::bool
return true;
get $is$B() → core::bool
return false;
get runtimeType() → core::Type
return this.{=self::A::$type};
}
class B extends self::A implements int::HasRuntimeTypeGetter {
constructor •(typ::ReifiedType $type) → void
: super self::A::internal($type)
;
get $B$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](1))).[](0);
get $is$A() → core::bool
return true;
get $is$B() → core::bool
return true;
}
class X extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](2));
get $is$A() → core::bool
return false;
get $is$B() → core::bool
return false;
}
class Y extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](3));
get $is$A() → core::bool
return false;
get $is$B() → core::bool
return false;
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](17)));
dec::init(d, 1, new typ::Interface::•(d.[](0), <dynamic>[d.[](1).variables.[](0)]));
dec::init(d, 2, new typ::Interface::•(d.[](17)));
dec::init(d, 3, new typ::Interface::•(d.[](17)));
dec::init(d, 4, new typ::Interface::•(d.[](17)));
dec::init(d, 5, new typ::Interface::•(d.[](17)));
dec::init(d, 6, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](19), <dynamic>[new typ::Interface::•(d.[](6))]), new typ::Interface::•(d.[](20))]);
dec::init(d, 7, new typ::Interface::•(d.[](21)));
dec::init(d, 8, new typ::Interface::•(d.[](21)));
dec::init(d, 9, new typ::Interface::•(d.[](17)));
dec::init(d, 10, new typ::Interface::•(d.[](22)));
dec::init(d, 11, new typ::Interface::•(d.[](22)));
dec::init(d, 12, new typ::Interface::•(d.[](22)));
dec::init(d, 13, new typ::Interface::•(d.[](22)));
dec::init(d, 14, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](23))]);
dec::init(d, 15, new typ::Interface::•(d.[](16)));
dec::init(d, 16, new typ::Interface::•(d.[](22)));
dec::init(d, 17, null);
dec::init(d, 19, new typ::Interface::•(d.[](17)));
dec::init(d, 20, new typ::Interface::•(d.[](17)));
dec::init(d, 21, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](19), <dynamic>[new typ::Interface::•(d.[](21))])]);
dec::init(d, 22, new typ::Interface::•(d.[](17)));
dec::init(d, 23, new typ::Interface::•(d.[](17)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["A", "B", "X", "Y", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method main() → dynamic {
tes::expectTrue(let dynamic #t1 = self::A::named(new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](2))])) in #t1 is int::HasRuntimeTypeGetter && #t1.$is$A && (let dynamic #t2 = new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](2))]) in typ::isSubtypeOf(#t1.$type, #t2)));
tes::expectTrue(!(let dynamic #t3 = self::A::named(new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](2))])) in #t3 is int::HasRuntimeTypeGetter && #t3.$is$A && (let dynamic #t4 = new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](3))]) in typ::isSubtypeOf(#t3.$type, #t4))));
tes::expectTrue(let dynamic #t5 = new self::A::internal(new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](2))])) in #t5 is int::HasRuntimeTypeGetter && #t5.$is$A && (let dynamic #t6 = new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](2))]) in typ::isSubtypeOf(#t5.$type, #t6)));
tes::expectTrue(!(let dynamic #t7 = new self::A::internal(new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](2))])) in #t7 is int::HasRuntimeTypeGetter && #t7.$is$A && (let dynamic #t8 = new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](3))]) in typ::isSubtypeOf(#t7.$type, #t8))));
tes::expectTrue(let dynamic #t9 = self::A::•(new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](2))])) in #t9 is int::HasRuntimeTypeGetter && #t9.$is$B && (let dynamic #t10 = new typ::Interface::•(self::$declarations.[](1), <dynamic>[new typ::Interface::•(self::$declarations.[](2))]) in typ::isSubtypeOf(#t9.$type, #t10)));
tes::expectTrue(!(let dynamic #t11 = self::A::•(new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](2))])) in #t11 is int::HasRuntimeTypeGetter && #t11.$is$B && (let dynamic #t12 = new typ::Interface::•(self::$declarations.[](1), <dynamic>[new typ::Interface::•(self::$declarations.[](3))]) in typ::isSubtypeOf(#t11.$type, #t12))));
tes::expectTrue(!(let dynamic #t13 = self::A::named(new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](2))])) in #t13 is int::HasRuntimeTypeGetter && #t13.$is$B && (let dynamic #t14 = new typ::Interface::•(self::$declarations.[](1), <dynamic>[new typ::Interface::•(self::$declarations.[](2))]) in typ::isSubtypeOf(#t13.$type, #t14))));
tes::expectTrue(!(let dynamic #t15 = new self::A::internal(new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](2))])) in #t15 is int::HasRuntimeTypeGetter && #t15.$is$B && (let dynamic #t16 = new typ::Interface::•(self::$declarations.[](1), <dynamic>[new typ::Interface::•(self::$declarations.[](2))]) in typ::isSubtypeOf(#t15.$type, #t16))));
}

View file

@ -1,24 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library field_initializer2_test;
import 'test_base.dart';
class A<T> {}
class B<T> {
var x = new A<T>();
var y;
B() : y = new A<T>();
}
main() {
var b = new B<A>();
expectTrue(b.x is A<A>);
expectTrue(b.y is A<A>);
expectFalse(b.x is A<B>);
expectFalse(b.y is A<B>);
}

View file

@ -1,70 +0,0 @@
library field_initializer2_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class A extends core::Object implements int::HasRuntimeTypeGetter {
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type) → void
: self::A::$type = $type, super core::Object::•()
;
get $A$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](0))).[](0);
get $is$A() → core::bool
return true;
get runtimeType() → core::Type
return this.{=self::A::$type};
}
class B extends core::Object implements int::HasRuntimeTypeGetter {
field self::A x;
field dynamic y;
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type) → void
: self::B::x = self::B::$init$x($type), self::B::$type = $type, self::B::y = new self::A::•(new typ::Interface::•(self::$declarations.[](0), typ::getTypeArguments(typ::asInstanceOf($type, self::$declarations.[](1))))), super core::Object::•()
;
set x$cc(self::A x_) → dynamic {
this.{=self::B::x} = x_ as self::A;
}
get $B$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](1))).[](0);
get $is$A() → core::bool
return false;
get runtimeType() → core::Type
return this.{=self::B::$type};
static method $init$x(dynamic $type) → dynamic
return new self::A::•(new typ::Interface::•(self::$declarations.[](0), typ::getTypeArguments(typ::asInstanceOf($type, self::$declarations.[](1)))));
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](15)));
dec::init(d, 1, new typ::Interface::•(d.[](15)));
dec::init(d, 2, new typ::Interface::•(d.[](15)));
dec::init(d, 3, new typ::Interface::•(d.[](15)));
dec::init(d, 4, new typ::Interface::•(d.[](15)), <dynamic>[new typ::Interface::•(d.[](17), <dynamic>[new typ::Interface::•(d.[](4))]), new typ::Interface::•(d.[](18))]);
dec::init(d, 5, new typ::Interface::•(d.[](19)));
dec::init(d, 6, new typ::Interface::•(d.[](19)));
dec::init(d, 7, new typ::Interface::•(d.[](15)));
dec::init(d, 8, new typ::Interface::•(d.[](20)));
dec::init(d, 9, new typ::Interface::•(d.[](20)));
dec::init(d, 10, new typ::Interface::•(d.[](20)));
dec::init(d, 11, new typ::Interface::•(d.[](20)));
dec::init(d, 12, new typ::Interface::•(d.[](15)), <dynamic>[new typ::Interface::•(d.[](21))]);
dec::init(d, 13, new typ::Interface::•(d.[](14)));
dec::init(d, 14, new typ::Interface::•(d.[](20)));
dec::init(d, 15, null);
dec::init(d, 17, new typ::Interface::•(d.[](15)));
dec::init(d, 18, new typ::Interface::•(d.[](15)));
dec::init(d, 19, new typ::Interface::•(d.[](15)), <dynamic>[new typ::Interface::•(d.[](17), <dynamic>[new typ::Interface::•(d.[](19))])]);
dec::init(d, 20, new typ::Interface::•(d.[](15)));
dec::init(d, 21, new typ::Interface::•(d.[](15)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["A", "B", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method main() → dynamic {
self::B b = new self::B::•(new typ::Interface::•(self::$declarations.[](1), <dynamic>[new typ::Interface::•(self::$declarations.[](0), <dynamic>[const typ::Dynamic::•()])]));
tes::expectTrue(let dynamic #t1 = b.{self::B::x} in #t1 is int::HasRuntimeTypeGetter && #t1.$is$A && (let dynamic #t2 = new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](0), <dynamic>[const typ::Dynamic::•()])]) in typ::isSubtypeOf(#t1.$type, #t2)));
tes::expectTrue(let dynamic #t3 = b.{self::B::y} in #t3 is int::HasRuntimeTypeGetter && #t3.$is$A && (let dynamic #t4 = new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](0), <dynamic>[const typ::Dynamic::•()])]) in typ::isSubtypeOf(#t3.$type, #t4)));
tes::expectFalse(let dynamic #t5 = b.{self::B::x} in #t5 is int::HasRuntimeTypeGetter && #t5.$is$A && (let dynamic #t6 = new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](1), <dynamic>[const typ::Dynamic::•()])]) in typ::isSubtypeOf(#t5.$type, #t6)));
tes::expectFalse(let dynamic #t7 = b.{self::B::y} in #t7 is int::HasRuntimeTypeGetter && #t7.$is$A && (let dynamic #t8 = new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](1), <dynamic>[const typ::Dynamic::•()])]) in typ::isSubtypeOf(#t7.$type, #t8)));
}

View file

@ -1,40 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library field_initializer_test;
import 'test_base.dart';
p(x) {
write(x);
return x;
}
class A<T> {
var a1 = p("a1");
var a2;
A() : a2 = p("a2") {
p("A");
}
}
class B<T> extends A<T> {
var b1 = p("b1");
var b2 = p("b2");
var b3;
var b4;
B()
: b3 = p("b3"),
b4 = p("b4"),
super() {
p("B");
}
}
main() {
var b = new B();
expectOutput("b1\nb2\nb3\nb4\na1\na2\nA\nB");
}

View file

@ -1,65 +0,0 @@
library field_initializer_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class A extends core::Object implements int::HasRuntimeTypeGetter {
field dynamic a1 = self::p("a1");
field dynamic a2;
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type) → void
: self::A::$type = $type, self::A::a2 = self::p("a2"), super core::Object::•() {
self::p("A");
}
get $A$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](0))).[](0);
get runtimeType() → core::Type
return this.{=self::A::$type};
}
class B extends self::A implements int::HasRuntimeTypeGetter {
field dynamic b1 = self::p("b1");
field dynamic b2 = self::p("b2");
field dynamic b3;
field dynamic b4;
constructor •(typ::ReifiedType $type) → void
: self::B::b3 = self::p("b3"), self::B::b4 = self::p("b4"), super self::A::•($type) {
self::p("B");
}
get $B$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](1))).[](0);
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](15)));
dec::init(d, 1, new typ::Interface::•(d.[](0), <dynamic>[d.[](1).variables.[](0)]));
dec::init(d, 2, new typ::Interface::•(d.[](15)));
dec::init(d, 3, new typ::Interface::•(d.[](15)));
dec::init(d, 4, new typ::Interface::•(d.[](15)), <dynamic>[new typ::Interface::•(d.[](17), <dynamic>[new typ::Interface::•(d.[](4))]), new typ::Interface::•(d.[](18))]);
dec::init(d, 5, new typ::Interface::•(d.[](19)));
dec::init(d, 6, new typ::Interface::•(d.[](19)));
dec::init(d, 7, new typ::Interface::•(d.[](15)));
dec::init(d, 8, new typ::Interface::•(d.[](20)));
dec::init(d, 9, new typ::Interface::•(d.[](20)));
dec::init(d, 10, new typ::Interface::•(d.[](20)));
dec::init(d, 11, new typ::Interface::•(d.[](20)));
dec::init(d, 12, new typ::Interface::•(d.[](15)), <dynamic>[new typ::Interface::•(d.[](21))]);
dec::init(d, 13, new typ::Interface::•(d.[](14)));
dec::init(d, 14, new typ::Interface::•(d.[](20)));
dec::init(d, 15, null);
dec::init(d, 17, new typ::Interface::•(d.[](15)));
dec::init(d, 18, new typ::Interface::•(d.[](15)));
dec::init(d, 19, new typ::Interface::•(d.[](15)), <dynamic>[new typ::Interface::•(d.[](17), <dynamic>[new typ::Interface::•(d.[](19))])]);
dec::init(d, 20, new typ::Interface::•(d.[](15)));
dec::init(d, 21, new typ::Interface::•(d.[](15)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["A", "B", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method p(dynamic x) → dynamic {
tes::write(x);
return x;
}
static method main() → dynamic {
self::B b = new self::B::•(new typ::Interface::•(self::$declarations.[](1), <dynamic>[const typ::Dynamic::•()]));
tes::expectOutput("b1\nb2\nb3\nb4\na1\na2\nA\nB");
}

View file

@ -1,266 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library function_type_test;
import 'test_base.dart';
class A {}
class B extends A {}
class C extends A {}
class D implements Function {
B call(A a) {
return null;
}
}
class ER0P1 {
void call([A a]) {}
}
class ER1P0 {
void call(A a) {}
}
class ER1P1 {
void call(A a, [B b]) {}
}
class ER1P2 {
void call(A a, [B b, C c]) {}
}
class ER2P1 {
void call(A a, B b, [C c]) {}
}
class ER0N1 {
void call({A a}) {}
}
class ER1N0 {
void call(A a) {}
}
class ER1N1 {
void call(A a, {B b}) {}
}
class ER1N2 {
void call(A a, {B b, C c}) {}
}
class ER2N1 {
void call(A a, B b, {C c}) {}
}
class ER0N8 {
void call({kE, ii, oP, Ij, pA, zD, aZ, UU}) {}
}
C foo(A a) {
return null;
}
typedef B A2B(A a);
typedef C C2C(C c);
typedef void R0P1([A a]);
typedef void R1P0(A a);
typedef void R1P1(A a, [B b]);
typedef void R1P2(A a, [B b, C c]);
typedef void R2P1(A a, B b, [C c]);
typedef void R0N1({A a});
typedef void R1N0(A a);
typedef void R1N1(A a, {B b});
typedef void R1N2(A a, {B b, C c});
typedef void R2N1(A a, B b, {C c});
typedef void R0N8({aZ, oP, Ij, kE, pA, zD, UU, ii});
void test(x) {
write(x is Function);
write(x is A2B);
write(x is C2C);
write(x is R0P1);
write(x is R1P0);
write(x is R1P1);
write(x is R1P2);
write(x is R2P1);
write(x is R0N1);
write(x is R1N0);
write(x is R1N1);
write(x is R1N2);
write(x is R2N1);
}
main() {
test(new D());
for (var c in [
new ER0P1(),
new ER1P0(),
new ER1P1(),
new ER1P2(),
new ER2P1(),
new ER0N1(),
new ER1N0(),
new ER1N1(),
new ER1N2(),
new ER2N1()
]) {
test(c);
}
expectOutput("""
true
true
false
false
true
false
false
false
false
true
false
false
false
true
false
false
true
true
false
false
false
false
true
false
false
false
true
false
false
false
true
false
false
false
false
true
false
false
false
true
false
false
false
true
true
false
false
false
true
false
false
false
true
false
false
false
true
true
true
true
false
true
false
false
false
true
false
false
false
false
false
false
true
false
false
false
false
false
true
false
false
false
false
false
false
false
true
false
false
false
false
true
false
false
false
true
false
false
false
false
true
false
false
false
true
false
false
false
true
false
false
false
false
true
true
false
false
true
false
false
false
true
false
false
false
false
true
true
true
false
true
false
false
false
false
false
false
false
false
false
false
false
true""");
}

View file

@ -1,223 +0,0 @@
library function_type_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class A extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](0));
get $is$Function() → core::bool
return false;
}
class B extends self::A implements int::HasRuntimeTypeGetter {
constructor •() → void
: super self::A::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](1));
get $is$Function() → core::bool
return false;
}
class C extends self::A implements int::HasRuntimeTypeGetter {
constructor •() → void
: super self::A::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](2));
get $is$Function() → core::bool
return false;
}
class D extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method call(self::A a) → self::B {
return null;
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](3));
get $is$Function() → core::bool
return true;
}
class ER0P1 extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method call([self::A a]) → void {}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](4));
get $is$Function() → core::bool
return false;
}
class ER1P0 extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method call(self::A a) → void {}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](5));
get $is$Function() → core::bool
return false;
}
class ER1P1 extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method call(self::A a, [self::B b]) → void {}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](6));
get $is$Function() → core::bool
return false;
}
class ER1P2 extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method call(self::A a, [self::B b, self::C c]) → void {}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](7));
get $is$Function() → core::bool
return false;
}
class ER2P1 extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method call(self::A a, self::B b, [self::C c]) → void {}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](8));
get $is$Function() → core::bool
return false;
}
class ER0N1 extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method call({self::A a}) → void {}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](9));
get $is$Function() → core::bool
return false;
}
class ER1N0 extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method call(self::A a) → void {}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](10));
get $is$Function() → core::bool
return false;
}
class ER1N1 extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method call(self::A a, {self::B b}) → void {}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](11));
get $is$Function() → core::bool
return false;
}
class ER1N2 extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method call(self::A a, {self::B b, self::C c}) → void {}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](12));
get $is$Function() → core::bool
return false;
}
class ER2N1 extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method call(self::A a, self::B b, {self::C c}) → void {}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](13));
get $is$Function() → core::bool
return false;
}
class ER0N8 extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method call({dynamic kE, dynamic ii, dynamic oP, dynamic Ij, dynamic pA, dynamic zD, dynamic aZ, dynamic UU}) → void {}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](14));
get $is$Function() → core::bool
return false;
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](17)));
dec::init(d, 1, new typ::Interface::•(d.[](0)));
dec::init(d, 2, new typ::Interface::•(d.[](0)));
dec::init(d, 3, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](15))], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Interface::•(d.[](1)), 0, <dynamic>[new typ::Interface::•(d.[](0))]));
dec::init(d, 4, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 2, <dynamic>[new typ::Interface::•(d.[](0))]));
dec::init(d, 5, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 0, <dynamic>[new typ::Interface::•(d.[](0))]));
dec::init(d, 6, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 2, <dynamic>[new typ::Interface::•(d.[](0)), new typ::Interface::•(d.[](1))]));
dec::init(d, 7, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 4, <dynamic>[new typ::Interface::•(d.[](0)), new typ::Interface::•(d.[](1)), new typ::Interface::•(d.[](2))]));
dec::init(d, 8, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 2, <dynamic>[new typ::Interface::•(d.[](0)), new typ::Interface::•(d.[](1)), new typ::Interface::•(d.[](2))]));
dec::init(d, 9, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 3, <dynamic>["a", new typ::Interface::•(d.[](0))]));
dec::init(d, 10, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 0, <dynamic>[new typ::Interface::•(d.[](0))]));
dec::init(d, 11, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 3, <dynamic>[new typ::Interface::•(d.[](0)), "b", new typ::Interface::•(d.[](1))]));
dec::init(d, 12, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 5, <dynamic>[new typ::Interface::•(d.[](0)), "b", new typ::Interface::•(d.[](1)), "c", new typ::Interface::•(d.[](2))]));
dec::init(d, 13, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 3, <dynamic>[new typ::Interface::•(d.[](0)), new typ::Interface::•(d.[](1)), "c", new typ::Interface::•(d.[](2))]));
dec::init(d, 14, new typ::Interface::•(d.[](17)), <dynamic>[], new typ::FunctionType::•(new typ::Interface::•(d.[](15)), new typ::Void::•(), 17, <dynamic>["kE", const typ::Dynamic::•(), "ii", const typ::Dynamic::•(), "oP", const typ::Dynamic::•(), "Ij", const typ::Dynamic::•(), "pA", const typ::Dynamic::•(), "zD", const typ::Dynamic::•(), "aZ", const typ::Dynamic::•(), "UU", const typ::Dynamic::•()]));
dec::init(d, 15, new typ::Interface::•(d.[](17)));
dec::init(d, 16, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](32), <dynamic>[d.[](16).variables.[](0)])]);
dec::init(d, 17, null);
dec::init(d, 18, new typ::Interface::•(d.[](17)));
dec::init(d, 19, new typ::Interface::•(d.[](17)));
dec::init(d, 20, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](33), <dynamic>[new typ::Interface::•(d.[](20))]), new typ::Interface::•(d.[](34))]);
dec::init(d, 21, new typ::Interface::•(d.[](35)));
dec::init(d, 22, new typ::Interface::•(d.[](35)));
dec::init(d, 23, new typ::Interface::•(d.[](17)));
dec::init(d, 24, new typ::Interface::•(d.[](36)));
dec::init(d, 25, new typ::Interface::•(d.[](36)));
dec::init(d, 26, new typ::Interface::•(d.[](36)));
dec::init(d, 27, new typ::Interface::•(d.[](36)));
dec::init(d, 28, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](37))]);
dec::init(d, 29, new typ::Interface::•(d.[](30)));
dec::init(d, 30, new typ::Interface::•(d.[](36)));
dec::init(d, 32, new typ::Interface::•(d.[](38), <dynamic>[d.[](32).variables.[](0)]));
dec::init(d, 33, new typ::Interface::•(d.[](17)));
dec::init(d, 34, new typ::Interface::•(d.[](17)));
dec::init(d, 35, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](33), <dynamic>[new typ::Interface::•(d.[](35))])]);
dec::init(d, 36, new typ::Interface::•(d.[](17)));
dec::init(d, 37, new typ::Interface::•(d.[](17)));
dec::init(d, 38, new typ::Interface::•(d.[](17)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["A", "B", "C", "D", "ER0P1", "ER1P0", "ER1P1", "ER1P2", "ER2P1", "ER0N1", "ER1N0", "ER1N1", "ER1N2", "ER2N1", "ER0N8", "Function", "List", "Object", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "HasRuntimeTypeGetter", "EfficientLengthIterable", "Comparable", "Pattern", "num", "Error", "Exception", "Iterable"], <dynamic>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1]));
static method foo(self::A a) → self::C {
return null;
}
static method test(dynamic x) → void {
tes::write(typ::isSubtypeOf(int::type(x), new typ::Interface::•(self::$declarations.[](15))));
tes::write(typ::isSubtypeOf(int::type(x), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](15)), new typ::Interface::•(self::$declarations.[](1)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))])));
tes::write(typ::isSubtypeOf(int::type(x), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](15)), new typ::Interface::•(self::$declarations.[](2)), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](2))])));
tes::write(typ::isSubtypeOf(int::type(x), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](15)), new typ::Void::•(), 2, <dynamic>[new typ::Interface::•(self::$declarations.[](0))])));
tes::write(typ::isSubtypeOf(int::type(x), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](15)), new typ::Void::•(), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))])));
tes::write(typ::isSubtypeOf(int::type(x), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](15)), new typ::Void::•(), 2, <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](1))])));
tes::write(typ::isSubtypeOf(int::type(x), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](15)), new typ::Void::•(), 4, <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](1)), new typ::Interface::•(self::$declarations.[](2))])));
tes::write(typ::isSubtypeOf(int::type(x), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](15)), new typ::Void::•(), 2, <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](1)), new typ::Interface::•(self::$declarations.[](2))])));
tes::write(typ::isSubtypeOf(int::type(x), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](15)), new typ::Void::•(), 3, <dynamic>["a", new typ::Interface::•(self::$declarations.[](0))])));
tes::write(typ::isSubtypeOf(int::type(x), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](15)), new typ::Void::•(), 0, <dynamic>[new typ::Interface::•(self::$declarations.[](0))])));
tes::write(typ::isSubtypeOf(int::type(x), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](15)), new typ::Void::•(), 3, <dynamic>[new typ::Interface::•(self::$declarations.[](0)), "b", new typ::Interface::•(self::$declarations.[](1))])));
tes::write(typ::isSubtypeOf(int::type(x), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](15)), new typ::Void::•(), 5, <dynamic>[new typ::Interface::•(self::$declarations.[](0)), "b", new typ::Interface::•(self::$declarations.[](1)), "c", new typ::Interface::•(self::$declarations.[](2))])));
tes::write(typ::isSubtypeOf(int::type(x), new typ::FunctionType::•(new typ::Interface::•(self::$declarations.[](15)), new typ::Void::•(), 3, <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](1)), "c", new typ::Interface::•(self::$declarations.[](2))])));
}
static method main() → dynamic {
self::test(new self::D::•());
for (core::Object c in int::attachType(<core::Object>[new self::ER0P1::•(), new self::ER1P0::•(), new self::ER1P1::•(), new self::ER1P2::•(), new self::ER2P1::•(), new self::ER0N1::•(), new self::ER1N0::•(), new self::ER1N1::•(), new self::ER1N2::•(), new self::ER2N1::•()], new typ::Interface::•(self::$declarations.[](16), <dynamic>[new typ::Interface::•(self::$declarations.[](17))]))) {
self::test(c);
}
tes::expectOutput("true\ntrue\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\ntrue\ntrue\nfalse\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\ntrue\ntrue\ntrue\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\ntrue\ntrue\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\ntrue\ntrue\ntrue\nfalse\ntrue\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\ntrue");
}

View file

@ -1,23 +0,0 @@
// Copyright (c) 2017, 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.
// Test that a dynamic call to a generic function checks the type argument
// against its bound.
library generic_methods_bounds_test;
import "test_base.dart";
class A {}
class B {}
class C {
void fun<T extends A>(T t) {}
}
main() {
dynamic obj = new C();
expectThrows(() => obj.fun<B>(new B()), (e) => e is TypeError);
}

View file

@ -1,105 +0,0 @@
library generic_methods_bounds_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "dart:mock" as mock;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class A extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](0));
get $is$TypeError() → core::bool
return false;
}
class B extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](1));
get $is$TypeError() → core::bool
return false;
}
class C extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method fun<T extends self::A>(dynamic t, {core::List<typ::ReifiedType> $typeParameters}) → void {}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](2));
get $is$TypeError() → core::bool
return false;
}
class Closure#main#function extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field mock::Context context;
constructor •(final mock::Context context) → dynamic
: self::Closure#main#function::context = context
;
method call() → dynamic {
"This is a temporary solution. In the VM, this will become an additional parameter.";
final mock::Context #contextParameter = this.{self::Closure#main#function::context};
return #contextParameter.[](0).fun(new self::B::•(), $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](1))]);
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](3));
get $is$TypeError() → core::bool
return false;
}
class Closure#main#function#1 extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field mock::Context context;
constructor •(final mock::Context context) → dynamic
: self::Closure#main#function#1::context = context
;
method call(dynamic e) → core::bool {
"This is a temporary solution. In the VM, this will become an additional parameter.";
final mock::Context #contextParameter = this.{self::Closure#main#function#1::context};
return typ::isSubtypeOf(int::type(e), new typ::Interface::•(self::$declarations.[](5)));
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](4));
get $is$TypeError() → core::bool
return false;
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](20)));
dec::init(d, 1, new typ::Interface::•(d.[](20)));
dec::init(d, 2, new typ::Interface::•(d.[](20)));
dec::init(d, 3, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](22))], new typ::FunctionType::•(new typ::Interface::•(d.[](22)), const typ::Dynamic::•(), 0, <dynamic>[]));
dec::init(d, 4, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](22))], new typ::FunctionType::•(new typ::Interface::•(d.[](22)), new typ::Interface::•(d.[](8)), 0, <dynamic>[const typ::Dynamic::•()]));
dec::init(d, 5, new typ::Interface::•(d.[](23)));
dec::init(d, 6, new typ::Interface::•(d.[](20)));
dec::init(d, 7, new typ::Interface::•(d.[](20)));
dec::init(d, 8, new typ::Interface::•(d.[](20)));
dec::init(d, 9, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](24), <dynamic>[new typ::Interface::•(d.[](9))]), new typ::Interface::•(d.[](25))]);
dec::init(d, 10, new typ::Interface::•(d.[](26)));
dec::init(d, 11, new typ::Interface::•(d.[](26)));
dec::init(d, 12, new typ::Interface::•(d.[](20)));
dec::init(d, 13, new typ::Interface::•(d.[](27)));
dec::init(d, 14, new typ::Interface::•(d.[](27)));
dec::init(d, 15, new typ::Interface::•(d.[](27)));
dec::init(d, 16, new typ::Interface::•(d.[](27)));
dec::init(d, 17, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](28))]);
dec::init(d, 18, new typ::Interface::•(d.[](19)));
dec::init(d, 19, new typ::Interface::•(d.[](27)));
dec::init(d, 20, null);
dec::init(d, 22, new typ::Interface::•(d.[](20)));
dec::init(d, 23, new typ::Interface::•(d.[](27)));
dec::init(d, 24, new typ::Interface::•(d.[](20)));
dec::init(d, 25, new typ::Interface::•(d.[](20)));
dec::init(d, 26, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](24), <dynamic>[new typ::Interface::•(d.[](26))])]);
dec::init(d, 27, new typ::Interface::•(d.[](20)));
dec::init(d, 28, new typ::Interface::•(d.[](20)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["A", "B", "C", "Closure#main#function", "Closure#main#function#1", "TypeError", "Context", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Function", "AssertionError", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method main() → dynamic {
final mock::Context #context = int::attachType(new mock::Context::•(1), new typ::Interface::•(self::$declarations.[](6)));
#context.[]=(0, new self::C::•());
tes::expectThrows(new self::Closure#main#function::•(#context), new self::Closure#main#function#1::•(#context));
}

View file

@ -1,41 +0,0 @@
// Copyright (c) 2017, 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.
// Test that a generic closure is correctly constructed.
library generic_methods_closure_test;
import "test_base.dart";
class A {}
class I<T> {}
class B extends I<B> {}
void fun<T>(List<T> list) {
var helper1 = <S>(List<S> list) {
if (list.length > 0) {
expectTrue(list[0] is S);
}
expectTrue(list is List<S>);
expectTrue(list is List<T>);
};
void helper2<S>(List<S> list) {
if (list.length > 0) {
expectTrue(list[0] is S);
}
expectTrue(list is List<S>);
expectTrue(list is List<T>);
}
helper1<T>(list);
helper2<T>(list);
}
main() {
List<B> list = <B>[new B()];
fun<B>(list);
}

View file

@ -1,26 +0,0 @@
// Copyright (c) 2017, 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.
// Test that if the type of a parameter of a generic method depends on type
// parameter, the type of the passed argument is checked at runtime if the
// receiver is dynamic, and an exception is thrown.
library generic_methods_dynamic_dependent_type_error_test;
import "test_base.dart";
class A {}
class B {}
class C {
List<T> bar<T>(Iterable<T> t) => <T>[t.first];
}
main() {
C c = new C();
dynamic obj = c;
expectThrows(() => obj.bar<A>(<B>[new B()]), (e) => e is TypeError);
}

View file

@ -1,111 +0,0 @@
library generic_methods_dynamic_dependent_type_error_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "dart:mock" as mock;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class A extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](0));
get $is$TypeError() → core::bool
return false;
}
class B extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](1));
get $is$TypeError() → core::bool
return false;
}
class C extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method bar<T extends core::Object>(core::Iterable<self::C::bar::T> t, {core::List<typ::ReifiedType> $typeParameters}) → core::List<self::C::bar::T> {
return int::attachType(<dynamic>[t.{core::Iterable::first}], new typ::Interface::•(self::$declarations.[](3), <dynamic>[this.$C$T]));
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](2));
get $is$TypeError() → core::bool
return false;
}
class Closure#main#function extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field mock::Context context;
constructor •(final mock::Context context) → dynamic
: self::Closure#main#function::context = context
;
method call() → dynamic {
"This is a temporary solution. In the VM, this will become an additional parameter.";
final mock::Context #contextParameter = this.{self::Closure#main#function::context};
return #contextParameter.[](0).bar(int::attachType(<self::B>[new self::B::•()], new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](1))])), $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](0))]);
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](4));
get $is$TypeError() → core::bool
return false;
}
class Closure#main#function#1 extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field mock::Context context;
constructor •(final mock::Context context) → dynamic
: self::Closure#main#function#1::context = context
;
method call(dynamic e) → core::bool {
"This is a temporary solution. In the VM, this will become an additional parameter.";
final mock::Context #contextParameter = this.{self::Closure#main#function#1::context};
return typ::isSubtypeOf(int::type(e), new typ::Interface::•(self::$declarations.[](6)));
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](5));
get $is$TypeError() → core::bool
return false;
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](21)));
dec::init(d, 1, new typ::Interface::•(d.[](21)));
dec::init(d, 2, new typ::Interface::•(d.[](21)));
dec::init(d, 3, new typ::Interface::•(d.[](21)), <dynamic>[new typ::Interface::•(d.[](23), <dynamic>[d.[](3).variables.[](0)])]);
dec::init(d, 4, new typ::Interface::•(d.[](21)), <dynamic>[new typ::Interface::•(d.[](24))], new typ::FunctionType::•(new typ::Interface::•(d.[](24)), const typ::Dynamic::•(), 0, <dynamic>[]));
dec::init(d, 5, new typ::Interface::•(d.[](21)), <dynamic>[new typ::Interface::•(d.[](24))], new typ::FunctionType::•(new typ::Interface::•(d.[](24)), new typ::Interface::•(d.[](9)), 0, <dynamic>[const typ::Dynamic::•()]));
dec::init(d, 6, new typ::Interface::•(d.[](25)));
dec::init(d, 7, new typ::Interface::•(d.[](21)));
dec::init(d, 8, new typ::Interface::•(d.[](21)));
dec::init(d, 9, new typ::Interface::•(d.[](21)));
dec::init(d, 10, new typ::Interface::•(d.[](21)), <dynamic>[new typ::Interface::•(d.[](26), <dynamic>[new typ::Interface::•(d.[](10))]), new typ::Interface::•(d.[](27))]);
dec::init(d, 11, new typ::Interface::•(d.[](28)));
dec::init(d, 12, new typ::Interface::•(d.[](28)));
dec::init(d, 13, new typ::Interface::•(d.[](21)));
dec::init(d, 14, new typ::Interface::•(d.[](29)));
dec::init(d, 15, new typ::Interface::•(d.[](29)));
dec::init(d, 16, new typ::Interface::•(d.[](29)));
dec::init(d, 17, new typ::Interface::•(d.[](29)));
dec::init(d, 18, new typ::Interface::•(d.[](21)), <dynamic>[new typ::Interface::•(d.[](30))]);
dec::init(d, 19, new typ::Interface::•(d.[](20)));
dec::init(d, 20, new typ::Interface::•(d.[](29)));
dec::init(d, 21, null);
dec::init(d, 23, new typ::Interface::•(d.[](31), <dynamic>[d.[](23).variables.[](0)]));
dec::init(d, 24, new typ::Interface::•(d.[](21)));
dec::init(d, 25, new typ::Interface::•(d.[](29)));
dec::init(d, 26, new typ::Interface::•(d.[](21)));
dec::init(d, 27, new typ::Interface::•(d.[](21)));
dec::init(d, 28, new typ::Interface::•(d.[](21)), <dynamic>[new typ::Interface::•(d.[](26), <dynamic>[new typ::Interface::•(d.[](28))])]);
dec::init(d, 29, new typ::Interface::•(d.[](21)));
dec::init(d, 30, new typ::Interface::•(d.[](21)));
dec::init(d, 31, new typ::Interface::•(d.[](21)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["A", "B", "C", "List", "Closure#main#function", "Closure#main#function#1", "TypeError", "Context", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "EfficientLengthIterable", "Function", "AssertionError", "Comparable", "Pattern", "num", "Error", "Exception", "Iterable"], <dynamic>[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1]));
static method main() → dynamic {
self::C c = new self::C::•();
final mock::Context #context = int::attachType(new mock::Context::•(1), new typ::Interface::•(self::$declarations.[](7)));
#context.[]=(0, c);
tes::expectThrows(new self::Closure#main#function::•(#context), new self::Closure#main#function#1::•(#context));
}

View file

@ -1,27 +0,0 @@
// Copyright (c) 2017, 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.
// Test that if the type of a parameter of a generic method is a type parameter,
// the type of the passed argument is checked at runtime if the receiver is
// dynamic, and an exception is thrown.
library generic_methods_dynamic_simple_error_test;
import "test_base.dart";
class A {}
class B {}
class C {
T foo<T>(T t) => t;
}
main() {
B b = new B();
C c = new C();
dynamic obj = c;
expectThrows(() => obj.foo<A>(b), (e) => e is TypeError);
}

View file

@ -1,109 +0,0 @@
library generic_methods_dynamic_simple_error_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "dart:mock" as mock;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class A extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](0));
get $is$TypeError() → core::bool
return false;
}
class B extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](1));
get $is$TypeError() → core::bool
return false;
}
class C extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method foo<T extends core::Object>(dynamic t, {core::List<typ::ReifiedType> $typeParameters}) → dynamic {
return t;
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](2));
get $is$TypeError() → core::bool
return false;
}
class Closure#main#function extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field mock::Context context;
constructor •(final mock::Context context) → dynamic
: self::Closure#main#function::context = context
;
method call() → dynamic {
"This is a temporary solution. In the VM, this will become an additional parameter.";
final mock::Context #contextParameter = this.{self::Closure#main#function::context};
return #contextParameter.[](1).foo(#contextParameter.[](0), $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](0))]);
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](3));
get $is$TypeError() → core::bool
return false;
}
class Closure#main#function#1 extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field mock::Context context;
constructor •(final mock::Context context) → dynamic
: self::Closure#main#function#1::context = context
;
method call(dynamic e) → core::bool {
"This is a temporary solution. In the VM, this will become an additional parameter.";
final mock::Context #contextParameter = this.{self::Closure#main#function#1::context};
return typ::isSubtypeOf(int::type(e), new typ::Interface::•(self::$declarations.[](5)));
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](4));
get $is$TypeError() → core::bool
return false;
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](20)));
dec::init(d, 1, new typ::Interface::•(d.[](20)));
dec::init(d, 2, new typ::Interface::•(d.[](20)));
dec::init(d, 3, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](22))], new typ::FunctionType::•(new typ::Interface::•(d.[](22)), const typ::Dynamic::•(), 0, <dynamic>[]));
dec::init(d, 4, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](22))], new typ::FunctionType::•(new typ::Interface::•(d.[](22)), new typ::Interface::•(d.[](8)), 0, <dynamic>[const typ::Dynamic::•()]));
dec::init(d, 5, new typ::Interface::•(d.[](23)));
dec::init(d, 6, new typ::Interface::•(d.[](20)));
dec::init(d, 7, new typ::Interface::•(d.[](20)));
dec::init(d, 8, new typ::Interface::•(d.[](20)));
dec::init(d, 9, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](24), <dynamic>[new typ::Interface::•(d.[](9))]), new typ::Interface::•(d.[](25))]);
dec::init(d, 10, new typ::Interface::•(d.[](26)));
dec::init(d, 11, new typ::Interface::•(d.[](26)));
dec::init(d, 12, new typ::Interface::•(d.[](20)));
dec::init(d, 13, new typ::Interface::•(d.[](27)));
dec::init(d, 14, new typ::Interface::•(d.[](27)));
dec::init(d, 15, new typ::Interface::•(d.[](27)));
dec::init(d, 16, new typ::Interface::•(d.[](27)));
dec::init(d, 17, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](28))]);
dec::init(d, 18, new typ::Interface::•(d.[](19)));
dec::init(d, 19, new typ::Interface::•(d.[](27)));
dec::init(d, 20, null);
dec::init(d, 22, new typ::Interface::•(d.[](20)));
dec::init(d, 23, new typ::Interface::•(d.[](27)));
dec::init(d, 24, new typ::Interface::•(d.[](20)));
dec::init(d, 25, new typ::Interface::•(d.[](20)));
dec::init(d, 26, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](24), <dynamic>[new typ::Interface::•(d.[](26))])]);
dec::init(d, 27, new typ::Interface::•(d.[](20)));
dec::init(d, 28, new typ::Interface::•(d.[](20)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["A", "B", "C", "Closure#main#function", "Closure#main#function#1", "TypeError", "Context", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Function", "AssertionError", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method main() → dynamic {
final mock::Context #context = int::attachType(new mock::Context::•(2), new typ::Interface::•(self::$declarations.[](6)));
#context.[]=(0, new self::B::•());
self::C c = new self::C::•();
#context.[]=(1, c);
tes::expectThrows(new self::Closure#main#function::•(#context), new self::Closure#main#function#1::•(#context));
}

View file

@ -1,38 +0,0 @@
// Copyright (c) 2017, 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.
// Test that if the type of a parameter of a generic method depends on a type
// parameter, the type of the passed argument is checked at runtime if the
// receiver is dynamic. The checks should pass if the variables are declared
// correctly.
library generic_methods_dynamic_test;
import "test_base.dart";
class A {}
class B {}
class C {
T foo<T>(T t) => t;
List<T> bar<T>(Iterable<T> t) => <T>[t.first];
}
main() {
B b = new B();
C c = new C();
dynamic obj = c;
expectTrue(c.foo<B>(b) == b);
expectTrue(obj.foo<B>(b) == b);
dynamic x = c.bar<B>(<B>[new B()]);
expectTrue(x is List<B>);
expectTrue(x.length == 1);
dynamic y = obj.bar<B>(<B>[new B()]);
expectTrue(y is List<B>);
expectTrue(y.length == 1);
}

View file

@ -1,82 +0,0 @@
library generic_methods_dynamic_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class A extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](0));
get $is$List() → core::bool
return false;
}
class B extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](1));
get $is$List() → core::bool
return false;
}
class C extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method foo<T extends core::Object>(dynamic t, {core::List<typ::ReifiedType> $typeParameters}) → dynamic {
return t;
}
method bar<T extends core::Object>(core::Iterable<self::C::bar::T> t, {core::List<typ::ReifiedType> $typeParameters}) → core::List<self::C::bar::T> {
return int::attachType(<dynamic>[t.{core::Iterable::first}], new typ::Interface::•(self::$declarations.[](3), <dynamic>[this.$C$T]));
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](2));
get $is$List() → core::bool
return false;
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](17)));
dec::init(d, 1, new typ::Interface::•(d.[](17)));
dec::init(d, 2, new typ::Interface::•(d.[](17)));
dec::init(d, 3, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](19), <dynamic>[d.[](3).variables.[](0)])]);
dec::init(d, 4, new typ::Interface::•(d.[](17)));
dec::init(d, 5, new typ::Interface::•(d.[](17)));
dec::init(d, 6, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](20), <dynamic>[new typ::Interface::•(d.[](6))]), new typ::Interface::•(d.[](21))]);
dec::init(d, 7, new typ::Interface::•(d.[](22)));
dec::init(d, 8, new typ::Interface::•(d.[](22)));
dec::init(d, 9, new typ::Interface::•(d.[](17)));
dec::init(d, 10, new typ::Interface::•(d.[](23)));
dec::init(d, 11, new typ::Interface::•(d.[](23)));
dec::init(d, 12, new typ::Interface::•(d.[](23)));
dec::init(d, 13, new typ::Interface::•(d.[](23)));
dec::init(d, 14, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](24))]);
dec::init(d, 15, new typ::Interface::•(d.[](16)));
dec::init(d, 16, new typ::Interface::•(d.[](23)));
dec::init(d, 17, null);
dec::init(d, 19, new typ::Interface::•(d.[](25), <dynamic>[d.[](19).variables.[](0)]));
dec::init(d, 20, new typ::Interface::•(d.[](17)));
dec::init(d, 21, new typ::Interface::•(d.[](17)));
dec::init(d, 22, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](20), <dynamic>[new typ::Interface::•(d.[](22))])]);
dec::init(d, 23, new typ::Interface::•(d.[](17)));
dec::init(d, 24, new typ::Interface::•(d.[](17)));
dec::init(d, 25, new typ::Interface::•(d.[](17)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["A", "B", "C", "List", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "EfficientLengthIterable", "Comparable", "Pattern", "num", "Error", "Exception", "Iterable"], <dynamic>[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1]));
static method main() → dynamic {
self::B b = new self::B::•();
self::C c = new self::C::•();
dynamic obj = c;
tes::expectTrue(c.{self::C::foo}(b, $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](1))]).{core::Object::==}(b));
tes::expectTrue(obj.foo(b, $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](1))]).==(b));
dynamic x = c.{self::C::bar}(int::attachType(<self::B>[new self::B::•()], new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](1))])), $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](1))]);
tes::expectTrue(typ::isSubtypeOf(int::type(x), new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](1))])));
tes::expectTrue(x.length.==(1));
dynamic y = obj.bar(int::attachType(<self::B>[new self::B::•()], new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](1))])), $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](1))]);
tes::expectTrue(typ::isSubtypeOf(int::type(y), new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](1))])));
tes::expectTrue(y.length.==(1));
}

View file

@ -1,43 +0,0 @@
// Copyright (c) 2017, 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.
// Test that a torn off method of a generic class is not a generic method,
// and that it is correctly specialized.
library generic_methods_generic_class_tearoff_test;
import "test_base.dart";
class A<T> {
T fun(T t) => t;
}
typedef Int2Int = int Function(int);
typedef String2String = String Function(String);
typedef Object2Object = Object Function(Object);
typedef GenericMethod = T Function<T>(T);
main() {
A<int> x = new A<int>();
var f = x.fun; // The type of f should be 'int Function(Object)'.
A<String> y = new A<String>();
var g = y.fun; // The type of g should be 'String Function(Object)'.
A z = new A();
var h = z.fun; // The type of h should be 'dynamic Function(Object)'.
expectTrue(f is Int2Int);
expectTrue(f is! String2String);
expectTrue(f is Object2Object);
expectTrue(f is! GenericMethod);
expectTrue(g is! Int2Int);
expectTrue(g is String2String);
expectTrue(g is Object2Object);
expectTrue(g is! GenericMethod);
expectTrue(h is! Int2Int);
expectTrue(h is! String2String);
expectTrue(h is Object2Object);
expectTrue(h is! GenericMethod);
}

View file

@ -1,50 +0,0 @@
// Copyright (c) 2017, 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.
// Test that a type variable can be used to declare local variables, and that
// these local variables are of correct type.
library generic_methods_local_variable_declaration_test;
import "test_base.dart";
class X {}
abstract class Generator<T> {
T generate();
}
class A implements Generator<A> {
generate() {
return new A();
}
String toString() => "instance of A";
}
class B implements Generator<B> {
generate() {
return new B();
}
String toString() => "instance of B";
}
String fun<T extends Generator<T>>(T t) {
T another = t.generate();
String anotherName = "$another";
expectTrue(another is T);
expectTrue(another is Generator<T>);
return anotherName;
}
main() {
A a = new A();
B b = new B();
expectTrue(fun<A>(a) == "instance of A");
expectTrue(fun<B>(b) == "instance of B");
}

View file

@ -1,41 +0,0 @@
// Copyright (c) 2017, 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.
// Test that generic methods with named parameters are of correct type.
library generic_methods_named_parameters_test;
import "test_base.dart";
typedef FunObjObj = Object Function<T>(Object, {Object y});
typedef FunTypObj = Object Function<T>(T, {Object y});
typedef FunObjTyp = Object Function<T>(Object, {T y});
typedef FunTypTyp = Object Function<T>(T, {T y});
Object funObjObj<T>(Object x, {Object y}) => x;
Object funTypObj<T>(T x, {Object y}) => y;
Object funObjTyp<T>(Object x, {T y}) => x;
Object funTypTyp<T>(T x, {T y}) => null;
main() {
expectTrue(funObjObj is FunObjObj);
expectTrue(funObjObj is FunTypObj);
expectTrue(funObjObj is FunObjTyp);
expectTrue(funObjObj is FunTypTyp);
expectTrue(funTypObj is! FunObjObj);
expectTrue(funTypObj is FunTypObj);
expectTrue(funTypObj is! FunObjTyp);
expectTrue(funTypObj is FunTypTyp);
expectTrue(funObjTyp is! FunObjObj);
expectTrue(funObjTyp is! FunTypObj);
expectTrue(funObjTyp is FunObjTyp);
expectTrue(funObjTyp is FunTypTyp);
expectTrue(funTypTyp is! FunObjObj);
expectTrue(funTypTyp is! FunTypObj);
expectTrue(funTypTyp is! FunObjTyp);
expectTrue(funTypTyp is FunTypTyp);
}

View file

@ -1,41 +0,0 @@
// Copyright (c) 2017, 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.
// Test that generic methods with optional parameters are of correct type.
library generic_methods_optional_parameters_test;
import "test_base.dart";
typedef FunObjObj = Object Function<T>(Object, [Object]);
typedef FunTypObj = Object Function<T>(T, [Object]);
typedef FunObjTyp = Object Function<T>(Object, [T]);
typedef FunTypTyp = Object Function<T>(T, [T]);
Object funObjObj<T>(Object x, [Object y]) => x;
Object funTypObj<T>(T x, [Object y]) => y;
Object funObjTyp<T>(Object x, [T y]) => x;
Object funTypTyp<T>(T x, [T y]) => null;
main() {
expectTrue(funObjObj is FunObjObj);
expectTrue(funObjObj is FunTypObj);
expectTrue(funObjObj is FunObjTyp);
expectTrue(funObjObj is FunTypTyp);
expectTrue(funTypObj is! FunObjObj);
expectTrue(funTypObj is FunTypObj);
expectTrue(funTypObj is! FunObjTyp);
expectTrue(funTypObj is FunTypTyp);
expectTrue(funObjTyp is! FunObjObj);
expectTrue(funObjTyp is! FunTypObj);
expectTrue(funObjTyp is FunObjTyp);
expectTrue(funObjTyp is FunTypTyp);
expectTrue(funTypTyp is! FunObjObj);
expectTrue(funTypTyp is! FunTypObj);
expectTrue(funTypTyp is! FunObjTyp);
expectTrue(funTypTyp is FunTypTyp);
}

View file

@ -1,34 +0,0 @@
// Copyright (c) 2017, 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.
// Test that generic methods can be overridden using the bound of a type
// variable as the type of the parameter in the overloaded method.
library generic_methods_overriding_contravariance_test;
import "test_base.dart";
class X {}
class Y extends X {}
class Z extends Y {}
class C {
String fun<T extends Y>(T t) => "C";
}
class E extends C {
String fun<T extends Y>(Y y) => "E";
}
main() {
Y y = new Y();
C c = new C();
E e = new E();
expectTrue(c.fun<Y>(y) == "C");
expectTrue(e.fun<Y>(y) == "E");
}

View file

@ -1,83 +0,0 @@
library generic_methods_overriding_contravariance_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class X extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](0));
}
class Y extends self::X implements int::HasRuntimeTypeGetter {
constructor •() → void
: super self::X::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](1));
}
class Z extends self::Y implements int::HasRuntimeTypeGetter {
constructor •() → void
: super self::Y::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](2));
}
class C extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method fun<T extends self::Y>(dynamic t, {core::List<typ::ReifiedType> $typeParameters}) → core::String {
return "C";
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](3));
}
class E extends self::C implements int::HasRuntimeTypeGetter {
constructor •() → void
: super self::C::•()
;
method fun<T extends self::Y>(self::Y y, {core::List<typ::ReifiedType> $typeParameters}) → core::String {
return "E";
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](4));
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](18)));
dec::init(d, 1, new typ::Interface::•(d.[](0)));
dec::init(d, 2, new typ::Interface::•(d.[](1)));
dec::init(d, 3, new typ::Interface::•(d.[](18)));
dec::init(d, 4, new typ::Interface::•(d.[](3)));
dec::init(d, 5, new typ::Interface::•(d.[](18)));
dec::init(d, 6, new typ::Interface::•(d.[](18)));
dec::init(d, 7, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](20), <dynamic>[new typ::Interface::•(d.[](7))]), new typ::Interface::•(d.[](21))]);
dec::init(d, 8, new typ::Interface::•(d.[](22)));
dec::init(d, 9, new typ::Interface::•(d.[](22)));
dec::init(d, 10, new typ::Interface::•(d.[](18)));
dec::init(d, 11, new typ::Interface::•(d.[](23)));
dec::init(d, 12, new typ::Interface::•(d.[](23)));
dec::init(d, 13, new typ::Interface::•(d.[](23)));
dec::init(d, 14, new typ::Interface::•(d.[](23)));
dec::init(d, 15, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](24))]);
dec::init(d, 16, new typ::Interface::•(d.[](17)));
dec::init(d, 17, new typ::Interface::•(d.[](23)));
dec::init(d, 18, null);
dec::init(d, 20, new typ::Interface::•(d.[](18)));
dec::init(d, 21, new typ::Interface::•(d.[](18)));
dec::init(d, 22, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](20), <dynamic>[new typ::Interface::•(d.[](22))])]);
dec::init(d, 23, new typ::Interface::•(d.[](18)));
dec::init(d, 24, new typ::Interface::•(d.[](18)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["X", "Y", "Z", "C", "E", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method main() → dynamic {
self::Y y = new self::Y::•();
self::C c = new self::C::•();
self::E e = new self::E::•();
tes::expectTrue(c.{self::C::fun}(y, $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](1))]).{core::String::==}("C"));
tes::expectTrue(e.{self::E::fun}(y, $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](1))]).{core::String::==}("E"));
}

View file

@ -1,31 +0,0 @@
// Copyright (c) 2017, 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.
// Test that generic methods can be overridden.
library generic_methods_overriding_test;
import "test_base.dart";
class X {}
class Y extends X {}
class C {
String fun<T extends Y>(T t) => "C";
}
class D extends C {
String fun<T extends Y>(T t) => "D";
}
main() {
Y y = new Y();
C c = new C();
D d = new D();
expectTrue(c.fun<Y>(y) == "C");
expectTrue(d.fun<Y>(y) == "D");
}

View file

@ -1,75 +0,0 @@
library generic_methods_overriding_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class X extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](0));
}
class Y extends self::X implements int::HasRuntimeTypeGetter {
constructor •() → void
: super self::X::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](1));
}
class C extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method fun<T extends self::Y>(dynamic t, {core::List<typ::ReifiedType> $typeParameters}) → core::String {
return "C";
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](2));
}
class D extends self::C implements int::HasRuntimeTypeGetter {
constructor •() → void
: super self::C::•()
;
method fun<T extends self::Y>(dynamic t, {core::List<typ::ReifiedType> $typeParameters}) → core::String {
return "D";
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](3));
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](17)));
dec::init(d, 1, new typ::Interface::•(d.[](0)));
dec::init(d, 2, new typ::Interface::•(d.[](17)));
dec::init(d, 3, new typ::Interface::•(d.[](2)));
dec::init(d, 4, new typ::Interface::•(d.[](17)));
dec::init(d, 5, new typ::Interface::•(d.[](17)));
dec::init(d, 6, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](19), <dynamic>[new typ::Interface::•(d.[](6))]), new typ::Interface::•(d.[](20))]);
dec::init(d, 7, new typ::Interface::•(d.[](21)));
dec::init(d, 8, new typ::Interface::•(d.[](21)));
dec::init(d, 9, new typ::Interface::•(d.[](17)));
dec::init(d, 10, new typ::Interface::•(d.[](22)));
dec::init(d, 11, new typ::Interface::•(d.[](22)));
dec::init(d, 12, new typ::Interface::•(d.[](22)));
dec::init(d, 13, new typ::Interface::•(d.[](22)));
dec::init(d, 14, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](23))]);
dec::init(d, 15, new typ::Interface::•(d.[](16)));
dec::init(d, 16, new typ::Interface::•(d.[](22)));
dec::init(d, 17, null);
dec::init(d, 19, new typ::Interface::•(d.[](17)));
dec::init(d, 20, new typ::Interface::•(d.[](17)));
dec::init(d, 21, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](19), <dynamic>[new typ::Interface::•(d.[](21))])]);
dec::init(d, 22, new typ::Interface::•(d.[](17)));
dec::init(d, 23, new typ::Interface::•(d.[](17)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["X", "Y", "C", "D", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method main() → dynamic {
self::Y y = new self::Y::•();
self::C c = new self::C::•();
self::D d = new self::D::•();
tes::expectTrue(c.{self::C::fun}(y, $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](1))]).{core::String::==}("C"));
tes::expectTrue(d.{self::D::fun}(y, $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](1))]).{core::String::==}("D"));
}

View file

@ -1,46 +0,0 @@
// Copyright (c) 2017, 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.
// Test that generic methods that have bounds on type parameters can be
// overridden, and that type propagation can be used in such methods.
library generic_methods_overriding_type_propagation2_test;
import "test_base.dart";
class X {}
class Y extends X {}
class Z extends Y {}
class C {
String fun<T extends Y>(T t) => "C";
}
class F extends C {
String foobar(Z z) {
return "FZ";
}
String fun<T extends Y>(T t) {
if (t is Z) {
return this.foobar(t);
}
return "FY";
}
}
main() {
Y y = new Y();
Z z = new Z();
C c = new C();
F f = new F();
expectTrue(c.fun<Y>(y) == "C");
expectTrue(f.fun<Y>(y) == "FY");
expectTrue(f.fun<Z>(z) == "FZ");
}

View file

@ -1,101 +0,0 @@
library generic_methods_overriding_type_propagation2_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class X extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](0));
get $is$Z() → core::bool
return false;
}
class Y extends self::X implements int::HasRuntimeTypeGetter {
constructor •() → void
: super self::X::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](1));
get $is$Z() → core::bool
return false;
}
class Z extends self::Y implements int::HasRuntimeTypeGetter {
constructor •() → void
: super self::Y::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](2));
get $is$Z() → core::bool
return true;
}
class C extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method fun<T extends self::Y>(dynamic t, {core::List<typ::ReifiedType> $typeParameters}) → core::String {
return "C";
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](3));
get $is$Z() → core::bool
return false;
}
class F extends self::C implements int::HasRuntimeTypeGetter {
constructor •() → void
: super self::C::•()
;
method foobar(self::Z z) → core::String {
return "FZ";
}
method fun<T extends self::Y>(dynamic t, {core::List<typ::ReifiedType> $typeParameters}) → core::String {
if(let dynamic #t1 = t in #t1 is int::HasRuntimeTypeGetter && #t1.$is$Z) {
return this.{self::F::foobar}(t{self::Z});
}
return "FY";
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](4));
get $is$Z() → core::bool
return false;
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](18)));
dec::init(d, 1, new typ::Interface::•(d.[](0)));
dec::init(d, 2, new typ::Interface::•(d.[](1)));
dec::init(d, 3, new typ::Interface::•(d.[](18)));
dec::init(d, 4, new typ::Interface::•(d.[](3)));
dec::init(d, 5, new typ::Interface::•(d.[](18)));
dec::init(d, 6, new typ::Interface::•(d.[](18)));
dec::init(d, 7, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](20), <dynamic>[new typ::Interface::•(d.[](7))]), new typ::Interface::•(d.[](21))]);
dec::init(d, 8, new typ::Interface::•(d.[](22)));
dec::init(d, 9, new typ::Interface::•(d.[](22)));
dec::init(d, 10, new typ::Interface::•(d.[](18)));
dec::init(d, 11, new typ::Interface::•(d.[](23)));
dec::init(d, 12, new typ::Interface::•(d.[](23)));
dec::init(d, 13, new typ::Interface::•(d.[](23)));
dec::init(d, 14, new typ::Interface::•(d.[](23)));
dec::init(d, 15, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](24))]);
dec::init(d, 16, new typ::Interface::•(d.[](17)));
dec::init(d, 17, new typ::Interface::•(d.[](23)));
dec::init(d, 18, null);
dec::init(d, 20, new typ::Interface::•(d.[](18)));
dec::init(d, 21, new typ::Interface::•(d.[](18)));
dec::init(d, 22, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](20), <dynamic>[new typ::Interface::•(d.[](22))])]);
dec::init(d, 23, new typ::Interface::•(d.[](18)));
dec::init(d, 24, new typ::Interface::•(d.[](18)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["X", "Y", "Z", "C", "F", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method main() → dynamic {
self::Y y = new self::Y::•();
self::Z z = new self::Z::•();
self::C c = new self::C::•();
self::F f = new self::F::•();
tes::expectTrue(c.{self::C::fun}(y, $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](1))]).{core::String::==}("C"));
tes::expectTrue(f.{self::F::fun}(y, $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](1))]).{core::String::==}("FY"));
tes::expectTrue(f.{self::F::fun}(z, $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](2))]).{core::String::==}("FZ"));
}

View file

@ -1,46 +0,0 @@
// Copyright (c) 2017, 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.
// Test that generic methods that have bounds on type parameters can be
// overridden, and that type propagation can be used in such methods.
library generic_methods_overriding_type_propagation_test;
import "test_base.dart";
class X {}
class Y extends X {}
class Z extends Y {}
class C {
String fun<T extends Y>(T t) => "C";
}
class F extends C {
String foobar(Z z) {
return "FZ";
}
String fun<T extends Y>(T t) {
if (t is Z) {
return this.foobar(t as Z);
}
return "FY";
}
}
main() {
Y y = new Y();
Z z = new Z();
C c = new C();
F f = new F();
expectTrue(c.fun<Y>(y) == "C");
expectTrue(f.fun<Y>(y) == "FY");
expectTrue(f.fun<Z>(z) == "FZ");
}

View file

@ -1,101 +0,0 @@
library generic_methods_overriding_type_propagation_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class X extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](0));
get $is$Z() → core::bool
return false;
}
class Y extends self::X implements int::HasRuntimeTypeGetter {
constructor •() → void
: super self::X::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](1));
get $is$Z() → core::bool
return false;
}
class Z extends self::Y implements int::HasRuntimeTypeGetter {
constructor •() → void
: super self::Y::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](2));
get $is$Z() → core::bool
return true;
}
class C extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
method fun<T extends self::Y>(dynamic t, {core::List<typ::ReifiedType> $typeParameters}) → core::String {
return "C";
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](3));
get $is$Z() → core::bool
return false;
}
class F extends self::C implements int::HasRuntimeTypeGetter {
constructor •() → void
: super self::C::•()
;
method foobar(self::Z z) → core::String {
return "FZ";
}
method fun<T extends self::Y>(dynamic t, {core::List<typ::ReifiedType> $typeParameters}) → core::String {
if(let dynamic #t1 = t in #t1 is int::HasRuntimeTypeGetter && #t1.$is$Z) {
return this.{self::F::foobar}(t{self::Z} as self::Z);
}
return "FY";
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](4));
get $is$Z() → core::bool
return false;
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](18)));
dec::init(d, 1, new typ::Interface::•(d.[](0)));
dec::init(d, 2, new typ::Interface::•(d.[](1)));
dec::init(d, 3, new typ::Interface::•(d.[](18)));
dec::init(d, 4, new typ::Interface::•(d.[](3)));
dec::init(d, 5, new typ::Interface::•(d.[](18)));
dec::init(d, 6, new typ::Interface::•(d.[](18)));
dec::init(d, 7, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](20), <dynamic>[new typ::Interface::•(d.[](7))]), new typ::Interface::•(d.[](21))]);
dec::init(d, 8, new typ::Interface::•(d.[](22)));
dec::init(d, 9, new typ::Interface::•(d.[](22)));
dec::init(d, 10, new typ::Interface::•(d.[](18)));
dec::init(d, 11, new typ::Interface::•(d.[](23)));
dec::init(d, 12, new typ::Interface::•(d.[](23)));
dec::init(d, 13, new typ::Interface::•(d.[](23)));
dec::init(d, 14, new typ::Interface::•(d.[](23)));
dec::init(d, 15, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](24))]);
dec::init(d, 16, new typ::Interface::•(d.[](17)));
dec::init(d, 17, new typ::Interface::•(d.[](23)));
dec::init(d, 18, null);
dec::init(d, 20, new typ::Interface::•(d.[](18)));
dec::init(d, 21, new typ::Interface::•(d.[](18)));
dec::init(d, 22, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](20), <dynamic>[new typ::Interface::•(d.[](22))])]);
dec::init(d, 23, new typ::Interface::•(d.[](18)));
dec::init(d, 24, new typ::Interface::•(d.[](18)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["X", "Y", "Z", "C", "F", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method main() → dynamic {
self::Y y = new self::Y::•();
self::Z z = new self::Z::•();
self::C c = new self::C::•();
self::F f = new self::F::•();
tes::expectTrue(c.{self::C::fun}(y, $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](1))]).{core::String::==}("C"));
tes::expectTrue(f.{self::F::fun}(y, $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](1))]).{core::String::==}("FY"));
tes::expectTrue(f.{self::F::fun}(z, $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](2))]).{core::String::==}("FZ"));
}

View file

@ -1,33 +0,0 @@
// Copyright (c) 2017, 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.
// Test that F-bounded quantification works for generic methods, and that types
// that are passed to generic methods in dynamic calls are checked for being
// recursively defined. An exception should be thrown if the type doesn't meet
// the expectation.
library generic_methods_recursive_bound_error_test;
import "test_base.dart";
abstract class I<T> {
bool fun(T x);
}
void foo<T extends I<T>>(List<T> a) {
if (a.length > 1) {
a[0].fun(a[1]);
}
}
class C implements I<C> {
bool fun(C c) => true;
}
main() {
dynamic bar = foo;
List<int> list = <int>[4, 2];
// The type int does not extend I<int>.
expectThrows(() => bar<int>(list), (e) => e is TypeError);
}

View file

@ -1,28 +0,0 @@
// Copyright (c) 2017, 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.
// Test that F-bounded quantification works for generic methods.
library generic_methods_recursive_bound_test;
import "test_base.dart";
abstract class I<T> {
bool fun(T x);
}
int foo<T extends I<T>>(List<T> a) {
if (a.length > 1) {
a[0].fun(a[1]);
}
return a.length;
}
class C implements I<C> {
bool fun(C c) => true;
}
main() {
expectTrue(foo<C>(<C>[new C(), new C()]) == 2);
}

View file

@ -1,21 +0,0 @@
// Copyright (c) 2017, 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.
// Test that type parameter can be passed as a type argument in a definition of
// a local variable, and that this local variable is correctly constructed.
library generic_methods_reuse_type_variables_test;
import "test_base.dart";
int fun<T extends String>(T t) {
List<T> list = <T>[t, t, t];
expectTrue(list is List<String>);
expectTrue(list is! List<int>);
return list.length;
}
main() {
expectTrue(fun<String>("foo") == 3);
}

View file

@ -1,26 +0,0 @@
// Copyright (c) 2017, 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.
// Test that type parameters in generic methods can be shadowed.
library generic_methods_shadowing_test;
import "test_base.dart";
class X {}
class Y {}
bool foo<T, S>(T t, S s) {
// The type parameter T of bar shadows the type parameter T of foo.
bool bar<T>(T t) {
return t is T && t is S;
}
return bar<S>(s);
}
main() {
expectTrue(foo<X, Y>(new X(), new Y()));
}

View file

@ -1,18 +0,0 @@
// Copyright (c) 2017, 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.
// Test that type parameters in generic methods can be used in as-expressions,
// and that an exception is thrown if the cast can't be made.
library generic_methods_simple_as_expression_error_test;
import "test_base.dart";
T cast<T>(dynamic obj) {
return obj as T;
}
main() {
expectThrows(() => cast<String>(42), (e) => e is CastError);
}

View file

@ -1,73 +0,0 @@
library generic_methods_simple_as_expression_error_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "dart:mock" as mock;
import "../../runtime/reify/types.dart" as typ;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class Closure#main#function extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field mock::Context context;
constructor •(final mock::Context context) → dynamic
: self::Closure#main#function::context = context
;
method call() → core::String {
"This is a temporary solution. In the VM, this will become an additional parameter.";
final mock::Context #contextParameter = this.{self::Closure#main#function::context};
return self::cast(42, $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](1))]);
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](0));
get $is$CastError() → core::bool
return false;
}
class Closure#main#function#1 extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field mock::Context context;
constructor •(final mock::Context context) → dynamic
: self::Closure#main#function#1::context = context
;
method call(dynamic e) → core::bool {
"This is a temporary solution. In the VM, this will become an additional parameter.";
final mock::Context #contextParameter = this.{self::Closure#main#function#1::context};
return typ::isSubtypeOf(int::type(e), new typ::Interface::•(self::$declarations.[](3)));
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](2));
get $is$CastError() → core::bool
return false;
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](16)), <dynamic>[new typ::Interface::•(d.[](17))], new typ::FunctionType::•(new typ::Interface::•(d.[](17)), new typ::Interface::•(d.[](1)), 0, <dynamic>[]));
dec::init(d, 1, new typ::Interface::•(d.[](16)), <dynamic>[new typ::Interface::•(d.[](19), <dynamic>[new typ::Interface::•(d.[](1))]), new typ::Interface::•(d.[](20))]);
dec::init(d, 2, new typ::Interface::•(d.[](16)), <dynamic>[new typ::Interface::•(d.[](17))], new typ::FunctionType::•(new typ::Interface::•(d.[](17)), new typ::Interface::•(d.[](5)), 0, <dynamic>[const typ::Dynamic::•()]));
dec::init(d, 3, new typ::Interface::•(d.[](21)));
dec::init(d, 4, new typ::Interface::•(d.[](16)));
dec::init(d, 5, new typ::Interface::•(d.[](16)));
dec::init(d, 6, new typ::Interface::•(d.[](22)));
dec::init(d, 7, new typ::Interface::•(d.[](22)));
dec::init(d, 8, new typ::Interface::•(d.[](16)));
dec::init(d, 9, new typ::Interface::•(d.[](21)));
dec::init(d, 10, new typ::Interface::•(d.[](21)));
dec::init(d, 11, new typ::Interface::•(d.[](21)));
dec::init(d, 12, new typ::Interface::•(d.[](21)));
dec::init(d, 13, new typ::Interface::•(d.[](16)), <dynamic>[new typ::Interface::•(d.[](23))]);
dec::init(d, 14, new typ::Interface::•(d.[](15)));
dec::init(d, 15, new typ::Interface::•(d.[](21)));
dec::init(d, 16, null);
dec::init(d, 17, new typ::Interface::•(d.[](16)));
dec::init(d, 19, new typ::Interface::•(d.[](16)));
dec::init(d, 20, new typ::Interface::•(d.[](16)));
dec::init(d, 21, new typ::Interface::•(d.[](16)));
dec::init(d, 22, new typ::Interface::•(d.[](16)), <dynamic>[new typ::Interface::•(d.[](19), <dynamic>[new typ::Interface::•(d.[](22))])]);
dec::init(d, 23, new typ::Interface::•(d.[](16)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["Closure#main#function", "String", "Closure#main#function#1", "CastError", "Null", "bool", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "Function", "HasRuntimeTypeGetter", "Comparable", "Pattern", "Error", "num", "Exception"], <dynamic>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method cast(dynamic obj, {core::List<typ::ReifiedType> $typeParameters}) → dynamic {
return obj as dynamic;
}
static method main() → dynamic {
tes::expectThrows(new self::Closure#main#function::•(null), new self::Closure#main#function#1::•(null));
}

View file

@ -1,17 +0,0 @@
// Copyright (c) 2017, 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.
// Test that type parameters in generic methods can be used in as-expressions.
library generic_methods_simple_as_expression_test;
import "test_base.dart";
T cast<T>(dynamic obj) {
return obj as T;
}
main() {
expectTrue(cast<num>(42) == 42);
}

View file

@ -1,35 +0,0 @@
library generic_methods_simple_as_expression_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/types.dart" as typ;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](14)), <dynamic>[new typ::Interface::•(d.[](15), <dynamic>[new typ::Interface::•(d.[](0))])]);
dec::init(d, 1, new typ::Interface::•(d.[](14)));
dec::init(d, 2, new typ::Interface::•(d.[](14)));
dec::init(d, 3, new typ::Interface::•(d.[](14)), <dynamic>[new typ::Interface::•(d.[](15), <dynamic>[new typ::Interface::•(d.[](3))]), new typ::Interface::•(d.[](16))]);
dec::init(d, 4, new typ::Interface::•(d.[](0)));
dec::init(d, 5, new typ::Interface::•(d.[](0)));
dec::init(d, 6, new typ::Interface::•(d.[](14)));
dec::init(d, 7, new typ::Interface::•(d.[](17)));
dec::init(d, 8, new typ::Interface::•(d.[](17)));
dec::init(d, 9, new typ::Interface::•(d.[](17)));
dec::init(d, 10, new typ::Interface::•(d.[](17)));
dec::init(d, 11, new typ::Interface::•(d.[](14)), <dynamic>[new typ::Interface::•(d.[](18))]);
dec::init(d, 12, new typ::Interface::•(d.[](13)));
dec::init(d, 13, new typ::Interface::•(d.[](17)));
dec::init(d, 14, null);
dec::init(d, 15, new typ::Interface::•(d.[](14)));
dec::init(d, 16, new typ::Interface::•(d.[](14)));
dec::init(d, 17, new typ::Interface::•(d.[](14)));
dec::init(d, 18, new typ::Interface::•(d.[](14)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["num", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "Comparable", "Pattern", "Error", "Exception"], <dynamic>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]));
static method cast(dynamic obj, {core::List<typ::ReifiedType> $typeParameters}) → dynamic {
return obj as dynamic;
}
static method main() → dynamic {
tes::expectTrue(self::cast(42, $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](0))]).{core::num::==}(42));
}

View file

@ -1,18 +0,0 @@
// Copyright (c) 2017, 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.
// Test that type parameters in generic methods can be used in is-expressions.
library generic_methods_simple_is_expression_test;
import "test_base.dart";
bool fun<T>(int n) {
return n is T;
}
main() {
expectTrue(fun<int>(42));
expectFalse(fun<String>(42));
}

View file

@ -1,15 +0,0 @@
// Copyright (c) 2017, 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.
library generic_methods_simple_test;
import 'test_base.dart';
bool fun<T>(int s) {
return true;
}
main() {
expectTrue(fun<double>(2));
}

View file

@ -1,35 +0,0 @@
library generic_methods_simple_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/types.dart" as typ;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](13)));
dec::init(d, 1, new typ::Interface::•(d.[](14)));
dec::init(d, 2, new typ::Interface::•(d.[](14)));
dec::init(d, 3, new typ::Interface::•(d.[](14)), <dynamic>[new typ::Interface::•(d.[](15), <dynamic>[new typ::Interface::•(d.[](3))]), new typ::Interface::•(d.[](16))]);
dec::init(d, 4, new typ::Interface::•(d.[](13)));
dec::init(d, 5, new typ::Interface::•(d.[](14)));
dec::init(d, 6, new typ::Interface::•(d.[](17)));
dec::init(d, 7, new typ::Interface::•(d.[](17)));
dec::init(d, 8, new typ::Interface::•(d.[](17)));
dec::init(d, 9, new typ::Interface::•(d.[](17)));
dec::init(d, 10, new typ::Interface::•(d.[](14)), <dynamic>[new typ::Interface::•(d.[](18))]);
dec::init(d, 11, new typ::Interface::•(d.[](12)));
dec::init(d, 12, new typ::Interface::•(d.[](17)));
dec::init(d, 13, new typ::Interface::•(d.[](14)), <dynamic>[new typ::Interface::•(d.[](15), <dynamic>[new typ::Interface::•(d.[](13))])]);
dec::init(d, 14, null);
dec::init(d, 15, new typ::Interface::•(d.[](14)));
dec::init(d, 16, new typ::Interface::•(d.[](14)));
dec::init(d, 17, new typ::Interface::•(d.[](14)));
dec::init(d, 18, new typ::Interface::•(d.[](14)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["double", "Null", "bool", "String", "int", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "num", "Object", "Comparable", "Pattern", "Error", "Exception"], <dynamic>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0]));
static method fun(core::int s, {core::List<typ::ReifiedType> $typeParameters}) → core::bool {
return true;
}
static method main() → dynamic {
tes::expectTrue(self::fun(2, $typeParameters: <typ::ReifiedType>[new typ::Interface::•(self::$declarations.[](0))]));
}

View file

@ -1,47 +0,0 @@
// Copyright (c) 2017, 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.
// Test that generic methods can be specialized after being torn off, and that
// their specialized versions are correctly constructed.
library generic_methods_tearoff_specialization_test;
import "test_base.dart";
class A {
T fun<T>(T t) => t;
}
typedef Int2Int = int Function(int);
typedef String2String = String Function(String);
typedef Object2Object = Object Function(Object);
typedef GenericMethod = T Function<T>(T);
main() {
A a = new A();
Int2Int f = a.fun;
String2String g = a.fun;
Object2Object h = a.fun;
var generic = a.fun;
expectTrue(f is Int2Int);
expectTrue(f is! String2String);
expectTrue(f is! Object2Object);
expectTrue(f is! GenericMethod);
expectTrue(g is! Int2Int);
expectTrue(g is String2String);
expectTrue(g is! Object2Object);
expectTrue(g is! GenericMethod);
expectTrue(h is! Int2Int);
expectTrue(h is! String2String);
expectTrue(h is Object2Object);
expectTrue(g is! GenericMethod);
expectTrue(generic is! Int2Int);
expectTrue(generic is! String2String);
expectTrue(generic is! Object2Object);
expectTrue(generic is GenericMethod);
}

View file

@ -1,89 +0,0 @@
// Copyright (c) 2017, 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.
// Test that generic methods with unused parameters aren't treated as
// non-generic methods, but can be specialized as such.
library generic_methods_unused_parameter_test;
import "test_base.dart";
typedef Fun = int Function();
typedef FunReq = int Function(int);
typedef FunOpt = int Function([int]);
typedef FunReqOpt = int Function(int, [int]);
typedef FunNam = int Function({int p});
typedef FunReqNam = int Function(int, {int p});
typedef FunTyp = int Function<T>();
typedef FunTypReq = int Function<T>(int);
typedef FunTypOpt = int Function<T>([int]);
typedef FunTypReqOpt = int Function<T>(int, [int]);
typedef FunTypNam = int Function<T>({int p});
typedef FunTypReqNam = int Function<T>(int, {int p});
int fun() {}
int funReq(int x) => x;
int funOpt([int y]) => y ?? 42;
int funReqOpt(int x, [int y]) => x;
int funNam({int p}) => p ?? 42;
int funReqNam(int x, {int p}) => x;
int funTyp<T>() {}
int funTypReq<T>(int x) => x;
int funTypOpt<T>([int y]) => y ?? 42;
int funTypReqOpt<T>(int x, [int y]) => x;
int funTypNam<T>({int p}) => p ?? 42;
int funTypReqNam<T>(int x, {int p}) => x;
main() {
Fun varFun = funTyp;
FunReq varFunReq = funTypReq;
FunOpt varFunOpt = funTypOpt;
FunReqOpt varFunReqOpt = funTypReqOpt;
FunNam varFunNam = funTypNam;
FunReqNam varFunReqNam = funTypReqNam;
expectTrue(fun is Fun);
expectTrue(fun is! FunTyp);
expectTrue(funTyp is! Fun);
expectTrue(funTyp is FunTyp);
expectTrue(varFun is Fun);
expectTrue(varFun is! FunTyp);
expectTrue(funReq is FunReq);
expectTrue(funReq is! FunTypReq);
expectTrue(funTypReq is! FunReq);
expectTrue(funTypReq is FunTypReq);
expectTrue(varFunReq is FunReq);
expectTrue(varFunReq is! FunTypReq);
expectTrue(funOpt is FunOpt);
expectTrue(funOpt is! FunTypOpt);
expectTrue(funTypOpt is! FunOpt);
expectTrue(funTypOpt is FunTypOpt);
expectTrue(varFunOpt is FunOpt);
expectTrue(varFunOpt is! FunTypOpt);
expectTrue(funReqOpt is FunReqOpt);
expectTrue(funReqOpt is! FunTypReqOpt);
expectTrue(funTypReqOpt is! FunReqOpt);
expectTrue(funTypReqOpt is FunTypReqOpt);
expectTrue(varFunReqOpt is FunReqOpt);
expectTrue(varFunReqOpt is! FunTypReqOpt);
expectTrue(funNam is FunNam);
expectTrue(funNam is! FunTypNam);
expectTrue(funTypNam is! FunNam);
expectTrue(funTypNam is FunTypNam);
expectTrue(varFunNam is FunNam);
expectTrue(varFunNam is! FunTypNam);
expectTrue(funReqNam is FunReqNam);
expectTrue(funReqNam is! FunTypReqNam);
expectTrue(funTypReqNam is! FunReqNam);
expectTrue(funTypReqNam is FunTypReqNam);
expectTrue(varFunReqNam is FunReqNam);
expectTrue(varFunReqNam is! FunTypReqNam);
}

View file

@ -1,27 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library is1_test;
import 'test_base.dart';
class N {}
class I extends N {}
class D extends N {}
class A<T> {}
main() {
var x = new A<I>();
expectTrue(x is A<N>);
expectTrue(x is A<I>);
expectFalse(x is A<D>);
var y = new A();
expectTrue(y is A<N>);
expectTrue(y is A<I>);
expectTrue(y is A<D>);
}

View file

@ -1,83 +0,0 @@
library is1_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class N extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](0));
get $is$A() → core::bool
return false;
}
class I extends self::N implements int::HasRuntimeTypeGetter {
constructor •() → void
: super self::N::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](1));
get $is$A() → core::bool
return false;
}
class D extends self::N implements int::HasRuntimeTypeGetter {
constructor •() → void
: super self::N::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](2));
get $is$A() → core::bool
return false;
}
class A extends core::Object implements int::HasRuntimeTypeGetter {
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type) → void
: self::A::$type = $type, super core::Object::•()
;
get $A$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](3))).[](0);
get $is$A() → core::bool
return true;
get runtimeType() → core::Type
return this.{=self::A::$type};
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](17)));
dec::init(d, 1, new typ::Interface::•(d.[](0)));
dec::init(d, 2, new typ::Interface::•(d.[](0)));
dec::init(d, 3, new typ::Interface::•(d.[](17)));
dec::init(d, 4, new typ::Interface::•(d.[](17)));
dec::init(d, 5, new typ::Interface::•(d.[](17)));
dec::init(d, 6, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](19), <dynamic>[new typ::Interface::•(d.[](6))]), new typ::Interface::•(d.[](20))]);
dec::init(d, 7, new typ::Interface::•(d.[](21)));
dec::init(d, 8, new typ::Interface::•(d.[](21)));
dec::init(d, 9, new typ::Interface::•(d.[](17)));
dec::init(d, 10, new typ::Interface::•(d.[](22)));
dec::init(d, 11, new typ::Interface::•(d.[](22)));
dec::init(d, 12, new typ::Interface::•(d.[](22)));
dec::init(d, 13, new typ::Interface::•(d.[](22)));
dec::init(d, 14, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](23))]);
dec::init(d, 15, new typ::Interface::•(d.[](16)));
dec::init(d, 16, new typ::Interface::•(d.[](22)));
dec::init(d, 17, null);
dec::init(d, 19, new typ::Interface::•(d.[](17)));
dec::init(d, 20, new typ::Interface::•(d.[](17)));
dec::init(d, 21, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](19), <dynamic>[new typ::Interface::•(d.[](21))])]);
dec::init(d, 22, new typ::Interface::•(d.[](17)));
dec::init(d, 23, new typ::Interface::•(d.[](17)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["N", "I", "D", "A", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method main() → dynamic {
self::A x = new self::A::•(new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](1))]));
tes::expectTrue(let dynamic #t1 = x in #t1 is int::HasRuntimeTypeGetter && #t1.$is$A && (let dynamic #t2 = new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0))]) in typ::isSubtypeOf(#t1.$type, #t2)));
tes::expectTrue(let dynamic #t3 = x in #t3 is int::HasRuntimeTypeGetter && #t3.$is$A && (let dynamic #t4 = new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](1))]) in typ::isSubtypeOf(#t3.$type, #t4)));
tes::expectFalse(let dynamic #t5 = x in #t5 is int::HasRuntimeTypeGetter && #t5.$is$A && (let dynamic #t6 = new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](2))]) in typ::isSubtypeOf(#t5.$type, #t6)));
self::A y = new self::A::•(new typ::Interface::•(self::$declarations.[](3), <dynamic>[const typ::Dynamic::•()]));
tes::expectTrue(let dynamic #t7 = y in #t7 is int::HasRuntimeTypeGetter && #t7.$is$A && (let dynamic #t8 = new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0))]) in typ::isSubtypeOf(#t7.$type, #t8)));
tes::expectTrue(let dynamic #t9 = y in #t9 is int::HasRuntimeTypeGetter && #t9.$is$A && (let dynamic #t10 = new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](1))]) in typ::isSubtypeOf(#t9.$type, #t10)));
tes::expectTrue(let dynamic #t11 = y in #t11 is int::HasRuntimeTypeGetter && #t11.$is$A && (let dynamic #t12 = new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](2))]) in typ::isSubtypeOf(#t11.$type, #t12)));
}

View file

@ -1,20 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library literals_test;
import 'test_base.dart';
class A {}
class B {}
main() {
expectTrue(<A>[] is List<A>);
expectTrue(<A>[] is! List<B>);
expectTrue(<A, B>{} is Map<A, B>);
expectTrue(<A, B>{} is! Map<A, A>);
expectTrue(<A, B>{} is! Map<B, B>);
}

View file

@ -1,65 +0,0 @@
library literals_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class A extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](0));
get $is$List() → core::bool
return false;
get $is$Map() → core::bool
return false;
}
class B extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](1));
get $is$List() → core::bool
return false;
get $is$Map() → core::bool
return false;
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](17)));
dec::init(d, 1, new typ::Interface::•(d.[](17)));
dec::init(d, 2, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](19), <dynamic>[d.[](2).variables.[](0)])]);
dec::init(d, 3, new typ::Interface::•(d.[](17)));
dec::init(d, 4, new typ::Interface::•(d.[](17)));
dec::init(d, 5, new typ::Interface::•(d.[](17)));
dec::init(d, 6, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](20), <dynamic>[new typ::Interface::•(d.[](6))]), new typ::Interface::•(d.[](21))]);
dec::init(d, 7, new typ::Interface::•(d.[](22)));
dec::init(d, 8, new typ::Interface::•(d.[](22)));
dec::init(d, 9, new typ::Interface::•(d.[](17)));
dec::init(d, 10, new typ::Interface::•(d.[](23)));
dec::init(d, 11, new typ::Interface::•(d.[](23)));
dec::init(d, 12, new typ::Interface::•(d.[](23)));
dec::init(d, 13, new typ::Interface::•(d.[](23)));
dec::init(d, 14, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](24))]);
dec::init(d, 15, new typ::Interface::•(d.[](16)));
dec::init(d, 16, new typ::Interface::•(d.[](23)));
dec::init(d, 17, null);
dec::init(d, 19, new typ::Interface::•(d.[](25), <dynamic>[d.[](19).variables.[](0)]));
dec::init(d, 20, new typ::Interface::•(d.[](17)));
dec::init(d, 21, new typ::Interface::•(d.[](17)));
dec::init(d, 22, new typ::Interface::•(d.[](17)), <dynamic>[new typ::Interface::•(d.[](20), <dynamic>[new typ::Interface::•(d.[](22))])]);
dec::init(d, 23, new typ::Interface::•(d.[](17)));
dec::init(d, 24, new typ::Interface::•(d.[](17)));
dec::init(d, 25, new typ::Interface::•(d.[](17)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["A", "B", "List", "Map", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "EfficientLengthIterable", "Comparable", "Pattern", "num", "Error", "Exception", "Iterable"], <dynamic>[0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1]));
static method main() → dynamic {
tes::expectTrue(typ::isSubtypeOf(int::type(int::attachType(<self::A>[], new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](0))]))), new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])));
tes::expectTrue(!typ::isSubtypeOf(int::type(int::attachType(<self::A>[], new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](0))]))), new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](1))])));
tes::expectTrue(typ::isSubtypeOf(int::type(int::attachType(<self::A, self::B>{}, new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](1))]))), new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](1))])));
tes::expectTrue(!typ::isSubtypeOf(int::type(int::attachType(<self::A, self::B>{}, new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](1))]))), new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](0))])));
tes::expectTrue(!typ::isSubtypeOf(int::type(int::attachType(<self::A, self::B>{}, new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](1))]))), new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](1)), new typ::Interface::•(self::$declarations.[](1))])));
}

View file

@ -1,11 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library multiple_variables_test;
import '../../runtime/reify/types.dart' as rti;
class X<A, B, C, D, E> {}
main() {}

View file

@ -1,49 +0,0 @@
library multiple_variables_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "../../runtime/reify/declarations.dart" as dec;
class X extends core::Object implements int::HasRuntimeTypeGetter {
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type) → void
: self::X::$type = $type, super core::Object::•()
;
get $X$A() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](0))).[](0);
get $X$B() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](0))).[](1);
get $X$C() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](0))).[](2);
get $X$D() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](0))).[](3);
get $X$E() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](0))).[](4);
get runtimeType() → core::Type
return this.{=self::X::$type};
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](14)));
dec::init(d, 1, new typ::Interface::•(d.[](14)));
dec::init(d, 2, new typ::Interface::•(d.[](14)));
dec::init(d, 3, new typ::Interface::•(d.[](14)), <dynamic>[new typ::Interface::•(d.[](16), <dynamic>[new typ::Interface::•(d.[](3))]), new typ::Interface::•(d.[](17))]);
dec::init(d, 4, new typ::Interface::•(d.[](18)));
dec::init(d, 5, new typ::Interface::•(d.[](18)));
dec::init(d, 6, new typ::Interface::•(d.[](14)));
dec::init(d, 7, new typ::Interface::•(d.[](19)));
dec::init(d, 8, new typ::Interface::•(d.[](19)));
dec::init(d, 9, new typ::Interface::•(d.[](19)));
dec::init(d, 10, new typ::Interface::•(d.[](19)));
dec::init(d, 11, new typ::Interface::•(d.[](14)), <dynamic>[new typ::Interface::•(d.[](20))]);
dec::init(d, 12, new typ::Interface::•(d.[](13)));
dec::init(d, 13, new typ::Interface::•(d.[](19)));
dec::init(d, 14, null);
dec::init(d, 16, new typ::Interface::•(d.[](14)));
dec::init(d, 17, new typ::Interface::•(d.[](14)));
dec::init(d, 18, new typ::Interface::•(d.[](14)), <dynamic>[new typ::Interface::•(d.[](16), <dynamic>[new typ::Interface::•(d.[](18))])]);
dec::init(d, 19, new typ::Interface::•(d.[](14)));
dec::init(d, 20, new typ::Interface::•(d.[](14)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["X", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method main() → dynamic {}

View file

@ -1,51 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library native_types;
import 'test_base.dart';
abstract class C {}
class D {}
var foo = bar;
var bar = foo;
main() {
expectTrue(1 is int);
expectTrue(1 is! double);
expectTrue(new List<int>() is List<int>);
expectTrue(new List<int>() is! List<double>);
expectTrue("hest" is String);
expectTrue("hest" is! int);
expectTrue(null is! String);
expectTrue(null is dynamic);
expectTrue(null is Object);
expectTrue(true is bool);
expectTrue(true is! int);
// Test error and exception classes
expectThrows(() => new C(), (e) => e is AbstractClassInstantiationError);
/// 01: static type warning
expectThrows(() => new D().foo(), (e) => e is NoSuchMethodError);
/// 02: static type warning
expectThrows(() => foo, (e) => e is CyclicInitializationError);
expectThrows(() => [][1], (e) => e is RangeError);
expectTrue(new UnsupportedError("") is UnsupportedError);
expectTrue(new ArgumentError() is ArgumentError);
expectTrue(
new IntegerDivisionByZeroException() is IntegerDivisionByZeroException);
}

View file

@ -1,453 +0,0 @@
library native_types;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "dart:mock" as mock;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
abstract class C extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](0));
get $is$AbstractClassInstantiationError() → core::bool
return false;
get $is$NoSuchMethodError() → core::bool
return false;
get $is$CyclicInitializationError() → core::bool
return false;
get $is$RangeError() → core::bool
return false;
get $is$int() → core::bool
return false;
get $is$double() → core::bool
return false;
get $is$List() → core::bool
return false;
get $is$String() → core::bool
return false;
get $is$Object() → core::bool
return true;
get $is$bool() → core::bool
return false;
get $is$UnsupportedError() → core::bool
return false;
get $is$ArgumentError() → core::bool
return false;
get $is$IntegerDivisionByZeroException() → core::bool
return false;
}
class D extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](1));
get $is$AbstractClassInstantiationError() → core::bool
return false;
get $is$NoSuchMethodError() → core::bool
return false;
get $is$CyclicInitializationError() → core::bool
return false;
get $is$RangeError() → core::bool
return false;
get $is$int() → core::bool
return false;
get $is$double() → core::bool
return false;
get $is$List() → core::bool
return false;
get $is$String() → core::bool
return false;
get $is$Object() → core::bool
return true;
get $is$bool() → core::bool
return false;
get $is$UnsupportedError() → core::bool
return false;
get $is$ArgumentError() → core::bool
return false;
get $is$IntegerDivisionByZeroException() → core::bool
return false;
}
class Closure#main#function extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field mock::Context context;
constructor •(final mock::Context context) → dynamic
: self::Closure#main#function::context = context
;
method call() → self::C {
"This is a temporary solution. In the VM, this will become an additional parameter.";
final mock::Context #contextParameter = this.{self::Closure#main#function::context};
return throw int::attachType(new core::AbstractClassInstantiationError::•("C"), new typ::Interface::•(self::$declarations.[](3)));
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](2));
get $is$AbstractClassInstantiationError() → core::bool
return false;
get $is$NoSuchMethodError() → core::bool
return false;
get $is$CyclicInitializationError() → core::bool
return false;
get $is$RangeError() → core::bool
return false;
get $is$int() → core::bool
return false;
get $is$double() → core::bool
return false;
get $is$List() → core::bool
return false;
get $is$String() → core::bool
return false;
get $is$Object() → core::bool
return true;
get $is$bool() → core::bool
return false;
get $is$UnsupportedError() → core::bool
return false;
get $is$ArgumentError() → core::bool
return false;
get $is$IntegerDivisionByZeroException() → core::bool
return false;
}
class Closure#main#function#1 extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field mock::Context context;
constructor •(final mock::Context context) → dynamic
: self::Closure#main#function#1::context = context
;
method call(dynamic e) → core::bool {
"This is a temporary solution. In the VM, this will become an additional parameter.";
final mock::Context #contextParameter = this.{self::Closure#main#function#1::context};
return typ::isSubtypeOf(int::type(e), new typ::Interface::•(self::$declarations.[](3)));
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](4));
get $is$AbstractClassInstantiationError() → core::bool
return false;
get $is$NoSuchMethodError() → core::bool
return false;
get $is$CyclicInitializationError() → core::bool
return false;
get $is$RangeError() → core::bool
return false;
get $is$int() → core::bool
return false;
get $is$double() → core::bool
return false;
get $is$List() → core::bool
return false;
get $is$String() → core::bool
return false;
get $is$Object() → core::bool
return true;
get $is$bool() → core::bool
return false;
get $is$UnsupportedError() → core::bool
return false;
get $is$ArgumentError() → core::bool
return false;
get $is$IntegerDivisionByZeroException() → core::bool
return false;
}
class Closure#main#function#2 extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field mock::Context context;
constructor •(final mock::Context context) → dynamic
: self::Closure#main#function#2::context = context
;
method call() → dynamic {
"This is a temporary solution. In the VM, this will become an additional parameter.";
final mock::Context #contextParameter = this.{self::Closure#main#function#2::context};
return new self::D::•().foo();
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](5));
get $is$AbstractClassInstantiationError() → core::bool
return false;
get $is$NoSuchMethodError() → core::bool
return false;
get $is$CyclicInitializationError() → core::bool
return false;
get $is$RangeError() → core::bool
return false;
get $is$int() → core::bool
return false;
get $is$double() → core::bool
return false;
get $is$List() → core::bool
return false;
get $is$String() → core::bool
return false;
get $is$Object() → core::bool
return true;
get $is$bool() → core::bool
return false;
get $is$UnsupportedError() → core::bool
return false;
get $is$ArgumentError() → core::bool
return false;
get $is$IntegerDivisionByZeroException() → core::bool
return false;
}
class Closure#main#function#3 extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field mock::Context context;
constructor •(final mock::Context context) → dynamic
: self::Closure#main#function#3::context = context
;
method call(dynamic e) → core::bool {
"This is a temporary solution. In the VM, this will become an additional parameter.";
final mock::Context #contextParameter = this.{self::Closure#main#function#3::context};
return typ::isSubtypeOf(int::type(e), new typ::Interface::•(self::$declarations.[](7)));
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](6));
get $is$AbstractClassInstantiationError() → core::bool
return false;
get $is$NoSuchMethodError() → core::bool
return false;
get $is$CyclicInitializationError() → core::bool
return false;
get $is$RangeError() → core::bool
return false;
get $is$int() → core::bool
return false;
get $is$double() → core::bool
return false;
get $is$List() → core::bool
return false;
get $is$String() → core::bool
return false;
get $is$Object() → core::bool
return true;
get $is$bool() → core::bool
return false;
get $is$UnsupportedError() → core::bool
return false;
get $is$ArgumentError() → core::bool
return false;
get $is$IntegerDivisionByZeroException() → core::bool
return false;
}
class Closure#main#function#4 extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field mock::Context context;
constructor •(final mock::Context context) → dynamic
: self::Closure#main#function#4::context = context
;
method call() → dynamic {
"This is a temporary solution. In the VM, this will become an additional parameter.";
final mock::Context #contextParameter = this.{self::Closure#main#function#4::context};
return self::foo;
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](8));
get $is$AbstractClassInstantiationError() → core::bool
return false;
get $is$NoSuchMethodError() → core::bool
return false;
get $is$CyclicInitializationError() → core::bool
return false;
get $is$RangeError() → core::bool
return false;
get $is$int() → core::bool
return false;
get $is$double() → core::bool
return false;
get $is$List() → core::bool
return false;
get $is$String() → core::bool
return false;
get $is$Object() → core::bool
return true;
get $is$bool() → core::bool
return false;
get $is$UnsupportedError() → core::bool
return false;
get $is$ArgumentError() → core::bool
return false;
get $is$IntegerDivisionByZeroException() → core::bool
return false;
}
class Closure#main#function#5 extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field mock::Context context;
constructor •(final mock::Context context) → dynamic
: self::Closure#main#function#5::context = context
;
method call(dynamic e) → core::bool {
"This is a temporary solution. In the VM, this will become an additional parameter.";
final mock::Context #contextParameter = this.{self::Closure#main#function#5::context};
return typ::isSubtypeOf(int::type(e), new typ::Interface::•(self::$declarations.[](10)));
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](9));
get $is$AbstractClassInstantiationError() → core::bool
return false;
get $is$NoSuchMethodError() → core::bool
return false;
get $is$CyclicInitializationError() → core::bool
return false;
get $is$RangeError() → core::bool
return false;
get $is$int() → core::bool
return false;
get $is$double() → core::bool
return false;
get $is$List() → core::bool
return false;
get $is$String() → core::bool
return false;
get $is$Object() → core::bool
return true;
get $is$bool() → core::bool
return false;
get $is$UnsupportedError() → core::bool
return false;
get $is$ArgumentError() → core::bool
return false;
get $is$IntegerDivisionByZeroException() → core::bool
return false;
}
class Closure#main#function#6 extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field mock::Context context;
constructor •(final mock::Context context) → dynamic
: self::Closure#main#function#6::context = context
;
method call() → dynamic {
"This is a temporary solution. In the VM, this will become an additional parameter.";
final mock::Context #contextParameter = this.{self::Closure#main#function#6::context};
return int::attachType(<dynamic>[], new typ::Interface::•(self::$declarations.[](12), <dynamic>[const typ::Dynamic::•()])).{core::List::[]}(1);
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](11));
get $is$AbstractClassInstantiationError() → core::bool
return false;
get $is$NoSuchMethodError() → core::bool
return false;
get $is$CyclicInitializationError() → core::bool
return false;
get $is$RangeError() → core::bool
return false;
get $is$int() → core::bool
return false;
get $is$double() → core::bool
return false;
get $is$List() → core::bool
return false;
get $is$String() → core::bool
return false;
get $is$Object() → core::bool
return true;
get $is$bool() → core::bool
return false;
get $is$UnsupportedError() → core::bool
return false;
get $is$ArgumentError() → core::bool
return false;
get $is$IntegerDivisionByZeroException() → core::bool
return false;
}
class Closure#main#function#7 extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field mock::Context context;
constructor •(final mock::Context context) → dynamic
: self::Closure#main#function#7::context = context
;
method call(dynamic e) → core::bool {
"This is a temporary solution. In the VM, this will become an additional parameter.";
final mock::Context #contextParameter = this.{self::Closure#main#function#7::context};
return typ::isSubtypeOf(int::type(e), new typ::Interface::•(self::$declarations.[](14)));
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](13));
get $is$AbstractClassInstantiationError() → core::bool
return false;
get $is$NoSuchMethodError() → core::bool
return false;
get $is$CyclicInitializationError() → core::bool
return false;
get $is$RangeError() → core::bool
return false;
get $is$int() → core::bool
return false;
get $is$double() → core::bool
return false;
get $is$List() → core::bool
return false;
get $is$String() → core::bool
return false;
get $is$Object() → core::bool
return true;
get $is$bool() → core::bool
return false;
get $is$UnsupportedError() → core::bool
return false;
get $is$ArgumentError() → core::bool
return false;
get $is$IntegerDivisionByZeroException() → core::bool
return false;
}
static field dynamic foo = self::bar;
static field dynamic bar = self::foo;
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](18)));
dec::init(d, 1, new typ::Interface::•(d.[](18)));
dec::init(d, 2, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), new typ::Interface::•(d.[](0)), 0, <dynamic>[]));
dec::init(d, 3, new typ::Interface::•(d.[](27)));
dec::init(d, 4, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), new typ::Interface::•(d.[](19)), 0, <dynamic>[const typ::Dynamic::•()]));
dec::init(d, 5, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), const typ::Dynamic::•(), 0, <dynamic>[]));
dec::init(d, 6, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), new typ::Interface::•(d.[](19)), 0, <dynamic>[const typ::Dynamic::•()]));
dec::init(d, 7, new typ::Interface::•(d.[](27)));
dec::init(d, 8, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), const typ::Dynamic::•(), 0, <dynamic>[]));
dec::init(d, 9, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), new typ::Interface::•(d.[](19)), 0, <dynamic>[const typ::Dynamic::•()]));
dec::init(d, 10, new typ::Interface::•(d.[](27)));
dec::init(d, 11, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), const typ::Dynamic::•(), 0, <dynamic>[]));
dec::init(d, 12, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](28), <dynamic>[d.[](12).variables.[](0)])]);
dec::init(d, 13, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](26))], new typ::FunctionType::•(new typ::Interface::•(d.[](26)), new typ::Interface::•(d.[](19)), 0, <dynamic>[const typ::Dynamic::•()]));
dec::init(d, 14, new typ::Interface::•(d.[](21)));
dec::init(d, 15, new typ::Interface::•(d.[](29)));
dec::init(d, 16, new typ::Interface::•(d.[](29)));
dec::init(d, 17, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](30), <dynamic>[new typ::Interface::•(d.[](17))]), new typ::Interface::•(d.[](31))]);
dec::init(d, 18, null);
dec::init(d, 19, new typ::Interface::•(d.[](18)));
dec::init(d, 20, new typ::Interface::•(d.[](27)));
dec::init(d, 21, new typ::Interface::•(d.[](27)));
dec::init(d, 22, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](32))]);
dec::init(d, 23, new typ::Interface::•(d.[](18)));
dec::init(d, 24, new typ::Interface::•(d.[](18)));
dec::init(d, 26, new typ::Interface::•(d.[](18)));
dec::init(d, 27, new typ::Interface::•(d.[](18)));
dec::init(d, 28, new typ::Interface::•(d.[](33), <dynamic>[d.[](28).variables.[](0)]));
dec::init(d, 29, new typ::Interface::•(d.[](18)), <dynamic>[new typ::Interface::•(d.[](30), <dynamic>[new typ::Interface::•(d.[](29))])]);
dec::init(d, 30, new typ::Interface::•(d.[](18)));
dec::init(d, 31, new typ::Interface::•(d.[](18)));
dec::init(d, 32, new typ::Interface::•(d.[](18)));
dec::init(d, 33, new typ::Interface::•(d.[](18)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["C", "D", "Closure#main#function", "AbstractClassInstantiationError", "Closure#main#function#1", "Closure#main#function#2", "Closure#main#function#3", "NoSuchMethodError", "Closure#main#function#4", "Closure#main#function#5", "CyclicInitializationError", "Closure#main#function#6", "List", "Closure#main#function#7", "RangeError", "int", "double", "String", "Object", "bool", "UnsupportedError", "ArgumentError", "IntegerDivisionByZeroException", "Null", "Type", "HasRuntimeTypeGetter", "Function", "Error", "EfficientLengthIterable", "num", "Comparable", "Pattern", "Exception", "Iterable"], <dynamic>[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1]));
static method main() → dynamic {
tes::expectTrue(typ::isSubtypeOf(int::type(1), new typ::Interface::•(self::$declarations.[](15))));
tes::expectTrue(!typ::isSubtypeOf(int::type(1), new typ::Interface::•(self::$declarations.[](16))));
tes::expectTrue(typ::isSubtypeOf(int::type(int::attachType(core::List::_internal<core::int>(), new typ::Interface::•(self::$declarations.[](12), <dynamic>[new typ::Interface::•(self::$declarations.[](15))]))), new typ::Interface::•(self::$declarations.[](12), <dynamic>[new typ::Interface::•(self::$declarations.[](15))])));
tes::expectTrue(!typ::isSubtypeOf(int::type(int::attachType(core::List::_internal<core::int>(), new typ::Interface::•(self::$declarations.[](12), <dynamic>[new typ::Interface::•(self::$declarations.[](15))]))), new typ::Interface::•(self::$declarations.[](12), <dynamic>[new typ::Interface::•(self::$declarations.[](16))])));
tes::expectTrue(typ::isSubtypeOf(int::type("hest"), new typ::Interface::•(self::$declarations.[](17))));
tes::expectTrue(!typ::isSubtypeOf(int::type("hest"), new typ::Interface::•(self::$declarations.[](15))));
tes::expectTrue(!typ::isSubtypeOf(int::type(null), new typ::Interface::•(self::$declarations.[](17))));
tes::expectTrue(typ::isSubtypeOf(int::type(null), const typ::Dynamic::•()));
tes::expectTrue(typ::isSubtypeOf(int::type(null), new typ::Interface::•(self::$declarations.[](18))));
tes::expectTrue(typ::isSubtypeOf(int::type(true), new typ::Interface::•(self::$declarations.[](19))));
tes::expectTrue(!typ::isSubtypeOf(int::type(true), new typ::Interface::•(self::$declarations.[](15))));
tes::expectThrows(new self::Closure#main#function::•(null), new self::Closure#main#function#1::•(null));
tes::expectThrows(new self::Closure#main#function#2::•(null), new self::Closure#main#function#3::•(null));
tes::expectThrows(new self::Closure#main#function#4::•(null), new self::Closure#main#function#5::•(null));
tes::expectThrows(new self::Closure#main#function#6::•(null), new self::Closure#main#function#7::•(null));
tes::expectTrue(typ::isSubtypeOf(int::type(int::attachType(new core::UnsupportedError::•(""), new typ::Interface::•(self::$declarations.[](20)))), new typ::Interface::•(self::$declarations.[](20))));
tes::expectTrue(typ::isSubtypeOf(int::type(int::attachType(new core::ArgumentError::•(), new typ::Interface::•(self::$declarations.[](21)))), new typ::Interface::•(self::$declarations.[](21))));
tes::expectTrue(typ::isSubtypeOf(int::type(int::attachType(new core::IntegerDivisionByZeroException::•(), new typ::Interface::•(self::$declarations.[](22)))), new typ::Interface::•(self::$declarations.[](22))));
}

View file

@ -1,42 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library reuse_type_variables_test;
import 'test_base.dart';
class X {}
class Y {}
class Z {}
class C<T, U, V> {
foo() => new D<T, U, V>();
bar() => new E<T, U>();
hest() => new D<T, V, U>();
}
class D<T, U, V> {
baz() => new C<T, U, V>();
}
class E<T, U> {
qux() => new C<T, U, U>();
}
main() {
var c = new C<X, Y, Z>();
var d = c.foo();
expectTrue(d is D<X, Y, Z>);
d = c.hest();
expectTrue(d is! D<X, Y, Z>);
expectTrue(d is D<X, Z, Y>);
c = d.baz();
expectTrue(c is C<X, Z, Y>);
var e = c.bar();
expectTrue(e is E<X, Z>);
c = e.qux();
expectTrue(c is C<X, Z, Z>);
}

View file

@ -1,162 +0,0 @@
library reuse_type_variables_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class X extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](0));
get $is$D() → core::bool
return false;
get $is$C() → core::bool
return false;
get $is$E() → core::bool
return false;
}
class Y extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](1));
get $is$D() → core::bool
return false;
get $is$C() → core::bool
return false;
get $is$E() → core::bool
return false;
}
class Z extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](2));
get $is$D() → core::bool
return false;
get $is$C() → core::bool
return false;
get $is$E() → core::bool
return false;
}
class C extends core::Object implements int::HasRuntimeTypeGetter {
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type) → void
: self::C::$type = $type, super core::Object::•()
;
method foo() → dynamic {
return new self::D::•(new typ::Interface::•(self::$declarations.[](4), typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](3)))));
}
method bar() → dynamic {
return new self::E::•(new typ::Interface::•(self::$declarations.[](5), <dynamic>[this.$C$T, this.$C$U]));
}
method hest() → dynamic {
return new self::D::•(new typ::Interface::•(self::$declarations.[](4), <dynamic>[this.$C$T, this.$C$V, this.$C$U]));
}
get $C$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](3))).[](0);
get $C$U() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](3))).[](1);
get $C$V() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](3))).[](2);
get $is$D() → core::bool
return false;
get $is$C() → core::bool
return true;
get $is$E() → core::bool
return false;
get runtimeType() → core::Type
return this.{=self::C::$type};
}
class D extends core::Object implements int::HasRuntimeTypeGetter {
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type) → void
: self::D::$type = $type, super core::Object::•()
;
method baz() → dynamic {
return new self::C::•(new typ::Interface::•(self::$declarations.[](3), typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](4)))));
}
get $D$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](4))).[](0);
get $D$U() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](4))).[](1);
get $D$V() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](4))).[](2);
get $is$D() → core::bool
return true;
get $is$C() → core::bool
return false;
get $is$E() → core::bool
return false;
get runtimeType() → core::Type
return this.{=self::D::$type};
}
class E extends core::Object implements int::HasRuntimeTypeGetter {
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type) → void
: self::E::$type = $type, super core::Object::•()
;
method qux() → dynamic {
return new self::C::•(new typ::Interface::•(self::$declarations.[](3), <dynamic>[this.$E$T, this.$E$U, this.$E$U]));
}
get $E$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](5))).[](0);
get $E$U() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](5))).[](1);
get $is$D() → core::bool
return false;
get $is$C() → core::bool
return false;
get $is$E() → core::bool
return true;
get runtimeType() → core::Type
return this.{=self::E::$type};
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](19)));
dec::init(d, 1, new typ::Interface::•(d.[](19)));
dec::init(d, 2, new typ::Interface::•(d.[](19)));
dec::init(d, 3, new typ::Interface::•(d.[](19)));
dec::init(d, 4, new typ::Interface::•(d.[](19)));
dec::init(d, 5, new typ::Interface::•(d.[](19)));
dec::init(d, 6, new typ::Interface::•(d.[](19)));
dec::init(d, 7, new typ::Interface::•(d.[](19)));
dec::init(d, 8, new typ::Interface::•(d.[](19)), <dynamic>[new typ::Interface::•(d.[](21), <dynamic>[new typ::Interface::•(d.[](8))]), new typ::Interface::•(d.[](22))]);
dec::init(d, 9, new typ::Interface::•(d.[](23)));
dec::init(d, 10, new typ::Interface::•(d.[](23)));
dec::init(d, 11, new typ::Interface::•(d.[](19)));
dec::init(d, 12, new typ::Interface::•(d.[](24)));
dec::init(d, 13, new typ::Interface::•(d.[](24)));
dec::init(d, 14, new typ::Interface::•(d.[](24)));
dec::init(d, 15, new typ::Interface::•(d.[](24)));
dec::init(d, 16, new typ::Interface::•(d.[](19)), <dynamic>[new typ::Interface::•(d.[](25))]);
dec::init(d, 17, new typ::Interface::•(d.[](18)));
dec::init(d, 18, new typ::Interface::•(d.[](24)));
dec::init(d, 19, null);
dec::init(d, 21, new typ::Interface::•(d.[](19)));
dec::init(d, 22, new typ::Interface::•(d.[](19)));
dec::init(d, 23, new typ::Interface::•(d.[](19)), <dynamic>[new typ::Interface::•(d.[](21), <dynamic>[new typ::Interface::•(d.[](23))])]);
dec::init(d, 24, new typ::Interface::•(d.[](19)));
dec::init(d, 25, new typ::Interface::•(d.[](19)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["X", "Y", "Z", "C", "D", "E", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[0, 0, 0, 3, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method main() → dynamic {
self::C c = new self::C::•(new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](1)), new typ::Interface::•(self::$declarations.[](2))]));
dynamic d = c.{self::C::foo}();
tes::expectTrue(let dynamic #t1 = d in #t1 is int::HasRuntimeTypeGetter && #t1.$is$D && (let dynamic #t2 = new typ::Interface::•(self::$declarations.[](4), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](1)), new typ::Interface::•(self::$declarations.[](2))]) in typ::isSubtypeOf(#t1.$type, #t2)));
d = c.{self::C::hest}();
tes::expectTrue(!(let dynamic #t3 = d in #t3 is int::HasRuntimeTypeGetter && #t3.$is$D && (let dynamic #t4 = new typ::Interface::•(self::$declarations.[](4), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](1)), new typ::Interface::•(self::$declarations.[](2))]) in typ::isSubtypeOf(#t3.$type, #t4))));
tes::expectTrue(let dynamic #t5 = d in #t5 is int::HasRuntimeTypeGetter && #t5.$is$D && (let dynamic #t6 = new typ::Interface::•(self::$declarations.[](4), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](2)), new typ::Interface::•(self::$declarations.[](1))]) in typ::isSubtypeOf(#t5.$type, #t6)));
c = d.baz();
tes::expectTrue(let dynamic #t7 = c in #t7 is int::HasRuntimeTypeGetter && #t7.$is$C && (let dynamic #t8 = new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](2)), new typ::Interface::•(self::$declarations.[](1))]) in typ::isSubtypeOf(#t7.$type, #t8)));
dynamic e = c.{self::C::bar}();
tes::expectTrue(let dynamic #t9 = e in #t9 is int::HasRuntimeTypeGetter && #t9.$is$E && (let dynamic #t10 = new typ::Interface::•(self::$declarations.[](5), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](2))]) in typ::isSubtypeOf(#t9.$type, #t10)));
c = e.qux();
tes::expectTrue(let dynamic #t11 = c in #t11 is int::HasRuntimeTypeGetter && #t11.$is$C && (let dynamic #t12 = new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0)), new typ::Interface::•(self::$declarations.[](2)), new typ::Interface::•(self::$declarations.[](2))]) in typ::isSubtypeOf(#t11.$type, #t12)));
}

View file

@ -1,22 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library runtime_type_test;
import 'test_base.dart';
class A<T> {}
class X {}
class Y {}
bool eqt(a, b) => a.runtimeType == b.runtimeType;
main() {
expectTrue(eqt(new A(), new A<dynamic>()));
expectTrue(eqt(new A<X>(), new A<X>()));
expectFalse(eqt(new A<X>(), new A()));
expectFalse(eqt(new A<X>(), new A<Y>()));
}

View file

@ -1,66 +0,0 @@
library runtime_type_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class A extends core::Object implements int::HasRuntimeTypeGetter {
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type) → void
: self::A::$type = $type, super core::Object::•()
;
get $A$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](0))).[](0);
get runtimeType() → core::Type
return this.{=self::A::$type};
}
class X extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](1));
}
class Y extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](2));
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](16)));
dec::init(d, 1, new typ::Interface::•(d.[](16)));
dec::init(d, 2, new typ::Interface::•(d.[](16)));
dec::init(d, 3, new typ::Interface::•(d.[](16)));
dec::init(d, 4, new typ::Interface::•(d.[](16)));
dec::init(d, 5, new typ::Interface::•(d.[](16)), <dynamic>[new typ::Interface::•(d.[](18), <dynamic>[new typ::Interface::•(d.[](5))]), new typ::Interface::•(d.[](19))]);
dec::init(d, 6, new typ::Interface::•(d.[](20)));
dec::init(d, 7, new typ::Interface::•(d.[](20)));
dec::init(d, 8, new typ::Interface::•(d.[](16)));
dec::init(d, 9, new typ::Interface::•(d.[](21)));
dec::init(d, 10, new typ::Interface::•(d.[](21)));
dec::init(d, 11, new typ::Interface::•(d.[](21)));
dec::init(d, 12, new typ::Interface::•(d.[](21)));
dec::init(d, 13, new typ::Interface::•(d.[](16)), <dynamic>[new typ::Interface::•(d.[](22))]);
dec::init(d, 14, new typ::Interface::•(d.[](15)));
dec::init(d, 15, new typ::Interface::•(d.[](21)));
dec::init(d, 16, null);
dec::init(d, 18, new typ::Interface::•(d.[](16)));
dec::init(d, 19, new typ::Interface::•(d.[](16)));
dec::init(d, 20, new typ::Interface::•(d.[](16)), <dynamic>[new typ::Interface::•(d.[](18), <dynamic>[new typ::Interface::•(d.[](20))])]);
dec::init(d, 21, new typ::Interface::•(d.[](16)));
dec::init(d, 22, new typ::Interface::•(d.[](16)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["A", "X", "Y", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method eqt(dynamic a, dynamic b) → core::bool {
return a.runtimeType.==(b.runtimeType);
}
static method main() → dynamic {
tes::expectTrue(self::eqt(new self::A::•(new typ::Interface::•(self::$declarations.[](0), <dynamic>[const typ::Dynamic::•()])), new self::A::•(new typ::Interface::•(self::$declarations.[](0), <dynamic>[const typ::Dynamic::•()]))));
tes::expectTrue(self::eqt(new self::A::•(new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](1))])), new self::A::•(new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](1))]))));
tes::expectFalse(self::eqt(new self::A::•(new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](1))])), new self::A::•(new typ::Interface::•(self::$declarations.[](0), <dynamic>[const typ::Dynamic::•()]))));
tes::expectFalse(self::eqt(new self::A::•(new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](1))])), new self::A::•(new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](2))]))));
}

View file

@ -1,69 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library simple_test;
import 'test_base.dart';
class C {}
class A implements C {}
class B extends C {}
class D extends B {}
testIs(o) {
write(o is A);
write(o is B);
write(o is C);
write(o is D);
}
testIsNot(o) {
write(o is! A);
write(o is! B);
write(o is! C);
write(o is! D);
}
main() {
var objects = [new A(), new B(), new C(), new D()];
objects.forEach(testIs);
objects.forEach(testIsNot);
expectOutput("""
true
false
true
false
false
true
true
false
false
false
true
false
false
true
true
true
false
true
false
true
true
false
false
true
true
true
false
true
true
false
false
false""");
}

View file

@ -1,152 +0,0 @@
library simple_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class C extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](0));
get $is$A() → core::bool
return false;
get $is$B() → core::bool
return false;
get $is$C() → core::bool
return true;
get $is$D() → core::bool
return false;
}
class A extends core::Object implements self::C, int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](1));
get $is$A() → core::bool
return true;
get $is$B() → core::bool
return false;
get $is$C() → core::bool
return true;
get $is$D() → core::bool
return false;
}
class B extends self::C implements int::HasRuntimeTypeGetter {
constructor •() → void
: super self::C::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](2));
get $is$A() → core::bool
return false;
get $is$B() → core::bool
return true;
get $is$C() → core::bool
return true;
get $is$D() → core::bool
return false;
}
class D extends self::B implements int::HasRuntimeTypeGetter {
constructor •() → void
: super self::B::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](3));
get $is$A() → core::bool
return false;
get $is$B() → core::bool
return true;
get $is$C() → core::bool
return true;
get $is$D() → core::bool
return true;
}
class Closure#testIs extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
constructor •() → dynamic
;
method call(dynamic o) → dynamic
return self::testIs(o);
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](4));
get $is$A() → core::bool
return false;
get $is$B() → core::bool
return false;
get $is$C() → core::bool
return false;
get $is$D() → core::bool
return false;
}
class Closure#testIsNot extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
constructor •() → dynamic
;
method call(dynamic o) → dynamic
return self::testIsNot(o);
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](5));
get $is$A() → core::bool
return false;
get $is$B() → core::bool
return false;
get $is$C() → core::bool
return false;
get $is$D() → core::bool
return false;
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](20)));
dec::init(d, 1, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](0))]);
dec::init(d, 2, new typ::Interface::•(d.[](0)));
dec::init(d, 3, new typ::Interface::•(d.[](2)));
dec::init(d, 4, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](22))], new typ::FunctionType::•(new typ::Interface::•(d.[](22)), const typ::Dynamic::•(), 0, <dynamic>[const typ::Dynamic::•()]));
dec::init(d, 5, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](22))], new typ::FunctionType::•(new typ::Interface::•(d.[](22)), const typ::Dynamic::•(), 0, <dynamic>[const typ::Dynamic::•()]));
dec::init(d, 6, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](23), <dynamic>[d.[](6).variables.[](0)])]);
dec::init(d, 7, new typ::Interface::•(d.[](20)));
dec::init(d, 8, new typ::Interface::•(d.[](20)));
dec::init(d, 9, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](24), <dynamic>[new typ::Interface::•(d.[](9))]), new typ::Interface::•(d.[](25))]);
dec::init(d, 10, new typ::Interface::•(d.[](26)));
dec::init(d, 11, new typ::Interface::•(d.[](26)));
dec::init(d, 12, new typ::Interface::•(d.[](20)));
dec::init(d, 13, new typ::Interface::•(d.[](27)));
dec::init(d, 14, new typ::Interface::•(d.[](27)));
dec::init(d, 15, new typ::Interface::•(d.[](27)));
dec::init(d, 16, new typ::Interface::•(d.[](27)));
dec::init(d, 17, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](28))]);
dec::init(d, 18, new typ::Interface::•(d.[](19)));
dec::init(d, 19, new typ::Interface::•(d.[](27)));
dec::init(d, 20, null);
dec::init(d, 22, new typ::Interface::•(d.[](20)));
dec::init(d, 23, new typ::Interface::•(d.[](29), <dynamic>[d.[](23).variables.[](0)]));
dec::init(d, 24, new typ::Interface::•(d.[](20)));
dec::init(d, 25, new typ::Interface::•(d.[](20)));
dec::init(d, 26, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](24), <dynamic>[new typ::Interface::•(d.[](26))])]);
dec::init(d, 27, new typ::Interface::•(d.[](20)));
dec::init(d, 28, new typ::Interface::•(d.[](20)));
dec::init(d, 29, new typ::Interface::•(d.[](20)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["C", "A", "B", "D", "Closure#testIs", "Closure#testIsNot", "List", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Function", "EfficientLengthIterable", "Comparable", "Pattern", "num", "Error", "Exception", "Iterable"], <dynamic>[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1]));
static method testIs(dynamic o) → dynamic {
tes::write(let dynamic #t1 = o in #t1 is int::HasRuntimeTypeGetter && #t1.$is$A);
tes::write(let dynamic #t2 = o in #t2 is int::HasRuntimeTypeGetter && #t2.$is$B);
tes::write(let dynamic #t3 = o in #t3 is int::HasRuntimeTypeGetter && #t3.$is$C);
tes::write(let dynamic #t4 = o in #t4 is int::HasRuntimeTypeGetter && #t4.$is$D);
}
static method testIsNot(dynamic o) → dynamic {
tes::write(!(let dynamic #t5 = o in #t5 is int::HasRuntimeTypeGetter && #t5.$is$A));
tes::write(!(let dynamic #t6 = o in #t6 is int::HasRuntimeTypeGetter && #t6.$is$B));
tes::write(!(let dynamic #t7 = o in #t7 is int::HasRuntimeTypeGetter && #t7.$is$C));
tes::write(!(let dynamic #t8 = o in #t8 is int::HasRuntimeTypeGetter && #t8.$is$D));
}
static method main() → dynamic {
core::List<self::C> objects = int::attachType(<self::C>[new self::A::•(), new self::B::•(), new self::C::•(), new self::D::•()], new typ::Interface::•(self::$declarations.[](6), <dynamic>[new typ::Interface::•(self::$declarations.[](0))]));
objects.{core::Iterable::forEach}(new self::Closure#testIs::•());
objects.{core::Iterable::forEach}(new self::Closure#testIsNot::•());
tes::expectOutput("true\nfalse\ntrue\nfalse\nfalse\ntrue\ntrue\nfalse\nfalse\nfalse\ntrue\nfalse\nfalse\ntrue\ntrue\ntrue\nfalse\ntrue\nfalse\ntrue\ntrue\nfalse\nfalse\ntrue\ntrue\ntrue\nfalse\ntrue\ntrue\nfalse\nfalse\nfalse");
}

View file

@ -1,35 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE.md file.
library superclass_test;
import 'test_base.dart';
class X {}
class Y {}
class R<T> {}
class A<T> {
foo() => new R<T>();
}
class B<T> extends A<T> {}
class C<T> extends A<Y> {}
class D<T> extends B<R<T>> {}
main() {
expectTrue(new A<X>().foo() is R<X>);
expectTrue(new B<X>().foo() is R<X>);
expectTrue(new C<X>().foo() is R<Y>);
expectTrue(new D<X>().foo() is R<R<X>>);
expectTrue(new A<X>().foo() is! R<Y>);
expectTrue(new B<X>().foo() is! R<Y>);
expectTrue(new C<X>().foo() is! R<X>);
expectTrue(new D<X>().foo() is! R<R<Y>>);
}

View file

@ -1,119 +0,0 @@
library superclass_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "./test_base.dart" as tes;
import "../../runtime/reify/declarations.dart" as dec;
class X extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](0));
get $is$R() → core::bool
return false;
}
class Y extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](1));
get $is$R() → core::bool
return false;
}
class R extends core::Object implements int::HasRuntimeTypeGetter {
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type) → void
: self::R::$type = $type, super core::Object::•()
;
get $R$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](2))).[](0);
get $is$R() → core::bool
return true;
get runtimeType() → core::Type
return this.{=self::R::$type};
}
class A extends core::Object implements int::HasRuntimeTypeGetter {
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type) → void
: self::A::$type = $type, super core::Object::•()
;
method foo() → dynamic {
return new self::R::•(new typ::Interface::•(self::$declarations.[](2), typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](3)))));
}
get $A$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](3))).[](0);
get $is$R() → core::bool
return false;
get runtimeType() → core::Type
return this.{=self::A::$type};
}
class B extends self::A implements int::HasRuntimeTypeGetter {
constructor •(typ::ReifiedType $type) → void
: super self::A::•($type)
;
get $B$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](4))).[](0);
get $is$R() → core::bool
return false;
}
class C extends self::A implements int::HasRuntimeTypeGetter {
constructor •(typ::ReifiedType $type) → void
: super self::A::•($type)
;
get $C$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](5))).[](0);
get $is$R() → core::bool
return false;
}
class D extends self::B implements int::HasRuntimeTypeGetter {
constructor •(typ::ReifiedType $type) → void
: super self::B::•($type)
;
get $D$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](6))).[](0);
get $is$R() → core::bool
return false;
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](20)));
dec::init(d, 1, new typ::Interface::•(d.[](20)));
dec::init(d, 2, new typ::Interface::•(d.[](20)));
dec::init(d, 3, new typ::Interface::•(d.[](20)));
dec::init(d, 4, new typ::Interface::•(d.[](3), <dynamic>[d.[](4).variables.[](0)]));
dec::init(d, 5, new typ::Interface::•(d.[](3), <dynamic>[new typ::Interface::•(d.[](1))]));
dec::init(d, 6, new typ::Interface::•(d.[](4), <dynamic>[new typ::Interface::•(d.[](2), <dynamic>[d.[](6).variables.[](0)])]));
dec::init(d, 7, new typ::Interface::•(d.[](20)));
dec::init(d, 8, new typ::Interface::•(d.[](20)));
dec::init(d, 9, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](22), <dynamic>[new typ::Interface::•(d.[](9))]), new typ::Interface::•(d.[](23))]);
dec::init(d, 10, new typ::Interface::•(d.[](24)));
dec::init(d, 11, new typ::Interface::•(d.[](24)));
dec::init(d, 12, new typ::Interface::•(d.[](20)));
dec::init(d, 13, new typ::Interface::•(d.[](25)));
dec::init(d, 14, new typ::Interface::•(d.[](25)));
dec::init(d, 15, new typ::Interface::•(d.[](25)));
dec::init(d, 16, new typ::Interface::•(d.[](25)));
dec::init(d, 17, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](26))]);
dec::init(d, 18, new typ::Interface::•(d.[](19)));
dec::init(d, 19, new typ::Interface::•(d.[](25)));
dec::init(d, 20, null);
dec::init(d, 22, new typ::Interface::•(d.[](20)));
dec::init(d, 23, new typ::Interface::•(d.[](20)));
dec::init(d, 24, new typ::Interface::•(d.[](20)), <dynamic>[new typ::Interface::•(d.[](22), <dynamic>[new typ::Interface::•(d.[](24))])]);
dec::init(d, 25, new typ::Interface::•(d.[](20)));
dec::init(d, 26, new typ::Interface::•(d.[](20)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["X", "Y", "R", "A", "B", "C", "D", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method main() → dynamic {
tes::expectTrue(let dynamic #t1 = new self::A::•(new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).{self::A::foo}() in #t1 is int::HasRuntimeTypeGetter && #t1.$is$R && (let dynamic #t2 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](0))]) in typ::isSubtypeOf(#t1.$type, #t2)));
tes::expectTrue(let dynamic #t3 = new self::B::•(new typ::Interface::•(self::$declarations.[](4), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).{self::A::foo}() in #t3 is int::HasRuntimeTypeGetter && #t3.$is$R && (let dynamic #t4 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](0))]) in typ::isSubtypeOf(#t3.$type, #t4)));
tes::expectTrue(let dynamic #t5 = new self::C::•(new typ::Interface::•(self::$declarations.[](5), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).{self::A::foo}() in #t5 is int::HasRuntimeTypeGetter && #t5.$is$R && (let dynamic #t6 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](1))]) in typ::isSubtypeOf(#t5.$type, #t6)));
tes::expectTrue(let dynamic #t7 = new self::D::•(new typ::Interface::•(self::$declarations.[](6), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).{self::A::foo}() in #t7 is int::HasRuntimeTypeGetter && #t7.$is$R && (let dynamic #t8 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])]) in typ::isSubtypeOf(#t7.$type, #t8)));
tes::expectTrue(!(let dynamic #t9 = new self::A::•(new typ::Interface::•(self::$declarations.[](3), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).{self::A::foo}() in #t9 is int::HasRuntimeTypeGetter && #t9.$is$R && (let dynamic #t10 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](1))]) in typ::isSubtypeOf(#t9.$type, #t10))));
tes::expectTrue(!(let dynamic #t11 = new self::B::•(new typ::Interface::•(self::$declarations.[](4), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).{self::A::foo}() in #t11 is int::HasRuntimeTypeGetter && #t11.$is$R && (let dynamic #t12 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](1))]) in typ::isSubtypeOf(#t11.$type, #t12))));
tes::expectTrue(!(let dynamic #t13 = new self::C::•(new typ::Interface::•(self::$declarations.[](5), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).{self::A::foo}() in #t13 is int::HasRuntimeTypeGetter && #t13.$is$R && (let dynamic #t14 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](0))]) in typ::isSubtypeOf(#t13.$type, #t14))));
tes::expectTrue(!(let dynamic #t15 = new self::D::•(new typ::Interface::•(self::$declarations.[](6), <dynamic>[new typ::Interface::•(self::$declarations.[](0))])).{self::A::foo}() in #t15 is int::HasRuntimeTypeGetter && #t15.$is$R && (let dynamic #t16 = new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](2), <dynamic>[new typ::Interface::•(self::$declarations.[](1))])]) in typ::isSubtypeOf(#t15.$type, #t16))));
}

View file

@ -1,18 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library super1_test;
import 'test_base.dart';
class A<T> {}
class B<T> extends A<T> {
int i;
B(this.i) : super();
B.redirect() : this(42);
}
main() {}

View file

@ -1,55 +0,0 @@
library super1_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "dart:mock" as mock;
import "../../runtime/reify/declarations.dart" as dec;
class A extends core::Object implements int::HasRuntimeTypeGetter {
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type) → void
: self::A::$type = $type, super core::Object::•()
;
get $A$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](0))).[](0);
get runtimeType() → core::Type
return this.{=self::A::$type};
}
class B extends self::A implements int::HasRuntimeTypeGetter {
field core::int i;
constructor •(typ::ReifiedType $type, core::int i) → void
: self::B::i = let final mock::Context #context = int::attachType(new mock::Context::•(1), new typ::Interface::•(self::$declarations.[](2))) in let dynamic #t1 = #context.[]=(0, i) in #context.[](0), super self::A::•($type)
;
constructor redirect(typ::ReifiedType $type) → void
: this self::B::•($type, 42)
;
get $B$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](1))).[](0);
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](16)));
dec::init(d, 1, new typ::Interface::•(d.[](0), <dynamic>[d.[](1).variables.[](0)]));
dec::init(d, 2, new typ::Interface::•(d.[](16)));
dec::init(d, 3, new typ::Interface::•(d.[](16)));
dec::init(d, 4, new typ::Interface::•(d.[](16)));
dec::init(d, 5, new typ::Interface::•(d.[](16)), <dynamic>[new typ::Interface::•(d.[](18), <dynamic>[new typ::Interface::•(d.[](5))]), new typ::Interface::•(d.[](19))]);
dec::init(d, 6, new typ::Interface::•(d.[](20)));
dec::init(d, 7, new typ::Interface::•(d.[](20)));
dec::init(d, 8, new typ::Interface::•(d.[](16)));
dec::init(d, 9, new typ::Interface::•(d.[](21)));
dec::init(d, 10, new typ::Interface::•(d.[](21)));
dec::init(d, 11, new typ::Interface::•(d.[](21)));
dec::init(d, 12, new typ::Interface::•(d.[](21)));
dec::init(d, 13, new typ::Interface::•(d.[](16)), <dynamic>[new typ::Interface::•(d.[](22))]);
dec::init(d, 14, new typ::Interface::•(d.[](15)));
dec::init(d, 15, new typ::Interface::•(d.[](21)));
dec::init(d, 16, null);
dec::init(d, 18, new typ::Interface::•(d.[](16)));
dec::init(d, 19, new typ::Interface::•(d.[](16)));
dec::init(d, 20, new typ::Interface::•(d.[](16)), <dynamic>[new typ::Interface::•(d.[](18), <dynamic>[new typ::Interface::•(d.[](20))])]);
dec::init(d, 21, new typ::Interface::•(d.[](16)));
dec::init(d, 22, new typ::Interface::•(d.[](16)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["A", "B", "Context", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method main() → dynamic {}

View file

@ -1,15 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library super2_test;
import 'test_base.dart';
class X {}
class A<T> {}
class B extends A<X> {}
main() {}

View file

@ -1,57 +0,0 @@
library super2_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "../../runtime/reify/declarations.dart" as dec;
class X extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](0));
}
class A extends core::Object implements int::HasRuntimeTypeGetter {
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type) → void
: self::A::$type = $type, super core::Object::•()
;
get $A$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](1))).[](0);
get runtimeType() → core::Type
return this.{=self::A::$type};
}
class B extends self::A implements int::HasRuntimeTypeGetter {
constructor •() → void
: super self::A::•(null)
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](2));
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](16)));
dec::init(d, 1, new typ::Interface::•(d.[](16)));
dec::init(d, 2, new typ::Interface::•(d.[](1), <dynamic>[new typ::Interface::•(d.[](0))]));
dec::init(d, 3, new typ::Interface::•(d.[](16)));
dec::init(d, 4, new typ::Interface::•(d.[](16)));
dec::init(d, 5, new typ::Interface::•(d.[](16)), <dynamic>[new typ::Interface::•(d.[](18), <dynamic>[new typ::Interface::•(d.[](5))]), new typ::Interface::•(d.[](19))]);
dec::init(d, 6, new typ::Interface::•(d.[](20)));
dec::init(d, 7, new typ::Interface::•(d.[](20)));
dec::init(d, 8, new typ::Interface::•(d.[](16)));
dec::init(d, 9, new typ::Interface::•(d.[](21)));
dec::init(d, 10, new typ::Interface::•(d.[](21)));
dec::init(d, 11, new typ::Interface::•(d.[](21)));
dec::init(d, 12, new typ::Interface::•(d.[](21)));
dec::init(d, 13, new typ::Interface::•(d.[](16)), <dynamic>[new typ::Interface::•(d.[](22))]);
dec::init(d, 14, new typ::Interface::•(d.[](15)));
dec::init(d, 15, new typ::Interface::•(d.[](21)));
dec::init(d, 16, null);
dec::init(d, 18, new typ::Interface::•(d.[](16)));
dec::init(d, 19, new typ::Interface::•(d.[](16)));
dec::init(d, 20, new typ::Interface::•(d.[](16)), <dynamic>[new typ::Interface::•(d.[](18), <dynamic>[new typ::Interface::•(d.[](20))])]);
dec::init(d, 21, new typ::Interface::•(d.[](16)));
dec::init(d, 22, new typ::Interface::•(d.[](16)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["X", "A", "B", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method main() → dynamic {}

View file

@ -1,21 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE.md file.
library super3_test;
import 'test_base.dart';
class A<T> {
get foo => T;
}
class B extends A<A> {
B();
B.redirect() : this();
}
main() {
new B().foo;
new B.redirect();
}

View file

@ -1,58 +0,0 @@
library super3_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "../../runtime/reify/declarations.dart" as dec;
class A extends core::Object implements int::HasRuntimeTypeGetter {
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type) → void
: self::A::$type = $type, super core::Object::•()
;
get foo() → dynamic {
return dynamic;
}
get $A$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](0))).[](0);
get runtimeType() → core::Type
return this.{=self::A::$type};
}
class B extends self::A implements int::HasRuntimeTypeGetter {
constructor •() → void
: super self::A::•(null)
;
constructor redirect() → void
: this self::B::•()
;
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](1));
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](15)));
dec::init(d, 1, new typ::Interface::•(d.[](0), <dynamic>[new typ::Interface::•(d.[](0), <dynamic>[const typ::Dynamic::•()])]));
dec::init(d, 2, new typ::Interface::•(d.[](15)));
dec::init(d, 3, new typ::Interface::•(d.[](15)));
dec::init(d, 4, new typ::Interface::•(d.[](15)), <dynamic>[new typ::Interface::•(d.[](17), <dynamic>[new typ::Interface::•(d.[](4))]), new typ::Interface::•(d.[](18))]);
dec::init(d, 5, new typ::Interface::•(d.[](19)));
dec::init(d, 6, new typ::Interface::•(d.[](19)));
dec::init(d, 7, new typ::Interface::•(d.[](15)));
dec::init(d, 8, new typ::Interface::•(d.[](20)));
dec::init(d, 9, new typ::Interface::•(d.[](20)));
dec::init(d, 10, new typ::Interface::•(d.[](20)));
dec::init(d, 11, new typ::Interface::•(d.[](20)));
dec::init(d, 12, new typ::Interface::•(d.[](15)), <dynamic>[new typ::Interface::•(d.[](21))]);
dec::init(d, 13, new typ::Interface::•(d.[](14)));
dec::init(d, 14, new typ::Interface::•(d.[](20)));
dec::init(d, 15, null);
dec::init(d, 17, new typ::Interface::•(d.[](15)));
dec::init(d, 18, new typ::Interface::•(d.[](15)));
dec::init(d, 19, new typ::Interface::•(d.[](15)), <dynamic>[new typ::Interface::•(d.[](17), <dynamic>[new typ::Interface::•(d.[](19))])]);
dec::init(d, 20, new typ::Interface::•(d.[](15)));
dec::init(d, 21, new typ::Interface::•(d.[](15)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["A", "B", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method main() → dynamic {
new self::B::•().{self::A::foo};
new self::B::redirect();
}

View file

@ -1,40 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library test_base;
expectIs(expected, actual, [String note]) {
if (expected != actual) {
if (note != null) {
throw "Expected: '$expected': $note, actual: '$actual'";
}
throw "Expected: '$expected', actual: '$actual'";
}
}
expectTrue(actual) => expectIs(true, actual);
expectFalse(actual) => expectIs(false, actual);
expectThrows(f(), test(e)) {
var exception = false;
String note = null;
try {
f();
} catch (e) {
exception = test(e);
if (!exception) {
note = "$e [${e.runtimeType}]";
}
}
expectIs(true, exception, note);
}
expectOutput(String expected) => expectIs(expected, output);
String output;
write(o) {
output = output == null ? "$o" : "$output\n$o";
}

View file

@ -1,21 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library typevariable1_test;
import 'test_base.dart';
class Z {
get succ => new N<Z>();
}
class N<T> {
get succ => new N<N<T>>();
get pred => T;
}
main() {
var one = new Z().succ;
var two = one.succ;
}

View file

@ -1,61 +0,0 @@
library typevariable1_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "../../runtime/reify/declarations.dart" as dec;
class Z extends core::Object implements int::HasRuntimeTypeGetter {
constructor •() → void
: super core::Object::•()
;
get succ() → dynamic {
return new self::N::•(new typ::Interface::•(self::$declarations.[](1), <dynamic>[new typ::Interface::•(self::$declarations.[](0))]));
}
get $type() → typ::ReifiedType
return new typ::Interface::•(self::$declarations.[](0));
}
class N extends core::Object implements int::HasRuntimeTypeGetter {
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type) → void
: self::N::$type = $type, super core::Object::•()
;
get succ() → dynamic {
return new self::N::•(new typ::Interface::•(self::$declarations.[](1), <dynamic>[new typ::Interface::•(self::$declarations.[](1), typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](1))))]));
}
get pred() → dynamic {
return dynamic;
}
get $N$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](1))).[](0);
get runtimeType() → core::Type
return this.{=self::N::$type};
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](15)));
dec::init(d, 1, new typ::Interface::•(d.[](15)));
dec::init(d, 2, new typ::Interface::•(d.[](15)));
dec::init(d, 3, new typ::Interface::•(d.[](15)));
dec::init(d, 4, new typ::Interface::•(d.[](15)), <dynamic>[new typ::Interface::•(d.[](17), <dynamic>[new typ::Interface::•(d.[](4))]), new typ::Interface::•(d.[](18))]);
dec::init(d, 5, new typ::Interface::•(d.[](19)));
dec::init(d, 6, new typ::Interface::•(d.[](19)));
dec::init(d, 7, new typ::Interface::•(d.[](15)));
dec::init(d, 8, new typ::Interface::•(d.[](20)));
dec::init(d, 9, new typ::Interface::•(d.[](20)));
dec::init(d, 10, new typ::Interface::•(d.[](20)));
dec::init(d, 11, new typ::Interface::•(d.[](20)));
dec::init(d, 12, new typ::Interface::•(d.[](15)), <dynamic>[new typ::Interface::•(d.[](21))]);
dec::init(d, 13, new typ::Interface::•(d.[](14)));
dec::init(d, 14, new typ::Interface::•(d.[](20)));
dec::init(d, 15, null);
dec::init(d, 17, new typ::Interface::•(d.[](15)));
dec::init(d, 18, new typ::Interface::•(d.[](15)));
dec::init(d, 19, new typ::Interface::•(d.[](15)), <dynamic>[new typ::Interface::•(d.[](17), <dynamic>[new typ::Interface::•(d.[](19))])]);
dec::init(d, 20, new typ::Interface::•(d.[](15)));
dec::init(d, 21, new typ::Interface::•(d.[](15)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["Z", "N", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method main() → dynamic {
dynamic one = new self::Z::•().{self::Z::succ};
dynamic two = one.succ;
}

View file

@ -1,14 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library typevariable2_test;
import 'test_base.dart';
class C<T> {
bool test(o) => o is T;
Type get t => T;
}
main() {}

View file

@ -1,65 +0,0 @@
library typevariable2_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "../../runtime/reify/declarations.dart" as dec;
class C extends core::Object implements int::HasRuntimeTypeGetter {
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type) → void
: self::C::$type = $type, super core::Object::•()
;
method test(dynamic o) → core::bool {
return typ::isSubtypeOf(int::type(o), this.$C$T);
}
get t() → core::Type {
return dynamic;
}
get test#get() → dynamic
return new self::Closure#C#test::•(new typ::Interface::•(self::$declarations.[](1), typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](0)))), this);
get $C$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](0))).[](0);
get runtimeType() → core::Type
return this.{=self::C::$type};
}
class Closure#C#test extends core::Object implements core::Function, int::HasRuntimeTypeGetter {
field core::String note = "This is temporary. The VM doesn't need closure classes.";
field self::C self;
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type, final self::C self) → dynamic
: self::Closure#C#test::$type = $type, self::Closure#C#test::self = self
;
method call(dynamic o) → core::bool
return this.{self::Closure#C#test::self}.{self::C::test}(o);
get $Closure#C#test$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](1))).[](0);
get runtimeType() → core::Type
return this.{=self::Closure#C#test::$type};
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](15)));
dec::init(d, 1, new typ::Interface::•(d.[](15)), <dynamic>[new typ::Interface::•(d.[](17))], new typ::FunctionType::•(new typ::Interface::•(d.[](17)), new typ::Interface::•(d.[](3)), 0, <dynamic>[const typ::Dynamic::•()]));
dec::init(d, 2, new typ::Interface::•(d.[](15)));
dec::init(d, 3, new typ::Interface::•(d.[](15)));
dec::init(d, 4, new typ::Interface::•(d.[](15)), <dynamic>[new typ::Interface::•(d.[](18), <dynamic>[new typ::Interface::•(d.[](4))]), new typ::Interface::•(d.[](19))]);
dec::init(d, 5, new typ::Interface::•(d.[](20)));
dec::init(d, 6, new typ::Interface::•(d.[](20)));
dec::init(d, 7, new typ::Interface::•(d.[](15)));
dec::init(d, 8, new typ::Interface::•(d.[](21)));
dec::init(d, 9, new typ::Interface::•(d.[](21)));
dec::init(d, 10, new typ::Interface::•(d.[](21)));
dec::init(d, 11, new typ::Interface::•(d.[](21)));
dec::init(d, 12, new typ::Interface::•(d.[](15)), <dynamic>[new typ::Interface::•(d.[](22))]);
dec::init(d, 13, new typ::Interface::•(d.[](14)));
dec::init(d, 14, new typ::Interface::•(d.[](21)));
dec::init(d, 15, null);
dec::init(d, 17, new typ::Interface::•(d.[](15)));
dec::init(d, 18, new typ::Interface::•(d.[](15)));
dec::init(d, 19, new typ::Interface::•(d.[](15)));
dec::init(d, 20, new typ::Interface::•(d.[](15)), <dynamic>[new typ::Interface::•(d.[](18), <dynamic>[new typ::Interface::•(d.[](20))])]);
dec::init(d, 21, new typ::Interface::•(d.[](15)));
dec::init(d, 22, new typ::Interface::•(d.[](15)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["C", "Closure#C#test", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Function", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method main() → dynamic {}

View file

@ -1,18 +0,0 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
library typevariable3_test;
import 'test_base.dart';
class C<T> {
T foo(T t) {
T temp = t;
return temp;
}
}
main() {
C c = new C<C>().foo(new C());
}

View file

@ -1,50 +0,0 @@
library typevariable3_test;
import self as self;
import "dart:core" as core;
import "../../runtime/reify/interceptors.dart" as int;
import "../../runtime/reify/types.dart" as typ;
import "../../runtime/reify/declarations.dart" as dec;
class C extends core::Object implements int::HasRuntimeTypeGetter {
final field typ::ReifiedType $type;
constructor •(typ::ReifiedType $type) → void
: self::C::$type = $type, super core::Object::•()
;
method foo(dynamic t) → dynamic {
dynamic temp = t;
return temp;
}
method foo$cc(core::Object t) → dynamic {
return this.{=self::C::foo}(t as dynamic);
}
get $C$T() → typ::ReifiedType
return typ::getTypeArguments(typ::asInstanceOf(this.$type, self::$declarations.[](0))).[](0);
get runtimeType() → core::Type
return this.{=self::C::$type};
}
static final field core::List<dec::Class> $declarations = (core::List<dec::Class> d) → core::List<dec::Class> {
dec::init(d, 0, new typ::Interface::•(d.[](14)));
dec::init(d, 1, new typ::Interface::•(d.[](14)));
dec::init(d, 2, new typ::Interface::•(d.[](14)));
dec::init(d, 3, new typ::Interface::•(d.[](14)), <dynamic>[new typ::Interface::•(d.[](16), <dynamic>[new typ::Interface::•(d.[](3))]), new typ::Interface::•(d.[](17))]);
dec::init(d, 4, new typ::Interface::•(d.[](18)));
dec::init(d, 5, new typ::Interface::•(d.[](18)));
dec::init(d, 6, new typ::Interface::•(d.[](14)));
dec::init(d, 7, new typ::Interface::•(d.[](19)));
dec::init(d, 8, new typ::Interface::•(d.[](19)));
dec::init(d, 9, new typ::Interface::•(d.[](19)));
dec::init(d, 10, new typ::Interface::•(d.[](19)));
dec::init(d, 11, new typ::Interface::•(d.[](14)), <dynamic>[new typ::Interface::•(d.[](20))]);
dec::init(d, 12, new typ::Interface::•(d.[](13)));
dec::init(d, 13, new typ::Interface::•(d.[](19)));
dec::init(d, 14, null);
dec::init(d, 16, new typ::Interface::•(d.[](14)));
dec::init(d, 17, new typ::Interface::•(d.[](14)));
dec::init(d, 18, new typ::Interface::•(d.[](14)), <dynamic>[new typ::Interface::•(d.[](16), <dynamic>[new typ::Interface::•(d.[](18))])]);
dec::init(d, 19, new typ::Interface::•(d.[](14)));
dec::init(d, 20, new typ::Interface::•(d.[](14)));
return d;
}.call(dec::allocateDeclarations(<dynamic>["C", "Null", "bool", "String", "int", "double", "Type", "AbstractClassInstantiationError", "NoSuchMethodError", "CyclicInitializationError", "UnsupportedError", "IntegerDivisionByZeroException", "RangeError", "ArgumentError", "Object", "HasRuntimeTypeGetter", "Comparable", "Pattern", "num", "Error", "Exception"], <dynamic>[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]));
static method main() → dynamic {
self::C c = new self::C::•(new typ::Interface::•(self::$declarations.[](0), <dynamic>[new typ::Interface::•(self::$declarations.[](0), <dynamic>[const typ::Dynamic::•()])])).{self::C::foo}(new self::C::•(new typ::Interface::•(self::$declarations.[](0), <dynamic>[const typ::Dynamic::•()])));
}