Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(458)

Unified Diff: compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java

Issue 10837282: Issue 4518. Use inferred types to check if type of argumetn is assignable to the type of parameter (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
diff --git a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
index c8185f1675e0f95fa4756cb04110eedc844268c4..e76e3e48cb0adc6efa60c5f2abe144514ca14583 100644
--- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
@@ -181,7 +181,7 @@ public class TypeAnalyzer implements DartCompilationPhase {
private final InterfaceType dynamicIteratorType;
private final boolean developerModeChecks;
private final boolean suppressSdkWarnings;
- private final boolean memberWarningForInferredTypes;
+ private final boolean typeChecksForInferredTypes;
private final Map<DartBlock, VariableElementsRestorer> restoreOnBlockExit = Maps.newHashMap();
/**
@@ -208,7 +208,7 @@ public class TypeAnalyzer implements DartCompilationPhase {
this.dynamicIteratorType = typeProvider.getIteratorType(dynamicType);
CompilerOptions compilerOptions = context.getCompilerConfiguration().getCompilerOptions();
this.suppressSdkWarnings = compilerOptions.suppressSdkWarnings();
- this.memberWarningForInferredTypes = compilerOptions.memberWarningForInferredTypes();
+ this.typeChecksForInferredTypes = compilerOptions.typeChecksForInferredTypes();
}
@VisibleForTesting
@@ -562,7 +562,7 @@ public class TypeAnalyzer implements DartCompilationPhase {
}
Member member = itype.lookupMember(methodName);
if (member == null) {
- if (memberWarningForInferredTypes || !receiver.isInferred()) {
+ if (typeChecksForInferredTypes || !receiver.isInferred()) {
typeError(problemTarget, TypeErrorCode.INTERFACE_HAS_NO_METHOD_NAMED, receiver,
methodName);
}
@@ -860,8 +860,10 @@ public class TypeAnalyzer implements DartCompilationPhase {
t.getClass(); // Null check.
s.getClass(); // Null check.
// ignore inferred types, treat them as Dynamic
- if (t.isInferred() || s.isInferred()) {
- return true;
+ if (!typeChecksForInferredTypes) {
+ if (t.isInferred() || s.isInferred()) {
+ return true;
+ }
}
// do check and report error
if (!types.isAssignable(t, s)) {
@@ -926,7 +928,7 @@ public class TypeAnalyzer implements DartCompilationPhase {
}
}
default:
- if (memberWarningForInferredTypes || !receiver.isInferred()) {
+ if (typeChecksForInferredTypes || !receiver.isInferred()) {
typeError(diagnosticNode, TypeErrorCode.NOT_A_METHOD_IN, name, receiver);
}
return dynamicType;
@@ -2030,7 +2032,7 @@ public class TypeAnalyzer implements DartCompilationPhase {
String name = node.getPropertyName();
InterfaceType.Member member = cls.lookupMember(name);
if (member == null) {
- if (memberWarningForInferredTypes || !receiver.isInferred()) {
+ if (typeChecksForInferredTypes || !receiver.isInferred()) {
typeError(node.getName(), TypeErrorCode.NOT_A_MEMBER_OF, name, cls);
}
return dynamicType;

Powered by Google App Engine
This is Rietveld 408576698