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

Issue 2943273002: Implement type inference of getters/setters based on inheritance. (Closed)

Created:
3 years, 6 months ago by Paul Berry
Modified:
3 years, 6 months ago
CC:
reviews_dartlang.org, dart-fe-team+reviews_google.com
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Implement type inference of getters/setters based on inheritance. R=scheglov@google.com Committed: https://github.com/dart-lang/sdk/commit/7939ea00efd7179acc1ccd86625139abe5e05050

Patch Set 1 #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+670 lines, -167 lines) Patch
M pkg/analyzer/test/src/task/strong/front_end_inference_test.dart View 1 chunk +17 lines, -0 lines 3 comments Download
M pkg/front_end/lib/src/fasta/kernel/kernel_class_builder.dart View 2 chunks +6 lines, -5 lines 0 comments Download
M pkg/front_end/lib/src/fasta/kernel/kernel_field_builder.dart View 2 chunks +2 lines, -2 lines 0 comments Download
M pkg/front_end/lib/src/fasta/kernel/kernel_procedure_builder.dart View 7 chunks +39 lines, -5 lines 0 comments Download
M pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart View 5 chunks +77 lines, -34 lines 0 comments Download
M pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart View 14 chunks +79 lines, -76 lines 0 comments Download
M pkg/front_end/test/fasta/kompile.status View 5 chunks +6 lines, -0 lines 0 comments Download
M pkg/front_end/testcases/inference/conflicts_can_happen.dart View 1 chunk +2 lines, -2 lines 0 comments Download
M pkg/front_end/testcases/inference/conflicts_can_happen2.dart View 1 chunk +1 line, -1 line 0 comments Download
A + pkg/front_end/testcases/inference/infer_accessor_from_later_inferred_field.dart View 1 chunk +7 lines, -4 lines 0 comments Download
A pkg/front_end/testcases/inference/infer_accessor_from_later_inferred_field.dart.direct.expect View 1 chunk +21 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference/infer_accessor_from_later_inferred_field.dart.outline.expect View 1 chunk +21 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference/infer_accessor_from_later_inferred_field.dart.strong.expect View 1 chunk +21 lines, -0 lines 0 comments Download
A + pkg/front_end/testcases/inference/infer_field_from_later_inferred_getter.dart View 1 chunk +8 lines, -4 lines 0 comments Download
A pkg/front_end/testcases/inference/infer_field_from_later_inferred_getter.dart.direct.expect View 1 chunk +23 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference/infer_field_from_later_inferred_getter.dart.outline.expect View 1 chunk +21 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference/infer_field_from_later_inferred_getter.dart.strong.expect View 1 chunk +23 lines, -0 lines 0 comments Download
A + pkg/front_end/testcases/inference/infer_field_from_later_inferred_setter.dart View 1 chunk +8 lines, -4 lines 0 comments Download
A pkg/front_end/testcases/inference/infer_field_from_later_inferred_setter.dart.direct.expect View 1 chunk +23 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference/infer_field_from_later_inferred_setter.dart.outline.expect View 1 chunk +21 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference/infer_field_from_later_inferred_setter.dart.strong.expect View 1 chunk +23 lines, -0 lines 0 comments Download
A + pkg/front_end/testcases/inference/infer_getter_from_later_inferred_getter.dart View 1 chunk +10 lines, -4 lines 0 comments Download
A pkg/front_end/testcases/inference/infer_getter_from_later_inferred_getter.dart.direct.expect View 1 chunk +26 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference/infer_getter_from_later_inferred_getter.dart.outline.expect View 1 chunk +24 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference/infer_getter_from_later_inferred_getter.dart.strong.expect View 1 chunk +26 lines, -0 lines 0 comments Download
M pkg/front_end/testcases/inference/infer_parameter_type_setter_from_field.dart View 1 chunk +1 line, -1 line 0 comments Download
M pkg/front_end/testcases/inference/infer_parameter_type_setter_from_field.dart.strong.expect View 1 chunk +1 line, -1 line 0 comments Download
M pkg/front_end/testcases/inference/infer_parameter_type_setter_from_setter.dart View 1 chunk +1 line, -1 line 0 comments Download
M pkg/front_end/testcases/inference/infer_parameter_type_setter_from_setter.dart.strong.expect View 1 chunk +1 line, -1 line 0 comments Download
A + pkg/front_end/testcases/inference/infer_setter_from_later_inferred_setter.dart View 1 chunk +8 lines, -4 lines 0 comments Download
A pkg/front_end/testcases/inference/infer_setter_from_later_inferred_setter.dart.direct.expect View 1 chunk +23 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference/infer_setter_from_later_inferred_setter.dart.outline.expect View 1 chunk +22 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference/infer_setter_from_later_inferred_setter.dart.strong.expect View 1 chunk +23 lines, -0 lines 0 comments Download
M pkg/front_end/testcases/inference/infer_type_on_overridden_fields2.dart View 1 chunk +1 line, -1 line 0 comments Download
M pkg/front_end/testcases/inference/infer_type_on_overridden_fields2.dart.strong.expect View 1 chunk +1 line, -1 line 0 comments Download
M pkg/front_end/testcases/inference/infer_type_on_overridden_fields4.dart View 1 chunk +1 line, -1 line 0 comments Download
M pkg/front_end/testcases/inference/infer_type_on_overridden_fields4.dart.strong.expect View 1 chunk +1 line, -1 line 0 comments Download
M pkg/front_end/testcases/inference/infer_type_regardless_of_declaration_order_or_cycles.dart View 1 chunk +1 line, -1 line 0 comments Download
M pkg/front_end/testcases/inference/infer_type_regardless_of_declaration_order_or_cycles.dart.strong.expect View 1 chunk +1 line, -1 line 0 comments Download
M pkg/front_end/testcases/inference/infer_types_on_generic_instantiations_3.dart View 1 chunk +2 lines, -2 lines 0 comments Download
M pkg/front_end/testcases/inference/infer_types_on_generic_instantiations_3.dart.strong.expect View 1 chunk +2 lines, -2 lines 0 comments Download
M pkg/front_end/testcases/inference/infer_types_on_generic_instantiations_4.dart View 1 chunk +1 line, -1 line 0 comments Download
M pkg/front_end/testcases/inference/infer_types_on_generic_instantiations_4.dart.strong.expect View 1 chunk +1 line, -1 line 0 comments Download
A + pkg/front_end/testcases/inference/non_inferrable_getter_setter.dart View 1 chunk +3 lines, -6 lines 0 comments Download
A pkg/front_end/testcases/inference/non_inferrable_getter_setter.dart.direct.expect View 1 chunk +13 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference/non_inferrable_getter_setter.dart.outline.expect View 1 chunk +14 lines, -0 lines 0 comments Download
A pkg/front_end/testcases/inference/non_inferrable_getter_setter.dart.strong.expect View 1 chunk +13 lines, -0 lines 0 comments Download

