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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 12298029: Turn error into warning for non-static member access through the class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix co19 status. Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 Element operator[](Node node); 8 Element operator[](Node node);
9 Selector getSelector(Send send); 9 Selector getSelector(Send send);
10 DartType getType(Node node); 10 DartType getType(Node node);
(...skipping 1935 matching lines...) Expand 10 before | Expand all | Expand 10 after
1946 if (node.isOperator) { 1946 if (node.isOperator) {
1947 // When the resolved receiver is a class, we can have two cases: 1947 // When the resolved receiver is a class, we can have two cases:
1948 // 1) a static send: C.foo, or 1948 // 1) a static send: C.foo, or
1949 // 2) an operator send, where the receiver is a class literal: 'C + 1'. 1949 // 2) an operator send, where the receiver is a class literal: 'C + 1'.
1950 // The following code that looks up the selector on the resolved 1950 // The following code that looks up the selector on the resolved
1951 // receiver will treat the second as the invocation of a static operator 1951 // receiver will treat the second as the invocation of a static operator
1952 // if the resolved receiver is not null. 1952 // if the resolved receiver is not null.
1953 return null; 1953 return null;
1954 } 1954 }
1955 target = receiverClass.lookupLocalMember(name); 1955 target = receiverClass.lookupLocalMember(name);
1956 if (target == null) { 1956 if (target == null || target.isInstanceMember()) {
1957 compiler.backend.registerThrowNoSuchMethod(); 1957 compiler.backend.registerThrowNoSuchMethod();
1958 // TODO(johnniwinther): With the simplified [TreeElements] invariant, 1958 // TODO(johnniwinther): With the simplified [TreeElements] invariant,
1959 // try to resolve injected elements if [currentClass] is in the patch 1959 // try to resolve injected elements if [currentClass] is in the patch
1960 // library of [receiverClass]. 1960 // library of [receiverClass].
1961 1961
1962 // TODO(karlklose): this should be reported by the caller of 1962 // TODO(karlklose): this should be reported by the caller of
1963 // [resolveSend] to select better warning messages for getters and 1963 // [resolveSend] to select better warning messages for getters and
1964 // setters. 1964 // setters.
1965 return warnAndCreateErroneousElement(node, name, 1965 MessageKind kind = (target == null)
1966 MessageKind.METHOD_NOT_FOUND, 1966 ? MessageKind.METHOD_NOT_FOUND
1967 : MessageKind.MEMBER_NOT_STATIC;
1968 return warnAndCreateErroneousElement(node, name, kind,
1967 {'className': receiverClass.name, 1969 {'className': receiverClass.name,
1968 'methodName': name}); 1970 'methodName': name});
1969 } else if (target.isInstanceMember()) {
1970 error(node, MessageKind.MEMBER_NOT_STATIC,
1971 {'className': receiverClass.name,
1972 'memberName': name});
1973 } 1971 }
1974 } else if (identical(resolvedReceiver.kind, ElementKind.PREFIX)) { 1972 } else if (identical(resolvedReceiver.kind, ElementKind.PREFIX)) {
1975 PrefixElement prefix = resolvedReceiver; 1973 PrefixElement prefix = resolvedReceiver;
1976 target = prefix.lookupLocalMember(name); 1974 target = prefix.lookupLocalMember(name);
1977 if (Elements.isUnresolved(target)) { 1975 if (Elements.isUnresolved(target)) {
1978 compiler.backend.registerThrowNoSuchMethod(); 1976 compiler.backend.registerThrowNoSuchMethod();
1979 return warnAndCreateErroneousElement( 1977 return warnAndCreateErroneousElement(
1980 node, name, MessageKind.NO_SUCH_LIBRARY_MEMBER, 1978 node, name, MessageKind.NO_SUCH_LIBRARY_MEMBER,
1981 {'libraryName': prefix.name, 'memberName': name}); 1979 {'libraryName': prefix.name, 'memberName': name});
1982 } else if (target.kind == ElementKind.CLASS) { 1980 } else if (target.kind == ElementKind.CLASS) {
(...skipping 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after
3701 return e; 3699 return e;
3702 } 3700 }
3703 3701
3704 /// Assumed to be called by [resolveRedirectingFactory]. 3702 /// Assumed to be called by [resolveRedirectingFactory].
3705 Element visitReturn(Return node) { 3703 Element visitReturn(Return node) {
3706 Node expression = node.expression; 3704 Node expression = node.expression;
3707 return finishConstructorReference(visit(expression), 3705 return finishConstructorReference(visit(expression),
3708 expression, expression); 3706 expression, expression);
3709 } 3707 }
3710 } 3708 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/elements/modelx.dart ('k') | tests/co19/co19-dart2dart.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698