KT-2752: fix support of typealiases
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
package foo
|
||||
|
||||
@JsName("B") class A(val x: Int)
|
||||
|
||||
typealias B = A
|
||||
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
package foo {
|
||||
|
||||
@kotlin.js.JsName(name = "B") public final class A {
|
||||
public constructor A(/*0*/ x: kotlin.Int)
|
||||
public final val x: kotlin.Int
|
||||
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 typealias B = foo.A
|
||||
}
|
||||
@@ -301,6 +301,12 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("classAndTypealias.kt")
|
||||
public void testClassAndTypealias() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/classAndTypealias.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("classLevelMethodAndProperty.kt")
|
||||
public void testClassLevelMethodAndProperty() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/classLevelMethodAndProperty.kt");
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.resolve.constants.EnumValue
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.typeUtil.isAnyOrNullableAny
|
||||
import org.jetbrains.kotlin.types.typeUtil.makeNullable
|
||||
import org.jetbrains.kotlin.utils.DFS
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.check
|
||||
@@ -324,7 +325,7 @@ private fun ClassDescriptor.getAllSuperClassesTypesIncludeItself(): List<KotlinT
|
||||
|
||||
fun FunctionDescriptor.isEnumValueOfMethod(): Boolean {
|
||||
val methodTypeParameters = valueParameters
|
||||
val nullableString = TypeUtils.makeNullable(builtIns.stringType)
|
||||
val nullableString = builtIns.stringType.makeNullable()
|
||||
return DescriptorUtils.ENUM_VALUE_OF == name
|
||||
&& methodTypeParameters.size == 1
|
||||
&& KotlinTypeChecker.DEFAULT.isSubtypeOf(methodTypeParameters[0].type, nullableString)
|
||||
|
||||
@@ -87,7 +87,7 @@ class NameSuggestion {
|
||||
}
|
||||
|
||||
// It's a special case when an object has `invoke` operator defined, in this case we simply generate object itself
|
||||
is FakeCallableDescriptorForObject -> return suggest(descriptor.getReferencedDescriptor())
|
||||
is FakeCallableDescriptorForObject -> return suggest(descriptor.getReferencedObject())
|
||||
|
||||
// For primary constructors and constructors of native classes we generate references to containing classes
|
||||
is ConstructorDescriptor -> {
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
class C() {
|
||||
fun getInstance(): Runnable = C
|
||||
|
||||
companion object: Runnable {
|
||||
override fun run(): Unit {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun foo() = C().getInstance()
|
||||
@@ -1,7 +0,0 @@
|
||||
class GameError(msg: String) : Exception(msg) {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val e = GameError("foo")
|
||||
return if (e.getMessage() == "foo") "OK" else "fail"
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
class Foo() {
|
||||
}
|
||||
class Bar() {
|
||||
}
|
||||
|
||||
fun <T> isInstance(obj: Any?) = obj is T
|
||||
|
||||
fun <T> isInstance2(obj: Any?) = isInstance<T>(obj)
|
||||
|
||||
fun box(): String {
|
||||
if (!isInstance2<Foo>(Foo())) return "fail 1"
|
||||
if (isInstance2<Bar>(Foo())) return "fail 2"
|
||||
return "OK"
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
package foo
|
||||
|
||||
class A() {
|
||||
}
|
||||
|
||||
val a1 = Array<Int>(3)
|
||||
val a2 = Array<A>(2)
|
||||
|
||||
fun box() = if (a1[4] == null) "OK" else "fail"
|
||||
@@ -1,23 +0,0 @@
|
||||
package foo
|
||||
|
||||
class MyThrowable(message: String? = null) : Exception(message) {
|
||||
|
||||
override val message: String?
|
||||
get() = "My message: " + super.message
|
||||
|
||||
override val cause: Throwable?
|
||||
get() = super.cause ?: this
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
throw MyThrowable("test")
|
||||
} catch (t: MyThrowable) {
|
||||
if (t.cause != t) return "fail t.cause"
|
||||
if (t.message != "My message: test") return "fail t.message"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
return "fail: MyThrowable wasn't catched."
|
||||
}
|
||||
Reference in New Issue
Block a user