Open rosincc opened 1 year ago
Hi @hellsof
could you provide a more detailed example? I can reproduce the error but I'm entirely sure about what you are actually trying to do in the first place. If I create a groovy class in the compile scope (main) everything works fine.
Are you really trying to spy a class with is placed alongside your test classes?
There is no specific application scenario for the time being. When writing a demo program, this exception is reported, but no relevant records are found, and this problem is accidentally discovered when it is about to give up.
@hellsof It has something to do with the compile time groovy transformation for this extension. I'll take a closer look today.
Regards Joke
Coming across this issue as well when using thrown
with my custom Exception class in Groovy. Here's a short test case example:
class FooException extends RuntimeException {}
def exceptionThrower() { throw new FooException() }
def "Test"() {
when:
exceptionThrower()
then:
thrown(FooException)
}
This fails compilation (error below). If you swap thrown(FooException)
by thrown(RuntimeException)
compilation and test pass.
Caused by: BUG! exception in phase 'canonicalization' in source unit 'xxxxx/Test.groovy' ClassNode#getTypeClass for xxxxx.Test$FooException called before the type class is set
at io.github.joke.spockmockable.ast.visitors.MockVisitor$Visitor.extractClass(MockVisitor.java:88)
at io.github.joke.spockmockable.ast.visitors.MockVisitor$Visitor.visitClassExpression(MockVisitor.java:59)
at io.github.joke.spockmockable.ast.visitors.MockVisitor$Visitor.visitMethodCallExpression(MockVisitor.java:51)
at io.github.joke.spockmockable.ast.visitors.MockVisitor.visit(MockVisitor.java:37)
at io.github.joke.spockmockable.ast.visitors.SpecificationVisitor$Visitor.visitMethodCallExpression(SpecificationVisitor.java:37)
at io.github.joke.spockmockable.ast.visitors.SpecificationVisitor.visit(SpecificationVisitor.java:24)
at io.github.joke.spockmockable.ast.SpecificationProcessor.process(SpecificationProcessor.java:14)
at io.github.joke.spockmockable.ast.SourceUnitProcessor.lambda$process$1(SourceUnitProcessor.java:22)
at io.github.joke.spockmockable.ast.SourceUnitProcessor.process(SourceUnitProcessor.java:22)
at io.github.joke.spockmockable.ast.Processor.analyze(Processor.java:21)
at io.github.joke.spockmockable.ast.MockableASTTransformation.visit(MockableASTTransformation.java:34)
at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:271)
at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:64)
at org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:97)
at org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:76)
at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkAction.execute(AbstractDaemonCompiler.java:135)
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:49)
at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:43)
at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100)
at org.gradle.workers.internal.AbstractClassLoaderWorker.executeInClassLoader(AbstractClassLoaderWorker.java:43)
at org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:49)
at org.gradle.workers.internal.IsolatedClassloaderWorker.run(IsolatedClassloaderWorker.java:30)
at org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:87)
at org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:56)
at org.gradle.process.internal.worker.request.WorkerAction$1.call(WorkerAction.java:138)
at org.gradle.process.internal.worker.child.WorkerLogEventListener.withWorkerLoggingProtocol(WorkerLogEventListener.java:41)
at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:135)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:49)
The execution reports the following error: