Skip to content

Fixed suggestions when providing generic type of self as the first parameter #529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import org.apache.tools.ant.taskdefs.condition.Os
import java.io.ByteArrayOutputStream

plugins {
id("org.jetbrains.intellij").version("1.10.0")
id("org.jetbrains.kotlin.jvm").version("1.7.22")
id("org.jetbrains.intellij").version("1.13.2")
id("de.undercouch.download").version("5.3.0")
kotlin("jvm") version "1.7.22"
}

data class BuildData(
Expand Down Expand Up @@ -266,3 +266,9 @@ project(":") {
}
}
}
dependencies {
implementation(kotlin("stdlib"))
}
repositories {
mavenCentral()
}
5 changes: 5 additions & 0 deletions src/main/java/com/tang/intellij/lua/ty/Ty.kt
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ abstract class Ty(override val kind: TyKind) : ITy {
override fun eachTopClass(fn: Processor<ITyClass>) {
when (this) {
is ITyClass -> fn.process(this)
is ITyGeneric -> {
if(this.base is ITyClass) {
fn.process(this.base as ITyClass)
}
}
is TyUnion -> {
ContainerUtil.process(getChildTypes()) {
if (it is ITyClass && !fn.process(it))
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/tang/intellij/lua/ty/TyClass.kt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ abstract class TyClass(override val className: String,
if (other == Ty.TABLE) return true
if (super.subTypeOf(other, context, strict)) return true

if (other is ITyGeneric) {
return subTypeOf(other.base, context, strict)
}

// Lazy init for superclass
this.doLazyInit(context)
// Check if any of the superclasses are type
Expand All @@ -189,7 +193,7 @@ abstract class TyClass(override val className: String,
* to be initialized. So the JVM can't run `createSerializedClass` without
* having `TyClass`, and it can't use `TyClass` without running `createSerializedClass`.
* Thus the JVM deadlocks during classloading, resulting in frozen indexing...
*
*
* Workaround this by using Kotlin lazy properties,
* so `createSerializedClass` is not run until TyClass.G is actually accessed.
*
Expand Down