Skip to content

Fix #3476: Add Artifact flag to closures #3503

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

Merged
merged 6 commits into from
Apr 10, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ object desugar {
* If `inlineable` is true, tag $anonfun with an @inline annotation.
*/
def makeClosure(params: List[ValDef], body: Tree, tpt: Tree = TypeTree(), inlineable: Boolean)(implicit ctx: Context) = {
var mods = synthetic
var mods = synthetic | Artifact
if (inlineable) mods |= Inline
Block(
DefDef(nme.ANON_FUN, Nil, params :: Nil, tpt, body).withMods(mods),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import core.TypeErasure.erasure
import core.Types._
import core.classfile.ClassfileConstants
import ast.Trees._
import SymUtils._
import TypeUtils._
import java.lang.StringBuilder

Expand Down Expand Up @@ -500,7 +501,8 @@ object GenericSignatures {
case PolyType(_, _) =>
true
case ClassInfo(_, _, parents, _, _) =>
foldOver(tp.typeParams.nonEmpty, parents)
// Local classes don't need a signature
!tp.classSymbol.isLocal && foldOver(tp.typeParams.nonEmpty, parents)
case AnnotatedType(tpe, _) =>
foldOver(x, tpe)
case proxy: TypeProxy =>
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/LambdaLift.scala
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ object LambdaLift {
local.copySymDenotation(
owner = newOwner,
name = newName(local),
initFlags = local.flags &~ Module &~ Final | Private | maybeStatic,
initFlags = local.flags &~ Module &~ Final | Private | Lifted | maybeStatic,
// drop Module because class is no longer a singleton in the lifted context.
info = liftedInfo(local)).installAfter(thisPhase)
}
Expand Down
1 change: 1 addition & 0 deletions tests/generic-java-signatures/i3476.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
OK
14 changes: 14 additions & 0 deletions tests/generic-java-signatures/i3476.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
object Test {
def main(args: Array[String]): Unit = {
val members = classOf[Foo].getDeclaredMethods.map(_.toGenericString)
assert(members.forall(_ != "<java.lang.NullPointerException>"), members.mkString(", "))
println("OK")
}
}
class Foo {
def m[T](x: T): Int => T = {
def bar(y: Int): T = x
bar _
}
}