Index: pkg/compiler/lib/src/resolution/constructors.dart |
diff --git a/pkg/compiler/lib/src/resolution/constructors.dart b/pkg/compiler/lib/src/resolution/constructors.dart |
index 0f9f09920153103d3f6861c9300d7db6d387368e..7819081db35f1e33f25e007068118da6e2063648 100644 |
--- a/pkg/compiler/lib/src/resolution/constructors.dart |
+++ b/pkg/compiler/lib/src/resolution/constructors.dart |
@@ -720,8 +720,25 @@ class ConstructorResolver extends CommonResolverVisitor<ConstructorResult> { |
{PrefixElement prefix}) { |
String name = type.name; |
if (type.isMalformed) { |
Johnni Winther
2016/05/23 12:50:41
If you move `if (type.isTypeVariable) ...` before
eernst
2016/05/23 14:30:24
Done.
|
- return new ConstructorResult.forError( |
- ConstructorResultKind.INVALID_TYPE, type.element, type); |
+ if (type is MalformedType) { |
+ return new ConstructorResult.forError( |
+ ConstructorResultKind.INVALID_TYPE, type.element, type); |
+ } else { |
+ // GENERIC_METHODS: This block provides thin support for generic |
+ // methods: If a method type variable is used as a constructor, a |
+ // warning is issued and code for a runtime error generated. |
+ assert(type is MethodTypeVariableType); |
+ MethodTypeVariableType methodTypeVariableType = type; |
+ reporter.reportWarningMessage( |
+ node, |
+ MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE, |
+ { 'typeVariableName': methodTypeVariableType.name}); |
+ registry.registerFeature(Feature.THROW_RUNTIME_ERROR); |
+ return new ConstructorResult.forError( |
+ ConstructorResultKind.INVALID_TYPE, |
+ methodTypeVariableType.toMalformedElement, |
+ methodTypeVariableType); |
+ } |
} else if (type.isInterfaceType) { |
return new ConstructorResult.forType(prefix, type); |
} else if (type.isTypedef) { |