refined icon indicating copy to clipboard operation
refined copied to clipboard

nondeterministic compiler crash ¯\_(ツ)_/¯

Open tpolecat opened this issue 7 years ago • 33 comments

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.

[error] /home/travis/build/tpolecat/doobie/modules-cats/refined/target/scala-2.11/src_managed/test/scala/doobie/refined/refinedtypes.scala:82: exception during macro expansion: 
[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.Predef$.assert(Predef.scala:186)
[error] 	at scala.reflect.internal.Importers$StandardImporter.disambiguate$1(Importers.scala:181)
[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.recreatedTreeCompleter(Importers.scala:298)
[error] 	at scala.reflect.internal.Importers$StandardImporter$$anonfun$importTree$1.apply$mcV$sp(Importers.scala:417)
[error] 	at scala.reflect.internal.Importers$StandardImporter$$anonfun$tryFixup$1.apply(Importers.scala:49)
[error] 	at scala.reflect.internal.Importers$StandardImporter$$anonfun$tryFixup$1.apply(Importers.scala:49)
[error] 	at scala.collection.immutable.List.foreach(List.scala:381)
[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$class.eval(Evals.scala:19)
[error] 	at scala.reflect.macros.contexts.Context.eval(Context.scala:6)
[error] 	at eu.timepit.refined.macros.MacroUtils$$anonfun$eval$1.apply(MacroUtils.scala:20)
[error] 	at scala.Option.getOrElse(Option.scala:121)
[error] 	at eu.timepit.refined.macros.MacroUtils$class.tryN(MacroUtils.scala:24)
[error] 	at eu.timepit.refined.macros.RefineMacro.tryN(RefineMacro.scala:9)
[error] 	at eu.timepit.refined.macros.MacroUtils$class.eval(MacroUtils.scala:20)
[error] 	at eu.timepit.refined.macros.RefineMacro.eval(RefineMacro.scala:9)
[error] 	at eu.timepit.refined.macros.RefineMacro.impl(RefineMacro.scala:23)
[error]       val somePositiveInt: Option[PositiveInt] = Some(5)
[error]                                                       ^

And again nearby.

[error] /home/travis/build/tpolecat/doobie/modules/refined/target/scala-2.11/src_managed/test/scala/doobie/refined/refinedtypes.scala:84: exception during macro expansion: 
[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.Predef$.assert(Predef.scala:186)
[error] 	at scala.reflect.internal.Importers$StandardImporter.disambiguate$1(Importers.scala:181)
[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.recreatedTreeCompleter(Importers.scala:298)
[error] 	at scala.reflect.internal.Importers$StandardImporter$$anonfun$importTree$1.apply$mcV$sp(Importers.scala:417)
[error] 	at scala.reflect.internal.Importers$StandardImporter$$anonfun$tryFixup$1.apply(Importers.scala:49)
[error] 	at scala.reflect.internal.Importers$StandardImporter$$anonfun$tryFixup$1.apply(Importers.scala:49)
[error] 	at scala.collection.immutable.List.foreach(List.scala:381)
[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$class.eval(Evals.scala:19)
[error] 	at scala.reflect.macros.contexts.Context.eval(Context.scala:6)
[error] 	at eu.timepit.refined.macros.MacroUtils$$anonfun$eval$1.apply(MacroUtils.scala:20)
[error] 	at scala.Option.getOrElse(Option.scala:121)
[error] 	at eu.timepit.refined.macros.MacroUtils$class.tryN(MacroUtils.scala:24)
[error] 	at eu.timepit.refined.macros.RefineMacro.tryN(RefineMacro.scala:9)
[error] 	at eu.timepit.refined.macros.MacroUtils$class.eval(MacroUtils.scala:20)
[error] 	at eu.timepit.refined.macros.RefineMacro.eval(RefineMacro.scala:9)
[error] 	at eu.timepit.refined.macros.RefineMacro.impl(RefineMacro.scala:23)
[error]       val somePositiveInt: Option[PositiveInt] = Some(5)
[error]                                                       ^```

tpolecat avatar Feb 28 '17 00:02 tpolecat

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.

fthomas avatar Feb 28 '17 08:02 fthomas

@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.

fthomas avatar Mar 17 '17 05:03 fthomas

Will do, still seeing it with 0.7. I'll let you know. Thanks!

tpolecat avatar Mar 17 '17 05:03 tpolecat

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.)

tpolecat avatar Mar 21 '17 04:03 tpolecat

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.

fthomas avatar Oct 05 '17 21:10 fthomas

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.

Sample stack trace [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 avatar Jul 05 '18 18:07 NeQuissimus

@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 avatar Jul 05 '18 20:07 fthomas

@fthomas I had multiple of these, I can look them up tomorrow.

NeQuissimus avatar Jul 05 '18 23:07 NeQuissimus

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 avatar Jul 06 '18 15:07 NeQuissimus

@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.

fthomas avatar Jul 13 '18 20:07 fthomas

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.

oleg-py avatar Dec 08 '18 11:12 oleg-py

I'm seeing this in the Scala community build at https://github.com/scala/community-build/issues/1039

SethTisue avatar Jan 14 '20 23:01 SethTisue

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!

fthomas avatar Jan 15 '20 11:01 fthomas

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.

fthomas avatar Jan 25 '20 10:01 fthomas

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"

ferhtaydn avatar Feb 11 '20 15:02 ferhtaydn

Seeing this on 2.12.11, refined 0.9.12

jgogstad avatar Apr 07 '20 12:04 jgogstad

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)}"
  }

  // ...
}

jeffmay avatar May 01 '20 18:05 jeffmay

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.

jeffmay avatar May 01 '20 19:05 jeffmay

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)

jeffmay avatar May 01 '20 20:05 jeffmay

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.

steinybot avatar Jun 11 '20 03:06 steinybot

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
  }
}

pacdaemon avatar Jun 17 '20 15:06 pacdaemon

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 avatar Jul 07 '20 21:07 kubukoz

@kubukoz Can you deterministically reproduce this with bloop?

fthomas avatar Jul 13 '20 19:07 fthomas

Not really deterministically, now everything is working fine... :(

kubukoz avatar Jul 13 '20 19:07 kubukoz

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...

kubukoz avatar Jul 21 '20 23:07 kubukoz

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.

fthomas avatar Jul 24 '20 18:07 fthomas

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 ;-)

tpolecat avatar Mar 29 '21 19:03 tpolecat

Yes, it won't happen with Scala 3 because that macro cannot be ported! :-)

fthomas avatar Mar 29 '21 19:03 fthomas

I am experiencing this same issue (Scala 2.13.7, jdk17) very randomly and rarely. Is there any other mitigation than compile twice?

ThijsBroersen avatar Jan 10 '22 11:01 ThijsBroersen