pbyrne84 / DynamicReturnTypePlugin

135 stars 7 forks source link

Exception: PhpClassImpl$MyRenamableFakePsiElement cannot be cast to com.jetbrains.php.lang.psi.elements.impl.FieldImpl #39

Closed mirow closed 9 years ago

mirow commented 9 years ago

I get this is error in several of my projects: "com.jetbrains.php.lang.psi.elements.impl.PhpClassImpl$MyRenamableFakePsiElement cannot be cast to com.jetbrains.php.lang.psi.elements.impl.FieldImpl"

I've tried locate the actual line in my code which causes the exception, but I'm unable to find it... Here is the configuration I'm using: { "methodCalls": [ { "class": "\Registry", "method": "get", "position": 0 }, { "class": "\mapper", "method": "cloneItem", "position": 0 }, { "class": "\mapper", "method": "save", "position": 0 }, { "class": "\mapper", "method": "xmlEscape", "position": 0 } ], "functionCalls": [ { "function": "\get", "position": 0 } ] }

Stack trace: java.lang.ClassCastException: com.jetbrains.php.lang.psi.elements.impl.PhpClassImpl$MyRenamableFakePsiElement cannot be cast to com.jetbrains.php.lang.psi.elements.impl.FieldImpl at com.ptby.dynamicreturntypeplugin.index.OriginalCallAnalyzer.getFieldInstanceOriginalReturnType(OriginalCallAnalyzer.kt:46) at com.ptby.dynamicreturntypeplugin.index.FieldReferenceAnalyzer.getClassNameFromFieldLookup(FieldReferenceAnalyzer.kt:37) at com.ptby.dynamicreturntypeplugin.signatureconversion.CustomSignatureProcessor.processSignature(CustomSignatureProcessor.kt:48) at com.ptby.dynamicreturntypeplugin.signatureconversion.CustomSignatureProcessor.getBySignature(CustomSignatureProcessor.kt:28) at com.ptby.dynamicreturntypeplugin.DynamicReturnTypeProvider.processSingleSignature(DynamicReturnTypeProvider.kt:126) at com.ptby.dynamicreturntypeplugin.DynamicReturnTypeProvider.getBySignature(DynamicReturnTypeProvider.kt:106) at com.jetbrains.php.PhpIndexImpl.getBySignatureInternal(PhpIndexImpl.java:436)

pbyrne84 commented 9 years ago

It now casts to the interface that this class shares with the FieldImpl which was causing the issues, there is a jar here https://github.com/pbyrne84/DynamicReturnTypePlugin/raw/master/deploy/DynamicReturnTypePlugin.zip

That you can unzip and replace over the old one. I think MyRenamableFakePsiElement is newish and I am not sure what it does as your bug report is the only reference on the internet at the moment for it. It should have no side effects but if it does let me know.

I will do a proper publish if it fixes the problem.

Thanks.

mirow commented 9 years ago

It seems to work, no more exceptions.

pbyrne84 commented 9 years ago

Ooh nice.

I'll do a release tomorrow as it is getting pretty late now.

Thanks

pbyrne84 commented 9 years ago

Released. Cheers for the report. I only ever experienced it once and I thought is had gone away ( I got it in an EA)