From da07089568452b761b406b5b023ef0c6dfb15804 Mon Sep 17 00:00:00 2001 From: "codefu@google.com" Date: Thu, 6 Oct 2011 15:50:13 +0000 Subject: [PATCH] DynamicElementImplementation: return dynamic type MemberBuilder: accept broken methods DeltaAnalyzer: Corelib types BUG= TEST= Review URL: https://chromereviews.googleplex.com/3531013 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@133 260f80e4-7a28-3924-810f-c04153c831b5 --- .../google/dart/compiler/DartCompiler.java | 25 ++++++++++++++++++ .../DynamicElementImplementation.java | 2 +- .../dart/compiler/resolver/MemberBuilder.java | 1 + .../com/google/dart/compiler/DeltaBench.java | 26 ++----------------- .../resolver/NegativeResolverTest.java | 2 +- 5 files changed, 30 insertions(+), 26 deletions(-) diff --git a/compiler/java/com/google/dart/compiler/DartCompiler.java b/compiler/java/com/google/dart/compiler/DartCompiler.java index 31d9df08cc0..2334e3f3e96 100644 --- a/compiler/java/com/google/dart/compiler/DartCompiler.java +++ b/compiler/java/com/google/dart/compiler/DartCompiler.java @@ -51,6 +51,7 @@ import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -1089,4 +1090,28 @@ public class DartCompiler { config, listener); return analyzer.analyze(); } + + public static LibraryUnit findLibrary(LibraryUnit libraryUnit, String uri, + Set seen) { + if (seen.contains(libraryUnit.getElement())) { + return null; + } + seen.add(libraryUnit.getElement()); + for (LibraryNode src : libraryUnit.getSourcePaths()) { + if (src.getText().equals(uri)) { + return libraryUnit; + } + } + for (LibraryUnit importedLibrary : libraryUnit.getImports()) { + LibraryUnit unit = findLibrary(importedLibrary, uri, seen); + if (unit != null) { + return unit; + } + } + return null; + } + + public static LibraryUnit getCoreLib(LibraryUnit libraryUnit) { + return findLibrary(libraryUnit, "corelib.dart", new HashSet()); + } } diff --git a/compiler/java/com/google/dart/compiler/resolver/DynamicElementImplementation.java b/compiler/java/com/google/dart/compiler/resolver/DynamicElementImplementation.java index 46cd619d84c..300fb084897 100644 --- a/compiler/java/com/google/dart/compiler/resolver/DynamicElementImplementation.java +++ b/compiler/java/com/google/dart/compiler/resolver/DynamicElementImplementation.java @@ -78,7 +78,7 @@ class DynamicElementImplementation extends AbstractElement implements DynamicEle @Override public DynamicType getType() { - return null; + return Types.newDynamicType(); } @Override diff --git a/compiler/java/com/google/dart/compiler/resolver/MemberBuilder.java b/compiler/java/com/google/dart/compiler/resolver/MemberBuilder.java index 41e2192b9ee..89547451559 100644 --- a/compiler/java/com/google/dart/compiler/resolver/MemberBuilder.java +++ b/compiler/java/com/google/dart/compiler/resolver/MemberBuilder.java @@ -111,6 +111,7 @@ public class MemberBuilder { MethodElement element = method.getSymbol(); if (element == null) { switch (getMethodKind(method)) { + case NONE: case CONSTRUCTOR: element = buildConstructor(method); addConstructor((ClassElement) currentHolder, (ConstructorElement) element); diff --git a/compiler/javatests/com/google/dart/compiler/DeltaBench.java b/compiler/javatests/com/google/dart/compiler/DeltaBench.java index 8416bd315d2..cd86b53fcd1 100644 --- a/compiler/javatests/com/google/dart/compiler/DeltaBench.java +++ b/compiler/javatests/com/google/dart/compiler/DeltaBench.java @@ -5,7 +5,6 @@ package com.google.dart.compiler; import com.google.dart.compiler.ast.DartUnit; -import com.google.dart.compiler.ast.LibraryNode; import com.google.dart.compiler.ast.LibraryUnit; import com.google.dart.compiler.resolver.LibraryElement; import com.google.dart.compiler.testing.TestCompilerConfiguration; @@ -14,7 +13,6 @@ import com.google.dart.compiler.testing.TestCompilerContext; import java.io.File; import java.io.IOException; import java.util.HashSet; -import java.util.Set; public class DeltaBench { public static void main(String[] args) throws IOException { @@ -60,9 +58,9 @@ public class DeltaBench { if (incremental) { return; } - LibraryUnit enclosingLibraryUnit = findLibrary(libraryUnit, interestingFile, + LibraryUnit enclosingLibraryUnit = DartCompiler.findLibrary(libraryUnit, interestingFile, new HashSet()); - LibraryUnit coreLibraryUnit = findLibrary(libraryUnit, "object.dart", + LibraryUnit coreLibraryUnit = DartCompiler.findLibrary(libraryUnit, "object.dart", new HashSet()); DartUnit unit = null; for (DartUnit current : enclosingLibraryUnit.getUnits()) { @@ -79,24 +77,4 @@ public class DeltaBench { System.err.println("analyzeDelta(" + unit.getSource().getName() + ") took " + (System.currentTimeMillis() - start) + "ms"); } - - private static LibraryUnit findLibrary(LibraryUnit libraryUnit, String uri, - Set seen) { - if (seen.contains(libraryUnit.getElement())) { - return null; - } - seen.add(libraryUnit.getElement()); - for (LibraryNode src : libraryUnit.getSourcePaths()) { - if (src.getText().equals(uri)) { - return libraryUnit; - } - } - for (LibraryUnit importedLibrary : libraryUnit.getImports()) { - LibraryUnit unit = findLibrary(importedLibrary, uri, seen); - if (unit != null) { - return unit; - } - } - return null; - } } diff --git a/compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java b/compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java index d3c10f7b780..cd48cf36d99 100644 --- a/compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java +++ b/compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java @@ -162,7 +162,7 @@ public class NegativeResolverTest extends CompilerTestCase { } public void testBadNamedConstructorNegativeTest() { - checkNumErrors("BadNamedConstructorNegativeTest.dart", 1); + checkNumErrors("BadNamedConstructorNegativeTest.dart", 3); } public void testCyclicRedirectedConstructorNegativeTest() {