Support platform/impl modifiers for functions
Also add a new capability for ModuleDescriptor, which is used to obtain the platform in the multi-platform scenario in tests. Suppress the following errors for platform functions: "function has no body" and "nothing to inline". Also do not report redeclaration between platform and non-platform functions because this is the case when the common + platform-specific code are analyzed together. Note that some diagnostics reported in tests are not yet implemented in this commit, they appear in subsequent commits
This commit is contained in:
@@ -489,6 +489,11 @@ public interface Errors {
|
||||
DiagnosticFactory0<KtParameter> DATA_CLASS_VARARG_PARAMETER = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtParameter> DATA_CLASS_NOT_PROPERTY_PARAMETER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
// Multi-platform projects
|
||||
|
||||
DiagnosticFactory0<KtDeclaration> PLATFORM_DECLARATION_WITH_BODY = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
|
||||
DiagnosticFactory0<KtParameter> PLATFORM_DECLARATION_WITH_DEFAULT_PARAMETER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Errors/warnings inside code blocks
|
||||
|
||||
+3
@@ -257,6 +257,9 @@ public class DefaultErrorMessages {
|
||||
MAP.put(USELESS_VARARG_ON_PARAMETER, "Vararg on this parameter is useless");
|
||||
MAP.put(MULTIPLE_VARARG_PARAMETERS, "Multiple vararg-parameters are prohibited");
|
||||
|
||||
MAP.put(PLATFORM_DECLARATION_WITH_BODY, "Platform declaration must not have a body");
|
||||
MAP.put(PLATFORM_DECLARATION_WITH_DEFAULT_PARAMETER, "Platform declaration cannot have parameters with default values");
|
||||
|
||||
MAP.put(PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT, "Projections are not allowed on type arguments of functions and properties");
|
||||
MAP.put(SUPERTYPE_NOT_INITIALIZED, "This type has a constructor, and thus must be initialized here");
|
||||
MAP.put(NOTHING_TO_OVERRIDE, "''{0}'' overrides nothing", NAME);
|
||||
|
||||
@@ -732,10 +732,26 @@ class DeclarationsChecker(
|
||||
}
|
||||
}
|
||||
else /* top-level only */ {
|
||||
if (!function.hasBody() && !hasAbstractModifier && !hasExternalModifier) {
|
||||
if (!function.hasBody() && !hasAbstractModifier && !hasExternalModifier && !functionDescriptor.isPlatform) {
|
||||
trace.report(NON_MEMBER_FUNCTION_NO_BODY.on(function, functionDescriptor))
|
||||
}
|
||||
}
|
||||
|
||||
if (functionDescriptor.isPlatform) {
|
||||
checkPlatformFunction(function)
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkPlatformFunction(function: KtNamedFunction) {
|
||||
if (function.hasBody()) {
|
||||
trace.report(PLATFORM_DECLARATION_WITH_BODY.on(function))
|
||||
}
|
||||
|
||||
for (parameter in function.valueParameters) {
|
||||
if (parameter.hasDefaultValue()) {
|
||||
trace.report(PLATFORM_DECLARATION_WITH_DEFAULT_PARAMETER.on(parameter))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkImplicitCallableType(declaration: KtCallableDeclaration, descriptor: CallableDescriptor) {
|
||||
|
||||
@@ -184,6 +184,10 @@ class FunctionDescriptorResolver(
|
||||
functionDescriptor.isInline = function.hasModifier(KtTokens.INLINE_KEYWORD)
|
||||
functionDescriptor.isTailrec = function.hasModifier(KtTokens.TAILREC_KEYWORD)
|
||||
functionDescriptor.isSuspend = function.hasModifier(KtTokens.SUSPEND_KEYWORD)
|
||||
functionDescriptor.isPlatform = function.hasModifier(KtTokens.PLATFORM_KEYWORD) ||
|
||||
containingDescriptor is ClassDescriptor && containingDescriptor.isPlatform
|
||||
functionDescriptor.isImpl = function.hasModifier(KtTokens.IMPL_KEYWORD)
|
||||
|
||||
receiverType?.let { ForceResolveUtil.forceResolveAllContents(it.annotations) }
|
||||
for (valueParameterDescriptor in valueParameterDescriptors) {
|
||||
ForceResolveUtil.forceResolveAllContents(valueParameterDescriptor.type.annotations)
|
||||
@@ -293,6 +297,12 @@ class FunctionDescriptorResolver(
|
||||
isPrimary,
|
||||
declarationToTrace.toSourceElement()
|
||||
)
|
||||
if (classDescriptor.isPlatform) {
|
||||
constructorDescriptor.isPlatform = true
|
||||
}
|
||||
if (classDescriptor.isImpl) {
|
||||
constructorDescriptor.isImpl = true
|
||||
}
|
||||
trace.record(BindingContext.CONSTRUCTOR, declarationToTrace, constructorDescriptor)
|
||||
val parameterScope = LexicalWritableScope(
|
||||
scope,
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2010-2016 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.MemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
|
||||
sealed class MultiTargetPlatform {
|
||||
object Common : MultiTargetPlatform()
|
||||
|
||||
data class Specific(val platform: String) : MultiTargetPlatform()
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val CAPABILITY = ModuleDescriptor.Capability<MultiTargetPlatform>("MULTI_TARGET_PLATFORM")
|
||||
}
|
||||
}
|
||||
|
||||
fun ModuleDescriptor.getMultiTargetPlatform(): MultiTargetPlatform? =
|
||||
module.getCapability(MultiTargetPlatform.CAPABILITY)
|
||||
|
||||
fun MemberDescriptor.getMultiTargetPlatform(): String? =
|
||||
(module.getMultiTargetPlatform() as? MultiTargetPlatform.Specific)?.platform
|
||||
@@ -252,6 +252,8 @@ class OverloadResolver(
|
||||
if (member1 == member2) continue
|
||||
if (isConstructorsOfDifferentRedeclaredClasses(member1, member2)) continue
|
||||
if (isTopLevelMainInDifferentFiles(member1, member2)) continue
|
||||
if (isDefinitionsForDifferentPlatforms(member1, member2)) continue
|
||||
if (isPlatformDeclarationAndDefinition(member1, member2) || isPlatformDeclarationAndDefinition(member2, member1)) continue
|
||||
|
||||
if (!overloadChecker.isOverloadable(member1, member2)) {
|
||||
redeclarations.add(member1)
|
||||
@@ -281,6 +283,18 @@ class OverloadResolver(
|
||||
return file1 == null || file2 == null || file1 !== file2
|
||||
}
|
||||
|
||||
private fun isPlatformDeclarationAndDefinition(declaration: DeclarationDescriptor, definition: DeclarationDescriptor): Boolean {
|
||||
return declaration is MemberDescriptor && declaration.isPlatform &&
|
||||
definition is MemberDescriptor && !definition.isPlatform
|
||||
}
|
||||
|
||||
private fun isDefinitionsForDifferentPlatforms(member1: DeclarationDescriptorNonRoot, member2: DeclarationDescriptorNonRoot): Boolean {
|
||||
if (member1 !is MemberDescriptor || member2 !is MemberDescriptor) return false
|
||||
|
||||
return member1.isImpl && member2.isImpl &&
|
||||
member1.getMultiTargetPlatform() != member2.getMultiTargetPlatform()
|
||||
}
|
||||
|
||||
private fun reportRedeclarations(redeclarations: Collection<DeclarationDescriptorNonRoot>) {
|
||||
if (redeclarations.isEmpty()) return
|
||||
|
||||
|
||||
+8
-16
@@ -134,25 +134,17 @@ object InlineAnalyzerExtension : AnalyzerExtensions.AnalyzerExtension {
|
||||
containingDeclaration is ClassDescriptor && containingDeclaration.modality == Modality.FINAL
|
||||
}
|
||||
|
||||
private fun checkHasInlinableAndNullability(
|
||||
functionDescriptor: FunctionDescriptor,
|
||||
function: KtFunction,
|
||||
trace: BindingTrace) {
|
||||
var hasInlinable = false
|
||||
val parameters = functionDescriptor.valueParameters
|
||||
var index = 0
|
||||
for (parameter in parameters) {
|
||||
hasInlinable = hasInlinable or checkInlinableParameter(parameter, function.valueParameters[index++], functionDescriptor, trace)
|
||||
private fun checkHasInlinableAndNullability(functionDescriptor: FunctionDescriptor, function: KtFunction, trace: BindingTrace) {
|
||||
for ((parameter, descriptor) in function.valueParameters.zip(functionDescriptor.valueParameters)) {
|
||||
if (checkInlinableParameter(descriptor, parameter, functionDescriptor, trace)) return
|
||||
}
|
||||
|
||||
hasInlinable = hasInlinable or InlineUtil.containsReifiedTypeParameters(functionDescriptor)
|
||||
if (InlineUtil.containsReifiedTypeParameters(functionDescriptor) ||
|
||||
functionDescriptor.isInlineOnlyOrReified() ||
|
||||
functionDescriptor.isPlatform) return
|
||||
|
||||
if (!hasInlinable && !functionDescriptor.isInlineOnlyOrReified()) {
|
||||
val modifierList = function.modifierList
|
||||
val inlineModifier = modifierList?.getModifier(KtTokens.INLINE_KEYWORD)
|
||||
val reportOn = inlineModifier ?: function
|
||||
trace.report(Errors.NOTHING_TO_INLINE.on(reportOn, functionDescriptor))
|
||||
}
|
||||
val reportOn = function.modifierList?.getModifier(KtTokens.INLINE_KEYWORD) ?: function
|
||||
trace.report(Errors.NOTHING_TO_INLINE.on(reportOn, functionDescriptor))
|
||||
}
|
||||
|
||||
fun checkInlinableParameter(
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
platform fun foo(x: Int): Int
|
||||
|
||||
fun callFromCommonCode(x: Int) = foo(x)
|
||||
|
||||
// MODULE: m2-jvm(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
impl fun foo(x: Int): Int {
|
||||
return x + 1
|
||||
}
|
||||
|
||||
fun callFromJVM(x: Int) = foo(x)
|
||||
|
||||
// MODULE: m3-js(m1-common)
|
||||
// FILE: js.kt
|
||||
|
||||
impl fun foo(x: Int): Int {
|
||||
return x - 1
|
||||
}
|
||||
|
||||
fun callFromJS(x: Int) = foo(x)
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// -- Module: <m1-common> --
|
||||
package
|
||||
|
||||
public fun callFromCommonCode(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
public platform fun foo(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
|
||||
|
||||
// -- Module: <m2-jvm> --
|
||||
package
|
||||
|
||||
public fun callFromCommonCode(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
public fun callFromJVM(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
public impl fun foo(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
|
||||
|
||||
// -- Module: <m3-js> --
|
||||
package
|
||||
|
||||
public fun callFromCommonCode(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
public fun callFromJS(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
public impl fun foo(/*0*/ x: kotlin.Int): kotlin.Int
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
<!CONFLICTING_OVERLOADS!>platform fun foo()<!>
|
||||
<!CONFLICTING_OVERLOADS!>platform fun foo()<!>
|
||||
|
||||
platform fun foo(x: Int)
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
public platform fun foo(): kotlin.Unit
|
||||
public platform fun foo(): kotlin.Unit
|
||||
public platform fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
|
||||
Vendored
+17
@@ -0,0 +1,17 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
platform fun foo()
|
||||
|
||||
// MODULE: m2-jvm(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
<!CONFLICTING_OVERLOADS!>impl fun foo()<!> {}
|
||||
<!CONFLICTING_OVERLOADS!>impl fun foo()<!> {}
|
||||
|
||||
// MODULE: m3-js(m1-common)
|
||||
// FILE: js.kt
|
||||
|
||||
<!CONFLICTING_OVERLOADS!>impl fun foo()<!> {}
|
||||
<!CONFLICTING_OVERLOADS!>impl fun foo()<!> {}
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// -- Module: <m1-common> --
|
||||
package
|
||||
|
||||
public platform fun foo(): kotlin.Unit
|
||||
|
||||
|
||||
// -- Module: <m2-jvm> --
|
||||
package
|
||||
|
||||
public impl fun foo(): kotlin.Unit
|
||||
public impl fun foo(): kotlin.Unit
|
||||
|
||||
|
||||
// -- Module: <m3-js> --
|
||||
package
|
||||
|
||||
public impl fun foo(): kotlin.Unit
|
||||
public impl fun foo(): kotlin.Unit
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
package common
|
||||
|
||||
platform fun foo()
|
||||
|
||||
// MODULE: m2-jvm(m1-common)
|
||||
// FILE: jvm.kt
|
||||
package jvm
|
||||
|
||||
<!PLATFORM_DEFINITION_WITHOUT_DECLARATION!>impl<!> fun foo() {}
|
||||
|
||||
// MODULE: m3-js(m1-common)
|
||||
// FILE: js.kt
|
||||
package js
|
||||
|
||||
<!PLATFORM_DEFINITION_WITHOUT_DECLARATION!>impl<!> fun foo() {}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// -- Module: <m1-common> --
|
||||
package
|
||||
|
||||
package common {
|
||||
public platform fun foo(): kotlin.Unit
|
||||
}
|
||||
|
||||
|
||||
// -- Module: <m2-jvm> --
|
||||
package
|
||||
|
||||
package common {
|
||||
}
|
||||
|
||||
package jvm {
|
||||
public impl fun foo(): kotlin.Unit
|
||||
}
|
||||
|
||||
|
||||
// -- Module: <m3-js> --
|
||||
package
|
||||
|
||||
package common {
|
||||
}
|
||||
|
||||
package js {
|
||||
public impl fun foo(): kotlin.Unit
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
platform fun foo()
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
public platform fun foo(): kotlin.Unit
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
platform fun foo(x: Int, <!PLATFORM_DECLARATION_WITH_DEFAULT_PARAMETER!>y: String = ""<!>)
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
public platform fun foo(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ...): kotlin.Unit
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: m1-jvm
|
||||
// FILE: jvm.kt
|
||||
|
||||
<!PLATFORM_DEFINITION_WITHOUT_DECLARATION!>impl<!> fun foo() { }
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
public impl fun foo(): kotlin.Unit
|
||||
@@ -0,0 +1,18 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
inline platform fun inlineFun()
|
||||
platform fun nonInlineFun()
|
||||
|
||||
// MODULE: m2-jvm(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
<!PLATFORM_DEFINITION_WITHOUT_DECLARATION!>impl<!> fun inlineFun() { }
|
||||
impl fun nonInlineFun() { }
|
||||
|
||||
// MODULE: m3-js(m1-common)
|
||||
// FILE: js.kt
|
||||
|
||||
impl <!NOTHING_TO_INLINE!>inline<!> fun inlineFun() { }
|
||||
<!PLATFORM_DEFINITION_WITHOUT_DECLARATION!>impl<!> <!NOTHING_TO_INLINE!>inline<!> fun nonInlineFun() { }
|
||||
@@ -0,0 +1,19 @@
|
||||
// -- Module: <m1-common> --
|
||||
package
|
||||
|
||||
public inline platform fun inlineFun(): kotlin.Unit
|
||||
public platform fun nonInlineFun(): kotlin.Unit
|
||||
|
||||
|
||||
// -- Module: <m2-jvm> --
|
||||
package
|
||||
|
||||
public impl fun inlineFun(): kotlin.Unit
|
||||
public impl fun nonInlineFun(): kotlin.Unit
|
||||
|
||||
|
||||
// -- Module: <m3-js> --
|
||||
package
|
||||
|
||||
public inline impl fun inlineFun(): kotlin.Unit
|
||||
public inline impl fun nonInlineFun(): kotlin.Unit
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
<!CONFLICTING_OVERLOADS!>platform fun foo()<!>
|
||||
|
||||
<!CONFLICTING_OVERLOADS, PLATFORM_DECLARATION_WITH_BODY!>platform fun foo()<!> {}
|
||||
|
||||
<!PLATFORM_DECLARATION_WITH_BODY!>platform fun bar()<!> {}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
public platform fun bar(): kotlin.Unit
|
||||
public platform fun foo(): kotlin.Unit
|
||||
public platform fun foo(): kotlin.Unit
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
|
||||
platform fun foo()
|
||||
|
||||
// MODULE: m2-jvm(m1-common)
|
||||
// FILE: jvm.kt
|
||||
|
||||
<!NON_MEMBER_FUNCTION_NO_BODY!>impl fun foo()<!>
|
||||
|
||||
<!NON_MEMBER_FUNCTION_NO_BODY!><!PLATFORM_DEFINITION_WITHOUT_DECLARATION!>impl<!> fun bar()<!>
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// -- Module: <m1-common> --
|
||||
package
|
||||
|
||||
public platform fun foo(): kotlin.Unit
|
||||
|
||||
|
||||
// -- Module: <m2-jvm> --
|
||||
package
|
||||
|
||||
public impl fun bar(): kotlin.Unit
|
||||
public impl fun foo(): kotlin.Unit
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// !LANGUAGE: +MultiPlatformProjects
|
||||
// MODULE: m1-common
|
||||
// FILE: common.kt
|
||||
platform fun foo()
|
||||
|
||||
// MODULE: m2-jvm(m1-common)
|
||||
// FILE: jvm.kt
|
||||
impl fun foo() {}
|
||||
|
||||
// MODULE: m3-js(m1-common)
|
||||
// FILE: js.kt
|
||||
impl fun foo() {}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// -- Module: <m1-common> --
|
||||
package
|
||||
|
||||
public platform fun foo(): kotlin.Unit
|
||||
|
||||
|
||||
// -- Module: <m2-jvm> --
|
||||
package
|
||||
|
||||
public impl fun foo(): kotlin.Unit
|
||||
|
||||
|
||||
// -- Module: <m3-js> --
|
||||
package
|
||||
|
||||
public impl fun foo(): kotlin.Unit
|
||||
@@ -25,6 +25,7 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import kotlin.text.StringsKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.analyzer.AnalysisResult;
|
||||
@@ -148,7 +149,7 @@ public abstract class AbstractDiagnosticsTest extends BaseDiagnosticsTest {
|
||||
LanguageVersionSettings languageVersionSettings = loadLanguageVersionSettings(testFilesInModule);
|
||||
ModuleContext moduleContext = ContextKt.withModule(ContextKt.withProject(context, getProject()), module);
|
||||
|
||||
boolean separateModules = groupedByModule.size() == 1;
|
||||
boolean separateModules = groupedByModule.size() == 1 && groupedByModule.keySet().iterator().next() == null;
|
||||
AnalysisResult result = analyzeModuleContents(moduleContext, jetFiles, moduleTrace, languageVersionSettings, separateModules);
|
||||
if (separateModules) {
|
||||
modules.put(testModule, (ModuleDescriptorImpl) result.getModuleDescriptor());
|
||||
@@ -448,7 +449,7 @@ public abstract class AbstractDiagnosticsTest extends BaseDiagnosticsTest {
|
||||
ModuleDescriptorImpl module =
|
||||
testModule == null ?
|
||||
createSealedModule(storageManager) :
|
||||
createModule("<" + testModule.getName() + ">", storageManager);
|
||||
createModule(testModule.getName(), storageManager);
|
||||
|
||||
modules.put(testModule, module);
|
||||
}
|
||||
@@ -471,13 +472,24 @@ public abstract class AbstractDiagnosticsTest extends BaseDiagnosticsTest {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@SuppressWarnings("unchecked")
|
||||
protected ModuleDescriptorImpl createModule(@NotNull String moduleName, @NotNull StorageManager storageManager) {
|
||||
return new ModuleDescriptorImpl(Name.special(moduleName), storageManager, new JvmBuiltIns(storageManager));
|
||||
String nameSuffix = StringsKt.substringAfterLast(moduleName, "-", "");
|
||||
MultiTargetPlatform platform =
|
||||
nameSuffix.isEmpty() ? null :
|
||||
nameSuffix.equals("common") ? MultiTargetPlatform.Common.INSTANCE : new MultiTargetPlatform.Specific(nameSuffix);
|
||||
Map capabilities =
|
||||
platform == null
|
||||
? Collections.emptyMap()
|
||||
: Collections.singletonMap(MultiTargetPlatform.CAPABILITY, platform);
|
||||
return new ModuleDescriptorImpl(
|
||||
Name.special("<" + moduleName + ">"), storageManager, new JvmBuiltIns(storageManager), capabilities
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected ModuleDescriptorImpl createSealedModule(@NotNull StorageManager storageManager) {
|
||||
ModuleDescriptorImpl moduleDescriptor = createModule("<test-module>", storageManager);
|
||||
ModuleDescriptorImpl moduleDescriptor = createModule("test-module", storageManager);
|
||||
moduleDescriptor.setDependencies(moduleDescriptor, moduleDescriptor.getBuiltIns().getBuiltInsModule());
|
||||
return moduleDescriptor;
|
||||
}
|
||||
|
||||
+2
-2
@@ -88,13 +88,13 @@ public abstract class AbstractDiagnosticsTestWithJsStdLib extends AbstractDiagno
|
||||
@NotNull
|
||||
@Override
|
||||
protected ModuleDescriptorImpl createModule(@NotNull String moduleName, @NotNull StorageManager storageManager) {
|
||||
return new ModuleDescriptorImpl(Name.special(moduleName), storageManager, JsPlatform.INSTANCE.getBuiltIns());
|
||||
return new ModuleDescriptorImpl(Name.special("<" + moduleName + ">"), storageManager, JsPlatform.INSTANCE.getBuiltIns());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected ModuleDescriptorImpl createSealedModule(@NotNull StorageManager storageManager) {
|
||||
ModuleDescriptorImpl module = createModule("<kotlin-js-test-module>", storageManager);
|
||||
ModuleDescriptorImpl module = createModule("kotlin-js-test-module", storageManager);
|
||||
|
||||
List<ModuleDescriptorImpl> dependencies = new ArrayList<ModuleDescriptorImpl>();
|
||||
dependencies.add(module);
|
||||
|
||||
@@ -12548,6 +12548,90 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Multiplatform extends AbstractDiagnosticsTest {
|
||||
public void testAllFilesPresentInMultiplatform() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelFun")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class TopLevelFun extends AbstractDiagnosticsTest {
|
||||
public void testAllFilesPresentInTopLevelFun() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/topLevelFun"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("callPlatformFun.kt")
|
||||
public void testCallPlatformFun() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/callPlatformFun.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("conflictingPlatformDeclarations.kt")
|
||||
public void testConflictingPlatformDeclarations() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingPlatformDeclarations.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("conflictingPlatformDefinitions.kt")
|
||||
public void testConflictingPlatformDefinitions() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/conflictingPlatformDefinitions.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("declarationAndDefinitionInDIfferentPackages.kt")
|
||||
public void testDeclarationAndDefinitionInDIfferentPackages() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/declarationAndDefinitionInDIfferentPackages.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("declarationWithoutDefinition.kt")
|
||||
public void testDeclarationWithoutDefinition() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/declarationWithoutDefinition.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("defaultArguments.kt")
|
||||
public void testDefaultArguments() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/defaultArguments.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("definitionWithoutDeclaration.kt")
|
||||
public void testDefinitionWithoutDeclaration() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/definitionWithoutDeclaration.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inlineFun.kt")
|
||||
public void testInlineFun() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/inlineFun.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("platformDeclarationWithBody.kt")
|
||||
public void testPlatformDeclarationWithBody() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/platformDeclarationWithBody.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("platformDefinitionWithoutBody.kt")
|
||||
public void testPlatformDefinitionWithoutBody() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/platformDefinitionWithoutBody.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simplePlatformFun.kt")
|
||||
public void testSimplePlatformFun() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelFun/simplePlatformFun.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/namedArguments")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user