Messages

Total messages: 7 (2 generated)
Paul Berry
I only need a review from one of you.
3 years, 6 months ago (2017-06-18 22:53:41 UTC) #2
scheglov
LGTM https://codereview.chromium.org/2943273002/diff/1/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart File pkg/analyzer/test/src/task/strong/front_end_inference_test.dart (right): https://codereview.chromium.org/2943273002/diff/1/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart#newcode464 pkg/analyzer/test/src/task/strong/front_end_inference_test.dart:464: if (parameter.element.hasImplicitType) { Would "parameter.type == null" work? ...
3 years, 6 months ago (2017-06-18 23:03:43 UTC) #3
Paul Berry
https://codereview.chromium.org/2943273002/diff/1/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart File pkg/analyzer/test/src/task/strong/front_end_inference_test.dart (right): https://codereview.chromium.org/2943273002/diff/1/pkg/analyzer/test/src/task/strong/front_end_inference_test.dart#newcode464 pkg/analyzer/test/src/task/strong/front_end_inference_test.dart:464: if (parameter.element.hasImplicitType) { On 2017/06/18 23:03:43, scheglov wrote: > ...
3 years, 6 months ago (2017-06-18 23:34:32 UTC) #4
Paul Berry
Committed patchset #1 (id:1) manually as 7939ea00efd7179acc1ccd86625139abe5e05050 (presubmit successful).
3 years, 6 months ago (2017-06-18 23:35:10 UTC) #6
Paul Berry
3 years, 6 months ago (2017-06-19 18:18:27 UTC) #7
Message was sent while issue was closed.
https://codereview.chromium.org/2943273002/diff/1/pkg/analyzer/test/src/task/...
File pkg/analyzer/test/src/task/strong/front_end_inference_test.dart (right):

https://codereview.chromium.org/2943273002/diff/1/pkg/analyzer/test/src/task/...
pkg/analyzer/test/src/task/strong/front_end_inference_test.dart:464: if
(parameter.element.hasImplicitType) {
On 2017/06/18 23:34:31, Paul Berry wrote:
> On 2017/06/18 23:03:43, scheglov wrote:
> > Would "parameter.type == null" work?
> > It would be consistent with the returnType check.
> 
> I considered that too, but it wouldn't work because FormalParameter doesn't
have
> a getter `type`.  The reason is because of function-typed formal parameters,
> which have `returnType` and `parameters` getters rather than a `type` getter.
> 
> I suppose I could have done:
> 
>   var parameterElement = parameter.element;
>   if (parameterElement is SimpleFormalParameter && parameterElement.type ==
> null)
> 
> But it seemed simpler to just use `hasImplicitType`.
> 
> I've added a comment explaining this.

After further experimentation it turns out that ParameterElement.hasImplicitType
has a bug where it returns `true` for a function-typed parameter without an
explicit return type.  So this code is no good either until we fix the bug.

I'll send out a bug fix and add some more test cases.

Powered by Google App Engine
This is Rietveld 408576698