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

npe when adapting to implicit method #5578

Closed
scabug opened this issue Mar 16, 2012 · 3 comments
Closed

npe when adapting to implicit method #5578

scabug opened this issue Mar 16, 2012 · 3 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Mar 16, 2012

trait Base {
  type Rep[T]
}

trait Expressions {
  abstract class Exp[T]
  case class Sym[T](n: Int) extends Exp[T]
  abstract class Def[T]
  def findOrCreateDefinition[T](rhs: Def[T]): Sym[T]
  implicit def toExp[T:Manifest](d: Def[T]): Exp[T] = findOrCreateDefinition(d)
}

trait BaseExp extends Base with Expressions {
  type Rep[T] = Exp[T]

  def findOrCreateDefinition[T](rhs: Def[T]): Sym[T] = null // stub
}

trait NumericOps extends Base {
  def plus[T](x: Rep[T], y: Rep[T]): Rep[T]
}

trait NumericOpsExp extends BaseExp {
  case class Plus[T:Numeric](x: Rep[T], y: Rep[T])
    extends Def[T]

  def plus[T: Numeric](x: Rep[T], y: Rep[T]): Rep[T] = Plus[T](x,y)  

}
  

crashes with

Exception in thread "main" java.lang.NullPointerException
	at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:1097)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4554)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$adaptToImplicitMethod$1$1$$anonfun$apply$29.apply(Typers.scala:790)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$adaptToImplicitMethod$1$1$$anonfun$apply$29.apply(Typers.scala:787)
	at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:701)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$adaptToImplicitMethod$1$1.apply(Typers.scala:787)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$adaptToImplicitMethod$1$1.apply(Typers.scala:785)
	at scala.tools.nsc.typechecker.Typers$Typer.withCondConstrTyper(Typers.scala:471)
	at scala.tools.nsc.typechecker.Typers$Typer.adaptToImplicitMethod$1(Typers.scala:785)
	at scala.tools.nsc.typechecker.Typers$Typer.adapt(Typers.scala:997)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4554)
	at scala.tools.nsc.typechecker.Typers$Typer.transformedOrTyped(Typers.scala:4703)
	at scala.tools.nsc.typechecker.Typers$Typer.typedDefDef(Typers.scala:1861)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4214)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4545)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2220)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$37$$anonfun$38.apply(Typers.scala:2317)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$37$$anonfun$38.apply(Typers.scala:2317)
	at scala.collection.immutable.List.loop$1(List.scala:151)
	at scala.collection.immutable.List.mapConserve(List.scala:167)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$37.apply(Typers.scala:2317)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$37.apply(Typers.scala:2316)
	at scala.tools.nsc.typechecker.Typers$Typer.withSavedContext(Typers.scala:497)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2316)
	at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1611)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$26.apply(Typers.scala:1485)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$26.apply(Typers.scala:1485)
	at scala.tools.nsc.typechecker.Typers$Typer.typerReportAnyContextErrors(Typers.scala:488)
	at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1484)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4205)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4545)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2220)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$37$$anonfun$38.apply(Typers.scala:2317)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$37$$anonfun$38.apply(Typers.scala:2317)
	at scala.collection.immutable.List.loop$1(List.scala:151)
	at scala.collection.immutable.List.mapConserve(List.scala:167)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$37.apply(Typers.scala:2317)
	at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$37.apply(Typers.scala:2316)
	at scala.tools.nsc.typechecker.Typers$Typer.withSavedContext(Typers.scala:497)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2316)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4201)
@scabug
Copy link
Author

scabug commented Mar 16, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5578?orig=1
Reporter: @hubertp
Affected Versions: 2.10.0-M2

@scabug
Copy link
Author

scabug commented Mar 16, 2012

@hubertp said:
It seems that it is a bad interaction with ResetAttrs which side-effects on the tree.

@scabug
Copy link
Author

scabug commented May 3, 2012

@hubertp said:
Fixed in ae5ff6628bb74c16d871a2ada06.

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

No branches or pull requests

2 participants