dotlin-org/dotlin

java.lang.UnsupportedOperationException: Unexpected call: hashCode

Closed this issue ยท 9 comments

This error suddenly appeared. I think I had used .hashCode() before, but not sure.

I removed all my usages of .hashCode() and the error still occurs.

Using Commit: c9aa45e

Exception in thread "main" java.lang.UnsupportedOperationException: Unexpected call: hashCode
        at org.dotlin.compiler.backend.steps.ir2ast.lower.lowerings.DataClassLowering$transform$1.invoke(DataClassLowering.kt:38)
        at org.dotlin.compiler.backend.steps.ir2ast.lower.lowerings.DataClassLowering$transform$1.invoke(DataClassLowering.kt:30)
        at org.dotlin.compiler.backend.steps.ir2ast.ir.IrExpressionWithContextTransformerKt$transformExpressionsWithOptionalParent$1.visitExpressionWithContext(IrExpressionWithContextTransformer.kt:114)
        at org.dotlin.compiler.backend.steps.ir2ast.ir.IrExpressionWithContextTransformer.visitExpression(IrExpressionWithContextTransformer.kt:86)
        at org.dotlin.compiler.backend.steps.ir2ast.ir.IrExpressionWithContextTransformer.visitExpression(IrExpressionWithContextTransformer.kt:52)
        at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitDeclarationReference(IrElementTransformer.kt:188)
        at org.dotlin.compiler.backend.steps.ir2ast.ir.IrExpressionWithContextTransformer.visitDeclarationReference(IrExpressionWithContextTransformer.kt:52)
        at org.dotlin.compiler.backend.steps.ir2ast.ir.IrExpressionWithContextTransformer.visitDeclarationReference(IrExpressionWithContextTransformer.kt:52)
        at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitMemberAccess(IrElementTransformer.kt:191)
        at org.dotlin.compiler.backend.steps.ir2ast.ir.IrExpressionWithContextTransformer.visitMemberAccess(IrExpressionWithContextTransformer.kt:52)
        at org.dotlin.compiler.backend.steps.ir2ast.ir.IrExpressionWithContextTransformer.visitMemberAccess(IrExpressionWithContextTransformer.kt:52)
        at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitFunctionAccess(IrElementTransformer.kt:194)
        at org.dotlin.compiler.backend.steps.ir2ast.ir.IrExpressionWithContextTransformer.visitFunctionAccess(IrExpressionWithContextTransformer.kt:52)
        at org.dotlin.compiler.backend.steps.ir2ast.ir.IrExpressionWithContextTransformer.visitFunctionAccess(IrExpressionWithContextTransformer.kt:52)
        at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitCall(IrElementTransformer.kt:229)
        at org.dotlin.compiler.backend.steps.ir2ast.ir.IrExpressionWithContextTransformer.visitCall(IrExpressionWithContextTransformer.kt:52)
        at org.dotlin.compiler.backend.steps.ir2ast.ir.IrExpressionWithContextTransformer.visitCall(IrExpressionWithContextTransformer.kt:52)
        at org.jetbrains.kotlin.ir.expressions.IrCall.accept(IrCall.kt:25)
        at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:28)
        at org.jetbrains.kotlin.ir.declarations.IrVariable.transformChildren(IrVariable.kt:44)
        at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitDeclaration(IrElementTransformer.kt:103)
        at org.dotlin.compiler.backend.steps.ir2ast.ir.IrExpressionWithContextTransformer.visitDeclaration(IrExpressionWithContextTransformer.kt:78)
        at org.dotlin.compiler.backend.steps.ir2ast.ir.IrExpressionWithContextTransformer.visitDeclaration(IrExpressionWithContextTransformer.kt:52)
        at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitVariable(IrElementTransformer.kt:156)
        at org.dotlin.compiler.backend.steps.ir2ast.ir.IrExpressionWithContextTransformer.visitVariable(IrExpressionWithContextTransformer.kt:52)
        at org.dotlin.compiler.backend.steps.ir2ast.ir.IrExpressionWithContextTransformer.visitVariable(IrExpressionWithContextTransformer.kt:52)
        at org.jetbrains.kotlin.ir.declarations.IrVariable.accept(IrVariable.kt:37)
        at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.kt:24)
        at org.jetbrains.kotlin.ir.util.TransformKt.transformInPlace(transform.kt:35)
        at org.jetbrains.kotlin.ir.expressions.IrBlockBody.transformChildren(IrBlockBody.kt:31)
        at org.dotlin.compiler.backend.steps.ir2ast.ir.IrExpressionWithContextTransformerKt.transformExpressionsWithOptionalParent(IrExpressionWithContextTransformer.kt:107)
        at org.dotlin.compiler.backend.steps.ir2ast.ir.IrExpressionWithContextTransformerKt.transformExpressions(IrExpressionWithContextTransformer.kt:129)
        at org.dotlin.compiler.backend.steps.ir2ast.lower.lowerings.DataClassLowering.transform(DataClassLowering.kt:30)
        at org.dotlin.compiler.backend.steps.ir2ast.lower.IrDeclarationLowering$lower$1.invoke(IrLowering.kt:88)
        at org.dotlin.compiler.backend.steps.ir2ast.lower.IrDeclarationLowering$lower$1.invoke(IrLowering.kt:88)
        at org.dotlin.compiler.backend.steps.ir2ast.lower.IrDeclarationLowering$transformDeclarations$1.invoke(IrLowering.kt:61)
        at org.dotlin.compiler.backend.steps.ir2ast.lower.IrDeclarationLowering$transformDeclarations$1.invoke(IrLowering.kt:61)
        at org.dotlin.compiler.backend.steps.ir2ast.lower.IrLoweringKt.transformBy(IrLowering.kt:150)
        at org.dotlin.compiler.backend.steps.ir2ast.lower.IrDeclarationLowering$DefaultImpls.transformDeclarations(IrLowering.kt:61)
        at org.dotlin.compiler.backend.steps.ir2ast.lower.IrDeclarationLowering$DefaultImpls.lower(IrLowering.kt:88)
        at org.dotlin.compiler.backend.steps.ir2ast.lower.lowerings.DataClassLowering.lower(DataClassLowering.kt:23)
        at org.dotlin.compiler.backend.steps.ir2ast.lower.LowerKt.lower(Lower.kt:123)
        at org.dotlin.compiler.backend.steps.ir2ast.lower.LowerKt.lower(Lower.kt:102)
        at org.dotlin.compiler.backend.steps.ir2ast.IrToDartAstKt.irToDartAst(IrToDartAst.kt:47)
        at org.dotlin.compiler.KotlinToDartCompiler.generateDartCode(KotlinToDartCompiler.kt:173)
        at org.dotlin.compiler.KotlinToDartCompiler.compile(KotlinToDartCompiler.kt:103)
        at org.dotlin.compiler.KotlinToDartCompiler.compile$default(KotlinToDartCompiler.kt:83)
        at org.dotlin.compiler.KotlinToDartCompiler.compile(KotlinToDartCompiler.kt:78)
        at org.dotlin.compiler.cli.command.Compile.run(Compile.kt:37)
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:198)
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:18)
        at com.github.ajalt.clikt.core.CliktCommand.parse(CliktCommand.kt:400)
        at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:397)
        at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:415)
        at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:440)
        at org.dotlin.compiler.Dotlin.main(Main.kt:26)

