Scala Programming Language
  1. Scala Programming Language
  2. SI-6183

robust outer test generation for type test pattern

    Details

      Description

      https://groups.google.com/d/topic/scala-internals/fV6A-htv1og/discussion

      bad qualifier received: mkAttributedQualifier(<notype>, <none>)
      

      on compiling

      http://olim7t.github.com/liftweb-2.0-release-sxr/net/liftweb/mapper/MetaMapper.scala.html

      relevant snippet:

      trait KeyedMetaMapper[Type, A<:KeyedMapper[Type, A]] extends MetaMapper[A] with KeyedMapper[Type, A] {
        self: A  with MetaMapper[A] with KeyedMapper[Type, A] =>
      
        type Q = MappedForeignKey[AnyBound, A, OO] with MappedField[AnyBound, A] forSome
        {type OO <: KeyedMapper[AnyBound, OO]}
      
        def asSafeJs(actual: A, f: KeyObfuscator): JsExp = {
          val pk = actual.primaryKeyField
          val first = (pk.name, JE.Str(f.obscure(self, pk.is)))
          JE.JsObj(first :: ("$lift_class", JE.Str(dbTableName)) :: mappedFieldList.
                   map(f => this.??(f.method, actual)).
                   filter(f => !f.dbPrimaryKey_? && f.renderJs_?).flatMap{
              case fk:  Q =>
                val key = f.obscure(fk.dbKeyToTable, fk.is)
                List((fk.name, JE.Str(key)),
                     (fk.name+"_obj",
                      JE.AnonFunc("index", JE.JsRaw("return index["+key.encJs+"];").cmd)))
      
              case x => x.asJs}.toList :::
                   actual.suplementalJs(Full(f)) :_*)
        }
      

        Activity

        Hide
        Naftoli Gugenheim added a comment - - edited

        Not sure why you put that ancient link under "On compiling." Was the discussion post not clear enough how to reproduce? Copying here:

        git clone git://github.com/lift/framework.git
        cd framework
        git checkout origin/nafg_wip_scala210

        Then apply this patch:

        diff --git a/persistence/mapper/src/main/scala/net/liftweb/mapper/ManyToMany.scala b/persistence/mapper/src/main/scala/net/liftweb/mapper/ManyToMany.scala
        index 2872cb2..d28cb9e 100644
        --- a/persistence/mapper/src/main/scala/net/liftweb/mapper/ManyToMany.scala
        +++ b/persistence/mapper/src/main/scala/net/liftweb/mapper/ManyToMany.scala
        @@ -106,7 +106,8 @@ trait ManyToMany extends BaseKeyedMapper {
                       removedJoin // well, noLongerRemovedJoin...
                     case None =>
                       val newJoin = joinMeta.create
        -              thisFK(newJoin)(_.apply(ManyToMany.this))
        +              thisFK(newJoin)(_.apply(ManyToMany.this.primaryKeyField.is.asInstanceOf[K]))
        +              // thisField.actualField(newJoin) match { case mfk: MappedForeignKey[K,O,T] => mfk apply ManyToMany.this }
                       otherFK(newJoin)(_.apply(e))
                       newJoin
                   }
        @@ -190,7 +191,7 @@ trait ManyToMany extends BaseKeyedMapper {
              * Discard the cached state of this MappedManyToMany's children and reinitialize it from the database
              */
             def refresh = {
        -      val by = new Cmp[O, TheKeyType](thisField, OprEnum.Eql, Full(primaryKeyField.is), Empty, Empty)
        +      val by = new Cmp[O, TheKeyType](thisField, OprEnum.Eql, Full(primaryKeyField.is.asInstanceOf[K]), Empty, Empty)
         
               _joins = joinMeta.findAll( (by :: qp.toList): _*)
               all
        @@ -210,7 +211,9 @@ trait ManyToMany extends BaseKeyedMapper {
               _joins = joins.filter { join =>
                 otherFK(join)(f => f.is != f.defaultValue)
               }
        -      _joins foreach { thisFK(_)(_ set ManyToMany.this.primaryKeyField.is) }
        +      _joins foreach {
        +        thisFK(_)(_ set ManyToMany.this.primaryKeyField.is.asInstanceOf[K])
        +      }
         
               removedJoins.forall {_.delete_!} & ( // continue saving even if deleting fails
                 children.forall(_.save) &&
        diff --git a/persistence/mapper/src/main/scala/net/liftweb/mapper/MappedField.scala b/persistence/mapper/src/main/scala/net/liftweb/mapper/MappedField.scala
        index 0832874..a4f969b 100644
        --- a/persistence/mapper/src/main/scala/net/liftweb/mapper/MappedField.scala
        +++ b/persistence/mapper/src/main/scala/net/liftweb/mapper/MappedField.scala
        @@ -17,7 +17,7 @@
         package net.liftweb
         package mapper
         
        -import scala.collection.mutable._
        +import scala.collection.mutable.{ Node => _, _ }
         import java.lang.reflect.Method
         import scala.xml._
         import java.util.Date
        

        Then execute:

        ./liftsh 'project lift-mapper' compile # custom sbt bash script, using sbt 0.12-something

        Show
        Naftoli Gugenheim added a comment - - edited Not sure why you put that ancient link under "On compiling." Was the discussion post not clear enough how to reproduce? Copying here: git clone git://github.com/lift/framework.git cd framework git checkout origin/nafg_wip_scala210 Then apply this patch: diff --git a/persistence/mapper/src/main/scala/net/liftweb/mapper/ManyToMany.scala b/persistence/mapper/src/main/scala/net/liftweb/mapper/ManyToMany.scala index 2872cb2..d28cb9e 100644 --- a/persistence/mapper/src/main/scala/net/liftweb/mapper/ManyToMany.scala +++ b/persistence/mapper/src/main/scala/net/liftweb/mapper/ManyToMany.scala @@ -106,7 +106,8 @@ trait ManyToMany extends BaseKeyedMapper { removedJoin // well, noLongerRemovedJoin... case None => val newJoin = joinMeta.create - thisFK(newJoin)(_.apply(ManyToMany.this)) + thisFK(newJoin)(_.apply(ManyToMany.this.primaryKeyField.is.asInstanceOf[K])) + // thisField.actualField(newJoin) match { case mfk: MappedForeignKey[K,O,T] => mfk apply ManyToMany.this } otherFK(newJoin)(_.apply(e)) newJoin } @@ -190,7 +191,7 @@ trait ManyToMany extends BaseKeyedMapper { * Discard the cached state of this MappedManyToMany's children and reinitialize it from the database */ def refresh = { - val by = new Cmp[O, TheKeyType](thisField, OprEnum.Eql, Full(primaryKeyField.is), Empty, Empty) + val by = new Cmp[O, TheKeyType](thisField, OprEnum.Eql, Full(primaryKeyField.is.asInstanceOf[K]), Empty, Empty) _joins = joinMeta.findAll( (by :: qp.toList): _*) all @@ -210,7 +211,9 @@ trait ManyToMany extends BaseKeyedMapper { _joins = joins.filter { join => otherFK(join)(f => f.is != f.defaultValue) } - _joins foreach { thisFK(_)(_ set ManyToMany.this.primaryKeyField.is) } + _joins foreach { + thisFK(_)(_ set ManyToMany.this.primaryKeyField.is.asInstanceOf[K]) + } removedJoins.forall {_.delete_!} & ( // continue saving even if deleting fails children.forall(_.save) && diff --git a/persistence/mapper/src/main/scala/net/liftweb/mapper/MappedField.scala b/persistence/mapper/src/main/scala/net/liftweb/mapper/MappedField.scala index 0832874..a4f969b 100644 --- a/persistence/mapper/src/main/scala/net/liftweb/mapper/MappedField.scala +++ b/persistence/mapper/src/main/scala/net/liftweb/mapper/MappedField.scala @@ -17,7 +17,7 @@ package net.liftweb package mapper -import scala.collection.mutable._ +import scala.collection.mutable.{ Node => _, _ } import java.lang.reflect.Method import scala.xml._ import java.util.Date Then execute: ./liftsh 'project lift-mapper' compile # custom sbt bash script, using sbt 0.12-something
        Hide
        Adriaan Moors added a comment -

        well, having a small snippet of code to compile is much more desirable than a short list of commands that then suck in a ton of code

        Show
        Adriaan Moors added a comment - well, having a small snippet of code to compile is much more desirable than a short list of commands that then suck in a ton of code
        Hide
        Naftoli Gugenheim added a comment -

        Ah, you mean that "ancient code" also reproduces it, and doesn't need a lot of dependencies? Then never mind. And thanks for working on it!

        Show
        Naftoli Gugenheim added a comment - Ah, you mean that "ancient code" also reproduces it, and doesn't need a lot of dependencies? Then never mind. And thanks for working on it!
        Show
        Adriaan Moors added a comment - https://github.com/scala/scala/pull/1073

          People

          • Assignee:
            Adriaan Moors
            Reporter:
            Adriaan Moors
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development