KT-6774 Cannot find equals() when comparing with null
#KT-6774 Fixed
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
// KT-6774 Cannot find equals() when comparing with null
|
||||
|
||||
fun <T: Any> fn(t1: T, t2: T?) {
|
||||
val x = if (true) t1 else t2
|
||||
x == null
|
||||
x?.equals(null)
|
||||
x?.hashCode()
|
||||
x.toString()
|
||||
x!!.hashCode()
|
||||
|
||||
val y = t2 ?: t1
|
||||
y == t1
|
||||
y.equals(null)
|
||||
y.hashCode()
|
||||
y.toString()
|
||||
y.hashCode()
|
||||
}
|
||||
|
||||
trait Tr {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
fun <T: Tr> fn(t1: T, t2: T?) {
|
||||
val x = if (true) t1 else t2
|
||||
x?.foo()
|
||||
x!!.foo()
|
||||
|
||||
val y = t2 ?: t1
|
||||
y.foo()
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
internal fun </*0*/ T : Tr> fn(/*0*/ t1: T, /*1*/ t2: T?): kotlin.Unit
|
||||
internal fun </*0*/ T : kotlin.Any> fn(/*0*/ t1: T, /*1*/ t2: T?): kotlin.Unit
|
||||
|
||||
internal trait Tr {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
internal abstract fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -1950,6 +1950,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/controlStructures"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("commonSupertypeOfT.kt")
|
||||
public void testCommonSupertypeOfT() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/controlStructures/commonSupertypeOfT.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("emptyIf.kt")
|
||||
public void testEmptyIf() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/controlStructures/emptyIf.kt");
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||
@@ -223,12 +223,14 @@ public class CommonSupertypes {
|
||||
nullable |= type.isMarkedNullable();
|
||||
}
|
||||
|
||||
// TODO : attributes?
|
||||
JetScope newScope = JetScope.Empty.INSTANCE$;
|
||||
DeclarationDescriptor declarationDescriptor = constructor.getDeclarationDescriptor();
|
||||
ClassifierDescriptor declarationDescriptor = constructor.getDeclarationDescriptor();
|
||||
if (declarationDescriptor instanceof ClassDescriptor) {
|
||||
newScope = ((ClassDescriptor) declarationDescriptor).getMemberScope(newProjections);
|
||||
}
|
||||
else if (declarationDescriptor instanceof TypeParameterDescriptor) {
|
||||
newScope = ((TypeParameterDescriptor) declarationDescriptor).getUpperBoundsAsType().getMemberScope();
|
||||
}
|
||||
return new JetTypeImpl(Annotations.EMPTY, constructor, nullable, newProjections, newScope);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user