It seems to be because of a data class, which has certain contents in hashCode it did not expect. So indeed either you overridden hashCode in a data class, or something about your data class made it generate the hashCode in a different way I didn't anticipate ๐Ÿค”

Do you know maybe which data class in your code could cause this? In any case I probably have to fix the first case (overridden hashCode in data class)

To my knowledge I don't override hashCode in my data classes, they are really only data containers, nothing more.
I do have interfaces that override hashCode and then the classes that implement them.
But I disabled all of them for testing and the error still occurred. Maybe I overlooked a place ...

I see ๐Ÿค” Well, I'll add a test for explicitly overriding the hashCode in a data class, and maybe it fixes your case ๐Ÿ‘

Should be fixed with 341e31b, can you verify it works for you? If it does it means hashCode was overridden somewhere ๐Ÿ˜„

I checked again and temporarily removed every hashCode occurrence. Error persists.

I updated to 34... and the error still occurs :(

I see ๐Ÿค” The repo is on Github right? Which one is it? Then I can look for suspicious data classes ๐Ÿ˜„

Yep, the Kotlin repo is https://github.com/eggnstone/DartFormatJetbrainsPlugin

But I pull only a few specific classes into https://github.com/eggnstone/dart_format
with https://github.com/eggnstone/dart_format/blob/master/dotlin.sh
which then also calls dotlin-compiler.

Thanks! Found the issue, fixed it at e6d47a9, pretty sure it should work for you now, can you confirm?

Well, this error is gone but there's a new one :)

Exception in thread "main" kotlin.NotImplementedError: An operation is not implemented: IrBlockImpl is not supported
        at org.dotlin.compiler.backend.steps.ir2ast.ir.IrUtilsKt.todo(IrUtils.kt:261)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartExpressionTransformer.visitBlock(IrToDartExpression.kt:630)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartExpressionTransformer.visitBlock(IrToDartExpression.kt:53)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitBlock(IrDartAstTransformer.kt:47)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitBlock(IrDartAstTransformer.kt:30)
        at org.jetbrains.kotlin.ir.expressions.IrBlock.accept(IrBlock.kt:22)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartExpressionKt.accept(IrToDartExpression.kt:647)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartExpressionTransformer.visitTypeOperator(IrToDartExpression.kt:446)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartExpressionTransformer.visitTypeOperator(IrToDartExpression.kt:53)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitTypeOperator(IrDartAstTransformer.kt:522)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitTypeOperator(IrDartAstTransformer.kt:30)
        at org.jetbrains.kotlin.ir.expressions.IrTypeOperatorCall.accept(IrTypeOperatorCall.kt:30)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartExpressionKt.accept(IrToDartExpression.kt:647)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementTransformer.visitExpression(IrToDartStatement.kt:288)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementTransformer.visitExpression(IrToDartStatement.kt:55)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitExpression(IrDartAstTransformer.kt:572)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitExpression(IrDartAstTransformer.kt:30)
        at org.jetbrains.kotlin.ir.visitors.IrElementVisitor$DefaultImpls.visitTypeOperator(IrElementVisitor.kt:300)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitTypeOperator(IrDartAstTransformer.kt:525)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitTypeOperator(IrDartAstTransformer.kt:522)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitTypeOperator(IrDartAstTransformer.kt:30)
        at org.jetbrains.kotlin.ir.expressions.IrTypeOperatorCall.accept(IrTypeOperatorCall.kt:30)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementKt.acceptAsStatement(IrToDartStatement.kt:347)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementTransformer.visitWhen(IrToDartStatement.kt:84)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementTransformer.visitWhen(IrToDartStatement.kt:55)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitWhen(IrDartAstTransformer.kt:560)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitWhen(IrDartAstTransformer.kt:30)
        at org.jetbrains.kotlin.ir.expressions.IrWhen.accept(IrWhen.kt:25)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementKt.accept(IrToDartStatement.kt:345)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementKt.accept(IrToDartStatement.kt:346)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementTransformer.visitBlock(IrToDartStatement.kt:282)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementTransformer.visitBlock(IrToDartStatement.kt:55)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitBlock(IrDartAstTransformer.kt:47)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitBlock(IrDartAstTransformer.kt:30)
        at org.jetbrains.kotlin.ir.expressions.IrBlock.accept(IrBlock.kt:22)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementKt.accept(IrToDartStatement.kt:345)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementTransformer.visitBlock(IrToDartStatement.kt:281)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementTransformer.visitBlock(IrToDartStatement.kt:55)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitBlock(IrDartAstTransformer.kt:47)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitBlock(IrDartAstTransformer.kt:30)
        at org.jetbrains.kotlin.ir.expressions.IrBlock.accept(IrBlock.kt:22)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementKt.acceptAsStatement(IrToDartStatement.kt:347)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementTransformer$visitBlock$body$2.invoke(IrToDartStatement.kt:173)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementTransformer$visitBlock$body$2.invoke(IrToDartStatement.kt:173)
        at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementTransformer.visitBlock$lambda$8(IrToDartStatement.kt:173)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementTransformer.visitBlock(IrToDartStatement.kt:241)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementTransformer.visitBlock(IrToDartStatement.kt:55)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitBlock(IrDartAstTransformer.kt:47)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitBlock(IrDartAstTransformer.kt:30)
        at org.jetbrains.kotlin.ir.expressions.IrBlock.accept(IrBlock.kt:22)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementKt.accept(IrToDartStatement.kt:345)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartStatementKt.accept(IrToDartStatement.kt:346)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartFunctionBodyTransformer.visitBlockBody(IrToDartFunctionBody.kt:45)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartFunctionBodyTransformer.visitBlockBody(IrToDartFunctionBody.kt:33)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitBlockBody(IrDartAstTransformer.kt:53)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitBlockBody(IrDartAstTransformer.kt:30)
        at org.jetbrains.kotlin.ir.expressions.IrBlockBody.accept(IrBlockBody.kt:24)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartFunctionBodyKt.accept(IrToDartFunctionBody.kt:62)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartFunctionBodyKt.accept$default(IrToDartFunctionBody.kt:59)
        at org.dotlin.compiler.backend.steps.ir2ast.DartAstTransformContext.transformBy(DartAstTransformContext.kt:70)
        at org.dotlin.compiler.backend.steps.ir2ast.DartAstTransformContext.transformBy(DartAstTransformContext.kt:93)
        at org.dotlin.compiler.backend.steps.ir2ast.DartAstTransformContext.transformBy$default(DartAstTransformContext.kt:89)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartClassMemberTransformer.visitSimpleFunction(IrToDartClassMember.kt:49)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartClassMemberTransformer.visitSimpleFunction(IrToDartClassMember.kt:46)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitSimpleFunction(IrDartAstTransformer.kt:453)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitSimpleFunction(IrDartAstTransformer.kt:30)
        at org.jetbrains.kotlin.ir.declarations.IrSimpleFunction.accept(IrSimpleFunction.kt:36)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartClassMemberKt.acceptAsClassMember(IrToDartClassMember.kt:192)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartDeclarationTransformer$visitClass$members$3.invoke(IrToDartDeclaration.kt:147)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartDeclarationTransformer$visitClass$members$3.invoke(IrToDartDeclaration.kt:147)
        at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:210)
        at kotlin.sequences.SequencesKt___SequencesKt.toCollection(_Sequences.kt:787)
        at kotlin.sequences.SequencesKt___SequencesKt.toMutableList(_Sequences.kt:817)
        at kotlin.sequences.SequencesKt___SequencesKt.toList(_Sequences.kt:808)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartDeclarationTransformer.visitClass(IrToDartDeclaration.kt:148)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartDeclarationTransformer.visitClass(IrToDartDeclaration.kt:42)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitClass(IrDartAstTransformer.kt:97)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitClass(IrDartAstTransformer.kt:30)
        at org.jetbrains.kotlin.ir.declarations.IrClass.accept(IrClass.kt:64)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartDeclarationKt.accept(IrToDartDeclaration.kt:224)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartCompilationUnitTransformer.visitFile(IrToDartCompilationUnit.kt:36)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrToDartCompilationUnitTransformer.visitFile(IrToDartCompilationUnit.kt:32)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitFile(IrDartAstTransformer.kt:282)
        at org.dotlin.compiler.backend.steps.ir2ast.transformer.IrDartAstTransformer.visitFile(IrDartAstTransformer.kt:30)
        at org.jetbrains.kotlin.ir.declarations.IrFile.accept(IrFile.kt:30)
        at org.dotlin.compiler.backend.steps.ir2ast.IrToDartAstKt.irToDartAst(IrToDartAst.kt:66)
        at org.dotlin.compiler.KotlinToDartCompiler.generateDartCode(KotlinToDartCompiler.kt:173)
        at org.dotlin.compiler.KotlinToDartCompiler.compile(KotlinToDartCompiler.kt:103)
        at org.dotlin.compiler.KotlinToDartCompiler.compile$default(KotlinToDartCompiler.kt:83)
        at org.dotlin.compiler.KotlinToDartCompiler.compile(KotlinToDartCompiler.kt:78)
        at org.dotlin.compiler.cli.command.Compile.run(Compile.kt:37)
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:198)
        at com.github.ajalt.clikt.parsers.Parser.parse(Parser.kt:18)
        at com.github.ajalt.clikt.core.CliktCommand.parse(CliktCommand.kt:400)
        at com.github.ajalt.clikt.core.CliktCommand.parse$default(CliktCommand.kt:397)
        at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:415)
        at com.github.ajalt.clikt.core.CliktCommand.main(CliktCommand.kt:440)
        at org.dotlin.compiler.Dotlin.main(Main.kt:26)