@Override public JetTypeInfo visitMultiDeclaration( JetMultiDeclaration multiDeclaration, final ExpressionTypingContext context) { final JetExpression initializer = multiDeclaration.getInitializer(); if (initializer == null) { context.trace.report(INITIALIZER_REQUIRED_FOR_MULTIDECLARATION.on(multiDeclaration)); return JetTypeInfo.create(null, context.dataFlowInfo); } final ExpressionReceiver expressionReceiver = ExpressionTypingUtils.getExpressionReceiver( facade, initializer, context.replaceExpectedType(TypeUtils.NO_EXPECTED_TYPE)); DataFlowInfo dataFlowInfo = facade.getTypeInfo(initializer, context).getDataFlowInfo(); if (expressionReceiver == null) { return JetTypeInfo.create(null, dataFlowInfo); } ExpressionTypingUtils.defineLocalVariablesFromMultiDeclaration( scope, multiDeclaration, expressionReceiver, initializer, context); return DataFlowUtils.checkStatementType(multiDeclaration, context, dataFlowInfo); }
@Override public JetTypeInfo visitProperty(JetProperty property, ExpressionTypingContext context) { JetTypeReference receiverTypeRef = property.getReceiverTypeRef(); if (receiverTypeRef != null) { context.trace.report(LOCAL_EXTENSION_PROPERTY.on(receiverTypeRef)); } JetPropertyAccessor getter = property.getGetter(); if (getter != null) { context.trace.report(LOCAL_VARIABLE_WITH_GETTER.on(getter)); } JetPropertyAccessor setter = property.getSetter(); if (setter != null) { context.trace.report(LOCAL_VARIABLE_WITH_SETTER.on(setter)); } VariableDescriptor propertyDescriptor = context .expressionTypingServices .getDescriptorResolver() .resolveLocalVariableDescriptor( scope.getContainingDeclaration(), scope, property, context.dataFlowInfo, context.trace); JetExpression initializer = property.getInitializer(); DataFlowInfo dataFlowInfo = context.dataFlowInfo; if (initializer != null) { JetType outType = propertyDescriptor.getType(); JetTypeInfo typeInfo = facade.getTypeInfo(initializer, context.replaceExpectedType(outType).replaceScope(scope)); dataFlowInfo = typeInfo.getDataFlowInfo(); } { VariableDescriptor olderVariable = scope.getLocalVariable(propertyDescriptor.getName()); ExpressionTypingUtils.checkVariableShadowing(context, propertyDescriptor, olderVariable); } scope.addVariableDescriptor(propertyDescriptor); ModifiersChecker.create(context.trace).checkModifiersForLocalDeclaration(property); return DataFlowUtils.checkStatementType(property, context, dataFlowInfo); }