diff --git a/compiler/fir/resolve/build.gradle.kts b/compiler/fir/resolve/build.gradle.kts index 1f7909bb53e..a30aec068ba 100644 --- a/compiler/fir/resolve/build.gradle.kts +++ b/compiler/fir/resolve/build.gradle.kts @@ -25,6 +25,7 @@ dependencies { testCompileOnly(project(":kotlin-reflect-api")) testRuntime(project(":kotlin-reflect")) + implementation(kotlin("reflect")) } sourceSets { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/ConeDiagnostic.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/ConeDiagnostic.kt new file mode 100644 index 00000000000..6d147cce822 --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/ConeDiagnostic.kt @@ -0,0 +1,19 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.resolve.diagnostics + +import org.jetbrains.kotlin.fir.FirSourceElement + +class ConeDiagnosticFactory { + lateinit var name: String + + fun on(source: FirSourceElement): ConeDiagnostic = ConeDiagnostic(this, source) +} + +class ConeDiagnostic( + val factory: ConeDiagnosticFactory, + val source: FirSourceElement +) \ No newline at end of file diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/ConeDiagnostics.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/ConeDiagnostics.kt new file mode 100644 index 00000000000..45a73298c0b --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/ConeDiagnostics.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.resolve.diagnostics + +import kotlin.reflect.KProperty + +object ConeDiagnostics { + val INFIX_MODIFIER_REQUIRED = ConeDiagnosticFactory() + val INAPPLICABLE_INFIX_MODIFIER = ConeDiagnosticFactory() + + init { + ConeDiagnostics::class.members.filterIsInstance>().forEach { property -> + val factory = property.getter.call(this) as? ConeDiagnosticFactory + factory?.name = property.name + } + } +} \ No newline at end of file diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/DiagnosticReporter.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/DiagnosticReporter.kt new file mode 100644 index 00000000000..75fe471459a --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/DiagnosticReporter.kt @@ -0,0 +1,18 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.resolve.diagnostics + +abstract class DiagnosticReporter { + abstract fun report(diagnostic: ConeDiagnostic) +} + +class SimpleDiagnosticReporter : DiagnosticReporter() { + val diagnostics: MutableList = mutableListOf() + + override fun report(diagnostic: ConeDiagnostic) { + diagnostics += diagnostic + } +} \ No newline at end of file diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/checkers/call/FirCallChecker.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/checkers/call/FirCallChecker.kt new file mode 100644 index 00000000000..5623789a145 --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/checkers/call/FirCallChecker.kt @@ -0,0 +1,13 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.resolve.diagnostics.checkers.call + +import org.jetbrains.kotlin.fir.expressions.FirFunctionCall +import org.jetbrains.kotlin.fir.resolve.diagnostics.DiagnosticReporter + +abstract class FirCallChecker { + abstract fun check(functionCall: FirFunctionCall, reporter: DiagnosticReporter) +} \ No newline at end of file diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/checkers/declaration/DeclarationCheckers.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/checkers/declaration/DeclarationCheckers.kt new file mode 100644 index 00000000000..557e48a014c --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/checkers/declaration/DeclarationCheckers.kt @@ -0,0 +1,14 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.resolve.diagnostics.checkers.declaration + +import org.jetbrains.kotlin.fir.declarations.FirDeclaration +import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration + +object DeclarationCheckers { + val DECLARATIONS: List> = listOf() + val MEMBER_DECLARATIONS: List> = DECLARATIONS + listOf(FirInfixFunctionDeclarationChecker) +} \ No newline at end of file diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/checkers/declaration/FirDeclarationChecker.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/checkers/declaration/FirDeclarationChecker.kt new file mode 100644 index 00000000000..14a38977a1e --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/checkers/declaration/FirDeclarationChecker.kt @@ -0,0 +1,13 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.resolve.diagnostics.checkers.declaration + +import org.jetbrains.kotlin.fir.declarations.FirDeclaration +import org.jetbrains.kotlin.fir.resolve.diagnostics.DiagnosticReporter + +abstract class FirDeclarationChecker { + abstract fun check(declaration: D, reporter: DiagnosticReporter) +} \ No newline at end of file diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/checkers/declaration/FirInfixFunctionDeclarationChecker.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/checkers/declaration/FirInfixFunctionDeclarationChecker.kt new file mode 100644 index 00000000000..b85bb67c7e9 --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/checkers/declaration/FirInfixFunctionDeclarationChecker.kt @@ -0,0 +1,31 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.resolve.diagnostics.checkers.declaration + +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration +import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction +import org.jetbrains.kotlin.fir.declarations.isInfix +import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeDiagnostics +import org.jetbrains.kotlin.fir.resolve.diagnostics.DiagnosticReporter + +object FirInfixFunctionDeclarationChecker : FirDeclarationChecker() { + override fun check(declaration: FirMemberDeclaration, reporter: DiagnosticReporter) { + if (declaration is FirSimpleFunction && declaration.isInfix) { + if (declaration.valueParameters.size != 1 || declaration.receiverTypeRef == null) { + reporter.report(declaration.source) + } + return + } + if (declaration.isInfix) { + reporter.report(declaration.source) + } + } + + private fun DiagnosticReporter.report(source: FirSourceElement?) { + source?.let { report(ConeDiagnostics.INAPPLICABLE_INFIX_MODIFIER.on(it)) } + } +} \ No newline at end of file diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/collectors/AbstractDiagnosticCollector.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/collectors/AbstractDiagnosticCollector.kt new file mode 100644 index 00000000000..09c3a7b3c61 --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/collectors/AbstractDiagnosticCollector.kt @@ -0,0 +1,61 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.resolve.diagnostics.collectors + +import org.jetbrains.kotlin.fir.FirElement +import org.jetbrains.kotlin.fir.declarations.FirFile +import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeDiagnostic +import org.jetbrains.kotlin.fir.resolve.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid + +abstract class AbstractDiagnosticCollectorComponent(private val collector: AbstractDiagnosticCollector) : FirVisitorVoid() { + override fun visitElement(element: FirElement) {} + + protected fun runCheck(block: (DiagnosticReporter) -> Unit) { + collector.runCheck(block) + } +} + +abstract class AbstractDiagnosticCollector { + fun collectDiagnostics(firFile: FirFile): Iterable { + if (!componentsInitialized) { + throw IllegalStateException("Components are not initialized") + } + initializeCollector() + firFile.accept(visitor) + return getCollectedDiagnostics() + } + + protected abstract fun initializeCollector() + protected abstract fun getCollectedDiagnostics(): Iterable + internal abstract fun runCheck(block: (DiagnosticReporter) -> Unit) + + private val components: MutableList = mutableListOf() + private var componentsInitialized = false + private val visitor = Visitor() + + fun initializeComponents(vararg components: AbstractDiagnosticCollectorComponent) { + if (componentsInitialized) { + throw IllegalStateException() + } + this.components += components + componentsInitialized = true + } + + private inner class Visitor : FirVisitorVoid() { + private fun T.runComponents() { + components.forEach { + this.accept(it) + } + } + + override fun visitElement(element: FirElement) { + element.runComponents() + element.acceptChildren(this) + } + } +} + diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/collectors/ParallelDiagnosticsCollector.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/collectors/ParallelDiagnosticsCollector.kt new file mode 100644 index 00000000000..45b8d19279a --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/collectors/ParallelDiagnosticsCollector.kt @@ -0,0 +1,76 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.resolve.diagnostics.collectors + +import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeDiagnostic +import org.jetbrains.kotlin.fir.resolve.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.fir.resolve.diagnostics.SimpleDiagnosticReporter +import java.util.* +import java.util.concurrent.Executors +import java.util.concurrent.Future +import java.util.concurrent.atomic.AtomicInteger + +class ParallelDiagnosticsCollector(private val numberOfThreads: Int) : AbstractDiagnosticCollector() { + init { + require(numberOfThreads >= 1) { + "Number of threads should be at least 1" + } + } + + private var reporters = initializeReporters() + private val collectorLocalIndex = ThreadLocal() + private val collectorIndexCounter = AtomicInteger() + private val futures = LinkedList>() + + private val pool = Executors.newFixedThreadPool(numberOfThreads) { runnable -> + Thread { + collectorLocalIndex.set(collectorIndexCounter.getAndIncrement()) + runnable.run() + } + } + + private fun initializeReporters(): List { + return (1..numberOfThreads).map { SimpleDiagnosticReporter() } + } + + override fun initializeCollector() { + reporters = initializeReporters() + futures.clear() + } + + override fun getCollectedDiagnostics(): Iterable { + futures.forEach { it.get() } + return Iterable { + object : Iterator { + private val globalIterator = reporters.iterator() + private var localIterator = globalIterator.next().diagnostics.iterator() + + private fun update() { + while (!localIterator.hasNext() && globalIterator.hasNext()) { + localIterator = globalIterator.next().diagnostics.iterator() + } + } + + override fun hasNext(): Boolean { + update() + return localIterator.hasNext() + } + + override fun next(): ConeDiagnostic { + update() + return localIterator.next() + } + } + } + } + + override fun runCheck(block: (DiagnosticReporter) -> Unit) { + futures += pool.submit { + val reporter = reporters[collectorLocalIndex.get()] + block(reporter) + } + } +} \ No newline at end of file diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/collectors/SimpleDiagnosticsCollector.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/collectors/SimpleDiagnosticsCollector.kt new file mode 100644 index 00000000000..7c6d08ddaca --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/collectors/SimpleDiagnosticsCollector.kt @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.resolve.diagnostics.collectors + +import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeDiagnostic +import org.jetbrains.kotlin.fir.resolve.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.fir.resolve.diagnostics.SimpleDiagnosticReporter + +class SimpleDiagnosticsCollector : AbstractDiagnosticCollector() { + private var reporter = SimpleDiagnosticReporter() + + override fun initializeCollector() { + reporter = SimpleDiagnosticReporter() + } + + override fun getCollectedDiagnostics(): Iterable { + return reporter.diagnostics + } + + override fun runCheck(block: (DiagnosticReporter) -> Unit) { + block(reporter) + } +} + diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/collectors/components/DeclarationCheckersDiagnosticComponent.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/collectors/components/DeclarationCheckersDiagnosticComponent.kt new file mode 100644 index 00000000000..a4ca70f695a --- /dev/null +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/diagnostics/collectors/components/DeclarationCheckersDiagnosticComponent.kt @@ -0,0 +1,37 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir.resolve.diagnostics.collectors.components + +import org.jetbrains.kotlin.fir.declarations.* +import org.jetbrains.kotlin.fir.resolve.diagnostics.DiagnosticReporter +import org.jetbrains.kotlin.fir.resolve.diagnostics.checkers.declaration.DeclarationCheckers +import org.jetbrains.kotlin.fir.resolve.diagnostics.checkers.declaration.FirDeclarationChecker +import org.jetbrains.kotlin.fir.resolve.diagnostics.collectors.AbstractDiagnosticCollector +import org.jetbrains.kotlin.fir.resolve.diagnostics.collectors.AbstractDiagnosticCollectorComponent + +class DeclarationCheckersDiagnosticComponent(collector: AbstractDiagnosticCollector) : AbstractDiagnosticCollectorComponent(collector) { + override fun visitProperty(property: FirProperty) { + runCheck { DeclarationCheckers.MEMBER_DECLARATIONS.check(property, it) } + } + + override fun visitRegularClass(regularClass: FirRegularClass) { + runCheck { DeclarationCheckers.MEMBER_DECLARATIONS.check(regularClass, it) } + } + + override fun visitSimpleFunction(simpleFunction: FirSimpleFunction) { + runCheck { DeclarationCheckers.MEMBER_DECLARATIONS.check(simpleFunction, it) } + } + + override fun visitTypeAlias(typeAlias: FirTypeAlias) { + runCheck { DeclarationCheckers.MEMBER_DECLARATIONS.check(typeAlias, it) } + } + + private fun List>.check(declaration: D, reporter: DiagnosticReporter) { + for (checker in this) { + checker.check(declaration, reporter) + } + } +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/diagnostics/infixFunctions.diagnostics.txt b/compiler/fir/resolve/testData/resolve/diagnostics/infixFunctions.diagnostics.txt new file mode 100644 index 00000000000..b7a97bbcb4e --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/diagnostics/infixFunctions.diagnostics.txt @@ -0,0 +1,5 @@ +: infix fun Int.foo(x: Int, y: Int) {} + +: infix fun Int.bar() {} + +: infix fun baz(x: Int, y: Int) {} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/diagnostics/infixFunctions.kt b/compiler/fir/resolve/testData/resolve/diagnostics/infixFunctions.kt new file mode 100644 index 00000000000..a5098ffdb42 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/diagnostics/infixFunctions.kt @@ -0,0 +1,13 @@ +infix fun Int.good(x: Int) {} + +infix fun Int.foo(x: Int, y: Int) {} + +infix fun Int.bar() {} + +infix fun baz(x: Int, y: Int) {} + +infix class A + +infix typealias B = A + +infix val x = 1 \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/diagnostics/infixFunctions.txt b/compiler/fir/resolve/testData/resolve/diagnostics/infixFunctions.txt new file mode 100644 index 00000000000..a77c9adeee3 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/diagnostics/infixFunctions.txt @@ -0,0 +1,18 @@ +FILE: infixFunctions.kt + public final infix fun R|kotlin/Int|.good(x: R|kotlin/Int|): R|kotlin/Unit| { + } + public final infix fun R|kotlin/Int|.foo(x: R|kotlin/Int|, y: R|kotlin/Int|): R|kotlin/Unit| { + } + public final infix fun R|kotlin/Int|.bar(): R|kotlin/Unit| { + } + public final infix fun baz(x: R|kotlin/Int|, y: R|kotlin/Int|): R|kotlin/Unit| { + } + public final class A : R|kotlin/Any| { + public constructor(): R|A| { + super() + } + + } + public final typealias B = R|A| + public final val x: R|kotlin/Int| = Int(1) + public get(): R|kotlin/Int| diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/AbstractFirResolveWithDiagnosticsTestCase.kt b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/AbstractFirResolveWithDiagnosticsTestCase.kt new file mode 100644 index 00000000000..7e8a7e2a227 --- /dev/null +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/AbstractFirResolveWithDiagnosticsTestCase.kt @@ -0,0 +1,44 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir + +import org.jetbrains.kotlin.fir.declarations.FirFile +import org.jetbrains.kotlin.fir.resolve.diagnostics.* +import org.jetbrains.kotlin.fir.resolve.diagnostics.collectors.ParallelDiagnosticsCollector +import org.jetbrains.kotlin.fir.resolve.diagnostics.collectors.SimpleDiagnosticsCollector +import org.jetbrains.kotlin.fir.resolve.diagnostics.collectors.components.DeclarationCheckersDiagnosticComponent +import org.jetbrains.kotlin.test.KotlinTestUtils +import java.io.File + +abstract class AbstractFirResolveWithDiagnosticsTestCase : AbstractFirResolveTestCase() { + override fun doTest(path: String) { + val firFiles = processInputFile(path) + checkFir(path, firFiles) + checkDiagnostics(path, firFiles) + } + + private fun checkDiagnostics(path: String, firFiles: List) { +// val collector = SimpleDiagnosticsCollector() + val collector = ParallelDiagnosticsCollector(4) + collector.initializeComponents(DeclarationCheckersDiagnosticComponent(collector)) + val diagnostics = mutableListOf() + for (file in firFiles) { + diagnostics += collector.collectDiagnostics(file) + } + val expectedPath = path.replace(".kt", ".diagnostics.txt") + val expectedFile = File(expectedPath) + if (diagnostics.isEmpty()) { + assertFalse("There is no diagnostics but expected file exists", expectedFile.exists()) + return + } + + val actual = diagnostics.joinToString("\n\n") { + val text = (it.source as FirPsiSourceElement).psi.text + "<${it.factory.name}>: $text" + } + KotlinTestUtils.assertEqualsToFile(expectedFile, actual) + } +} \ No newline at end of file diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java index c6eb468a2ee..1f0ff3f59d0 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java @@ -25,7 +25,7 @@ public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase { } public void testAllFilesPresentInResolve() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/fir/resolve/testData/resolve"), Pattern.compile("^([^.]+)\\.kt$"), true, "stdlib", "cfg", "smartcasts"); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/fir/resolve/testData/resolve"), Pattern.compile("^([^.]+)\\.kt$"), true, "stdlib", "cfg", "smartcasts", "diagnostics"); } @TestMetadata("cast.kt") diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveWithDiagnosticsTestCaseGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveWithDiagnosticsTestCaseGenerated.java new file mode 100644 index 00000000000..80e5630e7db --- /dev/null +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveWithDiagnosticsTestCaseGenerated.java @@ -0,0 +1,35 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.fir; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("compiler/fir/resolve/testData/resolve/diagnostics") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class FirResolveWithDiagnosticsTestCaseGenerated extends AbstractFirResolveWithDiagnosticsTestCase { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInDiagnostics() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/fir/resolve/testData/resolve/diagnostics"), Pattern.compile("^([^.]+)\\.kt$"), true); + } + + @TestMetadata("infixFunctions.kt") + public void testInfixFunctions() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/diagnostics/infixFunctions.kt"); + } +} diff --git a/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt b/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt index c8886ab8a07..c6099360f52 100644 --- a/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt +++ b/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt @@ -513,7 +513,7 @@ fun main(args: Array) { testGroup("compiler/fir/resolve/tests", "compiler/fir/resolve/testData") { testClass { - model("resolve", pattern = KT_WITHOUT_DOTS_IN_NAME, excludeDirs = listOf("stdlib", "cfg", "smartcasts")) + model("resolve", pattern = KT_WITHOUT_DOTS_IN_NAME, excludeDirs = listOf("stdlib", "cfg", "smartcasts", "diagnostics")) } testClass { @@ -528,6 +528,10 @@ fun main(args: Array) { testClass { model("resolve/stdlib/contracts", pattern = KT_WITHOUT_DOTS_IN_NAME) } + + testClass { + model("resolve/diagnostics", pattern = KT_WITHOUT_DOTS_IN_NAME) + } } testGroup("compiler/fir/resolve/tests", "compiler/testData") {