Allow to import members from object by name
Wrap object members so they do not require dispatch receiver Hack jvm backend to make it work
This commit is contained in:
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.codegen.state.JetTypeMapper;
|
|||||||
import org.jetbrains.kotlin.descriptors.*;
|
import org.jetbrains.kotlin.descriptors.*;
|
||||||
import org.jetbrains.kotlin.load.java.JvmAbi;
|
import org.jetbrains.kotlin.load.java.JvmAbi;
|
||||||
import org.jetbrains.kotlin.psi.JetExpression;
|
import org.jetbrains.kotlin.psi.JetExpression;
|
||||||
|
import org.jetbrains.kotlin.resolve.ImportedFromObjectCallableDescriptor;
|
||||||
import org.jetbrains.kotlin.resolve.annotations.AnnotationsPackage;
|
import org.jetbrains.kotlin.resolve.annotations.AnnotationsPackage;
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument;
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument;
|
||||||
@@ -489,7 +490,8 @@ public abstract class StackValue {
|
|||||||
) {
|
) {
|
||||||
ReceiverValue callDispatchReceiver = resolvedCall.getDispatchReceiver();
|
ReceiverValue callDispatchReceiver = resolvedCall.getDispatchReceiver();
|
||||||
ReceiverValue callExtensionReceiver = resolvedCall.getExtensionReceiver();
|
ReceiverValue callExtensionReceiver = resolvedCall.getExtensionReceiver();
|
||||||
if (callDispatchReceiver.exists() || callExtensionReceiver.exists() || isLocalFunCall(callableMethod)) {
|
if (callDispatchReceiver.exists() || callExtensionReceiver.exists()
|
||||||
|
|| isLocalFunCall(callableMethod) || isCallToMemberObjectImportedByName(resolvedCall)) {
|
||||||
CallableDescriptor descriptor = resolvedCall.getResultingDescriptor();
|
CallableDescriptor descriptor = resolvedCall.getResultingDescriptor();
|
||||||
ReceiverParameterDescriptor dispatchReceiverParameter = descriptor.getDispatchReceiverParameter();
|
ReceiverParameterDescriptor dispatchReceiverParameter = descriptor.getDispatchReceiverParameter();
|
||||||
ReceiverParameterDescriptor extensionReceiverParameter = descriptor.getExtensionReceiverParameter();
|
ReceiverParameterDescriptor extensionReceiverParameter = descriptor.getExtensionReceiverParameter();
|
||||||
@@ -527,11 +529,13 @@ public abstract class StackValue {
|
|||||||
return codegen.generateReceiverValue(receiverValue);
|
return codegen.generateReceiverValue(receiverValue);
|
||||||
}
|
}
|
||||||
else if (isLocalFunCall(callableMethod) && !isExtension) {
|
else if (isLocalFunCall(callableMethod) && !isExtension) {
|
||||||
CallableDescriptor descriptor = resolvedCall.getResultingDescriptor();
|
StackValue value = codegen.findLocalOrCapturedValue(resolvedCall.getResultingDescriptor().getOriginal());
|
||||||
StackValue value = codegen.findLocalOrCapturedValue(descriptor.getOriginal());
|
|
||||||
assert value != null : "Local fun should be found in locals or in captured params: " + resolvedCall;
|
assert value != null : "Local fun should be found in locals or in captured params: " + resolvedCall;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
else if (isCallToMemberObjectImportedByName(resolvedCall)) {
|
||||||
|
return singleton(((ImportedFromObjectCallableDescriptor) resolvedCall.getResultingDescriptor()).getContainingObject(), codegen.typeMapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (receiverValue.exists()) {
|
else if (receiverValue.exists()) {
|
||||||
return receiver;
|
return receiver;
|
||||||
@@ -539,6 +543,10 @@ public abstract class StackValue {
|
|||||||
return none();
|
return none();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isCallToMemberObjectImportedByName(@NotNull ResolvedCall resolvedCall) {
|
||||||
|
return resolvedCall.getResultingDescriptor() instanceof ImportedFromObjectCallableDescriptor;
|
||||||
|
}
|
||||||
|
|
||||||
private static StackValue platformStaticCallIfPresent(@NotNull StackValue resultReceiver, @NotNull CallableDescriptor descriptor) {
|
private static StackValue platformStaticCallIfPresent(@NotNull StackValue resultReceiver, @NotNull CallableDescriptor descriptor) {
|
||||||
if (AnnotationsPackage.isPlatformStaticInObjectOrClass(descriptor)) {
|
if (AnnotationsPackage.isPlatformStaticInObjectOrClass(descriptor)) {
|
||||||
if (resultReceiver.canHaveSideEffects()) {
|
if (resultReceiver.canHaveSideEffects()) {
|
||||||
|
|||||||
@@ -47,9 +47,7 @@ import org.jetbrains.kotlin.psi.JetExpression;
|
|||||||
import org.jetbrains.kotlin.psi.JetFile;
|
import org.jetbrains.kotlin.psi.JetFile;
|
||||||
import org.jetbrains.kotlin.psi.JetFunctionLiteral;
|
import org.jetbrains.kotlin.psi.JetFunctionLiteral;
|
||||||
import org.jetbrains.kotlin.psi.JetFunctionLiteralExpression;
|
import org.jetbrains.kotlin.psi.JetFunctionLiteralExpression;
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
import org.jetbrains.kotlin.resolve.*;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
|
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
|
||||||
import org.jetbrains.kotlin.resolve.annotations.AnnotationsPackage;
|
import org.jetbrains.kotlin.resolve.annotations.AnnotationsPackage;
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument;
|
import org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument;
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||||
@@ -712,9 +710,11 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (isStaticDeclaration(functionDescriptor) ||
|
boolean isStaticInvocation = (isStaticDeclaration(functionDescriptor) &&
|
||||||
isStaticAccessor(functionDescriptor) ||
|
!(functionDescriptor instanceof ImportedFromObjectCallableDescriptor)) ||
|
||||||
AnnotationsPackage.isPlatformStaticInObjectOrClass(functionDescriptor)) {
|
isStaticAccessor(functionDescriptor) ||
|
||||||
|
AnnotationsPackage.isPlatformStaticInObjectOrClass(functionDescriptor);
|
||||||
|
if (isStaticInvocation) {
|
||||||
invokeOpcode = INVOKESTATIC;
|
invokeOpcode = INVOKESTATIC;
|
||||||
}
|
}
|
||||||
else if (isInterface) {
|
else if (isInterface) {
|
||||||
@@ -858,6 +858,10 @@ public class JetTypeMapper {
|
|||||||
@NotNull
|
@NotNull
|
||||||
public JvmMethodSignature mapSignature(@NotNull FunctionDescriptor f, @NotNull OwnerKind kind,
|
public JvmMethodSignature mapSignature(@NotNull FunctionDescriptor f, @NotNull OwnerKind kind,
|
||||||
List<ValueParameterDescriptor> valueParameters) {
|
List<ValueParameterDescriptor> valueParameters) {
|
||||||
|
if (f instanceof FunctionImportedFromObject) {
|
||||||
|
return mapSignature(((FunctionImportedFromObject) f).getFunctionFromObject());
|
||||||
|
}
|
||||||
|
|
||||||
BothSignatureWriter sw = new BothSignatureWriter(BothSignatureWriter.Mode.METHOD);
|
BothSignatureWriter sw = new BothSignatureWriter(BothSignatureWriter.Mode.METHOD);
|
||||||
|
|
||||||
if (f instanceof ConstructorDescriptor) {
|
if (f instanceof ConstructorDescriptor) {
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ public interface Errors {
|
|||||||
|
|
||||||
// Imports
|
// Imports
|
||||||
|
|
||||||
DiagnosticFactory1<JetSimpleNameExpression, ClassDescriptor> CANNOT_IMPORT_MEMBERS_FROM_SINGLETON = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<JetSimpleNameExpression, ClassDescriptor> CANNOT_ALL_UNDER_IMPORT_FROM_SINGLETON = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory1<JetSimpleNameExpression, Name> CANNOT_BE_IMPORTED = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<JetSimpleNameExpression, Name> CANNOT_BE_IMPORTED = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory0<JetSimpleNameExpression> PACKAGE_CANNOT_BE_IMPORTED = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<JetSimpleNameExpression> PACKAGE_CANNOT_BE_IMPORTED = DiagnosticFactory0.create(ERROR);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -147,8 +147,8 @@ public class DefaultErrorMessages {
|
|||||||
MAP.put(LABEL_NAME_CLASH, "There is more than one label with such a name in this scope");
|
MAP.put(LABEL_NAME_CLASH, "There is more than one label with such a name in this scope");
|
||||||
MAP.put(EXPRESSION_EXPECTED_PACKAGE_FOUND, "Expression expected, but a package name found");
|
MAP.put(EXPRESSION_EXPECTED_PACKAGE_FOUND, "Expression expected, but a package name found");
|
||||||
|
|
||||||
MAP.put(CANNOT_IMPORT_MEMBERS_FROM_SINGLETON, "Cannot import members from object ''{0}''", NAME);
|
MAP.put(CANNOT_ALL_UNDER_IMPORT_FROM_SINGLETON, "Cannot import-on-demand from object ''{0}''", NAME);
|
||||||
MAP.put(CANNOT_BE_IMPORTED, "Cannot import ''{0}'', functions and properties can be imported only from packages", TO_STRING);
|
MAP.put(CANNOT_BE_IMPORTED, "Cannot import ''{0}'', functions and properties can be imported only from packages or objects", TO_STRING);
|
||||||
MAP.put(PACKAGE_CANNOT_BE_IMPORTED, "Packages cannot be imported");
|
MAP.put(PACKAGE_CANNOT_BE_IMPORTED, "Packages cannot be imported");
|
||||||
MAP.put(CONFLICTING_IMPORT, "Conflicting import, imported name ''{0}'' is ambiguous", STRING);
|
MAP.put(CONFLICTING_IMPORT, "Conflicting import, imported name ''{0}'' is ambiguous", STRING);
|
||||||
MAP.put(PLATFORM_CLASS_MAPPED_TO_KOTLIN, "This class shouldn''t be used in Kotlin. Use {0} instead.", CLASSES_OR_SEPARATED);
|
MAP.put(PLATFORM_CLASS_MAPPED_TO_KOTLIN, "This class shouldn''t be used in Kotlin. Use {0} instead.", CLASSES_OR_SEPARATED);
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageVa
|
|||||||
val packageOrClassDescriptor = resolveToPackageOrClass(path, moduleDescriptor, trace, packageFragmentForVisibilityCheck,
|
val packageOrClassDescriptor = resolveToPackageOrClass(path, moduleDescriptor, trace, packageFragmentForVisibilityCheck,
|
||||||
scopeForFirstPart = null, inImport = true) ?: return null
|
scopeForFirstPart = null, inImport = true) ?: return null
|
||||||
if (packageOrClassDescriptor is ClassDescriptor && packageOrClassDescriptor.kind.isSingleton) {
|
if (packageOrClassDescriptor is ClassDescriptor && packageOrClassDescriptor.kind.isSingleton) {
|
||||||
trace.report(Errors.CANNOT_IMPORT_MEMBERS_FROM_SINGLETON.on(lastPart.expression, packageOrClassDescriptor)) // todo report on star
|
trace.report(Errors.CANNOT_ALL_UNDER_IMPORT_FROM_SINGLETON.on(lastPart.expression, packageOrClassDescriptor)) // todo report on star
|
||||||
}
|
}
|
||||||
return AllUnderImportsScope(packageOrClassDescriptor)
|
return AllUnderImportsScope(packageOrClassDescriptor)
|
||||||
}
|
}
|
||||||
@@ -185,6 +185,15 @@ public class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageVa
|
|||||||
val staticClassScope = packageOrClassDescriptor.staticScope
|
val staticClassScope = packageOrClassDescriptor.staticScope
|
||||||
descriptors.addAll(staticClassScope.getFunctions(lastName, location))
|
descriptors.addAll(staticClassScope.getFunctions(lastName, location))
|
||||||
descriptors.addAll(staticClassScope.getProperties(lastName, location))
|
descriptors.addAll(staticClassScope.getProperties(lastName, location))
|
||||||
|
|
||||||
|
if (packageOrClassDescriptor.kind == ClassKind.OBJECT) {
|
||||||
|
descriptors.addAll(packageOrClassDescriptor.unsubstitutedMemberScope.getFunctions(lastName, location).map {
|
||||||
|
FunctionImportedFromObject(it)
|
||||||
|
})
|
||||||
|
val properties = packageOrClassDescriptor.unsubstitutedMemberScope.getProperties(lastName, location)
|
||||||
|
.filterIsInstance<PropertyDescriptor>().map { PropertyImportedFromObject(it) }
|
||||||
|
descriptors.addAll(properties)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> throw IllegalStateException("Should be class or package: $packageOrClassDescriptor")
|
else -> throw IllegalStateException("Should be class or package: $packageOrClassDescriptor")
|
||||||
@@ -214,12 +223,7 @@ public class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageVa
|
|||||||
descriptors.addAll(memberScope.getFunctions(lastName, lastPart.location))
|
descriptors.addAll(memberScope.getFunctions(lastName, lastPart.location))
|
||||||
descriptors.addAll(memberScope.getProperties(lastName, lastPart.location))
|
descriptors.addAll(memberScope.getProperties(lastName, lastPart.location))
|
||||||
if (descriptors.isNotEmpty()) {
|
if (descriptors.isNotEmpty()) {
|
||||||
if (packageOrClassDescriptor.kind.isSingleton) {
|
trace.report(Errors.CANNOT_BE_IMPORTED.on(lastPart.expression, lastName))
|
||||||
trace.report(Errors.CANNOT_IMPORT_MEMBERS_FROM_SINGLETON.on(lastPart.expression, packageOrClassDescriptor))
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
trace.report(Errors.CANNOT_BE_IMPORTED.on(lastPart.expression, lastName))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2015 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.*
|
||||||
|
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||||
|
|
||||||
|
abstract class ImportedFromObjectCallableDescriptor(val containingObject: ClassDescriptor): CallableDescriptor
|
||||||
|
|
||||||
|
// members imported from object should be wrapped to not require dispatch receiver
|
||||||
|
class FunctionImportedFromObject(val functionFromObject: FunctionDescriptor) :
|
||||||
|
FunctionDescriptor by functionFromObject,
|
||||||
|
ImportedFromObjectCallableDescriptor(functionFromObject.containingDeclaration as ClassDescriptor) {
|
||||||
|
override fun getDispatchReceiverParameter(): ReceiverParameterDescriptor? = null
|
||||||
|
|
||||||
|
override fun substitute(substitutor: TypeSubstitutor) = functionFromObject.substitute(substitutor).wrap()
|
||||||
|
|
||||||
|
override fun getOriginal() = functionFromObject.original.wrap()
|
||||||
|
|
||||||
|
override fun copy(
|
||||||
|
newOwner: DeclarationDescriptor?, modality: Modality?, visibility: Visibility?,
|
||||||
|
kind: CallableMemberDescriptor.Kind?, copyOverrides: Boolean
|
||||||
|
): FunctionDescriptor {
|
||||||
|
throw IllegalStateException("copy() should not be called on ${this.javaClass.simpleName}, was called for $this")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class PropertyImportedFromObject(private val propertyFromObject: PropertyDescriptor) :
|
||||||
|
PropertyDescriptor by propertyFromObject,
|
||||||
|
ImportedFromObjectCallableDescriptor(propertyFromObject.containingDeclaration as ClassDescriptor) {
|
||||||
|
override fun getDispatchReceiverParameter(): ReceiverParameterDescriptor? = null
|
||||||
|
|
||||||
|
override fun substitute(substitutor: TypeSubstitutor) = propertyFromObject.substitute(substitutor)?.wrap()
|
||||||
|
|
||||||
|
override fun getOriginal() = propertyFromObject.original.wrap()
|
||||||
|
|
||||||
|
override fun copy(
|
||||||
|
newOwner: DeclarationDescriptor?, modality: Modality?, visibility: Visibility?,
|
||||||
|
kind: CallableMemberDescriptor.Kind?, copyOverrides: Boolean
|
||||||
|
): FunctionDescriptor {
|
||||||
|
throw IllegalStateException("copy() should not be called on ${this.javaClass.simpleName}, was called for $this")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun FunctionDescriptor.wrap() = FunctionImportedFromObject(this)
|
||||||
|
private fun PropertyDescriptor.wrap() = PropertyImportedFromObject(this)
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import C.f
|
||||||
|
import C.p
|
||||||
|
import C.ext
|
||||||
|
import C.g1
|
||||||
|
import C.g2
|
||||||
|
import C.fromClass
|
||||||
|
import C.fromInterface
|
||||||
|
import C.genericFromSuper
|
||||||
|
|
||||||
|
interface I<G> {
|
||||||
|
fun <T> T.fromInterface(): T = this
|
||||||
|
|
||||||
|
fun genericFromSuper(g: G) = g
|
||||||
|
}
|
||||||
|
|
||||||
|
open class BaseClass {
|
||||||
|
val <T> T.fromClass: T
|
||||||
|
get() = this
|
||||||
|
}
|
||||||
|
|
||||||
|
object C: BaseClass(), I<String> {
|
||||||
|
fun f(s: Int) = 1
|
||||||
|
fun f(s: String) = 2
|
||||||
|
fun Boolean.f() = 3
|
||||||
|
|
||||||
|
var p: Int = 4
|
||||||
|
val Int.ext: Int
|
||||||
|
get() = 6
|
||||||
|
|
||||||
|
fun <T> g1(t: T): T = t
|
||||||
|
val <T> T.g2: T
|
||||||
|
get() = this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
if (f(1) != 1) return "1"
|
||||||
|
if (f("s") != 2) return "2"
|
||||||
|
if (true.f() != 3) return "3"
|
||||||
|
if (p != 4) return "4"
|
||||||
|
p = 5
|
||||||
|
if (p != 5) return "5"
|
||||||
|
if (5.ext != 6) return "6"
|
||||||
|
if (g1("7") != "7") return "7"
|
||||||
|
if ("8".g2 != "8") return "8"
|
||||||
|
if (9.fromInterface() != 9) return "9"
|
||||||
|
if ("10".fromClass != "10") return "10"
|
||||||
|
if (genericFromSuper("11") != "11") return "11"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
import Class.C.f
|
||||||
|
import Class.C.p
|
||||||
|
import Class.C.ext
|
||||||
|
import Class.C.g1
|
||||||
|
import Class.C.g2
|
||||||
|
import Class.C.fromClass
|
||||||
|
import Class.C.fromInterface
|
||||||
|
import Class.C.genericFromSuper
|
||||||
|
|
||||||
|
interface I<G> {
|
||||||
|
fun <T> T.fromInterface(): T = this
|
||||||
|
|
||||||
|
fun genericFromSuper(g: G) = g
|
||||||
|
}
|
||||||
|
|
||||||
|
open class BaseClass {
|
||||||
|
val <T> T.fromClass: T
|
||||||
|
get() = this
|
||||||
|
}
|
||||||
|
|
||||||
|
class Class {
|
||||||
|
companion object C: BaseClass(), I<String> {
|
||||||
|
fun f(s: Int) = 1
|
||||||
|
fun f(s: String) = 2
|
||||||
|
fun Boolean.f() = 3
|
||||||
|
|
||||||
|
var p: Int = 4
|
||||||
|
val Int.ext: Int
|
||||||
|
get() = 6
|
||||||
|
|
||||||
|
fun <T> g1(t: T): T = t
|
||||||
|
val <T> T.g2: T
|
||||||
|
get() = this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
if (f(1) != 1) return "1"
|
||||||
|
if (f("s") != 2) return "2"
|
||||||
|
if (true.f() != 3) return "3"
|
||||||
|
if (p != 4) return "4"
|
||||||
|
p = 5
|
||||||
|
if (p != 5) return "5"
|
||||||
|
if (5.ext != 6) return "6"
|
||||||
|
if (g1("7") != "7") return "7"
|
||||||
|
if ("8".g2 != "8") return "8"
|
||||||
|
if (9.fromInterface() != 9) return "9"
|
||||||
|
if ("10".fromClass != "10") return "10"
|
||||||
|
if (genericFromSuper("11") != "11") return "11"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
import O.p
|
||||||
|
import O.f
|
||||||
|
import C.Companion.p1
|
||||||
|
import C.Companion.f1
|
||||||
|
|
||||||
|
object O {
|
||||||
|
@JvmStatic
|
||||||
|
fun f(): Int = 3
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
val p: Int = 6
|
||||||
|
}
|
||||||
|
|
||||||
|
class C {
|
||||||
|
companion object {
|
||||||
|
@JvmStatic
|
||||||
|
fun f1(): Int = 3
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
val p1: Int = 6
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
if (p + f() != 9) return "fail"
|
||||||
|
if (p1 + f1() != 9) return "fail2"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
// FILE: a.Kt
|
||||||
|
package a
|
||||||
|
|
||||||
|
class C1 {
|
||||||
|
companion object O {
|
||||||
|
class A
|
||||||
|
object B
|
||||||
|
|
||||||
|
fun bar() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class C2 {
|
||||||
|
companion object S {
|
||||||
|
|
||||||
|
val prop: String = ""
|
||||||
|
|
||||||
|
fun o(<!UNUSED_PARAMETER!>s<!>: String) = Unit
|
||||||
|
fun o(<!UNUSED_PARAMETER!>i<!>: Int) = Unit
|
||||||
|
|
||||||
|
fun Int.ext() = Unit
|
||||||
|
var String.ext: Int
|
||||||
|
get() = 3
|
||||||
|
set(i) {
|
||||||
|
}
|
||||||
|
|
||||||
|
fun A(<!UNUSED_PARAMETER!>c<!>: Int) = A()
|
||||||
|
|
||||||
|
class A()
|
||||||
|
|
||||||
|
fun <T> genericFun(t: T, <!UNUSED_PARAMETER!>t2<!>: T): T = t
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Base {
|
||||||
|
fun f() {
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> g(<!UNUSED_PARAMETER!>t<!>: T) {
|
||||||
|
}
|
||||||
|
|
||||||
|
val p = 1
|
||||||
|
val Int.ext: Int
|
||||||
|
get() = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
interface BaseI<T> {
|
||||||
|
fun fromI(): Int = 3
|
||||||
|
|
||||||
|
fun genericFromI(t: T) = t
|
||||||
|
}
|
||||||
|
|
||||||
|
class C3 {
|
||||||
|
companion object K: Base(), BaseI<Int> {
|
||||||
|
val own: String = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: b.kt
|
||||||
|
package b
|
||||||
|
|
||||||
|
import a.C1.<!CANNOT_ALL_UNDER_IMPORT_FROM_SINGLETON!>O<!>.*
|
||||||
|
|
||||||
|
fun testErroneusAllUnderImportFromObject() {
|
||||||
|
A()
|
||||||
|
B
|
||||||
|
<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: c.kt
|
||||||
|
package c
|
||||||
|
|
||||||
|
import a.C2.S.prop
|
||||||
|
import a.C2.S.o
|
||||||
|
import a.C2.S.ext
|
||||||
|
import a.C2.S.A
|
||||||
|
import a.C2.S.genericFun
|
||||||
|
import a.C2.S.ext as extRenamed
|
||||||
|
|
||||||
|
fun testImportFromObjectByName() {
|
||||||
|
prop
|
||||||
|
o("a")
|
||||||
|
o(3)
|
||||||
|
3.ext()
|
||||||
|
"".ext = 3
|
||||||
|
val <!UNUSED_VARIABLE!>c<!>: Int = "".ext
|
||||||
|
|
||||||
|
3.extRenamed()
|
||||||
|
"".extRenamed = 3
|
||||||
|
val <!UNUSED_VARIABLE!>c2<!>: Int = "".extRenamed
|
||||||
|
|
||||||
|
A()
|
||||||
|
A(3)
|
||||||
|
|
||||||
|
val <!UNUSED_VARIABLE!>a<!>: Int = genericFun(3, 3)
|
||||||
|
val <!UNUSED_VARIABLE!>s<!>: String = genericFun("A", "b")
|
||||||
|
val <!UNUSED_VARIABLE!>b<!>: Boolean = genericFun(true, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> t(t: T): T {
|
||||||
|
return genericFun(t, t)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: d.kt
|
||||||
|
package d
|
||||||
|
|
||||||
|
import a.C2.S.prop as renamed
|
||||||
|
|
||||||
|
fun testFunImportedFromObjectHasNoDispatchReceiver(l: a.C2.S) {
|
||||||
|
l.<!UNRESOLVED_REFERENCE!>renamed<!>
|
||||||
|
l.prop
|
||||||
|
renamed
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: e.kt
|
||||||
|
|
||||||
|
package e
|
||||||
|
|
||||||
|
import a.C3.K.f
|
||||||
|
import a.C3.K.g
|
||||||
|
import a.C3.K.p
|
||||||
|
import a.C3.K.own
|
||||||
|
import a.C3.K.fromI
|
||||||
|
import a.C3.K.genericFromI
|
||||||
|
import a.C3.K.ext
|
||||||
|
|
||||||
|
fun testMembersFromSupertypes() {
|
||||||
|
f()
|
||||||
|
g("")
|
||||||
|
p
|
||||||
|
fromI()
|
||||||
|
|
||||||
|
genericFromI(3)
|
||||||
|
genericFromI(<!TYPE_MISMATCH!>"a"<!>)
|
||||||
|
|
||||||
|
own
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
package a {
|
||||||
|
|
||||||
|
public open class Base {
|
||||||
|
public constructor Base()
|
||||||
|
public final val p: kotlin.Int = 1
|
||||||
|
public final val kotlin.Int.ext: kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun f(): kotlin.Unit
|
||||||
|
public final fun </*0*/ T> g(/*0*/ t: T): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface BaseI</*0*/ T> {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open fun fromI(): kotlin.Int
|
||||||
|
public open fun genericFromI(/*0*/ t: T): T
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class C1 {
|
||||||
|
public constructor C1()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public companion object O {
|
||||||
|
private constructor O()
|
||||||
|
public final fun bar(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public final class A {
|
||||||
|
public constructor A()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public object B {
|
||||||
|
private constructor B()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class C2 {
|
||||||
|
public constructor C2()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public companion object S {
|
||||||
|
private constructor S()
|
||||||
|
public final val prop: kotlin.String = ""
|
||||||
|
public final var kotlin.String.ext: kotlin.Int
|
||||||
|
public final fun A(/*0*/ c: kotlin.Int): a.C2.S.A
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun </*0*/ T> genericFun(/*0*/ t: T, /*1*/ t2: T): T
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public final fun o(/*0*/ i: kotlin.Int): kotlin.Unit
|
||||||
|
public final fun o(/*0*/ s: kotlin.String): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
public final fun kotlin.Int.ext(): kotlin.Unit
|
||||||
|
|
||||||
|
public final class A {
|
||||||
|
public constructor A()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class C3 {
|
||||||
|
public constructor C3()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public companion object K : a.Base, a.BaseI<kotlin.Int> {
|
||||||
|
private constructor K()
|
||||||
|
public final val own: kotlin.String = ""
|
||||||
|
public final override /*1*/ /*fake_override*/ val p: kotlin.Int
|
||||||
|
public final override /*1*/ /*fake_override*/ val kotlin.Int.ext: kotlin.Int
|
||||||
|
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final override /*1*/ /*fake_override*/ fun f(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun fromI(): kotlin.Int
|
||||||
|
public final override /*1*/ /*fake_override*/ fun </*0*/ T> g(/*0*/ t: T): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun genericFromI(/*0*/ t: kotlin.Int): kotlin.Int
|
||||||
|
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
package b {
|
||||||
|
public fun testErroneusAllUnderImportFromObject(): kotlin.Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
package c {
|
||||||
|
public fun </*0*/ T> t(/*0*/ t: T): T
|
||||||
|
public fun testImportFromObjectByName(): kotlin.Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
package d {
|
||||||
|
public fun testFunImportedFromObjectHasNoDispatchReceiver(/*0*/ l: a.C2.S): kotlin.Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
package e {
|
||||||
|
public fun testMembersFromSupertypes(): kotlin.Unit
|
||||||
|
}
|
||||||
+114
-2
@@ -8,13 +8,125 @@ object O {
|
|||||||
fun bar() {}
|
fun bar() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
object S {
|
||||||
|
|
||||||
|
val prop: String = ""
|
||||||
|
|
||||||
|
fun o(<!UNUSED_PARAMETER!>s<!>: String) = Unit
|
||||||
|
fun o(<!UNUSED_PARAMETER!>i<!>: Int) = Unit
|
||||||
|
|
||||||
|
fun Int.ext() = Unit
|
||||||
|
var String.ext: Int
|
||||||
|
get() = 3
|
||||||
|
set(i) {
|
||||||
|
}
|
||||||
|
|
||||||
|
fun A(<!UNUSED_PARAMETER!>c<!>: Int) = A()
|
||||||
|
|
||||||
|
class A()
|
||||||
|
|
||||||
|
fun <T> genericFun(t: T, <!UNUSED_PARAMETER!>t2<!>: T): T = t
|
||||||
|
}
|
||||||
|
|
||||||
|
open class Base {
|
||||||
|
fun f() {
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> g(<!UNUSED_PARAMETER!>t<!>: T) {
|
||||||
|
}
|
||||||
|
|
||||||
|
val p = 1
|
||||||
|
val Int.ext: Int
|
||||||
|
get() = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
interface BaseI<T> {
|
||||||
|
fun fromI(): Int = 3
|
||||||
|
|
||||||
|
fun genericFromI(t: T) = t
|
||||||
|
}
|
||||||
|
|
||||||
|
object K: Base(), BaseI<Int> {
|
||||||
|
val own: String = ""
|
||||||
|
}
|
||||||
|
|
||||||
// FILE: b.kt
|
// FILE: b.kt
|
||||||
package b
|
package b
|
||||||
|
|
||||||
import a.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>O<!>.*
|
import a.<!CANNOT_ALL_UNDER_IMPORT_FROM_SINGLETON!>O<!>.*
|
||||||
|
|
||||||
fun test() {
|
fun testErroneusAllUnderImportFromObject() {
|
||||||
A()
|
A()
|
||||||
B
|
B
|
||||||
<!UNRESOLVED_REFERENCE!>bar<!>()
|
<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: c.kt
|
||||||
|
package c
|
||||||
|
|
||||||
|
import a.S.prop
|
||||||
|
import a.S.o
|
||||||
|
import a.S.ext
|
||||||
|
import a.S.A
|
||||||
|
import a.S.genericFun
|
||||||
|
import a.S.ext as extRenamed
|
||||||
|
|
||||||
|
fun testImportFromObjectByName() {
|
||||||
|
prop
|
||||||
|
o("a")
|
||||||
|
o(3)
|
||||||
|
3.ext()
|
||||||
|
"".ext = 3
|
||||||
|
val <!UNUSED_VARIABLE!>c<!>: Int = "".ext
|
||||||
|
|
||||||
|
3.extRenamed()
|
||||||
|
"".extRenamed = 3
|
||||||
|
val <!UNUSED_VARIABLE!>c2<!>: Int = "".extRenamed
|
||||||
|
|
||||||
|
A()
|
||||||
|
A(3)
|
||||||
|
|
||||||
|
val <!UNUSED_VARIABLE!>a<!>: Int = genericFun(3, 3)
|
||||||
|
val <!UNUSED_VARIABLE!>s<!>: String = genericFun("A", "b")
|
||||||
|
val <!UNUSED_VARIABLE!>b<!>: Boolean = genericFun(true, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> t(t: T): T {
|
||||||
|
return genericFun(t, t)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: d.kt
|
||||||
|
package d
|
||||||
|
|
||||||
|
import a.S.prop as renamed
|
||||||
|
|
||||||
|
fun testFunImportedFromObjectHasNoDispatchReceiver(l: a.S) {
|
||||||
|
l.<!UNRESOLVED_REFERENCE!>renamed<!>
|
||||||
|
l.prop
|
||||||
|
renamed
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: e.kt
|
||||||
|
|
||||||
|
package e
|
||||||
|
|
||||||
|
import a.K.f
|
||||||
|
import a.K.g
|
||||||
|
import a.K.p
|
||||||
|
import a.K.own
|
||||||
|
import a.K.fromI
|
||||||
|
import a.K.genericFromI
|
||||||
|
import a.K.ext
|
||||||
|
|
||||||
|
fun testMembersFromSupertypes() {
|
||||||
|
f()
|
||||||
|
g("")
|
||||||
|
p
|
||||||
|
fromI()
|
||||||
|
|
||||||
|
genericFromI(3)
|
||||||
|
genericFromI(<!TYPE_MISMATCH!>"a"<!>)
|
||||||
|
|
||||||
|
own
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,39 @@ package
|
|||||||
|
|
||||||
package a {
|
package a {
|
||||||
|
|
||||||
|
public open class Base {
|
||||||
|
public constructor Base()
|
||||||
|
public final val p: kotlin.Int = 1
|
||||||
|
public final val kotlin.Int.ext: kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun f(): kotlin.Unit
|
||||||
|
public final fun </*0*/ T> g(/*0*/ t: T): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface BaseI</*0*/ T> {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open fun fromI(): kotlin.Int
|
||||||
|
public open fun genericFromI(/*0*/ t: T): T
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public object K : a.Base, a.BaseI<kotlin.Int> {
|
||||||
|
private constructor K()
|
||||||
|
public final val own: kotlin.String = ""
|
||||||
|
public final override /*1*/ /*fake_override*/ val p: kotlin.Int
|
||||||
|
public final override /*1*/ /*fake_override*/ val kotlin.Int.ext: kotlin.Int
|
||||||
|
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final override /*1*/ /*fake_override*/ fun f(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun fromI(): kotlin.Int
|
||||||
|
public final override /*1*/ /*fake_override*/ fun </*0*/ T> g(/*0*/ t: T): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun genericFromI(/*0*/ t: kotlin.Int): kotlin.Int
|
||||||
|
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
public object O {
|
public object O {
|
||||||
private constructor O()
|
private constructor O()
|
||||||
public final fun bar(): kotlin.Unit
|
public final fun bar(): kotlin.Unit
|
||||||
@@ -23,8 +56,42 @@ package a {
|
|||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public object S {
|
||||||
|
private constructor S()
|
||||||
|
public final val prop: kotlin.String = ""
|
||||||
|
public final var kotlin.String.ext: kotlin.Int
|
||||||
|
public final fun A(/*0*/ c: kotlin.Int): a.S.A
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun </*0*/ T> genericFun(/*0*/ t: T, /*1*/ t2: T): T
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public final fun o(/*0*/ i: kotlin.Int): kotlin.Unit
|
||||||
|
public final fun o(/*0*/ s: kotlin.String): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
public final fun kotlin.Int.ext(): kotlin.Unit
|
||||||
|
|
||||||
|
public final class A {
|
||||||
|
public constructor A()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
package b {
|
package b {
|
||||||
public fun test(): kotlin.Unit
|
public fun testErroneusAllUnderImportFromObject(): kotlin.Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
package c {
|
||||||
|
public fun </*0*/ T> t(/*0*/ t: T): T
|
||||||
|
public fun testImportFromObjectByName(): kotlin.Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
package d {
|
||||||
|
public fun testFunImportedFromObjectHasNoDispatchReceiver(/*0*/ l: a.S): kotlin.Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
package e {
|
||||||
|
public fun testMembersFromSupertypes(): kotlin.Unit
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -5,12 +5,12 @@ import b.B //class
|
|||||||
import b.foo //function
|
import b.foo //function
|
||||||
import b.ext //extension function
|
import b.ext //extension function
|
||||||
import b.value //property
|
import b.value //property
|
||||||
import b.C.Companion.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>bar<!> //function from companion object
|
import b.C.Companion.bar //function from companion object
|
||||||
import b.C.Companion.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>cValue<!> //property from companion object
|
import b.C.Companion.cValue //property from companion object
|
||||||
import b.<!UNRESOLVED_REFERENCE!>constant<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>fff<!> //function from val
|
import b.<!UNRESOLVED_REFERENCE!>constant<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>fff<!> //function from val
|
||||||
import b.<!UNRESOLVED_REFERENCE!>constant<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>dValue<!> //property from val
|
import b.<!UNRESOLVED_REFERENCE!>constant<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>dValue<!> //property from val
|
||||||
import b.constant
|
import b.constant
|
||||||
import b.E.Companion.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>f<!> //val from companion object
|
import b.E.Companion.f //val from companion object
|
||||||
import <!UNRESOLVED_REFERENCE!>smth<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>illegal<!>
|
import <!UNRESOLVED_REFERENCE!>smth<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>illegal<!>
|
||||||
import b.C.<!UNRESOLVED_REFERENCE!>smth<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>illegal<!>
|
import b.C.<!UNRESOLVED_REFERENCE!>smth<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>illegal<!>
|
||||||
import b.<!UNRESOLVED_REFERENCE!>bar<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>smth<!>
|
import b.<!UNRESOLVED_REFERENCE!>bar<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>smth<!>
|
||||||
@@ -22,14 +22,14 @@ fun test(arg: B) {
|
|||||||
foo(value)
|
foo(value)
|
||||||
arg.ext()
|
arg.ext()
|
||||||
|
|
||||||
<!UNRESOLVED_REFERENCE!>bar<!>()
|
bar()
|
||||||
foo(<!UNRESOLVED_REFERENCE!>cValue<!>)
|
foo(cValue)
|
||||||
|
|
||||||
<!UNRESOLVED_REFERENCE!>fff<!>(<!UNRESOLVED_REFERENCE!>dValue<!>)
|
<!UNRESOLVED_REFERENCE!>fff<!>(<!UNRESOLVED_REFERENCE!>dValue<!>)
|
||||||
|
|
||||||
constant.fff(constant.dValue)
|
constant.fff(constant.dValue)
|
||||||
|
|
||||||
<!UNRESOLVED_REFERENCE!>f<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>f<!>()
|
f.f()
|
||||||
}
|
}
|
||||||
|
|
||||||
// FILE:b.kt
|
// FILE:b.kt
|
||||||
@@ -72,7 +72,7 @@ fun bar() {}
|
|||||||
//FILE:c.kt
|
//FILE:c.kt
|
||||||
package c
|
package c
|
||||||
|
|
||||||
import c.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>C<!>.*
|
import c.<!CANNOT_ALL_UNDER_IMPORT_FROM_SINGLETON!>C<!>.*
|
||||||
|
|
||||||
object C {
|
object C {
|
||||||
fun f() {
|
fun f() {
|
||||||
|
|||||||
@@ -2,21 +2,21 @@ package a
|
|||||||
|
|
||||||
import a.A.*
|
import a.A.*
|
||||||
import a.A.C
|
import a.A.C
|
||||||
import a.A.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>C<!>.*
|
import a.A.<!CANNOT_ALL_UNDER_IMPORT_FROM_SINGLETON!>C<!>.*
|
||||||
import a.A.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>D<!>.*
|
import a.A.<!CANNOT_ALL_UNDER_IMPORT_FROM_SINGLETON!>D<!>.*
|
||||||
import a.A.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>C<!>.*
|
import a.A.<!CANNOT_ALL_UNDER_IMPORT_FROM_SINGLETON!>C<!>.*
|
||||||
import a.A.C.G
|
import a.A.C.G
|
||||||
import a.A.E.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>J<!>.*
|
import a.A.E.<!CANNOT_ALL_UNDER_IMPORT_FROM_SINGLETON!>J<!>.*
|
||||||
import a.A.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>CO<!>.*
|
import a.A.<!CANNOT_ALL_UNDER_IMPORT_FROM_SINGLETON!>CO<!>.*
|
||||||
import a.A.CO
|
import a.A.CO
|
||||||
|
|
||||||
import a.B.C.*
|
import a.B.C.*
|
||||||
import a.B.C.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>A<!>.*
|
import a.B.C.<!CANNOT_ALL_UNDER_IMPORT_FROM_SINGLETON!>A<!>.*
|
||||||
import a.B.C.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>D<!>.*
|
import a.B.C.<!CANNOT_ALL_UNDER_IMPORT_FROM_SINGLETON!>D<!>.*
|
||||||
|
|
||||||
import a.E.*
|
import a.E.*
|
||||||
import a.E.E1
|
import a.E.E1
|
||||||
import a.E.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>E2<!>.*
|
import a.E.<!CANNOT_ALL_UNDER_IMPORT_FROM_SINGLETON!>E2<!>.*
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
object C {
|
object C {
|
||||||
|
|||||||
@@ -61,9 +61,9 @@ import a.B.<!UNRESOLVED_REFERENCE!>foo<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>bar<!
|
|||||||
import a.B.<!CANNOT_BE_IMPORTED!>bar<!>
|
import a.B.<!CANNOT_BE_IMPORTED!>bar<!>
|
||||||
import a.B.<!UNRESOLVED_REFERENCE!>bar<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>foo<!>
|
import a.B.<!UNRESOLVED_REFERENCE!>bar<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>foo<!>
|
||||||
|
|
||||||
import a.C.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>foo<!>
|
import a.C.foo
|
||||||
import a.C.<!UNRESOLVED_REFERENCE!>foo<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>bar<!>
|
import a.C.<!UNRESOLVED_REFERENCE!>foo<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>bar<!>
|
||||||
import a.C.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>bar<!>
|
import a.C.bar
|
||||||
import a.C.<!UNRESOLVED_REFERENCE!>bar<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>foo<!>
|
import a.C.<!UNRESOLVED_REFERENCE!>bar<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>foo<!>
|
||||||
import a.C.Nested
|
import a.C.Nested
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ import a.D.<!UNRESOLVED_REFERENCE!>foo<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>bar<!
|
|||||||
import a.D.<!UNRESOLVED_REFERENCE!>bar<!>
|
import a.D.<!UNRESOLVED_REFERENCE!>bar<!>
|
||||||
import a.D.<!UNRESOLVED_REFERENCE!>bar<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>foo<!>
|
import a.D.<!UNRESOLVED_REFERENCE!>bar<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>foo<!>
|
||||||
|
|
||||||
import a.D.Companion.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>foo<!>
|
import a.D.Companion.foo
|
||||||
import a.D.Companion.<!UNRESOLVED_REFERENCE!>foo<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>bar<!>
|
import a.D.Companion.<!UNRESOLVED_REFERENCE!>foo<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>bar<!>
|
||||||
import a.D.Companion.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>bar<!>
|
import a.D.Companion.bar
|
||||||
import a.D.Companion.<!UNRESOLVED_REFERENCE!>bar<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>foo<!>
|
import a.D.Companion.<!UNRESOLVED_REFERENCE!>bar<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>foo<!>
|
||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
package c
|
package c
|
||||||
|
|
||||||
import c.A.Companion.B
|
import c.A.Companion.B
|
||||||
import c.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>M<!>.*
|
import c.<!CANNOT_ALL_UNDER_IMPORT_FROM_SINGLETON!>M<!>.*
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
val <!UNUSED_VARIABLE!>b<!>: B = B()
|
val <!UNUSED_VARIABLE!>b<!>: B = B()
|
||||||
|
|||||||
+3
-3
@@ -2,9 +2,9 @@ package d
|
|||||||
|
|
||||||
//import from objects before properties resolve
|
//import from objects before properties resolve
|
||||||
|
|
||||||
import d.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>A<!>.*
|
import d.<!CANNOT_ALL_UNDER_IMPORT_FROM_SINGLETON!>A<!>.*
|
||||||
import d.M.R
|
import d.M.R
|
||||||
import d.M.R.<!CANNOT_IMPORT_MEMBERS_FROM_SINGLETON!>bar<!>
|
import d.M.R.bar
|
||||||
import d.M.T
|
import d.M.T
|
||||||
import d.M.Y
|
import d.M.Y
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ var r: T = T()
|
|||||||
val y: T = Y
|
val y: T = Y
|
||||||
|
|
||||||
fun f() {
|
fun f() {
|
||||||
<!UNRESOLVED_REFERENCE!>bar<!>()
|
bar()
|
||||||
R.bar()
|
R.bar()
|
||||||
B.foo()
|
B.foo()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6627,6 +6627,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("ImportFromCompanionObject.kt")
|
||||||
|
public void testImportFromCompanionObject() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/imports/ImportFromCompanionObject.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("ImportFromCurrentWithDifferentName.kt")
|
@TestMetadata("ImportFromCurrentWithDifferentName.kt")
|
||||||
public void testImportFromCurrentWithDifferentName() throws Exception {
|
public void testImportFromCurrentWithDifferentName() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/imports/ImportFromCurrentWithDifferentName.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/imports/ImportFromCurrentWithDifferentName.kt");
|
||||||
|
|||||||
+12
@@ -5697,6 +5697,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/useAnonymousObjectAsIterator.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/useAnonymousObjectAsIterator.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("useImportedMember.kt")
|
||||||
|
public void testUseImportedMember() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/useImportedMember.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("useImportedMemberFromCompanion.kt")
|
||||||
|
public void testUseImportedMemberFromCompanion() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/objects/useImportedMemberFromCompanion.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/operatorConventions")
|
@TestMetadata("compiler/testData/codegen/box/operatorConventions")
|
||||||
|
|||||||
+6
@@ -2473,6 +2473,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
|||||||
doTestWithStdlib(fileName);
|
doTestWithStdlib(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("importStaticMemberFromObject.kt")
|
||||||
|
public void testImportStaticMemberFromObject() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/platformStatic/importStaticMemberFromObject.kt");
|
||||||
|
doTestWithStdlib(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inline.kt")
|
@TestMetadata("inline.kt")
|
||||||
public void testInline() throws Exception {
|
public void testInline() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/platformStatic/inline.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/platformStatic/inline.kt");
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ public interface FunctionDescriptor extends CallableMemberDescriptor {
|
|||||||
@Override
|
@Override
|
||||||
FunctionDescriptor getOriginal();
|
FunctionDescriptor getOriginal();
|
||||||
|
|
||||||
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
FunctionDescriptor substitute(@NotNull TypeSubstitutor substitutor);
|
FunctionDescriptor substitute(@NotNull TypeSubstitutor substitutor);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user