Skip to content

Commit d3bc427

Browse files
committed
Cleanup InferableOverride
We don't use this anymore. [email protected] Review URL: https://codereview.chromium.org/1296723002 .
1 parent c010093 commit d3bc427

File tree

4 files changed

+8
-42
lines changed

4 files changed

+8
-42
lines changed

pkg/dev_compiler/lib/src/checker/checker.dart

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -295,34 +295,12 @@ class _OverrideChecker {
295295
// get foo => e; // no type specified.
296296
// toString() { ... } // no return type specified.
297297
// }
298-
if (_isInferableOverride(element, node, subType, baseType)) {
299-
_recordMessage(new InferableOverride(errorLocation, element, type,
300-
subType.returnType, baseType.returnType));
301-
} else {
302-
_recordMessage(new InvalidMethodOverride(
303-
errorLocation, element, type, subType, baseType));
304-
}
298+
_recordMessage(new InvalidMethodOverride(
299+
errorLocation, element, type, subType, baseType));
305300
}
306301
return true;
307302
}
308303

309-
bool _isInferableOverride(ExecutableElement element, AstNode node,
310-
FunctionType subType, FunctionType baseType) {
311-
if (_inferFromOverrides || node == null) return false;
312-
final isGetter = element is PropertyAccessorElement && element.isGetter;
313-
if (isGetter && element.isSynthetic) {
314-
var field = node.parent.parent;
315-
return field is FieldDeclaration && field.fields.type == null;
316-
}
317-
318-
// node is a MethodDeclaration whenever getters and setters are
319-
// declared explicitly. Setters declared from a field will have the
320-
// correct return type, so we don't need to check that separately.
321-
return node is MethodDeclaration &&
322-
node.returnType == null &&
323-
_rules.isFunctionSubTypeOf(subType, baseType, ignoreReturn: true);
324-
}
325-
326304
void _recordMessage(StaticInfo info) {
327305
if (info == null) return;
328306
var error = info.toAnalysisError();

pkg/dev_compiler/lib/src/info.dart

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -527,18 +527,6 @@ class InvalidMethodOverride extends InvalidOverride {
527527
String get message => _messageHelper('Invalid override');
528528
}
529529

530-
// TODO(sigmund): delete, if we fix this, this should be part of the type
531-
// inference, not something we detect in the checker.
532-
// TODO(sigmund): split and track field, getter, setter, method separately
533-
class InferableOverride extends InvalidOverride {
534-
InferableOverride(AstNode node, ExecutableElement element, InterfaceType base,
535-
DartType subType, DartType baseType)
536-
: super(node, element, base, subType, baseType);
537-
538-
toErrorCode() => new CompileTimeErrorCode(name, message);
539-
String get message => _messageHelper('Invalid but inferable override');
540-
}
541-
542530
/// Used to mark unexpected situations in our compiler were we couldn't compute
543531
/// the type of an expression.
544532
// TODO(sigmund): This is normally a result of another error that is caught by

pkg/dev_compiler/test/checker/checker_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ void main() {
13891389
class Child extends Base {
13901390
/*severe:InvalidMethodOverride*/A f1; // invalid for getter
13911391
/*severe:InvalidMethodOverride*/C f2; // invalid for setter
1392-
/*severe:InferableOverride,severe:InvalidMethodOverride*/var f3;
1392+
/*severe:InvalidMethodOverride,severe:InvalidMethodOverride*/var f3;
13931393
/*severe:InvalidMethodOverride,severe:InvalidMethodOverride*/dynamic f4;
13941394
}
13951395
'''
@@ -1439,7 +1439,7 @@ void main() {
14391439
class Child extends Base {
14401440
/*severe:InvalidMethodOverride*/A get f1 => null;
14411441
C get f2 => null;
1442-
/*severe:InferableOverride*/get f3 => null;
1442+
/*severe:InvalidMethodOverride*/get f3 => null;
14431443
/*severe:InvalidMethodOverride*/dynamic get f4 => null;
14441444
}
14451445
'''
@@ -2489,7 +2489,7 @@ void main() {
24892489
'/main.dart': '''
24902490
class A {}
24912491
class T1 implements A {
2492-
/*severe:InferableOverride*/toString() {}
2492+
/*severe:InvalidMethodOverride*/toString() {}
24932493
}
24942494
'''
24952495
},

pkg/dev_compiler/test/checker/inferred_type_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ void main() {
737737
}
738738
739739
class B extends A {
740-
/*severe:InferableOverride*/get x => 3;
740+
/*severe:InvalidMethodOverride*/get x => 3;
741741
}
742742
743743
foo() {
@@ -777,7 +777,7 @@ void main() {
777777
}
778778
779779
class B implements A {
780-
/*severe:InferableOverride*/get x => 3;
780+
/*severe:InvalidMethodOverride*/get x => 3;
781781
}
782782
783783
foo() {
@@ -841,7 +841,7 @@ void main() {
841841
}
842842
843843
class B implements A<int> {
844-
/*severe:InferableOverride*/get x => 3;
844+
/*severe:InvalidMethodOverride*/get x => 3;
845845
}
846846
847847
foo() {

0 commit comments

Comments
 (0)