1 /* |
1 /* |
2 * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
153 allowTypeAnnos = source.allowTypeAnnotations(); |
153 allowTypeAnnos = source.allowTypeAnnotations(); |
154 allowLambda = source.allowLambda(); |
154 allowLambda = source.allowLambda(); |
155 allowDefaultMethods = source.allowDefaultMethods(); |
155 allowDefaultMethods = source.allowDefaultMethods(); |
156 allowStaticInterfaceMethods = source.allowStaticInterfaceMethods(); |
156 allowStaticInterfaceMethods = source.allowStaticInterfaceMethods(); |
157 sourceName = source.name; |
157 sourceName = source.name; |
158 relax = (options.isSet("-retrofit") || |
|
159 options.isSet("-relax")); |
|
160 useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning"); |
158 useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning"); |
161 |
159 |
162 statInfo = new ResultInfo(KindSelector.NIL, Type.noType); |
160 statInfo = new ResultInfo(KindSelector.NIL, Type.noType); |
163 varAssignmentInfo = new ResultInfo(KindSelector.ASG, Type.noType); |
161 varAssignmentInfo = new ResultInfo(KindSelector.ASG, Type.noType); |
164 unknownExprInfo = new ResultInfo(KindSelector.VAL, Type.noType); |
162 unknownExprInfo = new ResultInfo(KindSelector.VAL, Type.noType); |
165 methodAttrInfo = new MethodAttrInfo(); |
163 methodAttrInfo = new MethodAttrInfo(); |
166 unknownTypeInfo = new ResultInfo(KindSelector.TYP, Type.noType); |
164 unknownTypeInfo = new ResultInfo(KindSelector.TYP, Type.noType); |
167 unknownTypeExprInfo = new ResultInfo(KindSelector.VAL_TYP, Type.noType); |
165 unknownTypeExprInfo = new ResultInfo(KindSelector.VAL_TYP, Type.noType); |
168 recoveryInfo = new RecoveryInfo(deferredAttr.emptyDeferredAttrContext); |
166 recoveryInfo = new RecoveryInfo(deferredAttr.emptyDeferredAttrContext); |
169 } |
167 } |
170 |
|
171 /** Switch: relax some constraints for retrofit mode. |
|
172 */ |
|
173 boolean relax; |
|
174 |
168 |
175 /** Switch: support target-typing inference |
169 /** Switch: support target-typing inference |
176 */ |
170 */ |
177 boolean allowPoly; |
171 boolean allowPoly; |
178 |
172 |
1023 if (tree.defaultValue != null) { |
1017 if (tree.defaultValue != null) { |
1024 if ((owner.flags() & ANNOTATION) == 0) |
1018 if ((owner.flags() & ANNOTATION) == 0) |
1025 log.error(tree.pos(), |
1019 log.error(tree.pos(), |
1026 "default.allowed.in.intf.annotation.member"); |
1020 "default.allowed.in.intf.annotation.member"); |
1027 } |
1021 } |
1028 if (isDefaultMethod || (tree.sym.flags() & (ABSTRACT | NATIVE)) == 0 && |
1022 if (isDefaultMethod || (tree.sym.flags() & (ABSTRACT | NATIVE)) == 0) |
1029 !relax) |
|
1030 log.error(tree.pos(), "missing.meth.body.or.decl.abstract"); |
1023 log.error(tree.pos(), "missing.meth.body.or.decl.abstract"); |
1031 } else if ((tree.sym.flags() & (ABSTRACT|DEFAULT|PRIVATE)) == ABSTRACT) { |
1024 } else if ((tree.sym.flags() & (ABSTRACT|DEFAULT|PRIVATE)) == ABSTRACT) { |
1032 if ((owner.flags() & INTERFACE) != 0) { |
1025 if ((owner.flags() & INTERFACE) != 0) { |
1033 log.error(tree.body.pos(), "intf.meth.cant.have.body"); |
1026 log.error(tree.body.pos(), "intf.meth.cant.have.body"); |
1034 } else { |
1027 } else { |
4382 c.markAbstractIfNeeded(types); |
4375 c.markAbstractIfNeeded(types); |
4383 |
4376 |
4384 // If this is a non-abstract class, check that it has no abstract |
4377 // If this is a non-abstract class, check that it has no abstract |
4385 // methods or unimplemented methods of an implemented interface. |
4378 // methods or unimplemented methods of an implemented interface. |
4386 if ((c.flags() & (ABSTRACT | INTERFACE)) == 0) { |
4379 if ((c.flags() & (ABSTRACT | INTERFACE)) == 0) { |
4387 if (!relax) |
4380 chk.checkAllDefined(tree.pos(), c); |
4388 chk.checkAllDefined(tree.pos(), c); |
|
4389 } |
4381 } |
4390 |
4382 |
4391 if ((c.flags() & ANNOTATION) != 0) { |
4383 if ((c.flags() & ANNOTATION) != 0) { |
4392 if (tree.implementing.nonEmpty()) |
4384 if (tree.implementing.nonEmpty()) |
4393 log.error(tree.implementing.head.pos(), |
4385 log.error(tree.implementing.head.pos(), |