Skip to content

Renamed implicit fails from TASTY #3607

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

Closed
nicolasstucki opened this issue Nov 30, 2017 · 2 comments
Closed

Renamed implicit fails from TASTY #3607

nicolasstucki opened this issue Nov 30, 2017 · 2 comments

Comments

@nicolasstucki
Copy link
Contributor

Fail to compile from TASTY

object A { implicit val x: Int = 1 }

object Test1 {
  import A.{x => y}
  implicitly[Int]
}

Can be reproduced with

dotc <source>
dotc -decompile -Ycheck:all Test
exception while typing implicitly[Int](A.y) of class class dotty.tools.dotc.ast.Trees$Apply # 62
exception while typing  val a: Int = implicitly[Int](A.y) of class class dotty.tools.dotc.ast.Trees$ValDef # 57
exception while typing @scala.annotation.internal.SourceFile("tests/pos/t2405.scala") final module 
  class
 Test1 () extends Object() { this: Test1.type => 
  import A.
    Thicket { 
      x
      y
     }
   val a: Int = implicitly[Int](A.y)
} of class class dotty.tools.dotc.ast.Trees$TypeDef # 20
exception while typing package <empty> {
  final lazy module val Test1: Test1 = new Test1()
  @scala.annotation.internal.SourceFile("tests/pos/t2405.scala") final module 
    class
   Test1 () extends Object() { this: Test1.type => 
    import A.
      Thicket { 
        x
        y
       }
     val a: Int = implicitly[Int](A.y)
  }
} of class class dotty.tools.dotc.ast.Trees$PackageDef # 27
*** error while checking ./Test1.class after phase frontend ***
Exception in thread "main" java.lang.AssertionError: assertion failed: found:    A.y.type
required: Int


tree = A.y
	at scala.Predef$.assert(Predef.scala:219)
	at dotty.tools.dotc.transform.TreeChecker$Checker.adapt(TreeChecker.scala:447)
	at dotty.tools.dotc.typer.ProtoTypes$FunProto.typedArg(ProtoTypes.scala:242)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:642)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.typedArg(Applications.scala:640)
	at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:412)
	at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:451)
	at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:233)
	at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:543)
	at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:641)
	at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:697)
	at dotty.tools.dotc.typer.Applications.$anonfun$typedApply$7(Applications.scala:722)
	at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:1809)
	at dotty.tools.dotc.typer.Applications.$anonfun$typedApply$1(Applications.scala:723)
	at dotty.tools.dotc.util.Stats$.track(Stats.scala:35)
	at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:667)
	at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:767)
	at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:665)
	at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:69)
	at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:1678)
	at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:1727)
	at dotty.tools.dotc.typer.ReTyper.typedUnadapted(ReTyper.scala:94)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typedUnadapted(TreeChecker.scala:272)
	at dotty.tools.dotc.typer.Typer.$anonfun$typed$2(Typer.scala:1744)
	at dotty.tools.dotc.reporting.trace$.apply(trace.scala:23)
	at dotty.tools.dotc.typer.Typer.typed(Typer.scala:1740)
	at dotty.tools.dotc.transform.TreeChecker$Checker.typed(TreeChecker.scala:257)
@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Nov 30, 2017

Note that if we add the parameter explicitly implicitly[Int](y) the pickled version will be implicitly[Int](A.x). We probably want the same to happen for implicits.

@nicolasstucki
Copy link
Contributor Author

The explicit y has type TermRef(TermRef(ThisType(TypeRef(NoPrefix,module class <empty>)),A),x) while the implcit one has type TermRef(TermRef(ThisType(TypeRef(NoPrefix,module class <empty>)),A),y).

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Nov 30, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Nov 30, 2017
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Dec 7, 2017
@smarter smarter closed this as completed in 01dad1a Dec 7, 2017
smarter added a commit that referenced this issue Dec 7, 2017
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

1 participant