| Index: pkg/compiler/lib/src/ssa/builder.dart
|
| diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
|
| index 1a754fd18f29628daabe4c52d8651e26dd3bbd0d..1740338b4d33aeaab31424c029d95085f7f477e0 100644
|
| --- a/pkg/compiler/lib/src/ssa/builder.dart
|
| +++ b/pkg/compiler/lib/src/ssa/builder.dart
|
| @@ -2587,13 +2587,17 @@ class SsaBuilder extends ast.Visitor
|
| "${localsHandler.contextClass}.");
|
| }
|
|
|
| - /// Build a [HTypeConversion] for convertion [original] to type [type].
|
| + /// Build a [HTypeConversion] for converting [original] to type [type].
|
| ///
|
| /// Invariant: [type] must be valid in the context.
|
| /// See [LocalsHandler.substInContext].
|
| HInstruction buildTypeConversion(
|
| HInstruction original, DartType type, int kind) {
|
| if (type == null) return original;
|
| + // GENERIC_METHODS: The following statement was added for parsing and
|
| + // ignoring method type variables; must be generalized for full support of
|
| + // generic methods.
|
| + type = type.dynamifyMethodTypeVariableType;
|
| type = type.unaliased;
|
| assert(assertTypeInContext(type, original));
|
| if (type.isInterfaceType && !type.treatAsRaw) {
|
| @@ -3814,8 +3818,15 @@ class SsaBuilder extends ast.Visitor
|
| void visitAs(ast.Send node, ast.Node expression, DartType type, _) {
|
| HInstruction expressionInstruction = visitAndPop(expression);
|
| if (type.isMalformed) {
|
| - ErroneousElement element = type.element;
|
| - generateTypeError(node, element.message);
|
| + String message;
|
| + if (type is MalformedType) {
|
| + ErroneousElement element = type.element;
|
| + message = element.message;
|
| + } else {
|
| + assert(type is MethodTypeVariableType);
|
| + message = "Method type variables are not reified.";
|
| + }
|
| + generateTypeError(node, message);
|
| } else {
|
| HInstruction converted = buildTypeConversion(expressionInstruction,
|
| localsHandler.substInContext(type), HTypeConversion.CAST_TYPE_CHECK);
|
| @@ -3841,7 +3852,20 @@ class SsaBuilder extends ast.Visitor
|
| HInstruction buildIsNode(
|
| ast.Node node, DartType type, HInstruction expression) {
|
| type = localsHandler.substInContext(type).unaliased;
|
| - if (type.isFunctionType) {
|
| + if (type.isMalformed) {
|
| + String message;
|
| + if (type is MethodTypeVariableType) {
|
| + message = "Method type variables are not reified, "
|
| + "so they cannot be tested with an `is` expression.";
|
| + } else {
|
| + assert(type is MalformedType);
|
| + ErroneousElement element = type.element;
|
| + message = element.message;
|
| + }
|
| + generateTypeError(node, message);
|
| + HInstruction call = pop();
|
| + return new HIs.compound(type, expression, call, backend.boolType);
|
| + } else if (type.isFunctionType) {
|
| List arguments = [buildFunctionType(type), expression];
|
| pushInvokeDynamic(
|
| node,
|
| @@ -3876,11 +3900,6 @@ class SsaBuilder extends ast.Visitor
|
| pushInvokeStatic(node, helper, inputs, typeMask: backend.boolType);
|
| HInstruction call = pop();
|
| return new HIs.compound(type, expression, call, backend.boolType);
|
| - } else if (type.isMalformed) {
|
| - ErroneousElement element = type.element;
|
| - generateTypeError(node, element.message);
|
| - HInstruction call = pop();
|
| - return new HIs.compound(type, expression, call, backend.boolType);
|
| } else {
|
| if (backend.hasDirectCheckFor(type)) {
|
| return new HIs.direct(type, expression, backend.boolType);
|
| @@ -5346,12 +5365,19 @@ class SsaBuilder extends ast.Visitor
|
| /// Generate the literal for [typeVariable] in the current context.
|
| void generateTypeVariableLiteral(
|
| ast.Send node, TypeVariableType typeVariable) {
|
| - DartType type = localsHandler.substInContext(typeVariable);
|
| - HInstruction value = analyzeTypeArgument(type,
|
| - sourceInformation: sourceInformationBuilder.buildGet(node));
|
| - pushInvokeStatic(node, helpers.runtimeTypeToString, [value],
|
| - typeMask: backend.stringType);
|
| - pushInvokeStatic(node, helpers.createRuntimeType, [pop()]);
|
| + // GENERIC_METHODS: This provides thin support for method type variables
|
| + // by treating them as malformed when evaluated as a literal. For full
|
| + // support of generic methods this must be revised.
|
| + if (typeVariable is MethodTypeVariableType) {
|
| + generateTypeError(node, "Method type variables are not reified");
|
| + } else {
|
| + DartType type = localsHandler.substInContext(typeVariable);
|
| + HInstruction value = analyzeTypeArgument(type,
|
| + sourceInformation: sourceInformationBuilder.buildGet(node));
|
| + pushInvokeStatic(node, helpers.runtimeTypeToString, [value],
|
| + typeMask: backend.stringType);
|
| + pushInvokeStatic(node, helpers.createRuntimeType, [pop()]);
|
| + }
|
| }
|
|
|
| /// Generate a call to a type literal.
|
|
|