scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

Trait pattern quasiquote might not match interface traits without mods #8399

Closed scabug closed 6 years ago

scabug commented 10 years ago
scala> val q"trait X { ..$stats }" = q"trait X { def x: Int }"
scala.MatchError: abstract trait X extends scala.AnyRef {
  def x: Int
} (of class scala.reflect.internal.Trees$ClassDef)
  ... 32 elided

Caused by the fact that interface trait has one extra INTERFACE flag which is not expected by the structure of the trait pattern on the left.

scabug commented 10 years ago

Imported From: https://issues.scala-lang.org/browse/SI-8399?orig=1 Reporter: @densh Affected Versions: 2.11.0-RC1

scabug commented 10 years ago

@densh said: Workaround: always extract modifiers even if they are not used:

scala> val q"$_ trait $name { ..$stats }" = q"trait X { def x: Int }"
name: reflect.runtime.universe.TypeName = X
stats: List[reflect.runtime.universe.Tree] = List(def x: Int)
scabug commented 10 years ago

@densh said (edited on Apr 4, 2014 10:35:16 AM UTC): Note to self: don't forget to update the docs before closing this issue.

SethTisue commented 6 years ago

closing all quasiquotes tickets; see #10755