[KT-4124] Suppress error reporting about native local classes

This commit is contained in:
Alexey Andreev
2016-02-12 18:28:52 +03:00
parent e3c7cd0021
commit 68828317b8
5 changed files with 14 additions and 23 deletions
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.diagnostics.rendering.renderKind
import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DeclarationChecker
@@ -32,7 +33,7 @@ class LocalClassChecker : DeclarationChecker {
if (descriptor !is ClassDescriptor || declaration !is KtNamedDeclaration) {
return;
}
if (isAnonymousObject(descriptor) || isObject(descriptor)) {
if (isAnonymousObject(descriptor) || isObject(descriptor) || AnnotationsUtils.isNativeObject(descriptor)) {
return
}
@@ -222,7 +222,7 @@ object ConstructorCallCase : FunctionCallCase() {
val functionRef = context.aliasOrValue(callableDescriptor) { fqName }
val constructorDescriptor = callableDescriptor as ConstructorDescriptor
val receiver = this.superCallReceiver
val receiver = superCallReceiver
var allArguments = when (receiver) {
null -> argumentsInfo.translateArguments
else -> (sequenceOf(receiver) + argumentsInfo.translateArguments).toList()
@@ -246,8 +246,7 @@ object SuperCallCase : FunctionCallCase() {
// TODO: spread operator
val prototypeClass = JsNameRef(Namer.getPrototypeName(), dispatchReceiver!!)
val functionRef = Namer.getFunctionCallRef(JsNameRef(functionName, prototypeClass))
val superReceiver = this.superCallReceiver
val receiver = if (superReceiver != null) superReceiver else JsLiteral.THIS;
val receiver = superCallReceiver ?: JsLiteral.THIS;
return JsInvocation(functionRef, argumentsInfo.argsWithReceiver(receiver))
}
}
@@ -110,7 +110,7 @@ object DelegatePropertyAccessIntrinsic : DelegateIntrinsic<VariableAccessInfo> {
object SuperPropertyAccessCase : VariableAccessCase() {
override fun VariableAccessInfo.dispatchReceiver(): JsExpression {
val variableName = context.program().getStringLiteral(this.variableName.ident)
val jsReceiver = this.superCallReceiver
val jsReceiver = superCallReceiver
var propertyOwner = when (jsReceiver) {
null -> JsLiteral.THIS
else -> jsReceiver
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.js.translate.context.TranslationContext;
import org.jetbrains.kotlin.js.translate.declaration.DelegationTranslator;
import org.jetbrains.kotlin.js.translate.general.AbstractTranslator;
import org.jetbrains.kotlin.js.translate.reference.CallArgumentTranslator;
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils;
import org.jetbrains.kotlin.js.translate.utils.jsAstUtils.AstUtilsKt;
import org.jetbrains.kotlin.lexer.KtTokens;
import org.jetbrains.kotlin.psi.*;
@@ -127,8 +128,8 @@ public final class ClassInitializerTranslator extends AbstractTranslator {
initFunction.getParameters().add(0, new JsParameter(outerName));
JsExpression target = new JsNameRef(outerName, JsLiteral.THIS);
JsExpression paramRef = new JsNameRef(outerName);
JsExpression assignment = new JsBinaryOperation(JsBinaryOperator.ASG, target, paramRef);
JsExpression paramRef = outerName.makeRef();
JsExpression assignment = JsAstUtils.assignment(target, paramRef);
initFunction.getBody().getStatements().add(new JsExpressionStatement(assignment));
}
@@ -18,24 +18,19 @@ package org.jetbrains.kotlin.js.translate.reference
import com.google.dart.compiler.backend.js.ast.*
import com.intellij.util.SmartList
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.js.descriptorUtils.nameIfStandardType
import org.jetbrains.kotlin.js.translate.context.TemporaryConstVariable
import org.jetbrains.kotlin.js.translate.context.TemporaryVariable
import org.jetbrains.kotlin.js.translate.context.TranslationContext
import org.jetbrains.kotlin.js.translate.expression.PatternTranslator
import org.jetbrains.kotlin.js.translate.general.AbstractTranslator
import org.jetbrains.kotlin.js.translate.general.Translation
import org.jetbrains.kotlin.js.translate.utils.*
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
import org.jetbrains.kotlin.js.translate.utils.TranslationUtils
import org.jetbrains.kotlin.psi.ValueArgument
import org.jetbrains.kotlin.resolve.calls.model.*
import org.jetbrains.kotlin.types.KotlinType
import java.util.ArrayList
import java.util.Collections
import java.util.*
class CallArgumentTranslator private constructor(
private val resolvedCall: ResolvedCall<*>,
@@ -102,13 +97,8 @@ class CallArgumentTranslator private constructor(
val arguments = actualArgument.getArguments()
val size = arguments.size
var i = 0
while (i != size) {
if (arguments.get(i).getSpreadElement() != null) {
hasSpreadOperator = true
break
}
++i
if (!hasSpreadOperator) {
hasSpreadOperator = arguments.any { it.getSpreadElement() != null }
}
if (hasSpreadOperator) {