diff --git a/compiler/jvm/njvmcnv.pas b/compiler/jvm/njvmcnv.pas index 11ed94868f..63d8442a2f 100644 --- a/compiler/jvm/njvmcnv.pas +++ b/compiler/jvm/njvmcnv.pas @@ -1392,7 +1392,23 @@ implementation function asis_target_specific_typecheck(node: tasisnode): boolean; var realtodef: tdef; + temp: tnode; begin + { the JVM supports loadvmtaddrnodes for interface types, but the generic + as/is code doesn't -> convert such loadvmtaddrnodes back to plain + type nodes here (they only make sense in the context of treating them + as entities loaded to store into e.g. a JLClass) } + if (node.right.resultdef.typ=classrefdef) and + is_javainterface(tclassrefdef(node.right.resultdef).pointeddef) and + (node.right.nodetype=loadvmtaddrn) and + (tloadvmtaddrnode(node.right).left.nodetype=typen) then + begin + temp:=tloadvmtaddrnode(node.right).left; + tloadvmtaddrnode(node.right).left:=nil; + node.right.free; + node.right:=temp; + end; + if not(nf_internal in node.flags) then begin { handle using normal code } diff --git a/compiler/nmem.pas b/compiler/nmem.pas index 64cc6cc21b..beb9d6832b 100644 --- a/compiler/nmem.pas +++ b/compiler/nmem.pas @@ -255,7 +255,8 @@ implementation else if not is_objcclass(left.resultdef) and not is_objcclassref(left.resultdef) and not is_javaclass(left.resultdef) and - not is_javaclassref(left.resultdef) then + not is_javaclassref(left.resultdef) and + not is_javainterface(left.resultdef) then begin if not(nf_ignore_for_wpo in flags) and (not assigned(current_procinfo) or diff --git a/compiler/pexpr.pas b/compiler/pexpr.pas index 374487e900..ba9cd842ab 100644 --- a/compiler/pexpr.pas +++ b/compiler/pexpr.pas @@ -1542,9 +1542,12 @@ implementation { class reference ? } if is_class(hdef) or is_objcclass(hdef) or - is_javaclass(hdef) then + { Java interfaces also can have loadvmtaddrnodes, + e.g. for expressions such as JLClass(intftype) } + is_java_class_or_interface(hdef) then begin - if getaddr and (token=_POINT) then + if getaddr and (token=_POINT) and + not is_javainterface(hdef) then begin consume(_POINT); { allows @Object.Method }