Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

robust outer test generation for type test pattern #6183

Closed
scabug opened this issue Aug 4, 2012 · 5 comments
Closed

robust outer test generation for type test pattern #6183

scabug opened this issue Aug 4, 2012 · 5 comments
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Aug 4, 2012

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)) :_*)
  }
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 4, 2012

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 6, 2012

Naftoli Gugenheim (naftoligug) said (edited on Aug 6, 2012 8:03:15 AM UTC):
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

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 6, 2012

@adriaanm said:
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

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 6, 2012

Naftoli Gugenheim (naftoligug) said:
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!

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 7, 2012

@scabug scabug closed this Aug 8, 2012
@scabug scabug added this to the 2.10.0-M6 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.