diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt index 40cff191a29..53d01e0c346 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProvider.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2016 JetBrains s.r.o. + * Copyright 2010-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -879,6 +879,7 @@ class ControlFlowInformationProvider private constructor( private fun markAndCheckRecursiveTailCalls(subroutineDescriptor: FunctionDescriptor) { if (!subroutineDescriptor.isTailrec) return + if (subroutine is KtNamedFunction && !subroutine.hasBody()) return // finally blocks are copied which leads to multiple diagnostics reported on one instruction class KindAndCall(var kind: TailRecursionKind, internal val call: ResolvedCall<*>) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ControlFlowAnalyzer.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ControlFlowAnalyzer.java index b551265b261..5d15fd7a1ca 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ControlFlowAnalyzer.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ControlFlowAnalyzer.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -103,7 +103,6 @@ public class ControlFlowAnalyzer { } private void checkFunction(@NotNull BodiesResolveContext c, @NotNull KtDeclarationWithBody function, @Nullable KotlinType expectedReturnType) { - if (!function.hasBody()) return; ControlFlowInformationProvider controlFlowInformationProvider = new ControlFlowInformationProvider(function, trace, languageVersionSettings); if (c.getTopDownAnalysisMode().isLocalDeclarations()) { diff --git a/compiler/testData/diagnostics/tests/DefaultValuesCheckWithoutBody.kt b/compiler/testData/diagnostics/tests/DefaultValuesCheckWithoutBody.kt new file mode 100644 index 00000000000..ac90467340b --- /dev/null +++ b/compiler/testData/diagnostics/tests/DefaultValuesCheckWithoutBody.kt @@ -0,0 +1,9 @@ +interface Inter { + fun foo(x: Int = y, y: Int = x) +} + +abstract class Abst { + abstract fun foo(x: Int = y, y: Int = x) +} + +fun extraDiagnostics(x: Int = y, y: Int) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/DefaultValuesCheckWithoutBody.txt b/compiler/testData/diagnostics/tests/DefaultValuesCheckWithoutBody.txt new file mode 100644 index 00000000000..1a60b5be472 --- /dev/null +++ b/compiler/testData/diagnostics/tests/DefaultValuesCheckWithoutBody.txt @@ -0,0 +1,18 @@ +package + +public fun extraDiagnostics(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.Int): kotlin.Unit + +public abstract class Abst { + public constructor Abst() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.Int = ...): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface Inter { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.Int = ...): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 307fe79429c..49713204f7e 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -188,6 +188,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("DefaultValuesCheckWithoutBody.kt") + public void testDefaultValuesCheckWithoutBody() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/DefaultValuesCheckWithoutBody.kt"); + doTest(fileName); + } + @TestMetadata("DefaultValuesTypechecking.kt") public void testDefaultValuesTypechecking() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/DefaultValuesTypechecking.kt");