Match error in backend using Java defined annotation with default parameters
See original GitHub issueWhile trying to compile the compiler-benchmark with Dotty I hit on a match error in the backend
[error] Error while emitting ColdDotcBenchmark.scala
[error] Block(List(ValDef(warmups$1,TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,scala)),Nothing)],Select(Ident(Fork),$lessinit$greater$default$2)), ValDef(jvm$1,TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,scala)),Nothing)],Select(Ident(Fork),$lessinit$greater$default$3)), ValDef(jvmArgs$1,TypeTree[RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,scala)),Array), scala$Array$$T, TypeAlias(TypeRef(ThisType(TypeRef(NoPrefix,lang)),String), 0))],Apply(Apply(TypeApply(Select(Ident(Array),apply),List(TypeTree[TypeVar(ParamRef(scala$Array$apply$$T) -> TypeRef(ThisType(TypeRef(NoPrefix,lang)),String))])),List(SeqLiteral(List(Literal(Constant(-XX:CICompilerCount=2))),TypeTree[TypeVar(ParamRef(scala$Array$apply$$T) -> TypeRef(ThisType(TypeRef(NoPrefix,lang)),String))]))),List(Apply(TypeApply(Select(Ident(ClassTag),apply),List(TypeTree[TypeVar(ParamRef(scala$Array$apply$$T) -> TypeRef(ThisType(TypeRef(NoPrefix,lang)),String))])),List(Literal(Constant(TypeRef(ThisType(TypeRef(NoPrefix,lang)),String)))))))), ValDef(jvmArgsPrepend$1,TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,scala)),Nothing)],Select(Ident(Fork),$lessinit$greater$default$5))),Apply(Select(New(TypeTree[TypeRef(TermRef(TermRef(TermRef(TermRef(ThisType(TypeRef(NoPrefix,<root>)),org)/withSig(Signature(List(),)),openjdk)/withSig(Signature(List(),)),jmh)/withSig(Signature(List(),)),annotations)/withSig(Signature(List(),)),Fork)]),<init>),List(Literal(Constant(16)), Select(This(Ident(ColdDotcBenchmark)),warmups$1), Select(This(Ident(ColdDotcBenchmark)),jvm$1), Select(This(Ident(ColdDotcBenchmark)),jvmArgs$1), Select(This(Ident(ColdDotcBenchmark)),jvmArgsPrepend$1), Select(Ident(Fork),$lessinit$greater$default$6)))) (of class dotty.tools.dotc.ast.Trees$Block)
scala.MatchError: Block(List(ValDef(warmups$3,TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,scala)),Nothing)],Select(Ident(Fork),$lessinit$greater$default$2)), ValDef(jvm$3,TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,scala)),Nothing)],Select(Ident(Fork),$lessinit$greater$default$3)), ValDef(jvmArgs$3,TypeTree[RefinedType(TypeRef(ThisType(TypeRef(NoPrefix,scala)),Array), scala$Array$$T, TypeAlias(TypeRef(ThisType(TypeRef(NoPrefix,lang)),String), 0))],Apply(Apply(TypeApply(Select(Ident(Array),apply),List(TypeTree[TypeVar(ParamRef(scala$Array$apply$$T) -> TypeRef(ThisType(TypeRef(NoPrefix,lang)),String))])),List(SeqLiteral(List(Literal(Constant(-XX:CICompilerCount=2))),TypeTree[TypeVar(ParamRef(scala$Array$apply$$T) -> TypeRef(ThisType(TypeRef(NoPrefix,lang)),String))]))),List(Apply(TypeApply(Select(Ident(ClassTag),apply),List(TypeTree[TypeVar(ParamRef(scala$Array$apply$$T) -> TypeRef(ThisType(TypeRef(NoPrefix,lang)),String))])),List(Literal(Constant(TypeRef(ThisType(TypeRef(NoPrefix,lang)),String)))))))), ValDef(jvmArgsPrepend$3,TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,scala)),Nothing)],Select(Ident(Fork),$lessinit$greater$default$5))),Apply(Select(New(TypeTree[TypeRef(TermRef(TermRef(TermRef(TermRef(ThisType(TypeRef(NoPrefix,<root>)),org)/withSig(Signature(List(),)),openjdk)/withSig(Signature(List(),)),jmh)/withSig(Signature(List(),)),annotations)/withSig(Signature(List(),)),Fork)]),<init>),List(Literal(Constant(16)), Select(This(Ident(ColdScalacBenchmark)),warmups$3), Select(This(Ident(ColdScalacBenchmark)),jvm$3), Select(This(Ident(ColdScalacBenchmark)),jvmArgs$3), Select(This(Ident(ColdScalacBenchmark)),jvmArgsPrepend$3), Select(Ident(Fork),$lessinit$greater$default$6)))) (of class dotty.tools.dotc.ast.Trees$Block)
at dotty.tools.backend.jvm.DottyBackendInterface.assocsFromApply(DottyBackendInterface.scala:530)
at dotty.tools.backend.jvm.DottyBackendInterface$$anon$10.assocs(DottyBackendInterface.scala:521)
at dotty.tools.backend.jvm.DottyBackendInterface.emitAnnotations$$anonfun$6(DottyBackendInterface.scala:306)
With -Xprint:all
[info] result of /Users/ollie/dev/compiler-benchmark/compilation/src/main/scala/dotty/tools/dotc/ColdDotcBenchmark.scala after genBCode:
[info]
[info] package dotty.tools.dotc {
[info] @scala.annotation.internal.SourceFile(
[info] "/Users/ollie/dev/compiler-benchmark/compilation/src/main/scala/dotty/tools/dotc/ColdDotcBenchmark.scala"
[info] ) @{
[info] <accessor> val warmups$1: Nothing =
[info] org.openjdk.jmh.annotations.Fork.$lessinit$greater$default$2
[info] <accessor> val jvm$1: Nothing =
[info] org.openjdk.jmh.annotations.Fork.$lessinit$greater$default$3
[info] <accessor> val jvmArgs$1: Array{scala$Array$$T = String} =
[info] Array.apply[String^](["-XX:CICompilerCount=2" : String^])(
[info] scala.reflect.ClassTag.apply[String^](classOf[class String])
[info] )
[info] <accessor> val jvmArgsPrepend$1: Nothing =
[info] org.openjdk.jmh.annotations.Fork.$lessinit$greater$default$5
[info] new org.openjdk.jmh.annotations.Fork(16,
[info] dotty.tools.dotc.ColdDotcBenchmark.this.warmups$1
[info] , dotty.tools.dotc.ColdDotcBenchmark.this.jvm$1,
[info] dotty.tools.dotc.ColdDotcBenchmark.this.jvmArgs$1
[info] , dotty.tools.dotc.ColdDotcBenchmark.this.jvmArgsPrepend$1,
[info] org.openjdk.jmh.annotations.Fork.$lessinit$greater$default$6
[info] )
[info] } @org.openjdk.jmh.annotations.OutputTimeUnit(MILLISECONDS) @
[info] org.openjdk.jmh.annotations.BenchmarkMode
[info] (
[info] Array.apply[org.openjdk.jmh.annotations.Mode^](
[info] [SingleShotTime : org.openjdk.jmh.annotations.Mode^]
[info] )(
[info] scala.reflect.ClassTag.apply[org.openjdk.jmh.annotations.Mode^](
[info] classOf[class Mode]
[info] )
[info] )
[info] ) @org.openjdk.jmh.annotations.State(Benchmark) class ColdDotcBenchmark
[info] extends
[info] base.BaseDotcBenchmark {
[info] def <init>(): Unit =
[info] {
[info] super()
[info] ()
[info] }
[info] @org.openjdk.jmh.annotations.Benchmark() override def compile(): Unit =
[info] super.compile()
[info] }
[info] }
[info]
The source file where the error happens ColdDotcBenchmark.scala: https://github.com/lampepfl/compiler-benchmark/blob/82392bc30df11946cb489d45afc2698e3b48bced/compilation/src/main/scala/dotty/tools/dotc/ColdDotcBenchmark.scala#L10-L18
The @Fork
annotations is defined in Java from the JMH project, https://github.com/jacek-lewandowski/jmh-jl/blob/fc92780b525f6376b2433518b3dc90a5f511feef/jmh-core/src/main/java/org/openjdk/jmh/annotations/Fork.java#L44
I made several attempts to minimize the error with Fork.java and a tiny Foo.scala but didn’t manage to reproduce. To reproduce in the environment I hit the error:
- at commit https://github.com/lampepfl/compiler-benchmark/commit/0e282a72f9a7ef4dcafcf7acacd09ecca756b66f
- git clone https://github.com/olafurpg/compiler-benchmark
- git checkout bootstrap
- run
sbt compilation/compile
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Parameter 0 of constructor in required a bean of type 'java ...
UPDATE: Your problem can be solved by removing @Component annotation and defining the bean in a configuration like this:
Read more >Get Started with Custom Error Handling in Spring Boot (Java)
Learn how to implement custom error handling logic in Spring Boot. You will see two approaches based on the @ControllerAdvice annotation.
Read more >Guide to Spring Boot REST API Error Handling - Toptal
Implement consumer-friendly support to a Spring Boot REST API by hiding implementation details and delivering easily digestible fields.
Read more >How to Handle the Incompatible Types Error in Java - Rollbar
The Java incompatible types error happens when a value assigned to a variable or returned by a method is incompatible with the one...
Read more >Java Annotations | DigitalOcean
Annotation methods can't have parameters. Annotation methods return types are limited to primitives, String, Enums, Annotation or array of these ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@olafurpg, I’ll prepare a fix to unblock you.
Yes