Skip to content

Implement adjusted member conflict rules #33235

Open
@eernstg

Description

@eernstg

(Edit May 31st by eernstg: The member conflicts rules have been simplified considerably, which is reflected in the simpler text below. E.g., many rows in the table are now justified by the same line number in the specification.)


Cf. issue #33077, CL 54410, and commits e8bb129 and 08c893d, the Dart 2 rules for which pairs of member declarations constitute a conflict have changed slightly, and expressed in a significantly simpler form. This issue is concerned with the implementation and testing of the updated rules.

For instance, it is now an error if a class declares a setter named v= and has a method named v, which will make the two declarations of m here a conflict. Here is a complete table showing the member declaration conflicts with the new ruleset:

Member1                       Member2                       Conflict Reason
-----------------------------------------------------------------------------
declares constructor `C.n`    declares static getter `n`    2449
declares constructor `C.n`    declares static method `n`    2449
declares constructor `C.n`    declares static setter `n=`   2449
declares static getter `n`    declares static method `n`    346, 2450, and 2451
declares static getter `n`    has instance getter `n`       2452
declares static getter `n`    has instance method `n`       2452
declares static getter `n`    has instance setter `n=`      2452
declares static method `n`    has instance getter `n`       2452
declares static method `n`    has instance method `n`       2452
declares static method `n`    has instance setter `n=`      2452
declares static setter `n=`   declares static method `n`    2450 and 2451
declares static setter `n=`   has instance getter `n`       2452
declares static setter `n=`   has instance method `n`       2452
declares static setter `n=`   has instance setter `n=`      2452
has instance getter `n`       has instance method `n`       2450 or 2451, possibly 346
has instance setter `n=`      has instance method `n`       2450 or 2451

The number in the third column is the line number in dartLangSpec.tex as of c6129f7 where the given situation is specified to be a conflict (that is, a compile-time error or a static warning (which is also an error in Dart 2)).

The conflicts listed above are concerned with conflicts among member declarations that are beyond the simple name clash where two declarations introduce the same name into the same scope, that is, the names may be different, and they may be in different scopes.

In particular, the above list says nothing about overriding (because overriding is always concerned with two declarations of the same kind, and the list does not mention any such case).

It may be useful to consider certain cases where there is no conflict:

Member1                       Member2
---------------------------------------------------------
declares static setter `n=`   declares static getter `n`
has instance getter `n`       has instance setter `n=`
declares constructor `C.n`    has instance method `n`
declares constructor `C.n`    has instance getter `n`
declares constructor `C.n`    has instance setter `n=`

Subtasks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-metaCross-cutting, high-level issues (for tracking many other implementation issues, ...).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions