| Index: compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java
|
| diff --git a/compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java b/compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java
|
| index 930133da3d7bdb1e2c5a0f1d695e5f686b90609d..ae7d902c2c8588c445e352ba137e97d261b454e8 100644
|
| --- a/compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java
|
| +++ b/compiler/java/com/google/dart/compiler/backend/js/GenerateJavascriptAST.java
|
| @@ -1727,32 +1727,34 @@ public class GenerateJavascriptAST {
|
| // Create the runtime type checks that will be inserted later
|
| List<JsStatement> checks = Lists.newArrayList();
|
|
|
| - // TODO(zundel): these runtime checks do not work in hoisted functions
|
| - // created inside of factory methods. A bad reference to $typeArgs caused an error
|
| - // in the closure compiler backend.
|
| - boolean emitChecks = true;
|
| - if (inFactory ) {
|
| + // TODO(zundel): Issue 925: these runtime checks do not work in hoisted functions
|
| + // created inside of factory methods if the parameter references type variables.
|
| + // A bad reference to $typeArgs caused an error in the closure compiler backend.
|
| + boolean omitTypeVariableChecks = false;
|
| + if (inFactory) {
|
| Element element = (Element)x.getParent().getSymbol();
|
| if (!ElementKind.of(element).equals(ElementKind.CONSTRUCTOR)) {
|
| // The code being emitted is something other than the factory method itself.
|
| - emitChecks = false;
|
| + omitTypeVariableChecks = true;
|
| }
|
| }
|
|
|
| - if (emitChecks) {
|
| - int numParams = params.size();
|
| - for (int i = 0; i < numParams; ++i) {
|
| - JsNameRef jsParam = jsParams.get(i).getName().makeRef();
|
| - DartParameter param = params.get(i);
|
| - Type paramType = param.getSymbol().getType();
|
| - JsExpression expr = rtt.addTypeCheck(getCurrentClass(), jsParam, paramType, null, param);
|
| - if (expr != jsParam) {
|
| - // if the expression was returned unchanged, omit the check
|
| - checks.add(new JsExprStmt(expr));
|
| - }
|
| + int numParams = params.size();
|
| + for (int i = 0; i < numParams; ++i) {
|
| + JsNameRef jsParam = jsParams.get(i).getName().makeRef();
|
| + DartParameter param = params.get(i);
|
| + Type paramType = param.getSymbol().getType();
|
| + if (omitTypeVariableChecks && TypeKind.of(paramType).equals(TypeKind.VARIABLE)) {
|
| + continue;
|
| + }
|
| + JsExpression expr = rtt.addTypeCheck(getCurrentClass(), jsParam, paramType, null, param);
|
| + if (expr != jsParam) {
|
| + // if the expression was returned unchanged, omit the check
|
| + checks.add(new JsExprStmt(expr));
|
| }
|
| }
|
|
|
| +
|
| // Add temporary variable declarations, if any.
|
| declareTempsInBlock(body, jsNewDeclarationsStack.pop());
|
|
|
|
|