Open tpolecat opened 7 years ago
Oh dear! I haven't seen this one yet. Stack traces I've seen so far are https://github.com/fthomas/refined/issues/3 and https://github.com/scalacenter/scalafix/issues/47.
@tpolecat I've just released refined 0.8.0 which contains a potential fix for these compiler crashes. If you see them again after the upgrade, please reopen this issue.
Will do, still seeing it with 0.7. I'll let you know. Thanks!
Sadly this is still happening. Only in 2.11, if that helps. It always compiles ok in 2.10 and 2.12.
(I am unable to re-open.)
This isn't fixed, but because of #332 and #334 these crashes will hopefully happen less often since we now try to avoid calling scala.reflect.macros.contexts.Context.eval
if possible.
I have started seeing this as well (refined 0.9.0).
All I have been able to notice is that a slower build slave seems to run into this more often. But that may be purely coincidental.
[error] java.lang.AssertionError: assertion failed: import failure: cannot determine unique overloaded method alternative from
[error] final package eu
[error] final package eu
[error] that matches package eu:eu.type
[error] at scala.reflect.internal.Importers$StandardImporter.disambiguate$1(Importers.scala:183)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:188)
[error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:210)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:169)
[error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:210)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:166)
[error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:210)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:166)
[error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:210)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:166)
[error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:210)
[error] at scala.reflect.internal.Importers$StandardImporter.recreatedTreeCompleter(Importers.scala:298)
[error] at scala.reflect.internal.Importers$StandardImporter.$anonfun$importTree$1(Importers.scala:417)
[error] at scala.reflect.internal.Importers$StandardImporter.tryFixup(Importers.scala:49)
[error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:418)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:383)
[error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:415)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:383)
[error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:415)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:367)
[error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:415)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:370)
[error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:415)
[error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:29)
[error] at scala.reflect.macros.contexts.Evals.eval(Evals.scala:19)
[error] at scala.reflect.macros.contexts.Evals.eval$(Evals.scala:14)
[error] at scala.reflect.macros.contexts.Context.eval(Context.scala:6)
[error] at eu.timepit.refined.macros.MacroUtils.$anonfun$eval$1(MacroUtils.scala:24)
[error] at scala.Option.getOrElse(Option.scala:121)
[error] at eu.timepit.refined.macros.MacroUtils.tryN(MacroUtils.scala:28)
[error] at eu.timepit.refined.macros.MacroUtils.tryN$(MacroUtils.scala:27)
[error] at eu.timepit.refined.macros.RefineMacro.tryN(RefineMacro.scala:11)
[error] at eu.timepit.refined.macros.MacroUtils.eval(MacroUtils.scala:24)
[error] at eu.timepit.refined.macros.MacroUtils.eval$(MacroUtils.scala:17)
[error] at eu.timepit.refined.macros.RefineMacro.eval(RefineMacro.scala:11)
[error] at eu.timepit.refined.macros.RefineMacro.$anonfun$validateInstance$1(RefineMacro.scala:57)
[error] at scala.Option.getOrElse(Option.scala:121)
[error] at eu.timepit.refined.macros.RefineMacro.validateInstance(RefineMacro.scala:57)
[error] at eu.timepit.refined.macros.RefineMacro.impl(RefineMacro.scala:27)
[error] at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
[error] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] at java.lang.reflect.Method.invoke(Method.java:498)
[error] at scala.reflect.macros.runtime.JavaReflectionRuntimes$JavaReflectionResolvers.$anonfun$resolveJavaReflectionRuntime$4(JavaReflectionRuntimes.scala:34)
[error] at scala.tools.nsc.typechecker.Macros.macroExpandWithRuntime(Macros.scala:772)
@NeQuissimus Do you know the predicate for which the macro is called in this case? If it is provided by the library, we can fix this for this particular predicate by adding the appropriate Validate
instance to https://github.com/fthomas/refined/blob/master/modules/core/shared/src/main/scala/eu/timepit/refined/macros/RefineMacro.scala#L59.
@fthomas I had multiple of these, I can look them up tomorrow.
Alright, so I had the following instances over the last couple of days:
"_"
and "A"
refinement into type ShortString = String Refined (NonEmpty And MaxSize[W.
255.T])
"0.0.0.0"
into type IPAddress = String Refined (IPv4 Or IPv6)
"2018-05-21T00:50:00.239Z"
into type ISO8601 = String Refined MatchesRegex[ W.`"^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(\\\\.[0-9]+)?(Z)?$"`.T]
None of these are built-in, I suppose :(
@NeQuissimus They are not primitive predicates but composed of primitive predicates that are defined by the library so in principle we could add their Validate
instances to the cache of precomputed instances. But this is an ugly band-aid and I'd much prefer an actual solution for this problem. I'll try again to find a more general fix.
I just received the same error compiling this exact file: https://github.com/oleg-py/arcomage-challenge/blob/d47b70cfb5521ad22bab88488c830d69569c0da6/core/src/main/scala/ac/game/GameConditions.scala
It only uses Greater
refinement and automatic conversions. Restarting sbt made the problem go away.
I'm seeing this in the Scala community build at https://github.com/scala/community-build/issues/1039
I've just read this comment by @retronym in https://github.com/scala/bug/issues/9218#issuecomment-565285839:
class Predicate[A, B] {
self => // self type needed to trigger the bug
}
I think we can get rid of the self type in Validate
and if we're lucky not trigger this bug anymore. That would be wonderful!
The self type is now gone in 0.9.12. If anyone observes this compiler crash with 0.9.12 or a newer version, please leave a comment here.
The self type is now gone in 0.9.12. If anyone observes this compiler crash with 0.9.12 or a newer version, please leave a comment here.
Hey, just saw it again with 0.9.12
and scalaVersion := "2.12.10"
Seeing this on 2.12.11, refined 0.9.12
I'm seeing the following error on Jenkins with Scala 2.13.1 and Refined 0.9.14:
[2020-05-01T17:08:29.858Z] [error] /home/jenkins/workspace/ization_Kerna_build-kerna_PR-546/mongo/src/main/scala/com/rallyhealth/mongo/models/InferenceType.scala:62:58: exception during macro expansion:
[2020-05-01T17:08:29.858Z] [error] java.lang.AssertionError: assertion failed: import failure: cannot determine unique overloaded method alternative from
[2020-05-01T17:08:29.858Z] [error] final package eu
[2020-05-01T17:08:29.858Z] [error] final package eu
[2020-05-01T17:08:29.858Z] [error] that matches package eu:eu.type
[2020-05-01T17:08:29.858Z] [error] at scala.reflect.internal.SymbolTable.throwAssertionError(SymbolTable.scala:170)
[2020-05-01T17:08:29.858Z] [error] at scala.reflect.internal.Importers$StandardImporter.disambiguate$1(Importers.scala:195)
[2020-05-01T17:08:29.858Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:200)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:181)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:178)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:178)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:178)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreatedTreeCompleter(Importers.scala:310)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.$anonfun$importTree$1(Importers.scala:429)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.tryFixup(Importers.scala:61)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:430)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:395)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:427)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:395)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:427)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:379)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:427)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:382)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:427)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:41)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.macros.contexts.Evals.eval(Evals.scala:31)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.macros.contexts.Evals.eval$(Evals.scala:26)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.macros.contexts.Context.eval(Context.scala:18)
[2020-05-01T17:08:29.859Z] [error] at eu.timepit.refined.macros.MacroUtils.$anonfun$eval$1(MacroUtils.scala:22)
[2020-05-01T17:08:29.859Z] [error] at scala.Option.getOrElse(Option.scala:201)
[2020-05-01T17:08:29.859Z] [error] at eu.timepit.refined.macros.MacroUtils.tryN(MacroUtils.scala:26)
[2020-05-01T17:08:29.859Z] [error] at eu.timepit.refined.macros.MacroUtils.tryN$(MacroUtils.scala:25)
[2020-05-01T17:08:29.859Z] [error] at eu.timepit.refined.macros.RefineMacro.tryN(RefineMacro.scala:10)
[2020-05-01T17:08:29.859Z] [error] at eu.timepit.refined.macros.MacroUtils.eval(MacroUtils.scala:22)
[2020-05-01T17:08:29.859Z] [error] at eu.timepit.refined.macros.MacroUtils.eval$(MacroUtils.scala:15)
[2020-05-01T17:08:29.859Z] [error] at eu.timepit.refined.macros.RefineMacro.eval(RefineMacro.scala:10)
[2020-05-01T17:08:29.859Z] [error] at eu.timepit.refined.macros.RefineMacro.$anonfun$validateInstance$2(RefineMacro.scala:55)
[2020-05-01T17:08:29.859Z] [error] at scala.Option.getOrElse(Option.scala:201)
[2020-05-01T17:08:29.859Z] [error] at eu.timepit.refined.macros.RefineMacro.validateInstance(RefineMacro.scala:55)
[2020-05-01T17:08:29.859Z] [error] at eu.timepit.refined.macros.RefineMacro.impl(RefineMacro.scala:25)
[2020-05-01T17:08:29.859Z] [error] at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
[2020-05-01T17:08:29.859Z] [error] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[2020-05-01T17:08:29.859Z] [error] at java.lang.reflect.Method.invoke(Method.java:498)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.macros.runtime.JavaReflectionRuntimes$JavaReflectionResolvers.$anonfun$resolveJavaReflectionRuntime$5(JavaReflectionRuntimes.scala:45)
[2020-05-01T17:08:29.859Z] [error] at scala.tools.nsc.typechecker.Macros.macroExpandWithRuntime(Macros.scala:758)
[2020-05-01T17:08:29.859Z] [error] s"Cannot find InferenceType with ${LogView.withKey("id", id)}, valid options are $validValuesString (${pos.show})"
[2020-05-01T17:08:29.859Z] [error] ^
[2020-05-01T17:08:29.859Z] [error] /home/jenkins/workspace/ization_Kerna_build-kerna_PR-546/mongo/src/main/scala/com/rallyhealth/mongo/models/InferenceType.scala:71:20: exception during macro expansion:
[2020-05-01T17:08:29.859Z] [error] java.lang.AssertionError: assertion failed: import failure: cannot determine unique overloaded method alternative from
[2020-05-01T17:08:29.859Z] [error] final package eu
[2020-05-01T17:08:29.859Z] [error] final package eu
[2020-05-01T17:08:29.859Z] [error] that matches package eu:eu.type
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.SymbolTable.throwAssertionError(SymbolTable.scala:170)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.disambiguate$1(Importers.scala:195)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:200)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:181)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:178)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:178)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:178)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreatedTreeCompleter(Importers.scala:310)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.$anonfun$importTree$1(Importers.scala:429)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.tryFixup(Importers.scala:61)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:430)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:395)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:427)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:395)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:427)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:379)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:427)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:382)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:427)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:41)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.macros.contexts.Evals.eval(Evals.scala:31)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.macros.contexts.Evals.eval$(Evals.scala:26)
[2020-05-01T17:08:29.859Z] [error] at scala.reflect.macros.contexts.Context.eval(Context.scala:18)
[2020-05-01T17:08:29.860Z] [error] at eu.timepit.refined.macros.MacroUtils.$anonfun$eval$1(MacroUtils.scala:22)
[2020-05-01T17:08:29.860Z] [error] at scala.Option.getOrElse(Option.scala:201)
[2020-05-01T17:08:29.860Z] [error] at eu.timepit.refined.macros.MacroUtils.tryN(MacroUtils.scala:26)
[2020-05-01T17:08:29.860Z] [error] at eu.timepit.refined.macros.MacroUtils.tryN$(MacroUtils.scala:25)
[2020-05-01T17:08:29.860Z] [error] at eu.timepit.refined.macros.RefineMacro.tryN(RefineMacro.scala:10)
[2020-05-01T17:08:29.860Z] [error] at eu.timepit.refined.macros.MacroUtils.eval(MacroUtils.scala:22)
[2020-05-01T17:08:29.860Z] [error] at eu.timepit.refined.macros.MacroUtils.eval$(MacroUtils.scala:15)
[2020-05-01T17:08:29.860Z] [error] at eu.timepit.refined.macros.RefineMacro.eval(RefineMacro.scala:10)
[2020-05-01T17:08:29.860Z] [error] at eu.timepit.refined.macros.RefineMacro.$anonfun$validateInstance$2(RefineMacro.scala:55)
[2020-05-01T17:08:29.860Z] [error] at scala.Option.getOrElse(Option.scala:201)
[2020-05-01T17:08:29.860Z] [error] at eu.timepit.refined.macros.RefineMacro.validateInstance(RefineMacro.scala:55)
[2020-05-01T17:08:29.860Z] [error] at eu.timepit.refined.macros.RefineMacro.impl(RefineMacro.scala:25)
[2020-05-01T17:08:29.860Z] [error] at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
[2020-05-01T17:08:29.860Z] [error] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[2020-05-01T17:08:29.860Z] [error] at java.lang.reflect.Method.invoke(Method.java:498)
[2020-05-01T17:08:29.860Z] [error] at scala.reflect.macros.runtime.JavaReflectionRuntimes$JavaReflectionResolvers.$anonfun$resolveJavaReflectionRuntime$5(JavaReflectionRuntimes.scala:45)
[2020-05-01T17:08:29.860Z] [error] at scala.tools.nsc.typechecker.Macros.macroExpandWithRuntime(Macros.scala:758)
[2020-05-01T17:08:29.860Z] [error] .withKey("name", lowercaseName)}, valid options are $validValuesString (${pos.show})"
[2020-05-01T17:08:29.860Z] [error] ^
[2020-05-01T17:08:29.860Z] [info] String("probability_to_engage") <: com.rallyhealth.mongo.models.InferenceType.Name?
[2020-05-01T17:08:29.860Z] [info] false
[2020-05-01T17:08:29.860Z] [error] /home/jenkins/workspace/ization_Kerna_build-kerna_PR-546/mongo/src/main/scala/com/rallyhealth/mongo/models/InferenceType.scala:82:7: no arguments allowed for nullary constructor Object: ()Object
[2020-05-01T17:08:29.860Z] [error] 1,
[2020-05-01T17:08:29.860Z] [error] ^
[2020-05-01T17:08:29.860Z] [info] String("unnecessary_er_visit") <: com.rallyhealth.mongo.models.InferenceType.Name?
[2020-05-01T17:08:29.860Z] [info] false
[2020-05-01T17:08:29.860Z] [error] /home/jenkins/workspace/ization_Kerna_build-kerna_PR-546/mongo/src/main/scala/com/rallyhealth/mongo/models/InferenceType.scala:91:7: no arguments allowed for nullary constructor Object: ()Object
[2020-05-01T17:08:29.860Z] [error] 2,
[2020-05-01T17:08:29.860Z] [error] ^
[2020-05-01T17:08:29.860Z] [info] String("has_cost_estimate") <: com.rallyhealth.mongo.models.InferenceType.Name?
[2020-05-01T17:08:29.860Z] [info] false
[2020-05-01T17:08:29.860Z] [error] /home/jenkins/workspace/ization_Kerna_build-kerna_PR-546/mongo/src/main/scala/com/rallyhealth/mongo/models/InferenceType.scala:100:7: no arguments allowed for nullary constructor Object: ()Object
[2020-05-01T17:08:29.860Z] [error] 3,
[2020-05-01T17:08:29.860Z] [error] ^
[2020-05-01T17:08:29.860Z] [info] String("search_urgent_care") <: com.rallyhealth.mongo.models.InferenceType.Name?
[2020-05-01T17:08:29.860Z] [info] false
[2020-05-01T17:08:29.860Z] [error] /home/jenkins/workspace/ization_Kerna_build-kerna_PR-546/mongo/src/main/scala/com/rallyhealth/mongo/models/InferenceType.scala:110:7: no arguments allowed for nullary constructor Object: ()Object
[2020-05-01T17:08:29.860Z] [error] 4,
[2020-05-01T17:08:29.860Z] [error] ^
[2020-05-01T17:08:29.860Z] [info] String("search_behavioral_health_care") <: com.rallyhealth.mongo.models.InferenceType.Name?
[2020-05-01T17:08:29.860Z] [info] false
[2020-05-01T17:08:29.860Z] [error] /home/jenkins/workspace/ization_Kerna_build-kerna_PR-546/mongo/src/main/scala/com/rallyhealth/mongo/models/InferenceType.scala:120:7: no arguments allowed for nullary constructor Object: ()Object
[2020-05-01T17:08:29.860Z] [error] 5,
[2020-05-01T17:08:29.860Z] [error] ^
[2020-05-01T17:08:29.860Z] [info] String("last_activity_engage_app") <: com.rallyhealth.mongo.models.InferenceType.Name?
[2020-05-01T17:08:29.860Z] [info] false
[2020-05-01T17:08:29.860Z] [error] /home/jenkins/workspace/ization_Kerna_build-kerna_PR-546/mongo/src/main/scala/com/rallyhealth/mongo/models/InferenceType.scala:130:7: no arguments allowed for nullary constructor Object: ()Object
[2020-05-01T17:08:29.860Z] [error] 6,
[2020-05-01T17:08:29.860Z] [error] ^
I'm not able to reproduce it locally on sbt, so I'm not sure how to simplify the code much, but here a sample of where it seems to be choking:
object InferenceType extends IntEnum[InferenceType[InferenceShape]] {
type Name = String Refined MatchesRegex[W.`"[a-z_0-9]+"`.T]
override val values: immutable.IndexedSeq[InferenceType[InferenceShape]] = findValues
private lazy val validValuesString: String = values.map(k => s"{name: '${k.name}', id: ${k.id}}").mkString(", ")
def withId(id: Int)(implicit pos: Position): InferenceType[InferenceShape] = withValueOpt(id).getOrElse {
// XXX This is where the compiler macro is choking...
// It seems to have trouble auto refining the string "id" for the LogView.withKey method
// TBD whether being inside string interpolation is the issue...
throw new NoSuchElementException(
s"Cannot find InferenceType with ${LogView.withKey("id", id)}, valid options are $validValuesString (${pos.show})"
)
}
// ...
}
object LogKey {
type Valid = MatchesRegex[W.`"[a-zA-Z_][a-zA-Z_0-9]+"`.T]
type Name = String Refined Valid
}
object LogView {
def withKey[V](
key: LogKey.Name,
value: V
)(implicit
format: LogFormat[V]
): String = {
s"${key.value}=${format.write(value)}"
}
// ...
}
Ok, update... it works after moving the LogView.withKey
call outside of the string interpolation, however, this issue has been intermittent, so I'm not sure if it is fixed for good. I'll update this thread again if I see the issue come back.
Another update: it is still broken 😢 Moving it out of the StringContext interpolation didn't help...
[2020-05-01T20:37:47.851Z] [error] java.lang.AssertionError: assertion failed: import failure: cannot determine unique overloaded method alternative from
[2020-05-01T20:37:47.851Z] [error] final package eu
[2020-05-01T20:37:47.851Z] [error] final package eu
[2020-05-01T20:37:47.851Z] [error] that matches package eu:eu.type
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.SymbolTable.throwAssertionError(SymbolTable.scala:170)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.disambiguate$1(Importers.scala:195)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:200)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:181)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:178)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:178)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:178)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreatedTreeCompleter(Importers.scala:310)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.$anonfun$importTree$1(Importers.scala:429)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.tryFixup(Importers.scala:61)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:430)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:395)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:427)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:395)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:427)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:379)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:427)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:382)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:427)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:41)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.macros.contexts.Evals.eval(Evals.scala:31)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.macros.contexts.Evals.eval$(Evals.scala:26)
[2020-05-01T20:37:47.851Z] [error] at scala.reflect.macros.contexts.Context.eval(Context.scala:18)
[2020-05-01T20:37:47.851Z] [error] at eu.timepit.refined.macros.MacroUtils.$anonfun$eval$1(MacroUtils.scala:22)
[2020-05-01T20:37:47.851Z] [error] at scala.Option.getOrElse(Option.scala:201)
[2020-05-01T20:37:47.851Z] [error] at eu.timepit.refined.macros.MacroUtils.tryN(MacroUtils.scala:26)
[2020-05-01T20:37:47.851Z] [error] at eu.timepit.refined.macros.MacroUtils.tryN$(MacroUtils.scala:25)
[2020-05-01T20:37:47.851Z] [error] at eu.timepit.refined.macros.RefineMacro.tryN(RefineMacro.scala:10)
[2020-05-01T20:37:47.851Z] [error] at eu.timepit.refined.macros.MacroUtils.eval(MacroUtils.scala:22)
[2020-05-01T20:37:47.851Z] [error] at eu.timepit.refined.macros.MacroUtils.eval$(MacroUtils.scala:15)
[2020-05-01T20:37:47.851Z] [error] at eu.timepit.refined.macros.RefineMacro.eval(RefineMacro.scala:10)
[2020-05-01T20:37:47.851Z] [error] at eu.timepit.refined.macros.RefineMacro.$anonfun$validateInstance$2(RefineMacro.scala:55)
[2020-05-01T20:37:47.851Z] [error] at scala.Option.getOrElse(Option.scala:201)
[2020-05-01T20:37:47.851Z] [error] at eu.timepit.refined.macros.RefineMacro.validateInstance(RefineMacro.scala:55)
[2020-05-01T20:37:47.852Z] [error] at eu.timepit.refined.macros.RefineMacro.impl(RefineMacro.scala:25)
[2020-05-01T20:37:47.852Z] [error] at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
[2020-05-01T20:37:47.852Z] [error] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[2020-05-01T20:37:47.852Z] [error] at java.lang.reflect.Method.invoke(Method.java:498)
[2020-05-01T20:37:47.852Z] [error] at scala.reflect.macros.runtime.JavaReflectionRuntimes$JavaReflectionResolvers.$anonfun$resolveJavaReflectionRuntime$5(JavaReflectionRuntimes.scala:45)
[2020-05-01T20:37:47.852Z] [error] at scala.tools.nsc.typechecker.Macros.macroExpandWithRuntime(Macros.scala:758)
[2020-05-01T20:37:47.852Z] [error] val logName = LogView.withKey("name", lowercaseName)
I was just getting something very similar to this with Scala 2.12.10 and refined 0.9.14 (previously 0.9.4).
If I run sbt compile
then it would fail but sbt runAll
(lagom run task) it would work. Very strange.
I just got one of those. I'm running Scala 2.12.11, SBT 1.13.10 and refined 0.9.14
[error] java.lang.AssertionError: assertion failed: import failure: cannot determine unique overloaded method alternative from
[error] final package eu
[error] final package eu
[error] that matches package eu:eu.type
[error] at scala.reflect.internal.SymbolTable.throwAssertionError(SymbolTable.scala:184)
[error] at scala.reflect.internal.Importers$StandardImporter.disambiguate$1(Importers.scala:195)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:200)
[error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:181)
[error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:178)
[error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:178)
[error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:178)
[error] at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
[error] at scala.reflect.internal.Importers$StandardImporter.recreatedTreeCompleter(Importers.scala:310)
[error] at scala.reflect.internal.Importers$StandardImporter.$anonfun$importTree$1(Importers.scala:429)
[error] at scala.reflect.internal.Importers$StandardImporter.tryFixup(Importers.scala:61)
[error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:430)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:395)
[error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:427)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:395)
[error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:427)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:379)
[error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:427)
[error] at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:382)
[error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:427)
[error] at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:41)
[error] at scala.reflect.macros.contexts.Evals.eval(Evals.scala:31)
[error] at scala.reflect.macros.contexts.Evals.eval$(Evals.scala:26)
[error] at scala.reflect.macros.contexts.Context.eval(Context.scala:18)
[error] at eu.timepit.refined.macros.MacroUtils.$anonfun$eval$1(MacroUtils.scala:22)
[error] at scala.Option.getOrElse(Option.scala:189)
[error] at eu.timepit.refined.macros.MacroUtils.tryN(MacroUtils.scala:26)
[error] at eu.timepit.refined.macros.MacroUtils.tryN$(MacroUtils.scala:25)
[error] at eu.timepit.refined.macros.RefineMacro.tryN(RefineMacro.scala:10)
[error] at eu.timepit.refined.macros.MacroUtils.eval(MacroUtils.scala:22)
[error] at eu.timepit.refined.macros.MacroUtils.eval$(MacroUtils.scala:15)
[error] at eu.timepit.refined.macros.RefineMacro.eval(RefineMacro.scala:10)
[error] at eu.timepit.refined.macros.RefineMacro.$anonfun$validateInstance$2(RefineMacro.scala:55)
[error] at scala.Option.getOrElse(Option.scala:189)
[error] at eu.timepit.refined.macros.RefineMacro.validateInstance(RefineMacro.scala:55)
[error] at eu.timepit.refined.macros.RefineMacro.impl(RefineMacro.scala:25)
Right now I'm using just a single refined, this one:
object EmailModels {
type EmailPred = MatchesRegex[W.`"""^([a-zA-Z0-9_\\-\\.\\+]+)@([a-zA-Z0-9_\\-\\.]+)\\.([a-zA-Z]{2,5})$"""`.T]
type EmailRefinement = String Refined EmailPred
@newtype
case class Email(toStr: EmailRefinement)
object Email {
implicit val emailClass: ClassTag[Email] = deriving
implicit val format: Format[Email] = deriving
}
}
Seeing this on: Refined 0.9.14 Scala 2.12.11 sbt 1.3.12 / bloop 1.4.3
exception during macro expansion:
java.lang.AssertionError: assertion failed: import failure: cannot determine unique overloaded method alternative from
final package eu
final package eu
that matches package eu:eu.type
at scala.reflect.internal.SymbolTable.throwAssertionError(SymbolTable.scala:184)
at scala.reflect.internal.Importers$StandardImporter.disambiguate$1(Importers.scala:195)
at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:200)
at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:181)
at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:178)
at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:178)
at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
at scala.reflect.internal.Importers$StandardImporter.recreateOrRelink$1(Importers.scala:178)
at scala.reflect.internal.Importers$StandardImporter.importSymbol(Importers.scala:222)
at scala.reflect.internal.Importers$StandardImporter.recreatedTreeCompleter(Importers.scala:310)
at scala.reflect.internal.Importers$StandardImporter.$anonfun$importTree$1(Importers.scala:429)
at scala.reflect.internal.Importers$StandardImporter.tryFixup(Importers.scala:61)
at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:430)
at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:395)
at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:427)
at scala.reflect.internal.Importers$StandardImporter.recreateTree(Importers.scala:395)
at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:427)
at scala.reflect.internal.Importers$StandardImporter.importTree(Importers.scala:41)
at scala.reflect.macros.contexts.Evals.eval(Evals.scala:31)
at scala.reflect.macros.contexts.Evals.eval$(Evals.scala:26)
at scala.reflect.macros.contexts.Context.eval(Context.scala:18)
at eu.timepit.refined.macros.MacroUtils.$anonfun$eval$1(MacroUtils.scala:22)
at scala.Option.getOrElse(Option.scala:189)
at eu.timepit.refined.macros.MacroUtils.tryN(MacroUtils.scala:26)
at eu.timepit.refined.macros.MacroUtils.tryN$(MacroUtils.scala:25)
at eu.timepit.refined.macros.RefineMacro.tryN(RefineMacro.scala:10)
at eu.timepit.refined.macros.MacroUtils.eval(MacroUtils.scala:22)
at eu.timepit.refined.macros.MacroUtils.eval$(MacroUtils.scala:15)
at eu.timepit.refined.macros.RefineMacro.eval(RefineMacro.scala:10)
at eu.timepit.refined.macros.RefineMacro.$anonfun$validateInstance$2(RefineMacro.scala:55)
at scala.Option.getOrElse(Option.scala:189)
at eu.timepit.refined.macros.RefineMacro.validateInstance(RefineMacro.scala:55)
at eu.timepit.refined.macros.RefineMacro.impl(RefineMacro.scala:25)
at jdk.internal.reflect.GeneratedMethodAccessor678.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at scala.reflect.macros.runtime.JavaReflectionRuntimes$JavaReflectionResolvers.$anonfun$resolveJavaReflectionRuntime$5(JavaReflectionRuntimes.scala:45)
at scala.tools.nsc.typechecker.Macros.macroExpandWithRuntime(Macros.scala:823)
On code like this:
import eu.timepit.refined.auto._
val url: String Refined Url = "https://track.example.com/123456"
Update: it actually only happens in bloop...
@kubukoz Can you deterministically reproduce this with bloop?
Not really deterministically, now everything is working fine... :(
aaaaand I got it again, on a codebase that used to compile... is there some diagnostic I can take when this happens? Scala 2.12.12 this time.
Looks like I can refine things like PosInt
and it usually (always?) works. Same for type Hour = Int Refined Positive
. But type Hour = Int Refined Even
breaks things...
Looks like I can refine things like PosInt and it usually (always?) works. Same for type Hour = Int Refined Positive. But type Hour = Int Refined Even breaks things...
That's because some Validate
instances are cached in RefineMacro
(Validate[Int, Positive]
is one of them) and are not reflectively evaluated at compile-time, see
https://github.com/fthomas/refined/blob/4fa9cbc7bc308d820f82e69d0f0ead7502d95f8d/modules/core/shared/src/main/scala/eu/timepit/refined/macros/RefineMacro.scala#L40-L89
For Int Refined Even
eval
is called which is the source for this crash.
I've noticed this fail sporadically with String Refined MatchesRegex[W.
"""[\w\-]+:[\w\-]+""".T]
, the compiler error reported cites the call site, not the refinement definition.
I just saw this again, fwiw. Restarted sbt and it compiled fine. Confidence high! Maybe it will stop doing this in Scala 3 ;-)
Yes, it won't happen with Scala 3 because that macro cannot be ported! :-)
I am experiencing this same issue (Scala 2.13.7, jdk17) very randomly and rarely. Is there any other mitigation than compile twice?
It seems that disabling parallel compilation might help, see https://github.com/scala/bug/issues/10682#issuecomment-1005130476 and https://github.com/gemini-hlsw/lucuma-core/pull/449. The easier fix is to change compile-time checks of literals to runtime checks. This will also make it easier to port code to Scala 3, since the compile-time checks cannot be ported to Scala 3.
Hello my team has encountered a lot flaky CI failure on GitHub action, scalac were failure with various and weird error. After a long search and isolating the first faulty commit. I found that removing all refineMV
on the following constraint MatchesRegex["^#([0-9a-fA-F]{6})$"]
resolved our issue.
We are using:
scalac option are set sbt-tpolecat (0.4.2).
Here some failure we got:
[error] ## Exception when compiling 27 sources to /home/runner/work/conduktor-platform-api/conduktor-platform-api/modules/core/target/scala-2.13/classes
[error] java.lang.AssertionError: assertion failed:
[error] Tried to resolve io.conduktor.core.domain.auth.UserCreated to a non local classes but the resolution works up to sbtDependency phase. We're at erasure
[error] while compiling: /home/runner/work/conduktor-platform-api/conduktor-platform-api/modules/core/src/main/scala/io/conduktor/core/domain/auth/Users.scala
[error] last tree to typer: Apply(method &&) [error] tree position: line 20 of /home/runner/work/conduktor-platform-api/conduktor-platform-api/modules/core/src/main/scala/io/conduktor/core/domain/permissions/package.scala [error] tree tpe: Boolean [error] symbol: method && in class Boolean [error] symbol definition: def &&(x: Boolean): Boolean (a MethodSymbol) [error] symbol package: scala [error] symbol owners: method && -> class Boolean [error] call site: trait UserRepository in package repository in package repository
[error] last tree to typer: Apply(method &&) [error] tree position: line 20 of /home/runner/work/conduktor-platform-api/conduktor-platform-api/modules/core/src/main/scala/io/conduktor/core/domain/permissions/package.scala [error] tree tpe: Boolean [error] symbol: method && in class Boolean [error] symbol definition: def &&(x: Boolean): Boolean (a MethodSymbol) [error] symbol package: scala [error] symbol owners: method && -> class Boolean [error] call site: trait UserRepository in package repository in package repository
[error] Error while emitting Domain.scala
[error] io.estatico.newtype.Coercible[A,B] (of class scala.reflect.internal.Types$NullaryMethodType)
[error] Error while emitting Domain.scala
[error] assertion failed:
[error] Bad superClass for class Any:
[error] Error while emitting Domain.scala [error] (): Int (of class scala.reflect.internal.Types$MethodType) [error] Error while emitting Domain.scala [error] assertion failed: Bad superClass for trait Tag: class Any [error] Error while emitting Domain.scala [error] assertion failed: type TC [error] Error while emitting Domain.scala [error] assertion failed: type Type [warn] an unexpected type representation reached the compiler backend while compiling Domain.scala: (): Int. If possible, please file a bug on https://github.com/scala/bug/issues. [error] Error while emitting Domain.scala [error] (): Int (of class scala.reflect.internal.Types$MethodType) [error] Error while emitting Domain.scala [error] assertion failed: Bad superClass for trait Tag: class Any [error] Error while emitting Users.scala [error] assertion failed: type Type
Ok my CI was also fix by:
Global / concurrentRestrictions += Tags.limit(Tags.Compile, 1)
So I think it's a scalac bug and not a refine bug.
I saw this on Travis, compiling doobie at commit b2f02078d0162827b93a1d3408c2a9950ce477d4 under ++2.11.8. I restarted the build and it worked fine, so it's nondeterministic. I'm offering this on the chance that you will find it useful, but I don't expect a fix so feel free to close.
And again nearby.