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

mixin transforms lazy vals incorrectly under specialization: crash #4717

Closed
scabug opened this issue Jun 19, 2011 · 5 comments
Closed

mixin transforms lazy vals incorrectly under specialization: crash #4717

scabug opened this issue Jun 19, 2011 · 5 comments

Comments

@scabug
Copy link

scabug commented Jun 19, 2011

trait Bug1[@specialized +A] extends TraversableOnce[A] {  
  def ++[B >: A](that: TraversableOnce[B]): Iterator[B] = new Iterator[B] {
    lazy val it = that.toIterator
    def hasNext = it.hasNext
    def next = it.next
  }
}

[running phase cleanup on bug1.scala]
[running phase icode on bug1.scala]
error: java.lang.Error: Unknown type: T0 >: ? <: ?T0, T0 >: ? <: ?T0 [class scala.reflect.internal.Types$PolyType, class scala.reflect.internal.Types$PolyType] TypeRef? false
at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:31)
at scala.tools.nsc.backend.icode.TypeKinds$class.toTypeKind(TypeKinds.scala:390)

Analysis points the finger at mixin.

// before mixin - asInstanceOf[Iterator]
private <stable> <accessor> lazy def it(): Iterator = {
  Bug1$mcD$sp$$anon$10.this.it _=(Bug1$mcD$sp$$anon$10.this.that$10.toIterator());
  Bug1$mcD$sp$$anon$10.this.it .$asInstanceOf[Iterator]()
};

// after mixin - asInstanceOf is unapplied, polytype reaches back end
private lazy var it : Iterator = _;
private <stable> <accessor> lazy def it(): Iterator = {
  if (Bug1$mcD$sp$$anon$10.this.bitmap$priv$0.&(4).==(0))
    {
      Bug1$mcD$sp$$anon$10.this.synchronized({
        if (Bug1$mcD$sp$$anon$10.this.bitmap$priv$0.&(4).==(0))
          {
            Bug1$mcD$sp$$anon$10.this.it _=(Bug1$mcD$sp$$anon$10.this.that$10.toIterator());
            Bug1$mcD$sp$$anon$10.this.bitmap$priv$0 = Bug1$mcD$sp$$anon$10.this.bitmap$priv$0.|(4);
            ()
          };
        scala.runtime.BoxedUnit.UNIT
      });
      Bug1$mcD$sp$$anon$10.this.that$10 = null
    };
  Bug1$mcD$sp$$anon$10.this.$asInstanceOf
};
@scabug
Copy link
Author

scabug commented Jun 19, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4717?orig=1
Reporter: @paulp

@scabug
Copy link
Author

scabug commented May 10, 2012

@paulp said:
Closed #4123 as a duplicate. Here's retronym's even more minimized case from that.

trait Bounds[@specialized A] {
  // okay without `>: A`
  def x[B >: A]: Unit = new Bounds[B] {
    lazy val it = ???  // def or val okay
    it
  }
}

@scabug
Copy link
Author

scabug commented May 15, 2012

@axel22 said (edited on May 15, 2012 1:15:29 PM UTC):
I'm getting:

error: scala.reflect.internal.Types$TypeError: value it  is not a member of Bounds[B]{}

For some reason the typedThis in the typechecker:

      def typedThis(qual: Name) = tree.symbol orElse qualifyingClass(tree, qual, packageOK = false) match {
        case NoSymbol => tree
        case clazz    =>
          log("typedThis: " + qual)
          tree setSymbol clazz setType clazz.thisType.underlying
          if (isStableContext(tree, mode, pt)) tree setType clazz.thisType else tree
      }

does not add lazy val it to the list of members. I'm trying to figure this out.

@scabug
Copy link
Author

scabug commented May 16, 2012

@axel22 said:
I think the lazy val gets assigned the wrong owner in the invalidate method in Duplicators.

@scabug
Copy link
Author

scabug commented May 21, 2012

@axel22 said:
Should be fixed here: scala/scala#576

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants