diff options
Diffstat (limited to 'org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java')
-rw-r--r-- | org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java index caf794b11..3a02309c6 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java @@ -37,7 +37,7 @@ * Bug 424930 - [1.8][compiler] Regression: "Cannot infer type arguments" error from compiler. * Bug 427483 - [Java 8] Variables in lambdas sometimes can't be resolved * Bug 427438 - [1.8][compiler] NPE at org.eclipse.jdt.internal.compiler.ast.ConditionalExpression.generateCode(ConditionalExpression.java:280) - * Bug 426996 - [1.8][inference] try to avoid method Expression.unresolve()? + * Bug 426996 - [1.8][inference] try to avoid method Expression.unresolve()? * Bug 428352 - [1.8][compiler] Resolution errors don't always surface * Bug 429203 - [1.8][compiler] NPE in AllocationExpression.binding * Bug 429430 - [1.8] Lambdas and method reference infer wrong exception type with generics (RuntimeException instead of IOException) @@ -122,7 +122,7 @@ public class AllocationExpression extends Expression implements IPolyExpression, public boolean argsContainCast; public TypeBinding[] argumentTypes = Binding.NO_PARAMETERS; public boolean argumentsHaveErrors = false; - + //{ObjectTeams: alternate AST in case the creation needs to be redirected through a creator call: private MessageSend roleCreatorCall = null; private NameReference valueParam; // if allocation type has value parameter: synthesized argument for ctor call @@ -145,8 +145,8 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl // process arguments if (this.arguments != null) { boolean analyseResources = currentScope.compilerOptions().analyseResourceLeaks; - boolean hasResourceWrapperType = analyseResources - && this.resolvedType instanceof ReferenceBinding + boolean hasResourceWrapperType = analyseResources + && this.resolvedType instanceof ReferenceBinding && ((ReferenceBinding)this.resolvedType).hasTypeBit(TypeIds.BitWrapperCloseable); for (int i = 0, count = this.arguments.length; i < count; i++) { flowInfo = @@ -168,7 +168,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl if ((this.bits & ASTNode.Unchecked) != 0 && this.genericTypeArguments == null) { // https://bugs.eclipse.org/bugs/show_bug.cgi?id=277643, align with javac on JLS 15.12.2.6 thrownExceptions = currentScope.environment().convertToRawTypes(this.binding.thrownExceptions, true, true); - } + } // check exception handling flowContext.checkExceptionHandlers( thrownExceptions, @@ -183,7 +183,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl ReferenceBinding declaringClass = this.binding.declaringClass; MethodScope methodScope = currentScope.methodScope(); - if ((declaringClass.isMemberType() && !declaringClass.isStatic()) || + if ((declaringClass.isMemberType() && !declaringClass.isStatic()) || (declaringClass.isLocalType() && !methodScope.isStatic && methodScope.isLambdaScope())) { // allocating a non-static member type without an enclosing instance of parent type // https://bugs.eclipse.org/bugs/show_bug.cgi?id=335845 @@ -364,7 +364,7 @@ public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo f // SH} ReferenceBinding declaringClass; - if (codegenBinding.isPrivate() && + if (codegenBinding.isPrivate() && !currentScope.enclosingSourceType().isNestmateOf(this.binding.declaringClass) && TypeBinding.notEquals(currentScope.enclosingSourceType(), (declaringClass = codegenBinding.declaringClass))) { @@ -506,7 +506,7 @@ public TypeBinding resolveType(BlockScope scope) { this.argumentsHaveErrors = true; } else { // orig: - if (this.arguments[i].resolvedType != null) + if (this.arguments[i].resolvedType != null) scope.problemReporter().genericInferenceError("Argument was unexpectedly found resolved", this); //$NON-NLS-1$ if ((this.argumentTypes[i] = argument.resolveType(scope)) == null) { this.argumentsHaveErrors = true; @@ -559,7 +559,7 @@ public TypeBinding resolveType(BlockScope scope) { scope.problemReporter().cannotInstantiate(this.type, this.resolvedType); return this.resolvedType; } - } + } if (isDiamond) { this.binding = inferConstructorOfElidedParameterizedType(scope); if (this.binding == null || !this.binding.isValidBinding()) { @@ -754,7 +754,7 @@ public static MethodBinding inferDiamondConstructor(Scope scope, InvocationSite ReferenceBinding genericType = ((ParameterizedTypeBinding) type).genericType(); ReferenceBinding enclosingType = type.enclosingType(); ParameterizedTypeBinding allocationType = scope.environment().createParameterizedType(genericType, genericType.typeVariables(), enclosingType); - + // Given the allocation type and the arguments to the constructor, see if we can infer the constructor of the elided parameterized type. MethodBinding factory = scope.getStaticFactory(allocationType, enclosingType, argumentTypes, site); if (factory instanceof ParameterizedGenericMethodBinding && factory.isValidBinding()) { @@ -764,7 +764,7 @@ public static MethodBinding inferDiamondConstructor(Scope scope, InvocationSite TypeVariableBinding[] constructorTypeVariables = sfmb.getConstructor().typeVariables(); TypeBinding [] constructorTypeArguments = constructorTypeVariables != null ? new TypeBinding[constructorTypeVariables.length] : Binding.NO_TYPES; if (constructorTypeArguments.length > 0) - System.arraycopy(((ParameterizedGenericMethodBinding)factory).typeArguments, sfmb.typeVariables().length - constructorTypeArguments.length , + System.arraycopy(((ParameterizedGenericMethodBinding)factory).typeArguments, sfmb.typeVariables().length - constructorTypeArguments.length , constructorTypeArguments, 0, constructorTypeArguments.length); if (allocationType.isInterface()) { ParameterizedTypeBinding parameterizedType = (ParameterizedTypeBinding) factory.returnType; @@ -778,11 +778,11 @@ public TypeBinding[] inferElidedTypes(final Scope scope) { return inferElidedTypes((ParameterizedTypeBinding) this.resolvedType, scope); } public TypeBinding[] inferElidedTypes(ParameterizedTypeBinding parameterizedType, final Scope scope) { - + ReferenceBinding genericType = parameterizedType.genericType(); ReferenceBinding enclosingType = parameterizedType.enclosingType(); ParameterizedTypeBinding allocationType = scope.environment().createParameterizedType(genericType, genericType.typeVariables(), enclosingType); - + /* Given the allocation type and the arguments to the constructor, see if we can synthesize a generic static factory method that would, given the argument types and the invocation site, manufacture a parameterized object of type allocationType. If we are successful then by design and construction, the parameterization of the return type of the factory method is identical @@ -815,13 +815,13 @@ public void checkTypeArgumentRedundancy(ParameterizedTypeBinding allocationType, if (i == allocationType.arguments.length) { scope.problemReporter().redundantSpecificationOfTypeArguments(this.type, allocationType.arguments); return; - } + } } } TypeBinding [] inferredTypes; int previousBits = this.type.bits; try { - // checking for redundant type parameters must fake a diamond, + // checking for redundant type parameters must fake a diamond, // so we infer the same results as we would get with a diamond in source code: this.type.bits |= IsDiamond; inferredTypes = inferElidedTypes(allocationType, scope); |