Skip to content

Commit

Permalink
Allow subclass of T to assign to Class<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
m0rkeulv committed Oct 15, 2023
1 parent 2b48243 commit 0b74a07
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.intellij.plugins.haxe.model.HaxeMemberModel;
import com.intellij.plugins.haxe.model.HaxeMethodModel;
import com.intellij.plugins.haxe.util.HaxeResolveUtil;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -561,6 +562,22 @@ private static boolean handleClassType(SpecificHaxeClassReference to, SpecificHa

if (from.isEnumClass()) return false;
if(!from.isContextAType()) return false;
// if from is literal class name
if (to.isClass() && from.context.getText().equals(from.getHaxeClass().getName())){
SpecificHaxeClassReference expectedType = to.getSpecifics()[0].getClassType();
boolean sameClass = canAssignToFromSpecificType(expectedType, from);
if (sameClass) {
return true;
} else {
// check if "from" class extends "to" class
PsiClass[] supers = from.getHaxeClass().getSupers();
for (PsiClass haxeType : supers) {
if (haxeType instanceof HaxeClass haxeClass) {
if (expectedType.getHaxeClass() == haxeClass) return true;
}
}
}
}

if(specificsTo.length != specificsFrom.length) return false;
if(specificsTo.length == 0) return false;
Expand Down

0 comments on commit 0b74a07

Please sign in to comment.